[AFR] Implemented Xorn

This commit is contained in:
Daniel Bomar 2021-07-05 11:42:37 -05:00
parent 044ccb4296
commit b0bdd34c0c
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 101 additions and 0 deletions

View file

@ -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<Token, Integer> 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;
}
}

View file

@ -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));