use of mage.abilities.effects.common.continuous.BoostTargetEffect 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