use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class DelayingShieldUpkeepEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
new AddCountersSourceEffect(CounterType.DELAY.createInstance(damageEvent.getAmount()), true).apply(game, source);
return true;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class GoblinBombEffect 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("Goblin Bomb: Won flip. Put a fuse counter on Goblin Bomb.");
new AddCountersSourceEffect(CounterType.FUSE.createInstance(1)).apply(game, source);
return true;
} else {
game.informPlayers("Goblin Bomb: Lost flip. Remove a fuse counter from Goblin Bomb.");
new RemoveCounterSourceEffect(CounterType.FUSE.createInstance(1)).apply(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class RescuerSphinxEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
if (!player.chooseUse(outcome, "Return a nonland permanent you control to your hand?", source, game)) {
return false;
}
Target target = new TargetPermanent(0, 1, filter, true);
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null || !player.moveCards(permanent, Zone.HAND, source, game)) {
return false;
}
return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class BingoCount method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source));
if (spell != null) {
if (spell.getManaValue() > 9) {
return true;
}
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
// Map<number, amount of counters>
Map<Integer, Integer> chipCounters = new HashMap<>();
if (game.getState().getValue(mageObject.getId() + "_chip") != null) {
chipCounters.putAll((Map<Integer, Integer>) game.getState().getValue(mageObject.getId() + "_chip"));
}
chipCounters.putIfAbsent(spell.getManaValue(), 0);
chipCounters.put(spell.getManaValue(), chipCounters.get(spell.getManaValue()) + 1);
game.getState().setValue(mageObject.getId() + "_chip", chipCounters);
if (mageObject instanceof Permanent) {
StringBuilder sb = new StringBuilder();
int i = 0;
for (Map.Entry<Integer, Integer> entry : chipCounters.entrySet()) {
i++;
sb.append(entry.getKey());
if (i < chipCounters.size()) {
sb.append(", ");
}
}
((Permanent) mageObject).addInfo("chip counters", CardUtil.addToolTipMarkTags("Chip counters at: " + sb), game);
new AddCountersSourceEffect(CounterType.CHIP.createInstance()).apply(game, source);
}
return true;
}
}
return false;
}
use of mage.abilities.effects.common.counter.AddCountersSourceEffect in project mage by magefree.
the class ForceBubbleStateTriggeredAbility method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
new AddCountersSourceEffect(CounterType.DEPLETION.createInstance(damageEvent.getAmount()), true).apply(game, source);
return true;
}
Aggregations