Search in sources :

Example 16 with Token

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;
}
Also used : Permanent(mage.game.permanent.Permanent) Token(mage.game.permanent.token.Token)

Example 17 with Token

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;
}
Also used : Player(mage.players.Player) Token(mage.game.permanent.token.Token) TemptWithVengeanceElementalToken(mage.game.permanent.token.TemptWithVengeanceElementalToken) TemptWithVengeanceElementalToken(mage.game.permanent.token.TemptWithVengeanceElementalToken) UUID(java.util.UUID)

Example 18 with Token

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;
}
Also used : Player(mage.players.Player) TombspawnZombieToken(mage.game.permanent.token.TombspawnZombieToken) Permanent(mage.game.permanent.Permanent) Token(mage.game.permanent.token.Token) TombspawnZombieToken(mage.game.permanent.token.TombspawnZombieToken) UUID(java.util.UUID)

Example 19 with Token

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());
}
Also used : Player(mage.players.Player) TreasureToken(mage.game.permanent.token.TreasureToken) FoodToken(mage.game.permanent.token.FoodToken) Token(mage.game.permanent.token.Token) TreasureToken(mage.game.permanent.token.TreasureToken) FoodToken(mage.game.permanent.token.FoodToken)

Example 20 with Token

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;
}
Also used : Player(mage.players.Player) GreenCatToken(mage.game.permanent.token.GreenCatToken) Token(mage.game.permanent.token.Token) GreenCatToken(mage.game.permanent.token.GreenCatToken) UUID(java.util.UUID)

Aggregations

Token (mage.game.permanent.token.Token)68 Permanent (mage.game.permanent.Permanent)30 Player (mage.players.Player)29 UUID (java.util.UUID)28 FixedTargets (mage.target.targetpointer.FixedTargets)9 Map (java.util.Map)7 Effect (mage.abilities.effects.Effect)6 OneShotEffect (mage.abilities.effects.OneShotEffect)6 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)6 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)6 FixedTarget (mage.target.targetpointer.FixedTarget)6 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)5 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)5 TargetPermanent (mage.target.TargetPermanent)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 FilterPermanent (mage.filter.FilterPermanent)4 CreateTokenEvent (mage.game.events.CreateTokenEvent)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Objects (java.util.Objects)3