playerinfo.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package gamelogic
  2. import (
  3. "bet24.com/log"
  4. )
  5. type PlayerInfo struct {
  6. IsValid bool // 是否有效玩家
  7. AutoOut bool // 托管标志
  8. HandCards []int // 手牌
  9. Score int // 携带分
  10. Status int // 玩家状态
  11. EndScore int // 结算分
  12. RobScore int // 抢庄分
  13. CardType int // 牌型
  14. LastAction int // 上个动作
  15. Param int // 动作参数
  16. Experience int // 玩家经验值
  17. ChangeScore int // 小局输赢变化值
  18. userID int // 玩家ID
  19. isRobot bool // 是否机器人
  20. robotType int // 机器人类型
  21. isEndToStart bool
  22. }
  23. func (p *PlayerInfo) initData(userId, enterGold int) {
  24. p.IsValid = false
  25. p.isRobot = false
  26. p.userID = userId
  27. p.Score = enterGold
  28. p.EndScore = 0
  29. p.Experience = 0
  30. p.gameInit()
  31. }
  32. func (p *PlayerInfo) gameInit() {
  33. p.HandCards = []int{}
  34. p.Status = Player_Status_Free
  35. p.AutoOut = false
  36. p.RobScore = 0
  37. p.LastAction = -1
  38. p.ChangeScore = 0
  39. p.Param = -1
  40. }
  41. func (p *PlayerInfo) setLastData(action, param int) {
  42. p.LastAction = action
  43. p.Param = param
  44. }
  45. func (p *PlayerInfo) hideSecretData() {
  46. for i := 0; i < len(p.HandCards); i++ {
  47. p.HandCards[i] = CARD_COUNT
  48. }
  49. }
  50. func (p *PlayerInfo) dump(chairId int) {
  51. robot := ""
  52. if p.isRobot {
  53. robot = "ROBOT"
  54. }
  55. log.Release(" ----Player[%d] Chair[%d] IsValid[%v] %s RobotType[%d]", p.userID, chairId, p.IsValid, robot, p.robotType)
  56. log.Release(" HandCards%s CardType[%d] ", getCardsHex(p.HandCards), p.CardType)
  57. log.Release(" AutoOut[%v] Score[%d] Status[%d] EndScore[%d] RobScore[%d] LastAction[%d], Param[%d]",
  58. p.AutoOut, p.Score, p.Status, p.EndScore, p.RobScore, p.LastAction, p.Param)
  59. log.Release(" Experience[%v] ChangeScore[%d]", p.Experience, p.ChangeScore)
  60. log.Release(" +++++++++++++++++")
  61. }