mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Added logic to remove control effects that refer to permanents of a player that leaves the game.
This commit is contained in:
parent
da9e9a1180
commit
d85b9943f1
3 changed files with 167 additions and 0 deletions
|
|
@ -1066,6 +1066,10 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public HashSet<Ability> getLayeredEffectAbilities(ContinuousEffect effect) {
|
||||
return layeredEffects.getAbility(effect.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a continuous ability with a reference to a sourceId. It's used for
|
||||
* effects that cease to exist again So this effects were removed again
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ import mage.cards.decks.Deck;
|
|||
import mage.choices.Choice;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
|
|
@ -2321,6 +2322,23 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
perm.removeFromCombat(this, true);
|
||||
}
|
||||
it.remove();
|
||||
} else if (perm.getControllerId().equals(player.getId())) {
|
||||
// and any effects which give that player control of any objects or players end
|
||||
Effects:
|
||||
for (ContinuousEffect effect : getContinuousEffects().getLayeredEffects(this)) {
|
||||
if (effect.hasLayer(Layer.ControlChangingEffects_2)) {
|
||||
for (Ability ability : getContinuousEffects().getLayeredEffectAbilities(effect)) {
|
||||
for (Target target : ability.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (targetId.equals(perm.getId())) {
|
||||
effect.discard();
|
||||
continue Effects;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Then, if that player controlled any objects on the stack not represented by cards, those objects cease to exist.
|
||||
|
|
@ -2332,6 +2350,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
// Then, if there are any objects still controlled by that player, those objects are exiled.
|
||||
applyEffects(); // to remove control from effects removed meanwhile
|
||||
List<Permanent> permanents = this.getBattlefield().getAllActivePermanents(playerId);
|
||||
for (Permanent permanent : permanents) {
|
||||
permanent.moveToExile(null, "", null, this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue