Search in sources :

Example 1 with MayTapOrUntapTargetEffect

use of mage.abilities.effects.common.MayTapOrUntapTargetEffect in project mage by magefree.

the class ChainStasisEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || sourceObject == null) {
        return false;
    }
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
        Effect effect = new MayTapOrUntapTargetEffect();
        effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
        effect.apply(game, source);
        Player player = game.getPlayer(permanent.getControllerId());
        if (player == null) {
            return false;
        }
        Cost cost = new ManaCostsImpl("{2}{U}");
        if (cost.pay(source, game, source, controller.getId(), false)) {
            if (player.chooseUse(outcome, "Copy the spell?", source, game)) {
                Spell spell = game.getStack().getSpell(source.getSourceId());
                if (spell != null) {
                    spell.createCopyOnStack(game, source, player.getId(), true);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) MayTapOrUntapTargetEffect(mage.abilities.effects.common.MayTapOrUntapTargetEffect) MageObject(mage.MageObject) MayTapOrUntapTargetEffect(mage.abilities.effects.common.MayTapOrUntapTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Spell(mage.game.stack.Spell)

Aggregations

MageObject (mage.MageObject)1 Cost (mage.abilities.costs.Cost)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 MayTapOrUntapTargetEffect (mage.abilities.effects.common.MayTapOrUntapTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 Spell (mage.game.stack.Spell)1 Player (mage.players.Player)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1