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.getSourceId(), 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, "Put " + xValue + " Elemental Tokens onto the battlefield?", game)) {
opponentsAddedTokens += xValue;
tokenCopy.putOntoBattlefield(xValue, game, source.getSourceId(), playerId, false, false);
}
}
}
if (opponentsAddedTokens > 0) {
tokenCopy.putOntoBattlefield(opponentsAddedTokens, game, source.getSourceId(), source.getControllerId(), false, false);
}
return true;
}
return false;