prod & completion
This commit is contained in:
parent
894ed9fb46
commit
4f11822c12
4 changed files with 20 additions and 10 deletions
|
@ -11,6 +11,8 @@ import dev.peerat.backend.utils.Mail;
|
|||
|
||||
public class Configuration {
|
||||
|
||||
private boolean prod;
|
||||
|
||||
private String db_host;
|
||||
private int db_port;
|
||||
private String db_user;
|
||||
|
@ -126,6 +128,10 @@ public class Configuration {
|
|||
writer.close();
|
||||
}
|
||||
|
||||
public boolean isProduction(){
|
||||
return this.prod;
|
||||
}
|
||||
|
||||
public String getDbHost() {
|
||||
return this.db_host;
|
||||
}
|
||||
|
|
|
@ -114,9 +114,12 @@ public class Main{
|
|||
Locker<Group> groupLock = new Locker<>();
|
||||
Locker<Completion> leaderboard = new Locker<>();
|
||||
|
||||
if(config.isProduction())
|
||||
router.
|
||||
register(new Register(repo, playersWaiting, mail)).
|
||||
register(new MailConfirmation(repo, router, config.getUsersFiles(), config.getGitToken(), playersWaiting, mail));
|
||||
|
||||
router.
|
||||
register(new Register(repo, playersWaiting, mail)).
|
||||
register(new MailConfirmation(repo, router, config.getUsersFiles(), config.getGitToken(), playersWaiting, mail)).
|
||||
register(new Login(repo, router)).
|
||||
register(new ProfileSettings(repo)).
|
||||
register(new ChangePassword(repo)).
|
||||
|
|
|
@ -11,7 +11,7 @@ public class Completion{
|
|||
private int score;
|
||||
private String puzzleName;
|
||||
|
||||
public Completion(int playerId, int puzzleId, int tries, String fileName, int score) {
|
||||
public Completion(int playerId, int puzzleId, int tries, String fileName, int score){
|
||||
this(playerId, puzzleId, tries, score, fileName, null, null, null, null);
|
||||
}
|
||||
public Completion(int playerId, int puzzleId, int tries, String fileName, int score, String puzzleName) {
|
||||
|
@ -22,13 +22,13 @@ public class Completion{
|
|||
this(playerId, puzzleId, 0, 0, fileName, file, response, currentPuzzle, null);
|
||||
}
|
||||
|
||||
public Completion(int initTries, int initScore) {
|
||||
public Completion(int initTries, int initScore){
|
||||
// For group leaderboard
|
||||
this(-1, -1, initTries, initScore, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public Completion(int playerId, int puzzleId, int tries, int score, String fileName, byte[] file, byte[] response,
|
||||
Puzzle currentPuzzle, String initPuzzleName) {
|
||||
Puzzle currentPuzzle, String initPuzzleName){
|
||||
this.playerId = playerId;
|
||||
this.puzzleId = puzzleId;
|
||||
this.fileName = fileName;
|
||||
|
@ -40,7 +40,7 @@ public class Completion{
|
|||
this.score = score;
|
||||
|
||||
if (currentPuzzle != null)
|
||||
addTry(currentPuzzle, response);
|
||||
addTry(currentPuzzle, response, 0);
|
||||
|
||||
puzzleName = initPuzzleName;
|
||||
}
|
||||
|
@ -62,13 +62,14 @@ public class Completion{
|
|||
return tries;
|
||||
}
|
||||
|
||||
public void addTry(Puzzle currentPuzzle, byte[] response){
|
||||
public void addTry(Puzzle currentPuzzle, byte[] response, int chapter){
|
||||
if (score <= 0){
|
||||
tries++;
|
||||
if(chapter < 4) return;
|
||||
if (response != null && Arrays.equals(currentPuzzle.getSoluce(), response)){
|
||||
if (tries > 1) { // Loose 5% each try with a minimum of 1 for score
|
||||
// score = (int) Math.ceil(currentPuzzle.getScoreMax() * (1 - ((tries - 1) / 20.)));
|
||||
score = currentPuzzle.getScoreMax();
|
||||
score = (int) Math.ceil(currentPuzzle.getScoreMax() * (1 - ((tries - 1) / 20.)));
|
||||
// score = currentPuzzle.getScoreMax();
|
||||
if (score < 1)
|
||||
score = 1;
|
||||
} else
|
||||
|
|
|
@ -593,7 +593,7 @@ public class DatabaseRepository {
|
|||
insertCompletion(completion);
|
||||
} else {
|
||||
System.out.println(completion);
|
||||
completion.addTry(currentPuzzle, response);
|
||||
completion.addTry(currentPuzzle, response, getChapter(currentPuzzle).getId());
|
||||
int lastUserId = completion.getPlayerId();
|
||||
completion.updatePlayer(userId);
|
||||
updateCompletion(completion, lastUserId);
|
||||
|
|
Loading…
Add table
Reference in a new issue