use of mage.game.permanent.token.TemptWithVengeanceElementalToken in project mage by magefree.
the class TemptWithVengeanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
int xValue = source.getManaCostsToPay().getX();
if (controller != null && xValue > 0) {
Token tokenCopy = new TemptWithVengeanceElementalToken();
tokenCopy.putOntoBattlefield(xValue, game, source, source.getControllerId(), false, false);
int opponentsAddedTokens = 0;
for (UUID playerId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null) {
if (opponent.chooseUse(outcome, "Create " + xValue + " Elemental tokens?", source, game)) {
opponentsAddedTokens += xValue;
tokenCopy.putOntoBattlefield(xValue, game, source, playerId, false, false);
}
}
}
if (opponentsAddedTokens > 0) {
tokenCopy.putOntoBattlefield(opponentsAddedTokens, game, source, source.getControllerId(), false, false);
}
return true;
}
return false;
}
Aggregations