Commit 27bec846db8e5d342b7f0f44307f58bf12c47d61

Authored by 王家文
1 parent b30068c9
Exists in master

feat:机器人计分衰减

Showing 1 changed file with 4 additions and 3 deletions   Show diff stats
service/roomrank/room.go
@@ -202,6 +202,7 @@ func TryCloseRoom(gameId string, room *Room, config *confroomrank.ActivityConfig @@ -202,6 +202,7 @@ func TryCloseRoom(gameId string, room *Room, config *confroomrank.ActivityConfig
202 } 202 }
203 } 203 }
204 // 填充完之后要排序计算 204 // 填充完之后要排序计算
  205 + TryResetRobot(room, config, true)
205 TryReSort(room, config) 206 TryReSort(room, config)
206 207
207 SaveRoom(gameId, room) 208 SaveRoom(gameId, room)
@@ -294,9 +295,9 @@ func TrySettleRoom(gameId string, room *Room, config *confroomrank.ActivityConfi @@ -294,9 +295,9 @@ func TrySettleRoom(gameId string, room *Room, config *confroomrank.ActivityConfi
294 } 295 }
295 296
296 // TryResetRobot 尝试改变机器人分数并重新排序 297 // TryResetRobot 尝试改变机器人分数并重新排序
297 -func TryResetRobot(room *Room, config *confroomrank.ActivityConfig) { 298 +func TryResetRobot(room *Room, config *confroomrank.ActivityConfig, force bool) {
298 secNow := lxtime.NowUninx() 299 secNow := lxtime.NowUninx()
299 - if secNow < room.ResetRobotTime+RoomResetRobotSecond { 300 + if !force && secNow < room.ResetRobotTime+RoomResetRobotSecond {
300 return 301 return
301 } 302 }
302 room.ResetRobotTime = secNow 303 room.ResetRobotTime = secNow
@@ -334,7 +335,7 @@ func TryResetRobot(room *Room, config *confroomrank.ActivityConfig) { @@ -334,7 +335,7 @@ func TryResetRobot(room *Room, config *confroomrank.ActivityConfig) {
334 335
335 // TryReSort 尝试重新排序 336 // TryReSort 尝试重新排序
336 func TryReSort(room *Room, config *confroomrank.ActivityConfig) { 337 func TryReSort(room *Room, config *confroomrank.ActivityConfig) {
337 - TryResetRobot(room, config) 338 + TryResetRobot(room, config, false)
338 sort.Sort(room.Details) 339 sort.Sort(room.Details)
339 } 340 }
340 341