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

Update: Persistence.java (minor fixes)

Update: PlayerStatistics.java (remade methods to add changes)
parent 352c622a
No related branches found
No related tags found
4 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!11Merge DataBase to development
......@@ -294,15 +294,16 @@ public class Persistence {
}
}
public void updatePlayerStatistics(int kills, int deaths, int gameTime, boolean gameWon) throws DatabaseException{ //after game round
statistics.setKills(statistics.getKills() + kills);
statistics.setDeaths(statistics.getDeaths() + deaths);
statistics.setGameTime(statistics.getGameTime() + gameTime);
public void updatePlayerStatistics(int kills, int deaths, int gameTime, int blocksDestroyed, boolean gameWon) throws DatabaseException{ //after game round
statistics.addKills(kills);
statistics.addDeaths(deaths);
statistics.addGameTime(gameTime);
statistics.addBlocksDestroyed(blocksDestroyed);
if(gameWon){
statistics.setGamesWon(statistics.getGamesWon() + 1);
statistics.addGamesWon();
}
else{
statistics.setGamesWon(statistics.getGamesLost() + 1);
statistics.addGamesLost();
}
log.info("Statistics successfully updated!");
}
......
......@@ -27,48 +27,48 @@ public class PlayerStatistics {
return gamesLost;
}
public void setGamesLost(int gamesLost) {
this.gamesLost = gamesLost;
protected void addGamesLost() {
gamesLost = gamesLost + 1;
}
public int getGamesWon() {
return gamesWon;
}
public void setGamesWon(int gamesWon) {
this.gamesWon = gamesWon;
protected void addGamesWon() {
gamesWon = gamesWon + 1;
}
public int getKills() {
return kills;
}
public void setKills(int kills) {
this.kills = kills;
protected void addKills(int kills) {
this.kills = this.kills + kills;
}
public int getDeaths() {
return deaths;
}
public void setDeaths(int deaths) {
this.deaths = deaths;
protected void addDeaths(int deaths) {
this.deaths = this.deaths + deaths;
}
public int getBlocksDestroyed() {
return blocksDestroyed;
}
public void setBlocksDestroyed(int blocksDestroyed) {
this.blocksDestroyed = blocksDestroyed;
protected void addBlocksDestroyed(int blocksDestroyed) {
this.blocksDestroyed = this.blocksDestroyed + blocksDestroyed;
}
public int getGameTime() {
return gameTime;
}
public void setGameTime(int gameTime) {
this.gameTime = gameTime;
protected void addGameTime(int gameTime) {
this.gameTime = this.gameTime + gameTime;
}
}
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