Commit bd19c0caea6f86008ec875ba7431f898c6f0d7a4

Authored by 王家文
1 parent 8f92ce68
Exists in master

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

configs/init.go
@@ -4,7 +4,14 @@ import ( @@ -4,7 +4,14 @@ import (
4 "apigame/configs/confapi" 4 "apigame/configs/confapi"
5 "apigame/configs/confcardholder" 5 "apigame/configs/confcardholder"
6 "apigame/configs/confglobal" 6 "apigame/configs/confglobal"
  7 + "apigame/configs/confroomrank"
7 "apigame/service-common/svconst" 8 "apigame/service-common/svconst"
  9 + "apigame/util/zconvert"
  10 + "apigame/util/zmap"
  11 + "fmt"
  12 + "github.com/astaxie/beego"
  13 + "sort"
  14 + "strings"
8 ) 15 )
9 16
10 func Init() bool { 17 func Init() bool {
@@ -25,5 +32,69 @@ func Init() bool { @@ -25,5 +32,69 @@ func Init() bool {
25 // _, _ = confroomrank.GetCurrent(gameId) 32 // _, _ = confroomrank.GetCurrent(gameId)
26 //} 33 //}
27 34
  35 + //{
  36 + // config, hasConfig := confroomrank.GetCurrent("10149", 30002)
  37 + // if hasConfig {
  38 + // items := zmap.Values(config.Robot)
  39 + // sort.Slice(items, func(i, j int) bool {
  40 + // return items[i].Id < items[j].Id
  41 + // })
  42 + // fmt.Println("----------------")
  43 + // for _, i2 := range items {
  44 + // fmt.Println(i2.Id)
  45 + // }
  46 + // fmt.Println("----------------")
  47 + // for _, i2 := range items {
  48 + // fmt.Println(i2.MinScore)
  49 + // }
  50 + // fmt.Println("----------------")
  51 + // for _, i2 := range items {
  52 + // fmt.Println(i2.TotalScore)
  53 + // }
  54 + // fmt.Println("----------------")
  55 + // for _, i2 := range items {
  56 + // fmt.Println(i2.Range)
  57 + // }
  58 + // fmt.Println("----------------")
  59 + // }
  60 + //}
  61 + if beego.BConfig.RunMode == "dev" {
  62 + dump()
  63 + }
  64 +
28 return true 65 return true
29 } 66 }
  67 +
  68 +func dump() {
  69 + config, hasConfig := confroomrank.GetCurrent("10149", 30002)
  70 + if hasConfig {
  71 + items := zmap.Values(config.Room)
  72 + sort.Slice(items, func(i, j int) bool {
  73 + return items[i].Id < items[j].Id
  74 + })
  75 + for _, i2 := range items {
  76 + //fmt.Println(i2.Levels)
  77 + //fmt.Println(strings.Join(zconvert.ListIntegerToListString(i2.SettleUserType), ","))
  78 + //{
  79 + // ltxt := make([]string, 0)
  80 + // for _, i3 := range i2.PlayerTypeCount {
  81 + // txt := strings.Join(zconvert.ListIntegerToListString(i3), ",")
  82 + // ltxt = append(ltxt, txt)
  83 + // }
  84 + // fmt.Println(strings.Join(ltxt, "|"))
  85 + //}
  86 + {
  87 + ltxt := make([]string, 0)
  88 + ks := zmap.Keys(i2.Awards)
  89 + sort.Slice(ks, func(i, j int) bool {
  90 + return zconvert.ToInt(ks[i]) < zconvert.ToInt(ks[j])
  91 + })
  92 + for _, k := range ks {
  93 + txt := fmt.Sprintf("%s:%s", k, i2.Awards[k])
  94 + ltxt = append(ltxt, txt)
  95 + }
  96 + fmt.Println(strings.Join(ltxt, "_"))
  97 + }
  98 + }
  99 + }
  100 +}
service/roomrank/room.go
@@ -318,6 +318,10 @@ func TryResetRobot(room *Room, config *confroomrank.ActivityConfig) { @@ -318,6 +318,10 @@ func TryResetRobot(room *Room, config *confroomrank.ActivityConfig) {
318 confRobot, hasConfRobot := config.Robot[roomPlayer.RobotConfigId] 318 confRobot, hasConfRobot := config.Robot[roomPlayer.RobotConfigId]
319 if hasConfRobot { 319 if hasConfRobot {
320 roomPlayer.Score = GetRobotScoreCurrent(&confRobot, percent) 320 roomPlayer.Score = GetRobotScoreCurrent(&confRobot, percent)
  321 + // 机器人分数最低是报名分数
  322 + if roomPlayer.Score < config.OpenScore {
  323 + roomPlayer.Score = config.OpenScore
  324 + }
321 } 325 }
322 } 326 }
323 } 327 }
util/zconvert/list.go
@@ -14,6 +14,13 @@ func ListNumberToListNumber[T1 ztype.UtNumber, T2 ztype.UtNumber](in []T1) (out @@ -14,6 +14,13 @@ func ListNumberToListNumber[T1 ztype.UtNumber, T2 ztype.UtNumber](in []T1) (out
14 return 14 return
15 } 15 }
16 16
  17 +func ListIntegerToListString[T1 ztype.UtInteger](in []T1) (out []string) {
  18 + for _, t1 := range in {
  19 + out = append(out, ToStr(t1))
  20 + }
  21 + return
  22 +}
  23 +
17 /* ----- list<string> -> list<number> ----- */ 24 /* ----- list<string> -> list<number> ----- */
18 25
19 func ListStrToListNumber[T ztype.UtNumber](list []string) []T { 26 func ListStrToListNumber[T ztype.UtNumber](list []string) []T {