diff --git a/Mage.Sets/src/mage/cards/c/CloakwoodHermit.java b/Mage.Sets/src/mage/cards/c/CloakwoodHermit.java new file mode 100644 index 00000000000..70f25f17a36 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CloakwoodHermit.java @@ -0,0 +1,45 @@ +package mage.cards.c; + +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.CreaturePutInYourGraveyardCondition; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.permanent.token.SquirrelToken; +import mage.watchers.common.CreaturePutIntoGraveyardWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CloakwoodHermit extends CardImpl { + + public CloakwoodHermit(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.BACKGROUND); + + // Commander creatures you own have "At the beginning of your end step, if a creature card was put into your graveyard from anywhere this turn, create two tapped 1/1 green Squirrel creature tokens." + this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect( + new BeginningOfEndStepTriggeredAbility( + new CreateTokenEffect(new SquirrelToken(), 2, true, false), + TargetController.YOU, CreaturePutInYourGraveyardCondition.instance, false + ), Duration.WhileOnBattlefield, StaticFilters.FILTER_CREATURES_OWNED_COMMANDER + )).addHint(CreaturePutInYourGraveyardCondition.getHint()), new CreaturePutIntoGraveyardWatcher()); + } + + private CloakwoodHermit(final CloakwoodHermit card) { + super(card); + } + + @Override + public CloakwoodHermit copy() { + return new CloakwoodHermit(this); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index a309a5cff48..a7d85c44cf3 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -36,6 +36,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Bountiful Promenade", 348, Rarity.RARE, mage.cards.b.BountifulPromenade.class)); cards.add(new SetCardInfo("Bramble Sovereign", 218, Rarity.MYTHIC, mage.cards.b.BrambleSovereign.class)); cards.add(new SetCardInfo("Charcoal Diamond", 305, Rarity.COMMON, mage.cards.c.CharcoalDiamond.class)); + cards.add(new SetCardInfo("Cloakwood Hermit", 221, Rarity.UNCOMMON, mage.cards.c.CloakwoodHermit.class)); cards.add(new SetCardInfo("Command Tower", 351, Rarity.COMMON, mage.cards.c.CommandTower.class)); cards.add(new SetCardInfo("Cultist of the Absolute", 123, Rarity.RARE, mage.cards.c.CultistOfTheAbsolute.class)); cards.add(new SetCardInfo("Dread Linnorm", 225, Rarity.COMMON, mage.cards.d.DreadLinnorm.class)); diff --git a/Mage/src/main/java/mage/abilities/condition/common/CreaturePutInYourGraveyardCondition.java b/Mage/src/main/java/mage/abilities/condition/common/CreaturePutInYourGraveyardCondition.java new file mode 100644 index 00000000000..03f22e4a8bc --- /dev/null +++ b/Mage/src/main/java/mage/abilities/condition/common/CreaturePutInYourGraveyardCondition.java @@ -0,0 +1,32 @@ +package mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.abilities.hint.ConditionHint; +import mage.abilities.hint.Hint; +import mage.game.Game; +import mage.watchers.common.CreaturePutIntoGraveyardWatcher; + +/** + * @author TheElk801 + */ +public enum CreaturePutInYourGraveyardCondition implements Condition { + instance; + private static final Hint hint = new ConditionHint( + instance, "A creature card was put into your graveyard this turn" + ); + + public static Hint getHint() { + return hint; + } + + @Override + public boolean apply(Game game, Ability source) { + return CreaturePutIntoGraveyardWatcher.checkPlayer(source.getControllerId(), game); + } + + @Override + public String toString() { + return "a creature card was put into your graveyard from anywhere this turn"; + } +} diff --git a/Mage/src/main/java/mage/watchers/common/CreaturePutIntoGraveyardWatcher.java b/Mage/src/main/java/mage/watchers/common/CreaturePutIntoGraveyardWatcher.java new file mode 100644 index 00000000000..2d2a716aaf8 --- /dev/null +++ b/Mage/src/main/java/mage/watchers/common/CreaturePutIntoGraveyardWatcher.java @@ -0,0 +1,51 @@ +package mage.watchers.common; + +import mage.cards.Card; +import mage.constants.WatcherScope; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class CreaturePutIntoGraveyardWatcher extends Watcher { + + private final Set players = new HashSet<>(); + + public CreaturePutIntoGraveyardWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.ZONE_CHANGE + || !Zone.GRAVEYARD.match(((ZoneChangeEvent) event).getToZone())) { + return; + } + Card card = game.getCard(event.getTargetId()); + if (card != null && card.isCreature(game)) { + players.add(card.getOwnerId()); + } + } + + @Override + public void reset() { + super.reset(); + players.clear(); + } + + public static boolean checkPlayer(UUID playerId, Game game) { + return game + .getState() + .getWatcher(CreaturePutIntoGraveyardWatcher.class) + .players + .contains(playerId); + } +}