diff --git a/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java b/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java new file mode 100644 index 00000000000..2f19168e19b --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java @@ -0,0 +1,129 @@ +package mage.cards.p; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import mage.MageInt; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.HexproofAbility; +import mage.abilities.keyword.VigilanceAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.WatcherScope; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.watchers.Watcher; + +/** + * + * @author TheElk801 + */ +public final class PalladiaMorsTheRuiner extends CardImpl { + + public PalladiaMorsTheRuiner(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{R}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.ELDER); + this.subtype.add(SubType.DRAGON); + this.power = new MageInt(6); + this.toughness = new MageInt(6); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Vigilance + this.addAbility(VigilanceAbility.getInstance()); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Palladia-Mors, the Ruiner has hexproof if it hasn't dealt damage yet. + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new ConditionalContinuousEffect( + new GainAbilitySourceEffect(HexproofAbility.getInstance()), + PalladiaMorsTheRuinerCondition.instance, + "{this} has hexproof if it hasn't dealt damage yet" + ) + )); + } + + public PalladiaMorsTheRuiner(final PalladiaMorsTheRuiner card) { + super(card); + } + + @Override + public PalladiaMorsTheRuiner copy() { + return new PalladiaMorsTheRuiner(this); + } +} + +enum PalladiaMorsTheRuinerCondition implements Condition { + + instance; + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); + PalladiaMorsTheRuinerWatcher watcher = (PalladiaMorsTheRuinerWatcher) game.getState().getWatchers().get(PalladiaMorsTheRuinerWatcher.class.getSimpleName()); + return !watcher.getDamagers().contains(new MageObjectReference(permanent, game)); + } + + @Override + public String toString() { + return "{this} hasn't dealt damage yet"; + } + +} + +class PalladiaMorsTheRuinerWatcher extends Watcher { + + private Set damagers = new HashSet(); + + public PalladiaMorsTheRuinerWatcher() { + super(PalladiaMorsTheRuinerWatcher.class.getSimpleName(), WatcherScope.GAME); + } + + public PalladiaMorsTheRuinerWatcher(final PalladiaMorsTheRuinerWatcher watcher) { + super(watcher); + damagers.addAll(watcher.damagers); + } + + @Override + public PalladiaMorsTheRuinerWatcher copy() { + return new PalladiaMorsTheRuinerWatcher(this); + } + + @Override + public void watch(GameEvent event, Game game) { + switch (event.getType()) { + case DAMAGED_CREATURE: + case DAMAGED_PLAYER: + case DAMAGED_PLANESWALKER: + break; + default: + return; + } + Permanent permanent = game.getPermanent(event.getSourceId()); + if (permanent != null) { + damagers.add(new MageObjectReference(permanent, game)); + } + } + + public Set getDamagers() { + return damagers; + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2019.java b/Mage.Sets/src/mage/sets/CoreSet2019.java index 26400ea64a2..380893d97ce 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2019.java +++ b/Mage.Sets/src/mage/sets/CoreSet2019.java @@ -122,6 +122,7 @@ public final class CoreSet2019 extends ExpansionSet { cards.add(new SetCardInfo("Omenspeaker", 64, Rarity.COMMON, mage.cards.o.Omenspeaker.class)); cards.add(new SetCardInfo("Onakke Ogre", 153, Rarity.COMMON, mage.cards.o.OnakkeOgre.class)); cards.add(new SetCardInfo("Oreskos Swiftclaw", 31, Rarity.COMMON, mage.cards.o.OreskosSwiftclaw.class)); + cards.add(new SetCardInfo("Palladia-Mors, the Ruiner", 219, Rarity.MYTHIC, mage.cards.p.PalladiaMorsTheRuiner.class)); cards.add(new SetCardInfo("Patient Rebuilding", 67, Rarity.RARE, mage.cards.p.PatientRebuilding.class)); cards.add(new SetCardInfo("Pegasus Courser", 32, Rarity.COMMON, mage.cards.p.PegasusCourser.class)); cards.add(new SetCardInfo("Plummet", 193, Rarity.COMMON, mage.cards.p.Plummet.class));