Skip to content
Snippets Groups Projects
Commit f504af11 authored by Schuh Martin's avatar Schuh Martin
Browse files

Minor Fixes

Update: Persistence.java (changed order of parameters in signature of method)
Update: RuntimeInfo.java (renamed some methods)
Update ThreadUpdateStats.java (changed order of method parameters of called method according to changes in Persistence.java)
parent 9a3d3b7c
No related branches found
No related tags found
1 merge request!75Merge DB in Dev
Pipeline #60606 passed
......@@ -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 {
......
......@@ -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;
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment