Search in sources :

Example 96 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl 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)

Example 97 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class ChainLightningEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        UUID targetId = source.getFirstTarget();
        Player affectedPlayer = null;
        Player player = game.getPlayer(targetId);
        if (player != null) {
            player.damage(3, source.getSourceId(), source, game);
            affectedPlayer = player;
        } else {
            Permanent permanent = game.getPermanent(targetId);
            if (permanent != null) {
                permanent.damage(3, source.getSourceId(), source, game, false, true);
                affectedPlayer = game.getPlayer(permanent.getControllerId());
            }
        }
        if (affectedPlayer != null) {
            if (affectedPlayer.chooseUse(Outcome.Copy, "Pay {R}{R} to copy the spell?", source, game)) {
                Cost cost = new ManaCostsImpl("{R}{R}");
                if (cost.pay(source, game, source, affectedPlayer.getId(), false, null)) {
                    Spell spell = game.getStack().getSpell(source.getSourceId());
                    if (spell != null) {
                        spell.createCopyOnStack(game, source, affectedPlayer.getId(), true);
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Spell(mage.game.stack.Spell)

Example 98 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class DimirDoppelgangerCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DimirDoppelgangerEffect(), new ManaCostsImpl("{1}{U}{B}"));
    ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
    blueprint.getAbilities().add(ability);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)98 Player (mage.players.Player)63 Permanent (mage.game.permanent.Permanent)33 Ability (mage.abilities.Ability)26 Cost (mage.abilities.costs.Cost)26 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)23 UUID (java.util.UUID)16 Card (mage.cards.Card)16 ManaCosts (mage.abilities.costs.mana.ManaCosts)15 SpellAbility (mage.abilities.SpellAbility)14 FixedTarget (mage.target.targetpointer.FixedTarget)13 Test (org.junit.Test)13 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)12 ManaCost (mage.abilities.costs.mana.ManaCost)11 ContinuousEffect (mage.abilities.effects.ContinuousEffect)8 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)7 TargetPermanent (mage.target.TargetPermanent)7 MageObjectReference (mage.MageObjectReference)6 Effect (mage.abilities.effects.Effect)6 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)6