From b5b4dec694007afab3242e68fa31b1db3ada599e Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Fri, 4 Jun 2021 20:08:01 -0500 Subject: [PATCH] [MH2] Implemented Nykthos Paragon (#7888) * [MH2] Implemented Nykthos Paragon * [MH2] Nykthos Paragon - Added check to checkTrigger --- .../src/mage/cards/n/NykthosParagon.java | 140 ++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons2.java | 1 + 2 files changed, 141 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/n/NykthosParagon.java diff --git a/Mage.Sets/src/mage/cards/n/NykthosParagon.java b/Mage.Sets/src/mage/cards/n/NykthosParagon.java new file mode 100644 index 00000000000..40ffbb9a8b0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NykthosParagon.java @@ -0,0 +1,140 @@ +package mage.cards.n; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * + * @author weirddan455 + */ +public final class NykthosParagon extends CardImpl { + + public NykthosParagon(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{4}{W}{W}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.SOLDIER); + this.power = new MageInt(4); + this.toughness = new MageInt(6); + + // Whenever you gain life, you may put that many +1/+1 counters on each creature you control. Do this only once each turn. + this.addAbility(new NykthosParagonTriggeredAbility()); + } + + private NykthosParagon(final NykthosParagon card) { + super(card); + } + + @Override + public NykthosParagon copy() { + return new NykthosParagon(this); + } +} + +class NykthosParagonTriggeredAbility extends TriggeredAbilityImpl { + + public NykthosParagonTriggeredAbility() { + super(Zone.BATTLEFIELD, new NykthosParagonEffect(), true); + } + + private NykthosParagonTriggeredAbility(final NykthosParagonTriggeredAbility ability) { + super(ability); + } + + @Override + public NykthosParagonTriggeredAbility copy() { + return new NykthosParagonTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.GAINED_LIFE; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (abilityAvailableThisTurn(game) && event.getPlayerId().equals(this.getControllerId())) { + for (Effect effect : this.getEffects()) { + effect.setValue("gainedLife", event.getAmount()); + } + return true; + } + return false; + } + + @Override + public boolean resolve(Game game) { + if (abilityAvailableThisTurn(game) && super.resolve(game)) { + game.getState().setValue(CardUtil.getCardZoneString( + "lastTurnResolved" + originalId, sourceId, game + ), game.getTurnNum()); + return true; + } + return false; + } + + private boolean abilityAvailableThisTurn(Game game) { + Integer lastTurnResolved = (Integer) game.getState().getValue( + CardUtil.getCardZoneString("lastTurnResolved" + originalId, sourceId, game) + ); + return lastTurnResolved == null || lastTurnResolved != game.getTurnNum(); + } + + @Override + public String getRule() { + return "Whenever you gain life, you may put that many +1/+1 counters on each creature you control. Do this only once each turn."; + } +} + +class NykthosParagonEffect extends OneShotEffect { + + public NykthosParagonEffect() { + super(Outcome.BoostCreature); + } + + private NykthosParagonEffect(final NykthosParagonEffect effect) { + super(effect); + } + + @Override + public NykthosParagonEffect copy() { + return new NykthosParagonEffect(this); + } + + @Override + public boolean apply (Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + Integer life = (Integer) this.getValue("gainedLife"); + if (controller != null && sourceObject != null && life != null) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) { + if (permanent != null && permanent.isCreature()) { + permanent.addCounters(CounterType.P1P1.createInstance(life), source.getControllerId(), source, game); + if (!game.isSimulation()) { + game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + life + + " +1/+1 counters on " + permanent.getLogName()); + } + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons2.java b/Mage.Sets/src/mage/sets/ModernHorizons2.java index 41cc862d913..310b9f95d48 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons2.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons2.java @@ -193,6 +193,7 @@ public final class ModernHorizons2 extends ExpansionSet { cards.add(new SetCardInfo("Nested Shambler", 95, Rarity.COMMON, mage.cards.n.NestedShambler.class)); cards.add(new SetCardInfo("Nettlecyst", 231, Rarity.RARE, mage.cards.n.Nettlecyst.class)); cards.add(new SetCardInfo("Nevinyrral's Disk", 298, Rarity.RARE, mage.cards.n.NevinyrralsDisk.class)); + cards.add(new SetCardInfo("Nykthos Paragon", 22, Rarity.RARE, mage.cards.n.NykthosParagon.class)); cards.add(new SetCardInfo("Obsidian Charmaw", 137, Rarity.RARE, mage.cards.o.ObsidianCharmaw.class)); cards.add(new SetCardInfo("Orchard Strider", 169, Rarity.COMMON, mage.cards.o.OrchardStrider.class)); cards.add(new SetCardInfo("Ornithopter of Paradise", 232, Rarity.COMMON, mage.cards.o.OrnithopterOfParadise.class));