Search in sources :

Example 1 with GetEnergyCountersControllerEffect

use of mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect in project mage by magefree.

the class ConfiscationCoupEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        new GetEnergyCountersControllerEffect(4).apply(game, source);
        Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (targetPermanent != null) {
            Cost cost = new PayEnergyCost(targetPermanent.getManaCost().manaValue());
            if (cost.canPay(source, source, source.getControllerId(), game)) {
                int manaValue = targetPermanent.getManaCost().manaValue();
                StringBuilder energy = new StringBuilder(manaValue);
                for (int i = 0; i < manaValue; i++) {
                    energy.append("{E}");
                }
                if (controller.chooseUse(outcome, "Pay " + energy + " to get control of " + targetPermanent.getLogName() + '?', source, game)) {
                    if (cost.pay(source, game, source, source.getControllerId(), true)) {
                        ContinuousEffect controllEffect = new GainControlTargetEffect(Duration.Custom);
                        controllEffect.setTargetPointer(new FixedTarget(targetPermanent, game));
                        game.addEffect(controllEffect, source);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GetEnergyCountersControllerEffect(mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cost(mage.abilities.costs.Cost) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 2 with GetEnergyCountersControllerEffect

use of mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect in project mage by magefree.

the class LightningRunnerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        new GetEnergyCountersControllerEffect(2).apply(game, source);
        if (controller.getCounters().getCount(CounterType.ENERGY) > 7) {
            Cost cost = new PayEnergyCost(8);
            if (controller.chooseUse(outcome, "Pay {E}{E}{E}{E}{E}{E}{E}{E} to use this? ", "Untap all creatures you control and after this phase, there is an additional combat phase.", "Yes", "No", source, game) && cost.pay(source, game, source, source.getControllerId(), true)) {
                new UntapAllControllerEffect(new FilterControlledCreaturePermanent()).apply(game, source);
                new AdditionalCombatPhaseEffect().apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) GetEnergyCountersControllerEffect(mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect) AdditionalCombatPhaseEffect(mage.abilities.effects.common.AdditionalCombatPhaseEffect) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost) Cost(mage.abilities.costs.Cost) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost) UntapAllControllerEffect(mage.abilities.effects.common.UntapAllControllerEffect)

Example 3 with GetEnergyCountersControllerEffect

use of mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect in project mage by magefree.

the class HarnessedLightningEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        new GetEnergyCountersControllerEffect(3).apply(game, source);
        int numberToPay = controller.getAmount(0, controller.getCounters().getCount(CounterType.ENERGY), "How many {E} do you like to pay?", game);
        if (numberToPay > 0) {
            Cost cost = new PayEnergyCost(numberToPay);
            if (cost.pay(source, game, source, source.getControllerId(), true)) {
                Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
                if (targetCreature != null) {
                    targetCreature.damage(numberToPay, source.getSourceId(), source, game, false, true);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) GetEnergyCountersControllerEffect(mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost) Cost(mage.abilities.costs.Cost) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost)

Example 4 with GetEnergyCountersControllerEffect

use of mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect in project mage by magefree.

the class DieYoungEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        new GetEnergyCountersControllerEffect(2).apply(game, source);
        int max = controller.getCounters().getCount(CounterType.ENERGY);
        int numberToPayed = controller.getAmount(0, max, "How many energy counters do you like to pay? (maximum = " + max + ')', game);
        if (numberToPayed > 0) {
            Cost cost = new PayEnergyCost(numberToPayed);
            if (cost.pay(source, game, source, source.getControllerId(), true)) {
                Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
                if (targetCreature != null) {
                    numberToPayed *= -1;
                    ContinuousEffect effect = new BoostTargetEffect(numberToPayed, numberToPayed, Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(targetCreature, game));
                    game.addEffect(effect, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GetEnergyCountersControllerEffect(mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cost(mage.abilities.costs.Cost) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost)

Aggregations

Cost (mage.abilities.costs.Cost)4 PayEnergyCost (mage.abilities.costs.common.PayEnergyCost)4 GetEnergyCountersControllerEffect (mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect)4 Player (mage.players.Player)4 Permanent (mage.game.permanent.Permanent)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 AdditionalCombatPhaseEffect (mage.abilities.effects.common.AdditionalCombatPhaseEffect)1 UntapAllControllerEffect (mage.abilities.effects.common.UntapAllControllerEffect)1 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 TargetPermanent (mage.target.TargetPermanent)1