Skip to content

Commit

Permalink
AllVsAll generating Duels with new fields. (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam147g authored Jun 10, 2024
1 parent cdffdb0 commit fccac25
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.rikishi.rikishi.system;
package com.rikishi.rikishi.system.matching;


import com.rikishi.rikishi.model.User;
Expand Down Expand Up @@ -68,8 +68,12 @@ private void generateDuels(Collection<User> players) {

Duel duel = new Duel(
player1.id(),
player1.name(),
player2.id(),
player2.name(),
duelNumber,
results.get(getPlayerId(player1)).get(getPlayerId(player2)).get(0),
results.get(getPlayerId(player1)).get(getPlayerId(player2)).get(1),
duelIdCounter++,
player1.weightClass().name() + " - " + player1.sex().toString().charAt(0),
-1
Expand Down Expand Up @@ -168,7 +172,17 @@ public void chooseWinner(User winner) {
}
if (foundDuel != null) {
duels.remove(foundDuel);
duels.add(new Duel(foundDuel.id1Contestant(), foundDuel.id2Contestant(), foundDuel.number(), foundDuel.id(), foundDuel.weightCategory(), winner.id()));
if (Objects.equals(winner.name(), foundDuel.name1())) {
duels.add(new Duel(foundDuel.id1Contestant(), foundDuel.name1(),
foundDuel.id2Contestant(), foundDuel.name2(),
foundDuel.number(), results.get(winnerId).get(loserId).get(0), results.get(winnerId).get(loserId).get(1),
foundDuel.id(), foundDuel.weightCategory(), winner.id()));
} else if (Objects.equals(winner.name(), foundDuel.name2())) {
duels.add(new Duel(foundDuel.id1Contestant(), foundDuel.name1(),
foundDuel.id2Contestant(), foundDuel.name2(),
foundDuel.number(), results.get(loserId).get(winnerId).get(0), results.get(loserId).get(winnerId).get(1),
foundDuel.id(), foundDuel.weightCategory(), winner.id()));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.rikishi.rikishi.system;
package com.rikishi.rikishi.system.matching;

import com.rikishi.rikishi.model.User;
import com.rikishi.rikishi.model.entity.Duel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.rikishi.rikishi.model.Sex;
import com.rikishi.rikishi.model.User;
import com.rikishi.rikishi.model.WeightClass;
import com.rikishi.rikishi.system.matching.AllVsAllManager;
import org.junit.jupiter.api.Test;

import java.util.Set;
Expand Down

0 comments on commit fccac25

Please sign in to comment.