From 57ed834c146e421b50c6906e614a02bca6edf9cf Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 18 Jun 2020 21:10:40 -0400 Subject: [PATCH] Implemented Ormos, Archive Keeper --- .../src/mage/cards/o/OrmosArchiveKeeper.java | 144 ++++++++++++++++++ Mage.Sets/src/mage/sets/Jumpstart.java | 1 + 2 files changed, 145 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/o/OrmosArchiveKeeper.java diff --git a/Mage.Sets/src/mage/cards/o/OrmosArchiveKeeper.java b/Mage.Sets/src/mage/cards/o/OrmosArchiveKeeper.java new file mode 100644 index 0000000000..f8bb8d77de --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OrmosArchiveKeeper.java @@ -0,0 +1,144 @@ +package mage.cards.o; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.DiscardTargetCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.filter.FilterCard; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInHand; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class OrmosArchiveKeeper extends CardImpl { + + public OrmosArchiveKeeper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.SPHINX); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // If you would draw a card while your library has no cards in it, instead put five +1/+1 counters on Ormos, Archive Keeper. + this.addAbility(new SimpleStaticAbility(new OrmosArchiveKeeperEffect())); + + // {1}{U}{U}, Discard three cards with different names: Draw five cards. + Ability ability = new SimpleActivatedAbility( + new DrawCardSourceControllerEffect(5), new ManaCostsImpl("{1}{U}{U}") + ); + ability.addCost(new DiscardTargetCost(new OrmosArchiveKeeperTarget())); + this.addAbility(ability); + } + + private OrmosArchiveKeeper(final OrmosArchiveKeeper card) { + super(card); + } + + @Override + public OrmosArchiveKeeper copy() { + return new OrmosArchiveKeeper(this); + } +} + +class OrmosArchiveKeeperEffect extends ReplacementEffectImpl { + + OrmosArchiveKeeperEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "If you would draw a card while your library has no cards in it, " + + "instead put five +1/+1 counters on {this}"; + } + + private OrmosArchiveKeeperEffect(final OrmosArchiveKeeperEffect effect) { + super(effect); + } + + @Override + public OrmosArchiveKeeperEffect copy() { + return new OrmosArchiveKeeperEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent == null) { + permanent.addCounters(CounterType.P1P1.createInstance(5), source, game); + } + return true; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DRAW_CARD; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getPlayerId().equals(source.getControllerId())) { + Player player = game.getPlayer(event.getPlayerId()); + if (player != null && !player.hasLost() && !player.getLibrary().hasCards()) { + return true; + } + } + return false; + } +} + +class OrmosArchiveKeeperTarget extends TargetCardInHand { + + private static final FilterCard filter = new FilterCard("cards with different names"); + + OrmosArchiveKeeperTarget() { + super(3, filter); + } + + private OrmosArchiveKeeperTarget(final OrmosArchiveKeeperTarget target) { + super(target); + } + + @Override + public OrmosArchiveKeeperTarget copy() { + return new OrmosArchiveKeeperTarget(this); + } + + @Override + public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { + if (!super.canTarget(controllerId, id, source, game)) { + return false; + } + Card card = game.getCard(id); + if (card == null) { + return false; + } + return this.getTargets() + .stream() + .map(game::getCard) + .map(MageObject::getName) + .noneMatch(card.getName()::equals); + } +} diff --git a/Mage.Sets/src/mage/sets/Jumpstart.java b/Mage.Sets/src/mage/sets/Jumpstart.java index 2cec2f0687..95455a6afe 100644 --- a/Mage.Sets/src/mage/sets/Jumpstart.java +++ b/Mage.Sets/src/mage/sets/Jumpstart.java @@ -156,6 +156,7 @@ public final class Jumpstart extends ExpansionSet { cards.add(new SetCardInfo("Oneirophage", 162, Rarity.UNCOMMON, mage.cards.o.Oneirophage.class)); cards.add(new SetCardInfo("Oracle of Mul Daya", 415, Rarity.RARE, mage.cards.o.OracleOfMulDaya.class)); cards.add(new SetCardInfo("Orazca Frillback", 416, Rarity.COMMON, mage.cards.o.OrazcaFrillback.class)); + cards.add(new SetCardInfo("Ormos, Archive Keeper", 13, Rarity.RARE, mage.cards.o.OrmosArchiveKeeper.class)); cards.add(new SetCardInfo("Overgrown Battlement", 417, Rarity.UNCOMMON, mage.cards.o.OvergrownBattlement.class)); cards.add(new SetCardInfo("Pacifism", 125, Rarity.COMMON, mage.cards.p.Pacifism.class)); cards.add(new SetCardInfo("Peel from Reality", 163, Rarity.COMMON, mage.cards.p.PeelFromReality.class));