Commit 7c2f7dbeabaefae80776cc63aa7ce82454886aad

Authored by 王家文
1 parent bd19c0ca
Exists in master

feat:机器人分数最低是报名分数

Showing 1 changed file with 10 additions and 22 deletions   Show diff stats
service/roomrank/room.go
... ... @@ -274,7 +274,10 @@ func TrySettleRoom(gameId string, room *Room, config *confroomrank.ActivityConfi
274 274 }
275 275 confRobot, hasConfRobot := config.Robot[roomPlayer.RobotConfigId]
276 276 if hasConfRobot {
277   - roomPlayer.Score = GetRobotScoreCurrent(&confRobot, percent)
  277 + roomPlayer.Score = GetRobotScoreCurrent(config, &confRobot, percent)
  278 + if roomPlayer.Score < int64(confRobot.MinScore) {
  279 + roomPlayer.Score = int64(confRobot.MinScore)
  280 + }
278 281 }
279 282 }
280 283  
... ... @@ -317,11 +320,7 @@ func TryResetRobot(room *Room, config *confroomrank.ActivityConfig) {
317 320 }
318 321 confRobot, hasConfRobot := config.Robot[roomPlayer.RobotConfigId]
319 322 if hasConfRobot {
320   - roomPlayer.Score = GetRobotScoreCurrent(&confRobot, percent)
321   - // 机器人分数最低是报名分数
322   - if roomPlayer.Score < config.OpenScore {
323   - roomPlayer.Score = config.OpenScore
324   - }
  323 + roomPlayer.Score = GetRobotScoreCurrent(config, &confRobot, percent)
325 324 }
326 325 }
327 326 }
... ... @@ -333,23 +332,12 @@ func TryReSort(room *Room, config *confroomrank.ActivityConfig) {
333 332 }
334 333  
335 334 // GetRobotScoreCurrent 从机器人配置里得到实时得分
336   -func GetRobotScoreCurrent(confRobot *confroomrank.RobotConfig, percent float64) int64 {
337   - score := (float64(confRobot.TotalScore-confRobot.MinScore) *
  335 +func GetRobotScoreCurrent(config *confroomrank.ActivityConfig, confRobot *confroomrank.RobotConfig, percent float64) int64 {
  336 + score := (float64(confRobot.TotalScore-int(config.OpenScore)) *
338 337 float64(100-confRobot.Range+rand.Intn(confRobot.Range*2)) / 100) * percent / 100
339   - result := int64(confRobot.MinScore) + int64(math.Ceil(score))
340   - if result < int64(confRobot.MinScore) {
341   - result = int64(confRobot.MinScore)
342   - }
343   - return result
344   -}
345   -
346   -// GetRobotScoreMax 从机器人配置里得到最高分
347   -func GetRobotScoreMax(confRobot *confroomrank.RobotConfig) int64 {
348   - score := float64(confRobot.TotalScore-confRobot.MinScore) *
349   - float64(100-confRobot.Range+rand.Intn(confRobot.Range*2)) / float64(100)
350   - result := int64(confRobot.MinScore) + int64(math.Ceil(score))
351   - if result < int64(confRobot.MinScore) {
352   - result = int64(confRobot.MinScore)
  338 + result := config.OpenScore + int64(math.Ceil(score))
  339 + if result < config.OpenScore {
  340 + result = config.OpenScore
353 341 }
354 342 return result
355 343 }
... ...