use of mage.counters.Counters in project mage by magefree.
the class UndyingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Counters countersToAdd = new Counters();
countersToAdd.addCounter(CounterType.P1P1.createInstance());
game.setEnterWithCounters(source.getSourceId(), countersToAdd);
return true;
}
use of mage.counters.Counters in project mage by magefree.
the class SkullbriarEffect method updateZoneChangeCounter.
@Override
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
boolean skullBriarEffectApplied = false;
if (event.getToZone() != Zone.HAND && event.getToZone() != Zone.LIBRARY) {
for (StaticAbility ability : getAbilities(game).getStaticAbilities(event.getFromZone())) {
for (Effect effect : ability.getEffects(game, EffectType.REPLACEMENT)) {
if (effect instanceof SkullbriarEffect && event.getAppliedEffects().contains(effect.getId())) {
skullBriarEffectApplied = true;
}
}
}
}
Counters copyFrom = null;
if (skullBriarEffectApplied) {
if (event.getTarget() != null && event.getFromZone() == Zone.BATTLEFIELD) {
copyFrom = new Counters(event.getTarget().getCounters(game));
} else {
copyFrom = new Counters(this.getCounters(game));
}
}
super.updateZoneChangeCounter(game, event);
Counters copyTo = null;
if (event.getTarget() != null && event.getToZone() == Zone.BATTLEFIELD) {
if (event.getFromZone() != Zone.BATTLEFIELD) {
copyTo = event.getTarget().getCounters(game);
}
} else {
copyTo = this.getCounters(game);
}
if (copyTo != null && copyFrom != null) {
for (Counter counter : copyFrom.values()) {
copyTo.addCounter(counter);
}
}
}
use of mage.counters.Counters in project mage by magefree.
the class IsarethTheAwakenerReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || card == null) {
return false;
}
Counters countersToAdd = new Counters();
countersToAdd.addCounter(CounterType.CORPSE.createInstance());
game.setEnterWithCounters(card.getId(), countersToAdd);
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
use of mage.counters.Counters in project mage by magefree.
the class TheOzolithMoveCountersEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!super.checkTrigger(event, game)) {
return false;
}
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
Counters counters = permanent.getCounters(game);
if (counters.values().stream().mapToInt(Counter::getCount).noneMatch(x -> x > 0)) {
return false;
}
this.getEffects().clear();
this.addEffect(new TheOzolithLeaveEffect(counters));
return true;
}
use of mage.counters.Counters in project mage by magefree.
the class PersistEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Counters countersToAdd = new Counters();
countersToAdd.addCounter(CounterType.M1M1.createInstance());
game.setEnterWithCounters(source.getSourceId(), countersToAdd);
return true;
}
Aggregations