diff --git a/.gitattributes b/.gitattributes
index c66b6296468..cf72bc367e2 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -9761,7 +9761,6 @@ src/main/java/forge/game/GameLossReason.java -text
src/main/java/forge/game/GamePlayerRating.java -text
src/main/java/forge/game/GameSummary.java svneol=native#text/plain
src/main/java/forge/game/GameType.java -text
-src/main/java/forge/game/PlayerIndex.java -text
src/main/java/forge/game/limited/BoosterDraft.java svneol=native#text/plain
src/main/java/forge/game/limited/BoosterDraftAI.java svneol=native#text/plain
src/main/java/forge/game/limited/BoosterDraft_1.java svneol=native#text/plain
diff --git a/src/main/java/forge/AllZone.java b/src/main/java/forge/AllZone.java
index 15756459743..08bd0c528ab 100644
--- a/src/main/java/forge/AllZone.java
+++ b/src/main/java/forge/AllZone.java
@@ -55,9 +55,6 @@ public final class AllZone implements NewConstants {
/** Constant inputControl. */
private static final InputControl INPUT_CONTROL = new InputControl(Singletons.getModel());
- /** Game state observer gameInfo collects statistics and players' performance. */
- private static GameSummary gameInfo = new GameSummary();
-
/**
* Match State for challenges are stored in a QuestMatchState class instance.
*/
@@ -301,7 +298,7 @@ public final class AllZone implements NewConstants {
* @since 1.0.15
*/
public static GameSummary getGameInfo() {
- return gameInfo;
+ return Singletons.getModel().getGameState().getGameInfo();
}
/**
@@ -439,26 +436,15 @@ public final class AllZone implements NewConstants {
*/
public static void newGameCleanup() {
- gameInfo = new GameSummary();
-
- getHumanPlayer().reset();
- getComputerPlayer().reset();
-
- getPhase().reset();
- getStack().reset();
- getCombat().reset();
+ Singletons.getModel().getGameState().newGameCleanup();
+
+
getDisplay().showCombat("");
getDisplay().loadPrefs();
- for (Player p : Singletons.getModel().getGameState().getPlayers()) {
- for(Zone z : Player.ALL_ZONES) {
- p.getZone(z).reset();
- }
- }
getInputControl().clearInput();
- getStaticEffects().reset();
getColorChanger().reset();
// player.reset() now handles this
diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java
index 4ff8efffd6d..96685eed513 100644
--- a/src/main/java/forge/GameAction.java
+++ b/src/main/java/forge/GameAction.java
@@ -22,7 +22,6 @@ import forge.deck.Deck;
import forge.game.GameEndReason;
import forge.game.GameSummary;
import forge.game.GameType;
-import forge.game.PlayerIndex;
import forge.gui.GuiUtils;
import forge.gui.input.Input_Mulligan;
import forge.gui.input.Input_PayManaCost;
@@ -598,9 +597,9 @@ public class GameAction {
humanWins = true;
if (human.getAltWin()) {
- game.end(GameEndReason.WinsGameSpellEffect, PlayerIndex.HUMAN, human.getWinConditionSource());
+ game.end(GameEndReason.WinsGameSpellEffect, human.getName(), human.getWinConditionSource());
} else {
- game.end(GameEndReason.AllOpponentsLost, PlayerIndex.HUMAN, null);
+ game.end(GameEndReason.AllOpponentsLost, human.getName(), null);
}
}
@@ -608,14 +607,14 @@ public class GameAction {
if (computer.hasWon() || human.hasLost()) {
if (humanWins) {
// both players won/lost at the same time.
- game.end(GameEndReason.Draw, PlayerIndex.DRAW, null);
+ game.end(GameEndReason.Draw, null, null);
} else {
computerWins = true;
if (computer.getAltWin()) {
- game.end(GameEndReason.WinsGameSpellEffect, PlayerIndex.AI, computer.getWinConditionSource());
+ game.end(GameEndReason.WinsGameSpellEffect, computer.getName(), computer.getWinConditionSource());
} else {
- game.end(GameEndReason.AllOpponentsLost, PlayerIndex.AI, null);
+ game.end(GameEndReason.AllOpponentsLost, computer.getName(), null);
}
}
@@ -623,8 +622,8 @@ public class GameAction {
boolean isGameDone = humanWins || computerWins;
if (isGameDone) {
- game.getPlayerRating(PlayerIndex.AI).setLossReason(computer.getLossState(), computer.getLossConditionSource());
- game.getPlayerRating(PlayerIndex.HUMAN).setLossReason(human.getLossState(), human.getLossConditionSource());
+ game.getPlayerRating(computer.getName()).setLossReason(computer.getLossState(), computer.getLossConditionSource());
+ game.getPlayerRating(human.getName()).setLossReason(human.getLossState(), human.getLossConditionSource());
AllZone.getMatchState().addGamePlayed(game);
}
@@ -1245,7 +1244,7 @@ public class GameAction {
} else {
seeWhoPlaysFirst_CoinToss();
}
- } else if (AllZone.getMatchState().hasHumanWonLastGame()) {
+ } else if (AllZone.getMatchState().hasWonLastGame(AllZone.getHumanPlayer().getName())) {
// if player won last, AI starts
computerStartsGame();
}
@@ -1517,8 +1516,9 @@ public class GameAction {
*
computerStartsGame.
*/ public final void computerStartsGame() { - AllZone.getPhase().setPlayerTurn(AllZone.getComputerPlayer()); - AllZone.getGameInfo().setPlayerWhoGotFirstTurn(PlayerIndex.AI); + Player computer = AllZone.getComputerPlayer(); + AllZone.getPhase().setPlayerTurn(computer); + AllZone.getGameInfo().setPlayerWhoGotFirstTurn(computer.getName()); } //if Card had the type "Aura" this method would always return true, since local enchantments are always attached to something diff --git a/src/main/java/forge/Gui_WinLose.java b/src/main/java/forge/Gui_WinLose.java index 4fddbe16446..a0bc477fdfd 100644 --- a/src/main/java/forge/Gui_WinLose.java +++ b/src/main/java/forge/Gui_WinLose.java @@ -6,7 +6,6 @@ import forge.game.GameFormat; import forge.game.GameLossReason; import forge.game.GamePlayerRating; import forge.game.GameSummary; -import forge.game.PlayerIndex; import forge.gui.CardListViewer; import forge.gui.ListChooser; import forge.item.CardPrinted; @@ -113,13 +112,14 @@ public class Gui_WinLose extends JFrame implements NewConstants { restartButton.setEnabled(!isQuestMode); // For quest always disabled, otherwise always on //show Wins and Loses - int humanWins = model.match.getGamesCountWonByHuman(); - int humanLosses = model.match.getGamesCountLostByHuman(); + Player human = AllZone.getHumanPlayer(); + int humanWins = model.match.countGamesWonBy(human.getName()); + int humanLosses = model.match.getGamesPlayedCount() - humanWins; statsLabel.setText(ForgeProps.getLocalized(WINLOSE_TEXT.WON) + humanWins + ForgeProps.getLocalized(WINLOSE_TEXT.LOST) + humanLosses); //show "You Won" or "You Lost" - if (model.match.hasHumanWonLastGame()) { + if (model.match.hasWonLastGame(human.getName())) { titleLabel.setText(ForgeProps.getLocalized(WINLOSE_TEXT.WIN)); } else { titleLabel.setText(ForgeProps.getLocalized(WINLOSE_TEXT.LOSE)); @@ -244,15 +244,16 @@ public class Gui_WinLose extends JFrame implements NewConstants { StringBuilder sb = new StringBuilder(""); boolean hasNeverLost = true; + Player computer = AllZone.getComputerPlayer(); for (GameSummary game : matchState.getGamesPlayed()) { - if (game.isAIWinner()) { - hasNeverLost = true; + if (game.isWinner(computer.getName())) { + hasNeverLost = false; continue; // no rewards for losing a game } - GamePlayerRating aiRating = game.getPlayerRating(PlayerIndex.AI); - GamePlayerRating humanRating = game.getPlayerRating(PlayerIndex.HUMAN); + GamePlayerRating aiRating = game.getPlayerRating(computer.getName()); + GamePlayerRating humanRating = game.getPlayerRating(AllZone.getHumanPlayer().getName()); GameLossReason whyAiLost = aiRating.getLossReason(); int rewardAltWinCondition = q.getRewards().getCreditsRewardForAltWin(whyAiLost); @@ -344,7 +345,7 @@ public class Gui_WinLose extends JFrame implements NewConstants { } else { //Quest boolean wonMatch = false; - if (model.match.isMatchWonByHuman()) { + if (model.match.isMatchWonBy(AllZone.getHumanPlayer().getName())) { model.quest.addWin(); wonMatch = true; } else { diff --git a/src/main/java/forge/game/GameSummary.java b/src/main/java/forge/game/GameSummary.java index c1076630078..9a3ac3e1d32 100644 --- a/src/main/java/forge/game/GameSummary.java +++ b/src/main/java/forge/game/GameSummary.java @@ -1,5 +1,8 @@ package forge.game; +import java.util.HashMap; +import java.util.Map; + /** *GameInfo class.
@@ -8,49 +11,44 @@ package forge.game; * @version $Id$ */ -// This should be divided into two: the very summary (immutable with only getters) and +// This class might be divided in two parts: the very summary (immutable with only getters) and // GameObserver class - who should be notified of any considerable ingame event -public class GameSummary { - protected int playerWinner = PlayerIndex.UNDEFINED; - protected int playerGotFirstTurn = PlayerIndex.UNDEFINED; +public final class GameSummary { + protected String playerWinner = "Nobody"; + protected String playerGotFirstTurn = "Nobody"; protected int lastTurnNumber = 0; protected GameEndReason winCondition; protected String spellEffectWin; - protected GamePlayerRating playerRating[] = new GamePlayerRating[2/*players*/]; + protected final Map