From a38c0bea3e1896975add601bf241406485537044 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 25 May 2022 07:40:27 -0400 Subject: [PATCH] [CLB] Implemented Agent of the Shadow Thieves --- .../mage/cards/a/AgentOfTheShadowThieves.java | 59 ++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + ...sOpponentWithMostLifeTriggeredAbility.java | 61 +++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/a/AgentOfTheShadowThieves.java create mode 100644 Mage/src/main/java/mage/abilities/common/AttacksOpponentWithMostLifeTriggeredAbility.java diff --git a/Mage.Sets/src/mage/cards/a/AgentOfTheShadowThieves.java b/Mage.Sets/src/mage/cards/a/AgentOfTheShadowThieves.java new file mode 100644 index 00000000000..8f3939001e5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AgentOfTheShadowThieves.java @@ -0,0 +1,59 @@ +package mage.cards.a; + +import mage.abilities.Ability; +import mage.abilities.common.AttacksOpponentWithMostLifeTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.continuous.GainAbilityAllEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.DeathtouchAbility; +import mage.abilities.keyword.IndestructibleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.counters.CounterType; +import mage.filter.StaticFilters; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class AgentOfTheShadowThieves extends CardImpl { + + public AgentOfTheShadowThieves(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.BACKGROUND); + + // Commander creatures you own have "Whenever this creature attacks a player, if no opponent has more life than that player, put a +1/+1 counter on this creature. It gains deathtouch and indestructible until end of turn." + Ability ability = new AttacksOpponentWithMostLifeTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance()) + .setText("put a +1/+1 counter on this creature"), + false + ); + ability.addEffect(new GainAbilitySourceEffect( + DeathtouchAbility.getInstance(), Duration.EndOfTurn + ).setText("It gains deathtouch")); + ability.addEffect(new GainAbilitySourceEffect( + IndestructibleAbility.getInstance(), Duration.EndOfTurn + ).setText("and indestructible until end of turn")); + this.addAbility(new SimpleStaticAbility(new GainAbilityAllEffect( + ability, Duration.WhileOnBattlefield, + StaticFilters.FILTER_CREATURES_OWNED_COMMANDER + ))); + } + + private AgentOfTheShadowThieves(final AgentOfTheShadowThieves card) { + super(card); + } + + @Override + public AgentOfTheShadowThieves copy() { + return new AgentOfTheShadowThieves(this); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index d4e233e057e..7cc63b43915 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -23,6 +23,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Aarakocra Sneak", 54, Rarity.COMMON, mage.cards.a.AarakocraSneak.class)); cards.add(new SetCardInfo("Agent of the Iron Throne", 107, Rarity.UNCOMMON, mage.cards.a.AgentOfTheIronThrone.class)); + cards.add(new SetCardInfo("Agent of the Shadow Thieves", 108, Rarity.UNCOMMON, mage.cards.a.AgentOfTheShadowThieves.class)); cards.add(new SetCardInfo("Alora, Merry Thief", 55, Rarity.UNCOMMON, mage.cards.a.AloraMerryThief.class)); cards.add(new SetCardInfo("Amber Gristle O'Maul", 159, Rarity.UNCOMMON, mage.cards.a.AmberGristleOMaul.class)); cards.add(new SetCardInfo("Ambition's Cost", 110, Rarity.UNCOMMON, mage.cards.a.AmbitionsCost.class)); diff --git a/Mage/src/main/java/mage/abilities/common/AttacksOpponentWithMostLifeTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksOpponentWithMostLifeTriggeredAbility.java new file mode 100644 index 00000000000..cc6b6d8e426 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/common/AttacksOpponentWithMostLifeTriggeredAbility.java @@ -0,0 +1,61 @@ +package mage.abilities.common; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.players.Player; + +import java.util.Objects; + +/** + * @author TheElk801 + */ +public class AttacksOpponentWithMostLifeTriggeredAbility extends TriggeredAbilityImpl { + + public AttacksOpponentWithMostLifeTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + } + + private AttacksOpponentWithMostLifeTriggeredAbility(final AttacksOpponentWithMostLifeTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return game.getCombat().getAttackers().contains(this.getSourceId()) + && game.getPlayer(game.getCombat().getDefenderId(this.getSourceId())) != null; + } + + @Override + public boolean checkInterveningIfClause(Game game) { + Player defender = game.getPlayer(game.getCombat().getDefenderId(getSourceId())); + return defender != null + && game + .getOpponents(getControllerId()) + .stream() + .map(game::getPlayer) + .filter(Objects::nonNull) + .mapToInt(Player::getLife) + .max() + .orElse(Integer.MIN_VALUE) + <= defender + .getLife(); + } + + @Override + public String getTriggerPhrase() { + return "Whenever this creature attacks a player, if no opponent has more life than that player, "; + } + + @Override + public AttacksOpponentWithMostLifeTriggeredAbility copy() { + return new AttacksOpponentWithMostLifeTriggeredAbility(this); + } +}