Search in sources :

Example 1 with OrCost

use of mage.abilities.costs.OrCost in project mage by magefree.

the class EmberwildeDjinnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Cost cost = new OrCost(new ManaCostsImpl("{R}{R}"), new PayLifeCost(2), "{R}{R} or 2 life");
    if (player.chooseUse(Outcome.GainControl, "Gain control of " + sourceObject.getLogName() + "?", source, game)) {
        if (cost.pay(source, game, source, player.getId(), false)) {
            ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, false, player.getId());
            effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
            game.addEffect(effect, source);
            player.resetStoredBookmark(game);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) OrCost(mage.abilities.costs.OrCost) MageObject(mage.MageObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) ContinuousEffect(mage.abilities.effects.ContinuousEffect) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) OrCost(mage.abilities.costs.OrCost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 2 with OrCost

use of mage.abilities.costs.OrCost in project mage by magefree.

the class LimDulsHexEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (sourcePermanent != null) {
        for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                OrCost costToPay = new OrCost(new ManaCostsImpl("{B}"), new ManaCostsImpl("{3}"), "{B} or {3}");
                costToPay.clearPaid();
                if (!(player.chooseUse(Outcome.Benefit, "Pay {B} or {3}?", source, game) && costToPay.pay(source, game, source, player.getId(), false, null))) {
                    game.informPlayers(player.getLogName() + " chooses not to pay " + costToPay.getText() + " to prevent 1 damage from " + sourcePermanent.getLogName());
                    player.damage(1, sourcePermanent.getId(), source, game);
                } else {
                    game.informPlayers(player.getLogName() + " chooses to pay " + costToPay.getText() + " to prevent 1 damage from " + sourcePermanent.getLogName());
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) OrCost(mage.abilities.costs.OrCost) UUID(java.util.UUID) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

OrCost (mage.abilities.costs.OrCost)2 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)2 Player (mage.players.Player)2 UUID (java.util.UUID)1 MageObject (mage.MageObject)1 Cost (mage.abilities.costs.Cost)1 PayLifeCost (mage.abilities.costs.common.PayLifeCost)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1