use of mage.abilities.costs.common.PayEnergyCost 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;
}
use of mage.abilities.costs.common.PayEnergyCost 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;
}
use of mage.abilities.costs.common.PayEnergyCost 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;
}
use of mage.abilities.costs.common.PayEnergyCost 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;
}
Aggregations