diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java index 6a11da7..24f0e42 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java @@ -841,17 +841,19 @@ public class GameLogic { } if(character.inventory.getFreeSlots() == 0) { // no slots => has all infinity stones - result.addAll(handlePlayerWin(state, character.id.type)); + result.addAll(handlePlayerWin(state, character.id.type, "collected all infinity stones")); return result; } } if(!anyAlive) { - EntityType winner = state.winConditions.getWinner(); + String[] reason = new String[1]; + EntityType winner = state.winConditions.getWinner(reason); if(winner == EntityType.None) { winner = rand.nextBoolean() ? EntityType.P1 : EntityType.P2; + reason[0] = "determined by lot as tiebreaker"; } - result.addAll(handlePlayerWin(state, winner)); + result.addAll(handlePlayerWin(state, winner, reason[0])); return result; } @@ -1224,8 +1226,8 @@ public class GameLogic { * @param winner The winning character * @return The list of resulting {@link Event Events} */ - private static ArrayList handlePlayerWin(GameState state, EntityType winner) { - Logger.trace("Player " + winner + " won"); + private static ArrayList handlePlayerWin(GameState state, EntityType winner, String reason) { + Logger.trace("Player " + winner + " won: " + reason); ArrayList result = new ArrayList<>(); diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/WinConditionManager.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/WinConditionManager.java index 2a8814e..0c53dec 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/WinConditionManager.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/WinConditionManager.java @@ -15,9 +15,20 @@ public class WinConditionManager { * @return The {@link EntityType} that is currently winning the game according to overtime ruling */ public EntityType getWinner() { + return getWinner(new String[1]); + } + + /** + * Returns the current winner + * @param reason Will be filled in with the deciding {@link WinCondition} + * @return The {@link EntityType} that is currently winning the game according to overtime ruling + */ + public EntityType getWinner(String[] reason) { int value1; int value2; for(WinCondition condition: WinCondition.values()) { + reason[0] = condition.name(); + value1 = getValue(EntityType.P1, condition); value2 = getValue(EntityType.P2, condition); @@ -29,6 +40,7 @@ public class WinConditionManager { } } + reason[0] = ""; return EntityType.None; }