diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java index 852381acc8c458097a1a91309fb1d567b2347b2b..6806b2307b57312f59a0d140a25fce8598ab5bec 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/Persistence.java @@ -217,14 +217,14 @@ public class Persistence { } } - public synchronized void updatePlayerStatistics(int kills, int deaths, int gameTime, int blocksDestroyed, int powerUpsCollected, boolean gameWon) throws DatabaseException { //after game round; only update stats in RAM, not in persistence (run savePlayerStatistics() method at end of program to save stats to persistence) + public synchronized void updatePlayerStatistics(boolean gameWon, int kills, int deaths, int blocksDestroyed, int powerUpsCollected, int gameTime) throws DatabaseException { //after game round; only update stats in RAM, not in persistence (run savePlayerStatistics() method at end of program to save stats to persistence) try { Parser.playerStatsValid(new PlayerStatistics(0, 0, kills, deaths, blocksDestroyed, powerUpsCollected, gameTime)); //temp instance of PLayerStatistics to validate new values statistics.addKills(kills); statistics.addDeaths(deaths); - statistics.addGameTime(gameTime); statistics.addBlocksDestroyed(blocksDestroyed); statistics.addPowerUpsCollected(powerUpsCollected); + statistics.addGameTime(gameTime); if (gameWon) { statistics.addGamesWon(); } else { diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java index e6fd178d56f5d8dd6780537cb7c5546e2188254a..667be0e8fbf7aecf1602440830875d6408b39c5a 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java @@ -152,7 +152,7 @@ public class RuntimeInfo { this.kills = kills; } - public void addKill() { + public void addOneKill() { kills = kills + 1; } @@ -164,7 +164,7 @@ public class RuntimeInfo { this.deaths = deaths; } - public void addDeath() { + public void addOneDeath() { deaths = deaths + 1; } @@ -176,7 +176,7 @@ public class RuntimeInfo { this.blocksDestroyed = blocksDestroyed; } - public void addBlockDestroyed() { + public void addOneBlockDestroyed() { blocksDestroyed = blocksDestroyed + 1; } @@ -188,7 +188,7 @@ public class RuntimeInfo { this.powerUpsCollected = powerUpsCollected; } - public void addPowerUpsCollected() { + public void addOnePowerUpCollected() { powerUpsCollected = powerUpsCollected + 1; } @@ -200,7 +200,7 @@ public class RuntimeInfo { this.gameTime = gameTime; } - public void addGameTime() { + public void incrementGameTime() { gameTime = gameTime + 1; } diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateStats.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateStats.java index c5b27d96d949fe888ac7486869df1b822b292c95..c34a7214c711ed9df1995ce060091e28d5541007 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateStats.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/ThreadUpdateStats.java @@ -17,7 +17,7 @@ public class ThreadUpdateStats extends Thread{ try { threadsInstance.setThreadUpdateStatsMsg(""); threadsInstance.setThreadUpdateStats(ThreadStatus.RUNNING); - persistenceInst.updatePlayerStatistics(runtimeInfoInst.getKills(), runtimeInfoInst.getDeaths(), runtimeInfoInst.getGameTime(), runtimeInfoInst.getBlocksDestroyed(), runtimeInfoInst.getPowerUpsCollected(), runtimeInfoInst.isGameWon()); + persistenceInst.updatePlayerStatistics(runtimeInfoInst.isGameWon(), runtimeInfoInst.getKills(), runtimeInfoInst.getDeaths(), runtimeInfoInst.getBlocksDestroyed(), runtimeInfoInst.getPowerUpsCollected(), runtimeInfoInst.getGameTime()); runtimeInfoInst.resetGameStats(); log.info("Update statistics thread finished successfully!"); threadsInstance.setThreadUpdateStats(ThreadStatus.FINISHED);