[MH2] fixed Urza's Saga not being sacrificed immediately when Blood Moon is on battlefield (ability still triggers on etb, related to Blood Moon issue)

This commit is contained in:
Evan Kranzler 2021-06-13 21:22:28 -04:00
parent 348e6d94cb
commit dfc2624d32

View file

@ -2186,36 +2186,36 @@ public abstract class GameImpl implements Game, Serializable {
// 704.5s If the number of lore counters on a Saga permanent is greater than or equal to its final chapter number // 704.5s If the number of lore counters on a Saga permanent is greater than or equal to its final chapter number
// and it isn't the source of a chapter ability that has triggered but not yet left the stack, that Saga's controller sacrifices it. // and it isn't the source of a chapter ability that has triggered but not yet left the stack, that Saga's controller sacrifices it.
if (perm.hasSubtype(SubType.SAGA, this)) { if (perm.hasSubtype(SubType.SAGA, this)) {
for (Ability sagaAbility : perm.getAbilities()) { int maxChapter = perm
if (sagaAbility instanceof SagaAbility) { .getAbilities(this)
int maxChapter = ((SagaAbility) sagaAbility).getMaxChapter().getNumber(); .stream()
if (maxChapter <= perm.getCounters(this).getCount(CounterType.LORE)) { .filter(SagaAbility.class::isInstance)
boolean noChapterAbilityTriggeredOrOnStack = true; .map(SagaAbility.class::cast)
// Check chapter abilities on stack .map(SagaAbility::getMaxChapter)
for (StackObject stackObject : getStack()) { .mapToInt(SagaChapter::getNumber)
if (stackObject.getSourceId().equals(perm.getId()) && SagaAbility.isChapterAbility(stackObject)) { .max()
noChapterAbilityTriggeredOrOnStack = false; .orElse(0);
break;
} boolean sacSaga = maxChapter <= perm
} .getCounters(this)
if (noChapterAbilityTriggeredOrOnStack) { .getCount(CounterType.LORE)
for (TriggeredAbility trigger : state.getTriggered(perm.getControllerId())) { && this.getStack()
if (SagaAbility.isChapterAbility(trigger) && trigger.getSourceId().equals(perm.getId())) { .stream()
noChapterAbilityTriggeredOrOnStack = false; .filter(SagaAbility::isChapterAbility)
break; .map(StackObject::getSourceId)
} .noneMatch(perm.getId()::equals)
} && this.state
} .getTriggered(perm.getControllerId())
if (noChapterAbilityTriggeredOrOnStack) { .stream()
.filter(SagaAbility::isChapterAbility)
.map(Ability::getSourceId)
.noneMatch(perm.getId()::equals);
if (sacSaga) {
// After the last chapter ability has left the stack, you'll sacrifice the Saga // After the last chapter ability has left the stack, you'll sacrifice the Saga
perm.sacrifice(null, this); perm.sacrifice(null, this);
somethingHappened = true; somethingHappened = true;
} }
} }
}
}
}
if (this.getState().isLegendaryRuleActive() && StaticFilters.FILTER_PERMANENT_LEGENDARY.match(perm, this)) { if (this.getState().isLegendaryRuleActive() && StaticFilters.FILTER_PERMANENT_LEGENDARY.match(perm, this)) {
legendary.add(perm); legendary.add(perm);
} }