Search in sources :

Example 1 with ZaxaraTheExemplaryHydraToken

use of mage.game.permanent.token.ZaxaraTheExemplaryHydraToken in project mage by magefree.

the class ZaxaraTheExemplaryHydraTokenEffect method apply.

@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, source.getControllerId());
            for (UUID tokenId : hydraToken.getLastAddedTokenIds()) {
                Permanent permanent = game.getPermanent(tokenId);
                if (permanent != null)
                    permanent.addCounters(CounterType.P1P1.createInstance(xValue), source.getControllerId(), source, game);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ZaxaraTheExemplaryHydraToken(mage.game.permanent.token.ZaxaraTheExemplaryHydraToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID) Spell(mage.game.stack.Spell) ZaxaraTheExemplaryHydraToken(mage.game.permanent.token.ZaxaraTheExemplaryHydraToken)

Aggregations

UUID (java.util.UUID)1 Permanent (mage.game.permanent.Permanent)1 Token (mage.game.permanent.token.Token)1 ZaxaraTheExemplaryHydraToken (mage.game.permanent.token.ZaxaraTheExemplaryHydraToken)1 Spell (mage.game.stack.Spell)1 Player (mage.players.Player)1