From fe0c989daa1c661aa1acd59ec4ffedfbca02abc6 Mon Sep 17 00:00:00 2001 From: CaptainIRS <36656347+CaptainIRS@users.noreply.github.com> Date: Tue, 1 Mar 2022 20:41:33 +0530 Subject: [PATCH 1/4] feat: Update parameters for learning phase --- .../codecharacter/server/config/GameConfiguration.kt | 11 ++++++----- .../codecharacter/server/params/GameParameters.kt | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/src/main/kotlin/delta/codecharacter/server/config/GameConfiguration.kt b/server/src/main/kotlin/delta/codecharacter/server/config/GameConfiguration.kt index 4427c107..bf6c5ef7 100644 --- a/server/src/main/kotlin/delta/codecharacter/server/config/GameConfiguration.kt +++ b/server/src/main/kotlin/delta/codecharacter/server/config/GameConfiguration.kt @@ -14,16 +14,17 @@ class GameConfiguration { return GameParameters( attackers = setOf( - Attacker(id = 1, hp = 10, range = 3, attackPower = 3, speed = 3, price = 1), - Attacker(id = 2, hp = 10, range = 3, attackPower = 3, speed = 3, price = 1), + Attacker(id = 1, hp = 10, range = 2, attackPower = 4, speed = 4, price = 2), + Attacker(id = 2, hp = 20, range = 4, attackPower = 2, speed = 2, price = 2), ), defenders = setOf( - Defender(id = 1, hp = 10, range = 4, attackPower = 5, price = 1), - Defender(id = 2, hp = 10, range = 6, attackPower = 5, price = 1), + Defender(id = 1, hp = 400, range = 4, attackPower = 10, price = 25), + Defender(id = 2, hp = 600, range = 6, attackPower = 20, price = 50), ), - numberOfTurns = 500, + numberOfTurns = 100, numberOfCoins = 1000, + mapCoins = 5000, ) } } diff --git a/server/src/main/kotlin/delta/codecharacter/server/params/GameParameters.kt b/server/src/main/kotlin/delta/codecharacter/server/params/GameParameters.kt index 1e5e3e3d..5bd5a830 100644 --- a/server/src/main/kotlin/delta/codecharacter/server/params/GameParameters.kt +++ b/server/src/main/kotlin/delta/codecharacter/server/params/GameParameters.kt @@ -1,5 +1,6 @@ package delta.codecharacter.server.params +import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonProperty import delta.codecharacter.server.params.game_entities.Attacker import delta.codecharacter.server.params.game_entities.Defender @@ -9,4 +10,5 @@ data class GameParameters( @field:JsonProperty("defenders", required = true) val defenders: Set, @field:JsonProperty("no_of_turns", required = true) val numberOfTurns: Int, @field:JsonProperty("no_of_coins", required = true) val numberOfCoins: Int, + @JsonIgnore val mapCoins: Int, ) From 653a2d54b74fb7d828d6df3876d6ff7a20a74094 Mon Sep 17 00:00:00 2001 From: CaptainIRS <36656347+CaptainIRS@users.noreply.github.com> Date: Tue, 1 Mar 2022 20:44:47 +0530 Subject: [PATCH 2/4] feat: Disable rating update for learning phase --- .../server/match/MatchService.kt | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/server/src/main/kotlin/delta/codecharacter/server/match/MatchService.kt b/server/src/main/kotlin/delta/codecharacter/server/match/MatchService.kt index 4690b3ae..02522e18 100644 --- a/server/src/main/kotlin/delta/codecharacter/server/match/MatchService.kt +++ b/server/src/main/kotlin/delta/codecharacter/server/match/MatchService.kt @@ -232,21 +232,22 @@ class MatchService( player2Game.destruction ) val finishedMatch = match.copy(verdict = verdict) - val (newUserRating, newOpponentRating) = - ratingHistoryService.updateRating(match.player1.userId, match.player2.userId, verdict) - - publicUserService.updatePublicRating( - userId = match.player1.userId, - isInitiator = true, - verdict = verdict, - newRating = newUserRating - ) - publicUserService.updatePublicRating( - userId = match.player2.userId, - isInitiator = false, - verdict = verdict, - newRating = newOpponentRating - ) + // val (newUserRating, newOpponentRating) = + // ratingHistoryService.updateRating(match.player1.userId, + // match.player2.userId, verdict) + // + // publicUserService.updatePublicRating( + // userId = match.player1.userId, + // isInitiator = true, + // verdict = verdict, + // newRating = newUserRating + // ) + // publicUserService.updatePublicRating( + // userId = match.player2.userId, + // isInitiator = false, + // verdict = verdict, + // newRating = newOpponentRating + // ) if (match.mode == MatchModeEnum.MANUAL) { notificationService.sendNotification( From 5b3425fedb50a1f327e81f1cbdd308821b60957e Mon Sep 17 00:00:00 2001 From: Dipesh Kafle Date: Tue, 1 Mar 2022 22:17:29 +0545 Subject: [PATCH 3/4] Bump coins to 1500 and turns to 500 --- .../delta/codecharacter/server/config/GameConfiguration.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/kotlin/delta/codecharacter/server/config/GameConfiguration.kt b/server/src/main/kotlin/delta/codecharacter/server/config/GameConfiguration.kt index bf6c5ef7..151bac96 100644 --- a/server/src/main/kotlin/delta/codecharacter/server/config/GameConfiguration.kt +++ b/server/src/main/kotlin/delta/codecharacter/server/config/GameConfiguration.kt @@ -22,8 +22,8 @@ class GameConfiguration { Defender(id = 1, hp = 400, range = 4, attackPower = 10, price = 25), Defender(id = 2, hp = 600, range = 6, attackPower = 20, price = 50), ), - numberOfTurns = 100, - numberOfCoins = 1000, + numberOfTurns = 500, + numberOfCoins = 1500, mapCoins = 5000, ) } From 4c80fb29259b2735c22919b3014a39a6a7f79253 Mon Sep 17 00:00:00 2001 From: CaptainIRS <36656347+CaptainIRS@users.noreply.github.com> Date: Wed, 2 Mar 2022 20:32:23 +0530 Subject: [PATCH 4/4] re-enable ratings after learning-phase --- .../server/logic/validation/MapValidator.kt | 12 +++++++ .../server/match/MatchService.kt | 31 +++++++++---------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/server/src/main/kotlin/delta/codecharacter/server/logic/validation/MapValidator.kt b/server/src/main/kotlin/delta/codecharacter/server/logic/validation/MapValidator.kt index da513a5f..3244f357 100644 --- a/server/src/main/kotlin/delta/codecharacter/server/logic/validation/MapValidator.kt +++ b/server/src/main/kotlin/delta/codecharacter/server/logic/validation/MapValidator.kt @@ -36,5 +36,17 @@ class MapValidator { ) { throw CustomException(HttpStatus.BAD_REQUEST, invalidMapMessage) } + + var totalCoins = 0 + map.forEach { row -> + row.forEach { cell -> + if (cell != 0) { + totalCoins += gameParameters.defenders.first { it.id == cell }.price + } + } + } + if (totalCoins > gameParameters.mapCoins) { + throw CustomException(HttpStatus.BAD_REQUEST, invalidMapMessage) + } } } diff --git a/server/src/main/kotlin/delta/codecharacter/server/match/MatchService.kt b/server/src/main/kotlin/delta/codecharacter/server/match/MatchService.kt index 02522e18..4690b3ae 100644 --- a/server/src/main/kotlin/delta/codecharacter/server/match/MatchService.kt +++ b/server/src/main/kotlin/delta/codecharacter/server/match/MatchService.kt @@ -232,22 +232,21 @@ class MatchService( player2Game.destruction ) val finishedMatch = match.copy(verdict = verdict) - // val (newUserRating, newOpponentRating) = - // ratingHistoryService.updateRating(match.player1.userId, - // match.player2.userId, verdict) - // - // publicUserService.updatePublicRating( - // userId = match.player1.userId, - // isInitiator = true, - // verdict = verdict, - // newRating = newUserRating - // ) - // publicUserService.updatePublicRating( - // userId = match.player2.userId, - // isInitiator = false, - // verdict = verdict, - // newRating = newOpponentRating - // ) + val (newUserRating, newOpponentRating) = + ratingHistoryService.updateRating(match.player1.userId, match.player2.userId, verdict) + + publicUserService.updatePublicRating( + userId = match.player1.userId, + isInitiator = true, + verdict = verdict, + newRating = newUserRating + ) + publicUserService.updatePublicRating( + userId = match.player2.userId, + isInitiator = false, + verdict = verdict, + newRating = newOpponentRating + ) if (match.mode == MatchModeEnum.MANUAL) { notificationService.sendNotification(