forked from IF-LK-2020/wordle
push und pull Stats überarbeitet
This commit is contained in:
parent
4636051237
commit
2337ad327d
45
Query.java
45
Query.java
|
@ -7,28 +7,43 @@ public class Query {
|
|||
|
||||
public void pullStats(User user) {
|
||||
String[][] r;
|
||||
db.executeStatement("SELECT * FROM user WHERE user LIKE" + user.username);
|
||||
db.executeStatement("SELECT * FROM user WHERE user LIKE" + user.getUsername());
|
||||
r = db.getCurrentQueryResult().getData();
|
||||
user.currentStreak = Integer.parseInt(r[1][0]);
|
||||
user.maxStreak = Integer.parseInt(r[2][0]);
|
||||
user.wins = Integer.parseInt(r[3][0]);
|
||||
user.timesPlayed = Integer.parseInt(r[4][0]);
|
||||
user.wonInTurn[0] = Integer.parseInt(r[5][0]);
|
||||
user.wonInTurn[1] = Integer.parseInt(r[6][0]);
|
||||
user.wonInTurn[2] = Integer.parseInt(r[7][0]);
|
||||
user.wonInTurn[3] = Integer.parseInt(r[8][0]);
|
||||
user.wonInTurn[4] = Integer.parseInt(r[9][0]);
|
||||
user.wonInTurn[5] = Integer.parseInt(r[10][0]);
|
||||
user.lastDayWOTDFinished = Integer.parseInt(r[11][0]);
|
||||
user.setCurrentStreak(Integer.parseInt(r[1][0]));
|
||||
user.setMaxStreak(Integer.parseInt(r[2][0]));
|
||||
user.setWins(Integer.parseInt(r[3][0]));
|
||||
user.setTimesPlayed(Integer.parseInt(r[4][0]));
|
||||
|
||||
int wonInTurn[] = new int[6];
|
||||
wonInTurn[0] = Integer.parseInt(r[5][0]);
|
||||
wonInTurn[1] = Integer.parseInt(r[6][0]);
|
||||
wonInTurn[2] = Integer.parseInt(r[7][0]);
|
||||
wonInTurn[3] = Integer.parseInt(r[8][0]);
|
||||
wonInTurn[4] = Integer.parseInt(r[9][0]);
|
||||
wonInTurn[5] = Integer.parseInt(r[10][0]);
|
||||
user.setWonInTurn(wonInTurn);
|
||||
|
||||
user.setLastDayWOTDFinished(Integer.parseInt(r[11][0]));
|
||||
|
||||
}
|
||||
|
||||
public void pushStats(User user) {
|
||||
|
||||
db.executeStatement("UPDATE INTO Stats (current_streak," + " max_streak, " + "wins, " + "times_played, "
|
||||
+ "won_on_1, " + "won_on_2, " + "won_on_3, " + "won_on_4, " + "won_on_5, " + "won_on_6, "
|
||||
+ "last_day_WOTD_finished) " + "VALUES (" + user.currentStreak + user.maxStreak + user.wins
|
||||
+ user.timesPlayed + user.wonInTurn[0] + user.wonInTurn[1] + user.wonInTurn[2] + user.wonInTurn[3]
|
||||
+ user.wonInTurn[4] + user.wonInTurn[5] + user.lastDayWOTDFinished + ")");
|
||||
+ "last_day_WOTD_finished) " + "VALUES ("
|
||||
+ Integer.toString(user.getCurrentStreak())
|
||||
+ Integer.toString(user.getMaxStreak())
|
||||
+ Integer.toString(user.getWins())
|
||||
+ Integer.toString(user.getTimesPlayed())
|
||||
+ Integer.toString(user.getWonInTurnIndex(0))
|
||||
+ Integer.toString(user.getWonInTurnIndex(1))
|
||||
+ Integer.toString(user.getWonInTurnIndex(2))
|
||||
+ Integer.toString(user.getWonInTurnIndex(3))
|
||||
+ Integer.toString(user.getWonInTurnIndex(4))
|
||||
+ Integer.toString(user.getWonInTurnIndex(5))
|
||||
+ Integer.toString(user.getLastDayWOTDFinished())
|
||||
+ ")");
|
||||
}
|
||||
|
||||
public boolean checkLogin(String username, String password) {
|
||||
|
|
41
User.java
41
User.java
|
@ -1,16 +1,16 @@
|
|||
public class User {
|
||||
String connectionID;
|
||||
String username;
|
||||
private String connectionID;
|
||||
private String username;
|
||||
String password;
|
||||
int timesPlayed;
|
||||
int winPercentage;
|
||||
int currentStreak;
|
||||
int maxStreak;
|
||||
int lastDayWOTDFinished;
|
||||
int state;
|
||||
int wins;
|
||||
int [] wonInTurn;
|
||||
Game game;
|
||||
private int timesPlayed;
|
||||
private int winPercentage;
|
||||
private int currentStreak;
|
||||
private int maxStreak;
|
||||
private int lastDayWOTDFinished;
|
||||
private int state;
|
||||
private int wins;
|
||||
private int [] wonInTurn;
|
||||
private Game game;
|
||||
|
||||
public User (String pConnectionID){
|
||||
connectionID =pConnectionID;
|
||||
|
@ -45,10 +45,21 @@ public class User {
|
|||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setWins(int wins) {
|
||||
this.wins = wins;
|
||||
}
|
||||
|
||||
public int getWinPercentage() {
|
||||
return winPercentage;
|
||||
}
|
||||
|
||||
public int getWonInTurnIndex(int index) {
|
||||
return wonInTurn[index];
|
||||
}
|
||||
|
||||
public int[] getWonInTurn() {
|
||||
return wonInTurn;
|
||||
}
|
||||
|
@ -61,6 +72,10 @@ public class User {
|
|||
return username;
|
||||
}
|
||||
|
||||
public int getWins() {
|
||||
return wins;
|
||||
}
|
||||
|
||||
public void setConnectionID(String connectionID) {
|
||||
this.connectionID = connectionID;
|
||||
}
|
||||
|
@ -97,6 +112,10 @@ public class User {
|
|||
this.winPercentage = winPercentage;
|
||||
}
|
||||
|
||||
public void setWonInTurnIndex(int index, int content) {
|
||||
this.wonInTurn[index] = content;
|
||||
}
|
||||
|
||||
public void setWonInTurn(int[] wonInTurn) {
|
||||
this.wonInTurn = wonInTurn;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue