Search in sources :

Example 26 with Token

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

the class SokenzanCrucibleOfDefianceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new SpiritToken();
    token.putOntoBattlefield(2, game, source);
    game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance()).setTargetPointer(new FixedTargets(token, game)), source);
    return true;
}
Also used : FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) Token(mage.game.permanent.token.Token) SpiritToken(mage.game.permanent.token.SpiritToken) SpiritToken(mage.game.permanent.token.SpiritToken)

Example 27 with Token

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

the class SwanSongEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean countered = false;
    for (UUID targetId : targetPointer.getTargets(game, source)) {
        Spell spell = game.getStack().getSpell(targetId);
        if (game.getStack().counter(targetId, source, game)) {
            countered = true;
        }
        if (spell != null) {
            Token token = new SwanSongBirdToken();
            token.putOntoBattlefield(1, game, source, spell.getControllerId());
        }
    }
    return countered;
}
Also used : SwanSongBirdToken(mage.game.permanent.token.SwanSongBirdToken) SwanSongBirdToken(mage.game.permanent.token.SwanSongBirdToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Example 28 with Token

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

the class WillTheWiseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int count = 1;
    Token token = new ClueArtifactToken();
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(playerId);
        if (opponent == null) {
            continue;
        }
        if (opponent.chooseUse(outcome, "Investigate?", source, game)) {
            count++;
            token.putOntoBattlefield(1, game, source, playerId);
            game.fireEvent(GameEvent.getEvent(GameEvent.EventType.INVESTIGATED, source.getSourceId(), source, playerId));
        } else {
            opponent.loseLife(1, game, source, false);
        }
    }
    token.putOntoBattlefield(count, game, source, source.getControllerId());
    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.INVESTIGATED, source.getSourceId(), source, source.getControllerId()));
    return true;
}
Also used : ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) Player(mage.players.Player) ClueArtifactToken(mage.game.permanent.token.ClueArtifactToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID)

Example 29 with Token

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

the class FlashFoliageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Token token = new SaprolingToken();
        token.putOntoBattlefield(1, game, source, source.getControllerId());
        Permanent attackingCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (attackingCreature != null && game.getState().getCombat() != null) {
            // Possible ruling (see Aetherplasm)
            // The token you created is blocking the attacking creature,
            // even if the block couldn't legally be declared (for example, if that creature
            // enters the battlefield tapped, or it can't block, or the attacking creature
            // has protection from it)
            CombatGroup combatGroup = game.getState().getCombat().findGroup(attackingCreature.getId());
            if (combatGroup != null) {
                for (UUID tokenId : token.getLastAddedTokenIds()) {
                    Permanent saprolingToken = game.getPermanent(tokenId);
                    if (saprolingToken != null) {
                        combatGroup.addBlocker(tokenId, source.getControllerId(), game);
                        game.getCombat().addBlockingGroup(tokenId, attackingCreature.getId(), controller.getId(), game);
                    }
                }
                combatGroup.pickBlockerOrder(attackingCreature.getControllerId(), game);
            }
        }
        return true;
    }
    return false;
}
Also used : SaprolingToken(mage.game.permanent.token.SaprolingToken) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) SaprolingToken(mage.game.permanent.token.SaprolingToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID) CombatGroup(mage.game.combat.CombatGroup)

Example 30 with Token

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

the class HiveheartShamanEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new InsectToken();
    token.putOntoBattlefield(1, game, source);
    int domainCount = xValue.calculate(game, source, this);
    if (domainCount < 1) {
        return true;
    }
    for (UUID tokenId : token.getLastAddedTokenIds()) {
        Permanent permanent = game.getPermanent(tokenId);
        if (permanent == null) {
            continue;
        }
        permanent.addCounters(CounterType.P1P1.createInstance(domainCount), source, game);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) InsectToken(mage.game.permanent.token.InsectToken) Token(mage.game.permanent.token.Token) InsectToken(mage.game.permanent.token.InsectToken) UUID(java.util.UUID) DomainHint(mage.abilities.hint.common.DomainHint)

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