use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class HeroOfLeinaTowerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
ManaCosts cost = new ManaCostsImpl("{X}");
if (you != null && you.chooseUse(Outcome.BoostCreature, "Do you want to to pay {X}?", source, game)) {
int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
cost.add(new GenericManaCost(costX));
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(costX), true).apply(game, source);
}
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class RavenousSlimeEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (controller == null || sourceCreature == null) {
return false;
}
if (((ZoneChangeEvent) event).getFromZone() != Zone.BATTLEFIELD) {
return false;
}
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent == null) {
return false;
}
int power = permanent.getPower().getValue();
controller.moveCards(permanent, Zone.EXILED, source, game);
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(power)).apply(game, source);
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class WildbornPreserverCreateReflexiveTriggerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ManaCosts cost = new ManaCostsImpl("{X}");
if (player == null) {
return false;
}
if (!player.chooseUse(outcome, "Pay " + cost.getText() + "?", source, game)) {
return false;
}
int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
cost.add(new GenericManaCost(costX));
if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
return false;
}
game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(costX)), false, "put X +1/+1 counters on {this}"), source);
return true;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class DevouringHellionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
int xValue = 0;
for (UUID targetId : target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null && permanent.sacrifice(source, game)) {
xValue++;
}
}
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(2 * xValue)).apply(game, source);
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class WhiptongueHydraEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int destroyedPermanents = 0;
destroyedPermanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game).stream().filter((permanent) -> (permanent.destroy(source, game, false))).map((_item) -> 1).reduce(destroyedPermanents, Integer::sum);
if (destroyedPermanents > 0) {
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(destroyedPermanents), true).apply(game, source);
}
return true;
}
Aggregations