MCPcopy Create free account
hub / github.com/Card-Forge/forge / onPlayerLost

Method onPlayerLost

forge-game/src/main/java/forge/game/Game.java:856–1005  ·  view source on GitHub ↗
(Player p)

Source from the content-addressed store, hash-verified

854 }
855
856 public void onPlayerLost(Player p) {
857 //set for Avatar
858 p.setHasLost(true);
859 // CR 800.4 Losing a Multiplayer game
860 CardCollectionView cards = this.getCardsInGame();
861 boolean planarControllerLost = false;
862 boolean planarOwnerLost = false;
863 boolean isMultiplayer = getPlayers().size() > 2;
864 CardZoneTable triggerList = new CardZoneTable(getLastStateBattlefield(), getLastStateGraveyard());
865
866 // CR 702.142f & 707.9
867 // If a player leaves the game, all face-down cards that player owns must be revealed to all players.
868 // At the end of each game, all face-down cards must be revealed to all players.
869 if (isMultiplayer) {
870 p.revealFaceDownCards();
871 } else {
872 for (Player pl : getPlayers()) {
873 pl.revealFaceDownCards();
874 }
875 }
876
877 // TODO free any mindslaves
878
879 for (Card c : cards) {
880 // CR 800.4d if card is controlled by opponent, LTB should trigger
881 if (c.getOwner().equals(p) && c.getController().equals(p)) {
882 getTriggerHandler().clearActiveTriggers(c, null);
883 }
884 }
885
886 if (getActivePlanes() != null) {
887 for (Card c : getActivePlanes()) {
888 if (c.getController().equals(p)) {
889 planarControllerLost = true;
890 }
891 if (c.getOwner().equals(p)) {
892 planarOwnerLost = true;
893 }
894 }
895 }
896
897 for (Card c : cards) {
898 if (isMultiplayer) {
899 // unattach all "Enchant Player"
900 c.removeAttachedTo(p);
901 if (c.getOwner().equals(p)) {
902 // check that it wasn't cleaned up already
903 if (c.getEffectSource() != null && !c.isEmblem() && p.getZone(ZoneType.Command).contains(c)) {
904 c.getZone().remove(c);
905 // move effect to another player so they continue to work
906 getNextPlayerAfter(p).getZone(ZoneType.Command).add(c);
907 } else {
908 for (Card cc : cards) {
909 cc.removeImprintedCard(c);
910 cc.removeEncodedCard(c);
911 cc.removeRemembered(c);
912 cc.removeAttachedTo(c);
913 cc.removeAttachedCard(c);

Callers 1

Calls 15

getCardsInGameMethod · 0.95
getPlayersMethod · 0.95
getLastStateGraveyardMethod · 0.95
getTriggerHandlerMethod · 0.95
getActivePlanesMethod · 0.95
getNextPlayerAfterMethod · 0.95
putMethod · 0.95
getActionMethod · 0.95
getStackMethod · 0.95
setActivatingPlayerMethod · 0.95
triggerChangesZoneAllMethod · 0.95

Tested by

no test coverage detected