Search in sources :

Example 1 with GeminiEngineTwinToken

use of mage.game.permanent.token.GeminiEngineTwinToken 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)

Aggregations

UUID (java.util.UUID)1 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 GeminiEngineTwinToken (mage.game.permanent.token.GeminiEngineTwinToken)1 Token (mage.game.permanent.token.Token)1 Player (mage.players.Player)1 FixedTarget (mage.target.targetpointer.FixedTarget)1