Search in sources :

Example 46 with Token

use of mage.game.permanent.token.Token in project mage by magefree.

the class DovescapeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
    int spellCMC = 0;
    UUID spellControllerID = null;
    if (spell != null) {
        spellCMC = spell.getManaValue();
        spellControllerID = spell.getControllerId();
        game.getStack().counter(spell.getId(), source, game);
    }
    Token token = new DovescapeToken();
    token.putOntoBattlefield(spellCMC, game, source, spellControllerID);
    return true;
}
Also used : DovescapeToken(mage.game.permanent.token.DovescapeToken) Token(mage.game.permanent.token.Token) DovescapeToken(mage.game.permanent.token.DovescapeToken) UUID(java.util.UUID) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell)

Example 47 with Token

use of mage.game.permanent.token.Token in project mage by magefree.

the class ForceOfRageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new AkoumStonewakerElementalToken();
    token.putOntoBattlefield(2, game, source, source.getControllerId());
    List<Permanent> permanentList = new ArrayList();
    for (UUID permId : token.getLastAddedTokenIds()) {
        permanentList.add(game.getPermanent(permId));
    }
    Effect effect = new SacrificeTargetEffect("sacrifice those tokens");
    effect.setTargetPointer(new FixedTargets(permanentList, game));
    game.addDelayedTriggeredAbility(new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect), source);
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) AkoumStonewakerElementalToken(mage.game.permanent.token.AkoumStonewakerElementalToken) ArrayList(java.util.ArrayList) AkoumStonewakerElementalToken(mage.game.permanent.token.AkoumStonewakerElementalToken) Token(mage.game.permanent.token.Token) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) UUID(java.util.UUID)

Example 48 with Token

use of mage.game.permanent.token.Token in project mage by magefree.

the class GeminiEngineCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    Token token;
    if (permanent != null) {
        token = new GeminiEngineTwinToken(permanent.getPower().getValue(), permanent.getToughness().getValue());
    } else {
        token = new GeminiEngineTwinToken(0, 0);
    }
    token.putOntoBattlefield(1, game, source, source.getControllerId(), false, true);
    for (UUID tokenId : token.getLastAddedTokenIds()) {
        Permanent tokenPerm = game.getPermanent(tokenId);
        if (tokenPerm != null) {
            Effect effect = new SacrificeTargetEffect("sacrifice " + tokenPerm.getLogName(), player.getId());
            effect.setTargetPointer(new FixedTarget(tokenPerm, game));
            game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(effect), source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) GeminiEngineTwinToken(mage.game.permanent.token.GeminiEngineTwinToken) GeminiEngineTwinToken(mage.game.permanent.token.GeminiEngineTwinToken) Token(mage.game.permanent.token.Token) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) UUID(java.util.UUID)

Example 49 with Token

use of mage.game.permanent.token.Token in project mage by magefree.

the class GeistSnatchCounterTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    game.getStack().counter(source.getFirstTarget(), source, game);
    Token token = new SpiritBlueToken();
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    return true;
}
Also used : Token(mage.game.permanent.token.Token) SpiritBlueToken(mage.game.permanent.token.SpiritBlueToken) SpiritBlueToken(mage.game.permanent.token.SpiritBlueToken)

Example 50 with Token

use of mage.game.permanent.token.Token in project mage by magefree.

the class GristTheHungerTideTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    Token token = new IzoniInsectToken();
    while (true) {
        token.putOntoBattlefield(1, game, source, source.getControllerId());
        if (player.millCards(1, source, game).count(filter, game) < 1) {
            break;
        }
        if (permanent != null) {
            permanent.addCounters(CounterType.LOYALTY.createInstance(), source.getControllerId(), source, game);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) IzoniInsectToken(mage.game.permanent.token.IzoniInsectToken) Token(mage.game.permanent.token.Token) IzoniInsectToken(mage.game.permanent.token.IzoniInsectToken)

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