From 0ffd895be95b59bf241e2ff809841b06cce1eb70 Mon Sep 17 00:00:00 2001 From: spjspj <spjspj4@gmail.com> Date: Sun, 15 Apr 2018 20:58:04 +1000 Subject: [PATCH] Minor revert. --- Mage/src/main/java/mage/game/GameImpl.java | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index b928fc7195..7f2ae4f357 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -36,6 +36,7 @@ import mage.MageObject; import mage.abilities.*; import mage.abilities.common.AttachableToRestrictedAbility; import mage.abilities.common.CantHaveMoreThanAmountCountersSourceAbility; +import mage.abilities.common.SagaAbility; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffects; import mage.abilities.effects.Effect; @@ -1923,7 +1924,7 @@ public abstract class GameImpl implements Game, Serializable { if (perm.isWorld()) { worldEnchantment.add(perm); } - if (StaticFilters.FILTER_PERMANENT_AURA.match(perm, this)) { + if (perm.hasSubtype(SubType.AURA, this)) { //20091005 - 704.5n, 702.14c if (perm.getAttachedTo() == null) { Card card = this.getCard(perm.getId()); @@ -2013,6 +2014,30 @@ public abstract class GameImpl implements Game, Serializable { } } } + // Remove Saga enchantment if last chapter is reached and chapter ability has left the stack + if (perm.hasSubtype(SubType.SAGA, this)) { + for (Ability sagaAbility : perm.getAbilities()) { + if (sagaAbility instanceof SagaAbility) { + int maxChapter = ((SagaAbility) sagaAbility).getMaxChapter().getNumber(); + if (maxChapter <= perm.getCounters(this).getCount(CounterType.LORE)) { + boolean noChapterAbilityOnStack = true; + // Check chapter abilities on stack + for (StackObject stackObject : getStack()) { + if (stackObject.getSourceId().equals(perm.getId()) && SagaAbility.isChapterAbility(stackObject)) { + noChapterAbilityOnStack = false; + break; + } + } + if (noChapterAbilityOnStack) { + // After the last chapter ability has left the stack, you'll sacrifice the Saga + perm.sacrifice(perm.getId(), this); + somethingHappened = true; + } + } + + } + } + } if (this.getState().isLegendaryRuleActive() && StaticFilters.FILTER_PERMANENT_LEGENDARY.match(perm, this)) { legendary.add(perm); }