Compare commits

..

No commits in common. "4f11822c12f17a14b5136f2780b95015957160ac" and "087cf59ae0ca83736b9bd2ab041a68f55d20b8aa" have entirely different histories.

6 changed files with 13 additions and 23 deletions

View file

@ -10,8 +10,6 @@ import java.lang.reflect.Field;
import dev.peerat.backend.utils.Mail;
public class Configuration {
private boolean prod;
private String db_host;
private int db_port;
@ -127,10 +125,6 @@ public class Configuration {
writer.flush();
writer.close();
}
public boolean isProduction(){
return this.prod;
}
public String getDbHost() {
return this.db_host;

View file

@ -114,12 +114,9 @@ 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)).

View file

@ -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, 0);
addTry(currentPuzzle, response);
puzzleName = initPuzzleName;
}
@ -62,14 +62,13 @@ public class Completion{
return tries;
}
public void addTry(Puzzle currentPuzzle, byte[] response, int chapter){
public void addTry(Puzzle currentPuzzle, byte[] response){
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

View file

@ -132,7 +132,7 @@ public class Group implements Comparable<Group> {
}
@Override
public int hashCode(){
public int hashCode() {
return Objects.hash(name);
}

View file

@ -190,7 +190,7 @@ public class Player implements Comparable<Player> {
@Override
public int hashCode(){
return Objects.hash(email, pseudo);
return Objects.hash(email);
}
@Override
@ -202,6 +202,6 @@ public class Player implements Comparable<Player> {
if (getClass() != obj.getClass())
return false;
Player other = (Player) obj;
return Objects.equals(email, other.email) && Objects.equals(pseudo, other.pseudo);
return Objects.equals(email, other.email);
}
}

View file

@ -593,7 +593,7 @@ public class DatabaseRepository {
insertCompletion(completion);
} else {
System.out.println(completion);
completion.addTry(currentPuzzle, response, getChapter(currentPuzzle).getId());
completion.addTry(currentPuzzle, response);
int lastUserId = completion.getPlayerId();
completion.updatePlayer(userId);
updateCompletion(completion, lastUserId);