combohistory.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package combomatch
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/common"
  5. item "bet24.com/servers/micros/item_inventory/proto"
  6. "bet24.com/servers/micros/matches/handler/matchbase"
  7. )
  8. type historyRound struct {
  9. MatchType int
  10. Target int
  11. WinnerCount int
  12. MatchNo int
  13. StartTime int64
  14. EndTime int64
  15. }
  16. type historyUser struct {
  17. matchbase.MatchUserBrief
  18. enrollTime int
  19. prize []item.ItemPack
  20. }
  21. type combohistory struct {
  22. MatchId int
  23. Name string
  24. GameId int
  25. GameName string
  26. GameRule string
  27. TotalUser int
  28. TableUser int
  29. EnrollFee []item.ItemPack
  30. Prizes []matchbase.Prize_config
  31. // 开始结束时间
  32. StartTime int64
  33. EndTime int64
  34. // 参赛玩家
  35. EnrollUsers []historyUser
  36. Winners []int
  37. Rounds []historyRound
  38. noShowUsers []matchbase.EnrollUser
  39. }
  40. func (h *combohistory) dump(detail bool) {
  41. log.Release(" MatchId[%d] GameRule[%s] TotalUser[%d],TableUser[%d],Fee[%v],Prizes[%v]",
  42. h.MatchId, h.GameRule, h.TotalUser, h.TableUser, h.EnrollFee, h.Prizes)
  43. log.Release(" Start[%s] End[%s] Winners %v", common.TimeStampToString(h.StartTime), common.TimeStampToString(h.EndTime), h.Winners)
  44. if !detail {
  45. return
  46. }
  47. for i := 0; i < len(h.EnrollUsers); i++ {
  48. v := h.EnrollUsers[i]
  49. log.Release(" User[%d]: %d.%s", v.Rank, v.UserId, v.NickName)
  50. }
  51. for i := 0; i < len(h.Rounds); i++ {
  52. v := h.Rounds[i]
  53. log.Release(" Round[%d]: %d.%d", i, v.MatchType, v.MatchNo)
  54. }
  55. }
  56. func (h *combohistory) isUserEnrolled(userId int) bool {
  57. for _, v := range h.EnrollUsers {
  58. if v.UserId == userId {
  59. return true
  60. }
  61. }
  62. return false
  63. }
  64. func (h *combohistory) setAllEnrolledUsers(users []matchbase.EnrollUser) {
  65. if len(users) == 0 {
  66. return
  67. }
  68. for i := 0; i < len(users); {
  69. if h.isUserEnrolled(users[i].UserId) {
  70. users = append(users[:i], users[i+1:]...)
  71. } else {
  72. i++
  73. }
  74. }
  75. if len(users) == 0 {
  76. return
  77. }
  78. h.noShowUsers = make([]matchbase.EnrollUser, len(users))
  79. copy(h.noShowUsers, users)
  80. }