From de83fe4d4fca0c239e62464225d9ff747131f167 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 23 Jun 2019 19:44:21 -0400 Subject: [PATCH] Implemented Woodland Champion --- .../src/mage/cards/w/WoodlandChampion.java | 91 +++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2020.java | 1 + 2 files changed, 92 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/w/WoodlandChampion.java diff --git a/Mage.Sets/src/mage/cards/w/WoodlandChampion.java b/Mage.Sets/src/mage/cards/w/WoodlandChampion.java new file mode 100644 index 00000000000..54963c6a597 --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WoodlandChampion.java @@ -0,0 +1,91 @@ +package mage.cards.w; + +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeGroupEvent; +import mage.game.permanent.PermanentToken; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class WoodlandChampion extends CardImpl { + + public WoodlandChampion(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); + + this.subtype.add(SubType.ELF); + this.subtype.add(SubType.SCOUT); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Whenever one or more tokens enter the battlefield under your control, put that many +1/+1 counters on Woodland Champion. + this.addAbility(new WoodlandChampionTriggeredAbility()); + } + + private WoodlandChampion(final WoodlandChampion card) { + super(card); + } + + @Override + public WoodlandChampion copy() { + return new WoodlandChampion(this); + } +} + +class WoodlandChampionTriggeredAbility extends TriggeredAbilityImpl { + + WoodlandChampionTriggeredAbility() { + super(Zone.BATTLEFIELD, null, false); + } + + private WoodlandChampionTriggeredAbility(final WoodlandChampionTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE_GROUP; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; + if (zEvent != null && Zone.BATTLEFIELD == zEvent.getToZone() + && zEvent.getCards() != null) { + int tokenCount = zEvent + .getCards() + .stream() + .filter(card -> card instanceof PermanentToken) + .mapToInt(card -> ((PermanentToken) card).isControlledBy(this.getControllerId()) ? 1 : 0) + .sum(); + if (tokenCount > 0) { + this.getEffects().clear(); + this.addEffect(new AddCountersSourceEffect(CounterType.P1P1.createInstance(tokenCount))); + return true; + } + } + return false; + } + + @Override + public WoodlandChampionTriggeredAbility copy() { + return new WoodlandChampionTriggeredAbility(this); + } + + @Override + public String getRule() { + return "Whenever one or more tokens enter the battlefield under your control, " + + "put that many +1/+1 counters on {this}"; + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index 43bb26bff39..3222cbad35d 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -201,6 +201,7 @@ public final class CoreSet2020 extends ExpansionSet { cards.add(new SetCardInfo("Winged Words", 80, Rarity.COMMON, mage.cards.w.WingedWords.class)); cards.add(new SetCardInfo("Wolfkin Bond", 203, Rarity.COMMON, mage.cards.w.WolfkinBond.class)); cards.add(new SetCardInfo("Wolfrider's Saddle", 204, Rarity.UNCOMMON, mage.cards.w.WolfridersSaddle.class)); + cards.add(new SetCardInfo("Woodland Champion", 205, Rarity.UNCOMMON, mage.cards.w.WoodlandChampion.class)); cards.add(new SetCardInfo("Yarok's Fenlurker", 123, Rarity.UNCOMMON, mage.cards.y.YaroksFenlurker.class)); cards.add(new SetCardInfo("Yarok, the Desecrated", 220, Rarity.MYTHIC, mage.cards.y.YarokTheDesecrated.class)); }