[ECL] Implement Wary Farmer (#14197)

This commit is contained in:
Muz 2026-01-09 10:00:31 -06:00 committed by GitHub
parent 679334dca0
commit 92bc6a3b9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 111 additions and 0 deletions

View file

@ -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<UUID, Set<MageObjectReference>> 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));
}
}

View file

@ -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));