Add finality counters (#11379)

* [LCI] Implement Soulcoil Viper

* add finality counter test

* fix bug, add extra test

* [LCI] Implement Uchbenbak, the Great Mistake
This commit is contained in:
Evan Kranzler 2023-11-01 22:08:57 -04:00 committed by GitHub
parent 6a33c68bb2
commit 595955a3cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 280 additions and 1 deletions

View file

@ -0,0 +1,57 @@
package mage.abilities.effects.keyword;
import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
/**
* @author TheElk801
*/
public class FinalityCounterEffect extends ReplacementEffectImpl {
public FinalityCounterEffect() {
super(Duration.Custom, Outcome.Tap);
this.staticText = "If a creature with a finality counter on it would die, exile it instead.";
}
private FinalityCounterEffect(final FinalityCounterEffect effect) {
super(effect);
}
@Override
public FinalityCounterEffect copy() {
return new FinalityCounterEffect(this);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
((ZoneChangeEvent) event).setToZone(Zone.EXILED);
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!((ZoneChangeEvent) event).isDiesEvent()) {
return false;
}
Permanent permanent = game.getPermanent(event.getTargetId());
return permanent != null && permanent.getCounters(game).getCount(CounterType.FINALITY) > 0;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
}