From 92bc6a3b9a761ff07cbf0fdf190dbef9b7e9afae Mon Sep 17 00:00:00 2001 From: Muz Date: Fri, 9 Jan 2026 10:00:31 -0600 Subject: [PATCH] [ECL] Implement Wary Farmer (#14197) --- Mage.Sets/src/mage/cards/w/WaryFarmer.java | 110 ++++++++++++++++++++ Mage.Sets/src/mage/sets/LorwynEclipsed.java | 1 + 2 files changed, 111 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/w/WaryFarmer.java diff --git a/Mage.Sets/src/mage/cards/w/WaryFarmer.java b/Mage.Sets/src/mage/cards/w/WaryFarmer.java new file mode 100644 index 00000000000..98d80497fcb --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WaryFarmer.java @@ -0,0 +1,110 @@ +package mage.cards.w; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import mage.MageInt; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.abilities.effects.keyword.SurveilEffect; +import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility; +import mage.constants.SubType; +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.watchers.Watcher; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; + +/** + * + * @author muz + */ +public final class WaryFarmer extends CardImpl { + + public WaryFarmer(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G/W}{G/W}"); + + this.subtype.add(SubType.KITHKIN); + this.subtype.add(SubType.CITIZEN); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // At the beginning of your end step, if another creature entered the battlefield under your control this turn, surveil 1. + this.addAbility( + new BeginningOfEndStepTriggeredAbility( + new SurveilEffect(1) + ).withInterveningIf(WaryFarmerCondition.instance), + new WaryFarmerWatcher() + ); + } + + private WaryFarmer(final WaryFarmer card) { + super(card); + } + + @Override + public WaryFarmer copy() { + return new WaryFarmer(this); + } +} + +enum WaryFarmerCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + return WaryFarmerWatcher.checkPermanent(game, source); + } + + @Override + public String toString() { + return "another creature entered the battlefield under your control this turn"; + } +} + +class WaryFarmerWatcher extends Watcher { + + // Key: Player id + // Value: set of all creatures that entered under that player's control this turn + private final Map> map = new HashMap<>(); + + WaryFarmerWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { + return; + } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null) { + map.computeIfAbsent(permanent.getControllerId(), x -> new HashSet<>()) + .add(new MageObjectReference(permanent, game)); + } + + } + + @Override + public void reset() { + map.clear(); + super.reset(); + } + + static boolean checkPermanent(Game game, Ability source) { + return game + .getState() + .getWatcher(WaryFarmerWatcher.class) + .map + .getOrDefault(source.getControllerId(), Collections.emptySet()) + .stream() + .anyMatch(mor -> !mor.refersTo(source, game)); + } +} diff --git a/Mage.Sets/src/mage/sets/LorwynEclipsed.java b/Mage.Sets/src/mage/sets/LorwynEclipsed.java index af2c4c6cf33..2a4a4d4f8ad 100644 --- a/Mage.Sets/src/mage/sets/LorwynEclipsed.java +++ b/Mage.Sets/src/mage/sets/LorwynEclipsed.java @@ -264,6 +264,7 @@ public final class LorwynEclipsed extends ExpansionSet { cards.add(new SetCardInfo("Wanderbrine Preacher", 41, Rarity.COMMON, mage.cards.w.WanderbrinePreacher.class)); cards.add(new SetCardInfo("Wanderwine Distracter", 82, Rarity.COMMON, mage.cards.w.WanderwineDistracter.class)); cards.add(new SetCardInfo("Warren Torchmaster", 163, Rarity.UNCOMMON, mage.cards.w.WarrenTorchmaster.class)); + cards.add(new SetCardInfo("Wary Farmer", 251, Rarity.COMMON, mage.cards.w.WaryFarmer.class)); cards.add(new SetCardInfo("Wild Unraveling", 84, Rarity.COMMON, mage.cards.w.WildUnraveling.class)); cards.add(new SetCardInfo("Wistfulness", 252, Rarity.MYTHIC, mage.cards.w.Wistfulness.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Wistfulness", 296, Rarity.MYTHIC, mage.cards.w.Wistfulness.class, NON_FULL_USE_VARIOUS));