[SPM] Implement Spider-UK

This commit is contained in:
theelk801 2025-09-02 17:19:24 -04:00
parent bd0fbaeef9
commit fa21c0e619
2 changed files with 112 additions and 0 deletions

View file

@ -0,0 +1,111 @@
package mage.cards.s;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.WebSlingingAbility;
import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.WatcherScope;
import mage.game.Controllable;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.util.CardUtil;
import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class SpiderUK extends CardImpl {
public SpiderUK(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.SPIDER);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.HERO);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// Web-slinging {2}{W}
this.addAbility(new WebSlingingAbility(this, "{2}{W}"));
// At the beginning of your end step, if two or more creatures entered the battlefield under your control this turn, you draw a card and gain 2 life.
Ability ability = new BeginningOfEndStepTriggeredAbility(
new DrawCardSourceControllerEffect(1, true)
).withInterveningIf(SpiderUKCondition.instance);
ability.addEffect(new GainLifeEffect(2).setText("and gain 2 life"));
this.addAbility(ability, new SpiderUKWatcher());
}
private SpiderUK(final SpiderUK card) {
super(card);
}
@Override
public SpiderUK copy() {
return new SpiderUK(this);
}
}
enum SpiderUKCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return SpiderUKWatcher.checkPlayer(game, source);
}
@Override
public String toString() {
return "two or more creatures entered the battlefield under your control this turn";
}
}
class SpiderUKWatcher extends Watcher {
private final Map<UUID, Integer> map = new HashMap<>();
SpiderUKWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
return;
}
Optional.of(event)
.map(EntersTheBattlefieldEvent.class::cast)
.map(EntersTheBattlefieldEvent::getTarget)
.map(Controllable::getControllerId)
.ifPresent(uuid -> map.compute(uuid, CardUtil::setOrIncrementValue));
}
@Override
public void reset() {
super.reset();
map.clear();
}
static boolean checkPlayer(Game game, Ability source) {
return game
.getState()
.getWatcher(SpiderUKWatcher.class)
.map
.getOrDefault(source.getControllerId(), 0) >= 2;
}
}

View file

@ -152,6 +152,7 @@ public final class MarvelsSpiderMan extends ExpansionSet {
cards.add(new SetCardInfo("Spider-Punk", 92, Rarity.RARE, mage.cards.s.SpiderPunk.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Spider-Punk", 92, Rarity.RARE, mage.cards.s.SpiderPunk.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Spider-Rex, Daring Dino", 116, Rarity.COMMON, mage.cards.s.SpiderRexDaringDino.class)); cards.add(new SetCardInfo("Spider-Rex, Daring Dino", 116, Rarity.COMMON, mage.cards.s.SpiderRexDaringDino.class));
cards.add(new SetCardInfo("Spider-Suit", 176, Rarity.UNCOMMON, mage.cards.s.SpiderSuit.class)); cards.add(new SetCardInfo("Spider-Suit", 176, Rarity.UNCOMMON, mage.cards.s.SpiderSuit.class));
cards.add(new SetCardInfo("Spider-UK", 17, Rarity.UNCOMMON, mage.cards.s.SpiderUK.class));
cards.add(new SetCardInfo("Spiders-Man, Heroic Horde", 117, Rarity.UNCOMMON, mage.cards.s.SpidersManHeroicHorde.class)); cards.add(new SetCardInfo("Spiders-Man, Heroic Horde", 117, Rarity.UNCOMMON, mage.cards.s.SpidersManHeroicHorde.class));
cards.add(new SetCardInfo("Starling, Aerial Ally", 18, Rarity.COMMON, mage.cards.s.StarlingAerialAlly.class)); cards.add(new SetCardInfo("Starling, Aerial Ally", 18, Rarity.COMMON, mage.cards.s.StarlingAerialAlly.class));
cards.add(new SetCardInfo("Steel Wrecking Ball", 177, Rarity.COMMON, mage.cards.s.SteelWreckingBall.class)); cards.add(new SetCardInfo("Steel Wrecking Ball", 177, Rarity.COMMON, mage.cards.s.SteelWreckingBall.class));