- Rule 800.4: When a player leaves a multiplayer game, removing objects associated with that Player from the game.

This commit is contained in:
Sol
2016-02-17 21:46:22 +00:00
parent 13eda99d4e
commit 20dcf652fe
3 changed files with 41 additions and 3 deletions

View File

@@ -573,6 +573,23 @@ public class Game {
}
public void onPlayerLost(Player p) {
// Rule 800.4 Losing a Multiplayer game
CardCollectionView cards = this.getCardsInGame();
for(Card c : cards) {
if (c.getOwner().equals(p)) {
c.ceaseToExist();
} else {
c.removeTempController(p);
if (c.getController().equals(p)) {
this.getAction().exile(c);
}
}
}
// Remove leftover items from
this.getStack().removeInstancesControlledBy(p);
ingamePlayers.remove(p);
final Map<String, Object> runParams = new TreeMap<String, Object>();

View File

@@ -2201,6 +2201,15 @@ public class Card extends GameEntity implements Comparable<Card> {
}
}
public final void removeTempController(final Player player) {
// Remove each key that yields this player
for(Entry<Long,Player> kv : tempControllers.entrySet()) {
if (kv.getValue().equals(player)) {
tempControllers.remove(kv.getKey());
}
}
}
public final void clearTempControllers() {
if (tempControllers.isEmpty()) { return; }
tempControllers.clear();
@@ -3436,9 +3445,7 @@ public class Card extends GameEntity implements Comparable<Card> {
// Just remove it's zone, so we don't run through the exile stuff
// This allows auras on phased out tokens to just phase out permanently
getGame().getTriggerHandler().suppressMode(TriggerType.ChangesZone);
getZone().remove(this);
getGame().getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
this.ceaseToExist();
}
if (!phasedOut) {
@@ -6710,4 +6717,10 @@ public class Card extends GameEntity implements Comparable<Card> {
this.changedCardColors.put(entry.getKey(), entry.getValue());
}
}
public void ceaseToExist() {
getGame().getTriggerHandler().suppressMode(TriggerType.ChangesZone);
getZone().remove(this);
getGame().getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
}
}

View File

@@ -719,6 +719,14 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
}
}
public final void removeInstancesControlledBy(final Player p) {
for (SpellAbilityStackInstance si : stack) {
if (si.getActivatingPlayer().equals(p)) {
remove(si);
}
}
}
public void fizzleTriggersOnStackTargeting(Card c, TriggerType t) {
for (SpellAbilityStackInstance si : stack) {
SpellAbility sa = si.getSpellAbility(false);