setsmatchuser.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package setsmatch
  2. import (
  3. "bet24.com/servers/micros/matches/handler/matchbase"
  4. "time"
  5. )
  6. type matchuser struct {
  7. matchbase.MatchUser
  8. RoomNo int
  9. // 私人场房间信息
  10. ServerAddr string
  11. TableId int
  12. ChairId int
  13. prize int
  14. tax int
  15. lastEndTime int // 上次比赛结束时间
  16. lastScore int
  17. lastArrageTime int // 上次被拉去匹配时间
  18. }
  19. func newMatchUser(userId int, nickName string, faceId int, faceUrl string, initialScore int, baseScore int) *matchuser {
  20. return &matchuser{
  21. MatchUser: matchbase.MatchUser{
  22. UserId: userId,
  23. NickName: nickName,
  24. FaceUrl: faceUrl,
  25. FaceId: faceId,
  26. Score: initialScore,
  27. BaseScore: baseScore,
  28. },
  29. }
  30. }
  31. func (mu *matchuser) arrangeRoom(roomNo int, serverAddr string, tableId int, chairId int) {
  32. mu.RoomNo = roomNo
  33. mu.ServerAddr = serverAddr
  34. mu.TableId = tableId
  35. mu.ChairId = chairId
  36. }
  37. func (mu *matchuser) clearRoomInfo() {
  38. mu.ServerAddr = ""
  39. mu.TableId = -1
  40. mu.ChairId = -1
  41. mu.RoomNo = 0
  42. //mu.Score = 0
  43. //mu.TotalScore += mu.Score
  44. mu.lastEndTime = int(time.Now().Unix())
  45. }
  46. func (mu *matchuser) getTotalScore() int {
  47. return mu.Score
  48. }
  49. func (mu *matchuser) getUserLastScore() int {
  50. return mu.lastScore
  51. }
  52. func (mu *matchuser) addScore(score int) {
  53. mu.lastScore = score
  54. mu.Score += score
  55. }