diff --git a/Mage.Sets/src/mage/cards/v/VengefulWarchief.java b/Mage.Sets/src/mage/cards/v/VengefulWarchief.java new file mode 100644 index 0000000000..bec090c924 --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VengefulWarchief.java @@ -0,0 +1,119 @@ +package mage.cards.v; + +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.WatcherScope; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.watchers.Watcher; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VengefulWarchief extends CardImpl { + + public VengefulWarchief(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}"); + + this.subtype.add(SubType.ORC); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Whenever you lose life for the first time each turn, put a +1/+1 counter on Vengeful Warchief. + this.addAbility(new VengefulWarchiefTriggeredAbility(), new VengefulWarchiefWatcher()); + } + + private VengefulWarchief(final VengefulWarchief card) { + super(card); + } + + @Override + public VengefulWarchief copy() { + return new VengefulWarchief(this); + } +} + +class VengefulWarchiefTriggeredAbility extends TriggeredAbilityImpl { + + VengefulWarchiefTriggeredAbility() { + super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false); + } + + private VengefulWarchiefTriggeredAbility(final VengefulWarchiefTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.LOST_LIFE; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!event.getPlayerId().equals(getControllerId())) { + return false; + } + VengefulWarchiefWatcher watcher = game.getState().getWatcher(VengefulWarchiefWatcher.class); + return watcher != null && watcher.timesLostLifeThisTurn(event.getTargetId()) < 2; + } + + @Override + public VengefulWarchiefTriggeredAbility copy() { + return new VengefulWarchiefTriggeredAbility(this); + } + + @Override + public String getRule() { + return "Whenever you lose life for the first time each turn, " + super.getRule(); + } +} + +class VengefulWarchiefWatcher extends Watcher { + + private final Map playersLostLife = new HashMap<>(); + + VengefulWarchiefWatcher() { + super(WatcherScope.GAME); + } + + private VengefulWarchiefWatcher(final VengefulWarchiefWatcher watcher) { + super(watcher); + this.playersLostLife.putAll(watcher.playersLostLife); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.LOST_LIFE) { + int timesLifeLost = playersLostLife.getOrDefault(event.getTargetId(), 0); + timesLifeLost++; + playersLostLife.put(event.getTargetId(), timesLifeLost); + } + } + + @Override + public VengefulWarchiefWatcher copy() { + return new VengefulWarchiefWatcher(this); + } + + @Override + public void reset() { + super.reset(); + playersLostLife.clear(); + } + + int timesLostLifeThisTurn(UUID playerId) { + return playersLostLife.getOrDefault(playerId, 0); + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index 2fe05115d7..a5303c0ea7 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -317,6 +317,7 @@ public final class CoreSet2020 extends ExpansionSet { cards.add(new SetCardInfo("Unsummon", 78, Rarity.COMMON, mage.cards.u.Unsummon.class)); cards.add(new SetCardInfo("Vampire of the Dire Moon", 120, Rarity.UNCOMMON, mage.cards.v.VampireOfTheDireMoon.class)); cards.add(new SetCardInfo("Veil of Summer", 198, Rarity.UNCOMMON, mage.cards.v.VeilOfSummer.class)); + cards.add(new SetCardInfo("Vengeful Warchief", 121, Rarity.UNCOMMON, mage.cards.v.VengefulWarchief.class)); cards.add(new SetCardInfo("Vial of Dragonfire", 241, Rarity.COMMON, mage.cards.v.VialOfDragonfire.class)); cards.add(new SetCardInfo("Vilis, Broker of Blood", 122, Rarity.RARE, mage.cards.v.VilisBrokerOfBlood.class)); cards.add(new SetCardInfo("Vivien's Crocodile", 301, Rarity.COMMON, mage.cards.v.ViviensCrocodile.class));