use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class WoodlandChampionTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
if (zEvent != null && Zone.BATTLEFIELD == zEvent.getToZone() && zEvent.getTokens() != null) {
int tokenCount = zEvent.getTokens().stream().mapToInt(card -> card.isControlledBy(this.getControllerId()) ? 1 : 0).sum();
if (tokenCount > 0) {
this.getEffects().clear();
this.addEffect(new AddCountersSourceEffect(CounterType.P1P1.createInstance(tokenCount)));
return true;
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class HeroOfBretagardTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
final int numberExiled = zEvent.getCards().size() + zEvent.getTokens().size();
if (zEvent.getToZone() != Zone.EXILED || numberExiled == 0) {
return false;
}
switch(zEvent.getFromZone()) {
case BATTLEFIELD:
if (controllerId.equals(zEvent.getSource().getControllerId()) && numberExiled > 0) {
// must include both card permanents and tokens on the battlefield
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(numberExiled)));
return true;
}
case HAND:
if (zEvent.getCards().stream().filter(Objects::nonNull).map(Card::getOwnerId).anyMatch(this::isControlledBy) && numberExiled > 0) {
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(numberExiled)));
return true;
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class BecomesRenownedSourceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && source instanceof RenownAbility) {
game.informPlayers(permanent.getLogName() + " is now renowned");
int renownValue = ((RenownAbility) source).getRenownValue();
// handle renown = X
if (renownValue == Integer.MAX_VALUE) {
renownValue = source.getManaCostsToPay().getX();
}
new AddCountersSourceEffect(CounterType.P1P1.createInstance(renownValue), true).apply(game, source);
permanent.setRenowned(true);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.BECOMES_RENOWNED, source.getSourceId(), source, source.getControllerId(), renownValue));
return true;
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class ChaoticGooEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
if (controller.flipCoin(source, game, true)) {
game.informPlayers("Chaotic Goo: Won flip. Put a +1/+1 counter on Chaotic Goo.");
new AddCountersSourceEffect(CounterType.P1P1.createInstance(1)).apply(game, source);
return true;
} else {
game.informPlayers("Chaotic Goo: Lost flip. Remove a +1/+1 counter on Chaotic Goo.");
new RemoveCounterSourceEffect(CounterType.P1P1.createInstance(1)).apply(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class BountyOfTheLuxaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent bountyOfLuxa = game.getPermanent(source.getSourceId());
if (bountyOfLuxa != null && bountyOfLuxa.getZoneChangeCounter(game) != source.getSourceObjectZoneChangeCounter()) {
bountyOfLuxa = null;
}
if (controller != null) {
if (bountyOfLuxa != null && bountyOfLuxa.getCounters(game).getCount(CounterType.FLOOD) > 0) {
bountyOfLuxa.removeCounters(CounterType.FLOOD.createInstance(bountyOfLuxa.getCounters(game).getCount(CounterType.FLOOD)), source, game);
if (bountyOfLuxa.getCounters(game).getCount(CounterType.FLOOD) == 0) {
Mana manaToAdd = new Mana();
manaToAdd.increaseColorless();
manaToAdd.increaseGreen();
manaToAdd.increaseBlue();
controller.getManaPool().addMana(manaToAdd, game, source);
}
} else {
if (bountyOfLuxa != null) {
new AddCountersSourceEffect(CounterType.FLOOD.createInstance()).apply(game, source);
}
controller.drawCards(1, source, game);
}
return true;
}
return false;
}
Aggregations