diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Rank.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Rank.java index 18ff3f9..d7ef054 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Rank.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Rank.java @@ -1,9 +1,9 @@ package djmil.cordacheckers.cordaclient.dao; public record Rank( - Integer gamesPlayed, - Integer gamesWon, - Integer gamesDraw + Integer total, // total played games + Integer victory, // total won games + Integer draw // agreed draw with opponent ) { } diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java index ff41b3b..7e301ca 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java @@ -58,13 +58,13 @@ public class RankingTests { final Map liderboard2 = cordaClient.fetchRanking(hiCustodian); - assertThat(liderboard1.get(winnerName).gamesWon() +1 == liderboard2.get(winnerName).gamesWon() ); - assertThat(liderboard1.get(winnerName).gamesPlayed() +1 == liderboard2.get(winnerName).gamesPlayed()); - assertThat(liderboard1.get(winnerName).gamesDraw() == liderboard2.get(winnerName).gamesDraw() ); + assertThat(liderboard1.get(winnerName).victory() +1 == liderboard2.get(winnerName).victory()); + assertThat(liderboard1.get(winnerName).total() +1 == liderboard2.get(winnerName).total() ); + assertThat(liderboard1.get(winnerName).draw() == liderboard2.get(winnerName).draw() ); - assertThat(liderboard1.get(losserName).gamesWon() == liderboard2.get(losserName).gamesWon() ); - assertThat(liderboard1.get(losserName).gamesPlayed() +1 == liderboard2.get(losserName).gamesPlayed()); - assertThat(liderboard1.get(losserName).gamesDraw() == liderboard2.get(losserName).gamesDraw() ); + assertThat(liderboard1.get(losserName).victory() == liderboard2.get(losserName).victory()); + assertThat(liderboard1.get(losserName).total() +1 == liderboard2.get(losserName).total() ); + assertThat(liderboard1.get(losserName).draw() == liderboard2.get(losserName).draw() ); } @Test @@ -87,13 +87,13 @@ public class RankingTests { final Map liderboard2 = cordaClient.fetchRanking(hiCustodian); - assertThat(liderboard1.get(winnerName).gamesWon() +1 == liderboard2.get(winnerName).gamesWon() ); - assertThat(liderboard1.get(winnerName).gamesPlayed() +1 == liderboard2.get(winnerName).gamesPlayed()); - assertThat(liderboard1.get(winnerName).gamesDraw() == liderboard2.get(winnerName).gamesDraw() ); + assertThat(liderboard1.get(winnerName).victory() +1 == liderboard2.get(winnerName).victory()); + assertThat(liderboard1.get(winnerName).total() +1 == liderboard2.get(winnerName).total() ); + assertThat(liderboard1.get(winnerName).draw() == liderboard2.get(winnerName).draw() ); - assertThat(liderboard1.get(losserName).gamesWon() == liderboard2.get(losserName).gamesWon() ); - assertThat(liderboard1.get(losserName).gamesPlayed() +1 == liderboard2.get(losserName).gamesPlayed()); - assertThat(liderboard1.get(losserName).gamesDraw() == liderboard2.get(losserName).gamesDraw() ); + assertThat(liderboard1.get(losserName).victory() == liderboard2.get(losserName).victory()); + assertThat(liderboard1.get(losserName).total() +1 == liderboard2.get(losserName).total() ); + assertThat(liderboard1.get(losserName).draw() == liderboard2.get(losserName).draw() ); } @Test @@ -114,13 +114,13 @@ public class RankingTests { cordaClient.gameDrawAccept(hiPlayer1, game.uuid()); final Map liderboard2 = cordaClient.fetchRanking(hiCustodian); - assertThat(liderboard1.get(player1).gamesWon() == liderboard2.get(player1).gamesWon() ); - assertThat(liderboard1.get(player1).gamesPlayed() +1 == liderboard2.get(player1).gamesPlayed()); - assertThat(liderboard1.get(player1).gamesDraw() +1 == liderboard2.get(player1).gamesDraw() ); + assertThat(liderboard1.get(player1).victory() == liderboard2.get(player1).victory()); + assertThat(liderboard1.get(player1).total() +1 == liderboard2.get(player1).total() ); + assertThat(liderboard1.get(player1).draw() +1 == liderboard2.get(player1).draw() ); - assertThat(liderboard1.get(player2).gamesWon() == liderboard2.get(player2).gamesWon() ); - assertThat(liderboard1.get(player2).gamesPlayed() +1 == liderboard2.get(player2).gamesPlayed()); - assertThat(liderboard1.get(player2).gamesDraw() +1 == liderboard2.get(player2).gamesDraw() ); + assertThat(liderboard1.get(player2).victory() == liderboard2.get(player2).victory()); + assertThat(liderboard1.get(player2).total() +1 == liderboard2.get(player2).total() ); + assertThat(liderboard1.get(player2).draw() +1 == liderboard2.get(player2).draw() ); } @Test diff --git a/corda/workflows/src/main/java/djmil/cordacheckers/gameresult/Rank.java b/corda/workflows/src/main/java/djmil/cordacheckers/gameresult/Rank.java index 0e19c95..0f0dfed 100644 --- a/corda/workflows/src/main/java/djmil/cordacheckers/gameresult/Rank.java +++ b/corda/workflows/src/main/java/djmil/cordacheckers/gameresult/Rank.java @@ -1,50 +1,50 @@ package djmil.cordacheckers.gameresult; public class Rank { - private Integer gamesPlayed; - private Integer gamesWon; - private Integer gamesDraw; + private Integer total; // total played games + private Integer victory; // total won games + private Integer draw; // agreed draw with opponent // Serialisation service requires a default constructor public Rank() { - gamesPlayed = 0; - gamesWon = 0; - gamesDraw = 0; + total = 0; + victory = 0; + draw = 0; } - public Rank(Integer gamesPlayed, Integer gamesWon, Integer gamesDraw) { - this.gamesPlayed = gamesPlayed; - this.gamesWon = gamesWon; - this.gamesDraw = gamesDraw; + public Rank(Integer total, Integer vicotry, Integer draw) { + this.total = total; + this.victory = vicotry; + this.draw = draw; } Rank gamePlayed() { - gamesPlayed++; + total++; return this; } Rank gameWon() { - gamesWon++; + victory++; return this; } Rank gameDraw(boolean isDraw) { if (isDraw) - gamesDraw++; + draw++; return this; } - public Integer getGamesPlayed() { - return gamesPlayed; + public Integer getTotal() { + return total; } - public Integer getGamesWon() { - return gamesWon; + public Integer getVictory() { + return victory; } - public Integer getGamesDraw() { - return gamesDraw; + public Integer getDraw() { + return draw; } } diff --git a/webapp/src/container/Leaderboard.jsx b/webapp/src/container/Leaderboard.jsx index 5e447eb..ca92490 100644 --- a/webapp/src/container/Leaderboard.jsx +++ b/webapp/src/container/Leaderboard.jsx @@ -14,9 +14,9 @@ export default function Leaderboard({ players }) { return {playerName} - {rank.gamesPlayed} - {rank.gamesWon} - {rank.gamesDraw} + {rank.total} + {rank.victory} + {rank.draw} }); @@ -26,8 +26,8 @@ export default function Leaderboard({ players }) { - Played - Won + Total + Victory Draw