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;
}