From 7c2f7dbeabaefae80776cc63aa7ce82454886aad Mon Sep 17 00:00:00 2001 From: 王家文 Date: Tue, 4 Jun 2024 10:11:13 +0800 Subject: [PATCH] feat:机器人分数最低是报名分数 --- service/roomrank/room.go | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/service/roomrank/room.go b/service/roomrank/room.go index 19582ec..f8452fa 100644 --- a/service/roomrank/room.go +++ b/service/roomrank/room.go @@ -274,7 +274,10 @@ func TrySettleRoom(gameId string, room *Room, config *confroomrank.ActivityConfi } confRobot, hasConfRobot := config.Robot[roomPlayer.RobotConfigId] if hasConfRobot { - roomPlayer.Score = GetRobotScoreCurrent(&confRobot, percent) + roomPlayer.Score = GetRobotScoreCurrent(config, &confRobot, percent) + if roomPlayer.Score < int64(confRobot.MinScore) { + roomPlayer.Score = int64(confRobot.MinScore) + } } } @@ -317,11 +320,7 @@ func TryResetRobot(room *Room, config *confroomrank.ActivityConfig) { } confRobot, hasConfRobot := config.Robot[roomPlayer.RobotConfigId] if hasConfRobot { - roomPlayer.Score = GetRobotScoreCurrent(&confRobot, percent) - // 机器人分数最低是报名分数 - if roomPlayer.Score < config.OpenScore { - roomPlayer.Score = config.OpenScore - } + roomPlayer.Score = GetRobotScoreCurrent(config, &confRobot, percent) } } } @@ -333,23 +332,12 @@ func TryReSort(room *Room, config *confroomrank.ActivityConfig) { } // GetRobotScoreCurrent 从机器人配置里得到实时得分 -func GetRobotScoreCurrent(confRobot *confroomrank.RobotConfig, percent float64) int64 { - score := (float64(confRobot.TotalScore-confRobot.MinScore) * +func GetRobotScoreCurrent(config *confroomrank.ActivityConfig, confRobot *confroomrank.RobotConfig, percent float64) int64 { + score := (float64(confRobot.TotalScore-int(config.OpenScore)) * float64(100-confRobot.Range+rand.Intn(confRobot.Range*2)) / 100) * percent / 100 - result := int64(confRobot.MinScore) + int64(math.Ceil(score)) - if result < int64(confRobot.MinScore) { - result = int64(confRobot.MinScore) - } - return result -} - -// GetRobotScoreMax 从机器人配置里得到最高分 -func GetRobotScoreMax(confRobot *confroomrank.RobotConfig) int64 { - score := float64(confRobot.TotalScore-confRobot.MinScore) * - float64(100-confRobot.Range+rand.Intn(confRobot.Range*2)) / float64(100) - result := int64(confRobot.MinScore) + int64(math.Ceil(score)) - if result < int64(confRobot.MinScore) { - result = int64(confRobot.MinScore) + result := config.OpenScore + int64(math.Ceil(score)) + if result < config.OpenScore { + result = config.OpenScore } return result } -- libgit2 0.21.0