mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 14:02:05 -08:00
* Fixed that effects with custom duration are not automatically removed from the game if source permanents leaves the game (fixes #6997).
This commit is contained in:
parent
dbea1e35eb
commit
8098dd690c
4 changed files with 76 additions and 13 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package mage.abilities.effects;
|
||||
|
||||
import java.util.*;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
|
|
@ -10,8 +11,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -121,10 +120,10 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
// They neither expire immediately nor last indefinitely.
|
||||
MageObject object = game.getObject(ability.getSourceId());
|
||||
boolean isObjectInGame = ability.getSourceId() == null || object != null; // Commander effects have no sourceId
|
||||
boolean isOwnerLeaveGame = false;
|
||||
boolean hasOwnerLeftGame = false;
|
||||
if (object instanceof Card) {
|
||||
Player owner = game.getPlayer(((Card) object).getOwnerId());
|
||||
isOwnerLeaveGame = !owner.isInGame();
|
||||
hasOwnerLeftGame = !owner.isInGame();
|
||||
}
|
||||
|
||||
switch (effect.getDuration()) {
|
||||
|
|
@ -136,18 +135,20 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
case EndOfCombat:
|
||||
case EndOfGame:
|
||||
// if the related source object does no longer exist in game - the effect has to be removed
|
||||
if (isOwnerLeaveGame || !isObjectInGame) {
|
||||
if (hasOwnerLeftGame || !isObjectInGame) {
|
||||
it.remove();
|
||||
}
|
||||
break;
|
||||
case OneUse:
|
||||
if (isOwnerLeaveGame || effect.isUsed()) {
|
||||
if (hasOwnerLeftGame || effect.isUsed()) {
|
||||
it.remove();
|
||||
}
|
||||
break;
|
||||
case Custom:
|
||||
// custom effects must process it's own inactive method (override), but can'be missied by devs
|
||||
if (isOwnerLeaveGame || effect.isInactive(ability, game)) {
|
||||
// custom effects must process it's own inactive method (override)
|
||||
// custom effects may not end, if the source permanent of the effect has left the game
|
||||
// 800.4a (only any effects which give that player control of any objects or players end)
|
||||
if (effect.isInactive(ability, game)) {
|
||||
it.remove();
|
||||
}
|
||||
break;
|
||||
|
|
@ -166,7 +167,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
}
|
||||
break;
|
||||
case UntilSourceLeavesBattlefield:
|
||||
if (isOwnerLeaveGame || Zone.BATTLEFIELD != game.getState().getZone(ability.getSourceId())) {
|
||||
if (hasOwnerLeftGame || Zone.BATTLEFIELD != game.getState().getZone(ability.getSourceId())) {
|
||||
it.remove();
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue