diff --git a/Mage.Sets/src/mage/cards/x/Xorn.java b/Mage.Sets/src/mage/cards/x/Xorn.java new file mode 100644 index 00000000000..10e3f3e2506 --- /dev/null +++ b/Mage.Sets/src/mage/cards/x/Xorn.java @@ -0,0 +1,100 @@ +package mage.cards.x; + +import java.util.Map; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.game.Game; +import mage.game.events.CreateTokenEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.token.Token; +import mage.game.permanent.token.TreasureToken; + +/** + * + * @author weirddan455 + */ +public final class Xorn extends CardImpl { + + public Xorn(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}"); + + this.subtype.add(SubType.ELEMENTAL); + this.power = new MageInt(3); + this.toughness = new MageInt(2); + + // If you would create one or more Treasure tokens, instead create those tokens plus an additional Treasure token. + this.addAbility(new SimpleStaticAbility(new XornReplacementEffect())); + } + + private Xorn(final Xorn card) { + super(card); + } + + @Override + public Xorn copy() { + return new Xorn(this); + } +} + +class XornReplacementEffect extends ReplacementEffectImpl { + + public XornReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + this.staticText = "If you would create one or more Treasure tokens, instead create those tokens plus an additional Treasure token"; + } + + private XornReplacementEffect(final XornReplacementEffect effect) { + super(effect); + } + + @Override + public XornReplacementEffect copy() { + return new XornReplacementEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CREATE_TOKEN; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event instanceof CreateTokenEvent && source.isControlledBy(event.getPlayerId())) { + for (Token token : ((CreateTokenEvent) event).getTokens().keySet()) { + if (token.hasSubtype(SubType.TREASURE, game)) { + return true; + } + } + } + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + if (event instanceof CreateTokenEvent) { + CreateTokenEvent tokenEvent = (CreateTokenEvent) event; + TreasureToken treasureToken = null; + Map tokens = tokenEvent.getTokens(); + for (Token token : tokens.keySet()) { + if (token instanceof TreasureToken) { + treasureToken = (TreasureToken) token; + break; + } + } + if (treasureToken == null) { + treasureToken = new TreasureToken(); + } + tokens.put(treasureToken, tokens.getOrDefault(treasureToken, 0) + 1); + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java b/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java index 352775450b0..f33d08dfc7f 100644 --- a/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java +++ b/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java @@ -147,6 +147,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet { cards.add(new SetCardInfo("Veteran Dungeoneer", 40, Rarity.COMMON, mage.cards.v.VeteranDungeoneer.class)); cards.add(new SetCardInfo("Vorpal Sword", 124, Rarity.RARE, mage.cards.v.VorpalSword.class)); cards.add(new SetCardInfo("Werewolf Pack Leader", 211, Rarity.RARE, mage.cards.w.WerewolfPackLeader.class)); + cards.add(new SetCardInfo("Xorn", 167, Rarity.RARE, mage.cards.x.Xorn.class)); cards.add(new SetCardInfo("You Come to a River", 83, Rarity.COMMON, mage.cards.y.YouComeToARiver.class)); cards.add(new SetCardInfo("You Come to the Gnoll Camp", 168, Rarity.COMMON, mage.cards.y.YouComeToTheGnollCamp.class)); cards.add(new SetCardInfo("You Find a Cursed Idol", 213, Rarity.COMMON, mage.cards.y.YouFindACursedIdol.class));