use of mage.game.permanent.token.Token in project mage by magefree.
the class SpiritWarriorToken method apply.
@Override
public boolean apply(Game game, Ability source) {
int value = Integer.MIN_VALUE;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
if (value < permanent.getToughness().getValue()) {
value = permanent.getToughness().getValue();
}
}
Token token = new SpiritWarriorToken(value);
// neccessary if token has ability like DevourAbility()
token.getAbilities().newId();
token.putOntoBattlefield(1, game, source, source.getControllerId());
return true;
}
use of mage.game.permanent.token.Token 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;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class TombstoneStairwellDestroyEffect method apply.
@Override
@SuppressWarnings("unchecked")
public boolean apply(Game game, Ability source) {
Token token = new TombspawnZombieToken();
Player activePlayer = game.getPlayer(game.getActivePlayerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (game.getPlayer(source.getControllerId()) != null && activePlayer != null && permanent != null) {
Object object = game.getState().getValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game));
Set<UUID> tokensCreated;
if (object != null) {
tokensCreated = (Set<UUID>) object;
} else {
tokensCreated = new HashSet<>();
}
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
int creatureCardsInGraveyard = player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, source.getControllerId(), source.getSourceId(), game);
token.putOntoBattlefield(creatureCardsInGraveyard, game, source, playerId);
for (UUID tokenId : token.getLastAddedTokenIds()) {
tokensCreated.add(tokenId);
}
}
game.getState().setValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game), tokensCreated);
return true;
}
return false;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class TirelessProvisionerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Token token = player.chooseUse(outcome, "Create a Food token or a Treasure token?", null, "Food", "Treasure", source, game) ? new FoodToken() : new TreasureToken();
return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class WaitingInTheWeedsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Token token = new GreenCatToken();
int amount = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size();
token.putOntoBattlefield(amount, game, source, playerId);
}
return true;
}
return false;
}
Aggregations