Search in sources :

Example 1 with EwokToken

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

the class EwokAmbushCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        CreateTokenEffect effect = new CreateTokenEffect(new EwokToken(), 2);
        effect.apply(game, source);
        for (UUID tokenId : effect.getLastAddedTokenIds()) {
            Permanent token = game.getPermanent(tokenId);
            if (token != null) {
                ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                continuousEffect.setTargetPointer(new FixedTarget(tokenId));
                game.addEffect(continuousEffect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : EwokToken(mage.game.permanent.token.EwokToken) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 EwokToken (mage.game.permanent.token.EwokToken)1 Player (mage.players.Player)1 FixedTarget (mage.target.targetpointer.FixedTarget)1