Merge pull request #6406 from AsterAether/master

Added Zaxara, the Exemplary.
This commit is contained in:
Evan Kranzler 2020-04-12 13:42:17 -04:00 committed by GitHub
commit e99c0549fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 169 additions and 0 deletions

View file

@ -0,0 +1,168 @@
package mage.cards.z;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.mana.AddManaOfAnyColorEffect;
import mage.abilities.keyword.DeathtouchAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.TokenImpl;
import mage.game.stack.Spell;
import mage.players.Player;
import java.util.UUID;
/**
* @author AsterAether
*/
public final class ZaxaraTheExemplary extends CardImpl {
final static String needPrefix = "_ZaxaraTheExemplary_NeedToken";
public ZaxaraTheExemplary(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{G}{U}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.NIGHTMARE);
this.subtype.add(SubType.HYDRA);
this.power = new MageInt(2);
this.toughness = new MageInt(3);
// Deathtouch
this.addAbility(DeathtouchAbility.getInstance());
// {T}: Add two mana of any one color.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(2), new TapSourceCost());
this.addAbility(ability);
// Whenever you cast a spell with {X} in its mana cost, create a 0/0 green Hydra creature token, then put X +1/+1 counters on it.
this.addAbility(new ZaxaraTheExemplaryHydraTokenAbility());
}
private ZaxaraTheExemplary(final ZaxaraTheExemplary card) {
super(card);
}
@Override
public ZaxaraTheExemplary copy() {
return new ZaxaraTheExemplary(this);
}
}
class ZaxaraTheExemplaryHydraTokenAbility extends TriggeredAbilityImpl {
public ZaxaraTheExemplaryHydraTokenAbility() {
super(Zone.BATTLEFIELD, new ZaxaraTheExemplaryHydraTokenEffect(), false);
}
public ZaxaraTheExemplaryHydraTokenAbility(final ZaxaraTheExemplaryHydraTokenAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.SPELL_CAST;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(getControllerId())) {
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null) {
if (spell.getSpellAbility().getManaCostsToPay().containsX()) {
game.getState().setValue(this.getSourceId() + ZaxaraTheExemplary.needPrefix, spell);
return true;
}
}
}
}
return false;
}
@Override
public TriggeredAbility copy() {
return new ZaxaraTheExemplaryHydraTokenAbility(this);
}
@Override
public String getRule() {
return "Whenever you cast a spell with {X} in its mana cost" + super.getRule();
}
}
class ZaxaraTheExemplaryHydraTokenEffect extends OneShotEffect {
ZaxaraTheExemplaryHydraTokenEffect() {
super(Outcome.Benefit);
this.staticText = ", create a 0/0 green Hydra creature token, then put X +1/+1 counters on it.";
}
ZaxaraTheExemplaryHydraTokenEffect(final ZaxaraTheExemplaryHydraTokenEffect effect) {
super(effect);
}
@Override
public ZaxaraTheExemplaryHydraTokenEffect copy() {
return new ZaxaraTheExemplaryHydraTokenEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
if (player != null && controller != null) {
Object needObject = game.getState().getValue(source.getSourceId() + ZaxaraTheExemplary.needPrefix);
// create token
if (needObject instanceof Spell) {
Spell spell = (Spell) needObject;
int xValue = spell.getSpellAbility().getManaCostsToPay().getX();
Token hydraToken = new ZaxaraTheExemplaryHydraToken();
hydraToken.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
for (UUID tokenId : hydraToken.getLastAddedTokenIds()) {
Permanent permanent = game.getPermanent(tokenId);
if (permanent != null)
permanent.addCounters(CounterType.P1P1.createInstance(xValue), source, game);
}
return true;
}
}
return false;
}
}
class ZaxaraTheExemplaryHydraToken extends TokenImpl {
public ZaxaraTheExemplaryHydraToken() {
super("Hydra", "0/0 green Hydra creature token");
setExpansionSetCodeForImage("C20");
cardType.add(CardType.CREATURE);
color.setGreen(true);
subtype.add(SubType.HYDRA);
power = new MageInt(0);
toughness = new MageInt(0);
}
private ZaxaraTheExemplaryHydraToken(final ZaxaraTheExemplaryHydraToken token) {
super(token);
}
@Override
public ZaxaraTheExemplaryHydraToken copy() {
return new ZaxaraTheExemplaryHydraToken(this);
}
}

View file

@ -309,6 +309,7 @@ public final class Commander2020Edition extends ExpansionSet {
cards.add(new SetCardInfo("Xathrid Necromancer", 141, Rarity.RARE, mage.cards.x.XathridNecromancer.class));
cards.add(new SetCardInfo("Yavimaya Coast", 322, Rarity.RARE, mage.cards.y.YavimayaCoast.class));
cards.add(new SetCardInfo("Yavimaya Dryad", 197, Rarity.UNCOMMON, mage.cards.y.YavimayaDryad.class));
cards.add(new SetCardInfo("Zaxara, the Exemplary", 20, Rarity.MYTHIC, mage.cards.z.ZaxaraTheExemplary.class));
cards.add(new SetCardInfo("Zetalpa, Primal Dawn", 107, Rarity.RARE, mage.cards.z.ZetalpaPrimalDawn.class));
cards.add(new SetCardInfo("Zulaport Cutthroat", 142, Rarity.UNCOMMON, mage.cards.z.ZulaportCutthroat.class));