slotcommon_msg.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package slotcommon
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/fishhall/config"
  5. "bet24.com/servers/games/slotcommon/betlevel"
  6. "bet24.com/servers/games/slotcommon/usermanager"
  7. "encoding/json"
  8. )
  9. type slot_message struct {
  10. MsgID int
  11. Data string
  12. }
  13. const (
  14. Msg_Unlock_Bet = 100 // 解锁所有下注
  15. )
  16. func (sc *Slotcommon) sendMessage(userId int, msgId int, msgData string) {
  17. sm := slot_message{MsgID: msgId, Data: msgData}
  18. data, _ := json.Marshal(sm)
  19. sc.slotSink.SendGameCmd(userId, sc.gameMessage, string(data))
  20. }
  21. func (sc *Slotcommon) SetBetLevelManager(levelMgr *betlevel.BetLevelManager) {
  22. sc.levelMgr = levelMgr
  23. }
  24. func (sc *Slotcommon) SendBetLevel(userId int) {
  25. if sc.levelMgr == nil {
  26. log.Release("Slotcommon.sendBetLevel [%s] levelMgr == nil", sc.gameName)
  27. return
  28. }
  29. var data []byte
  30. if config.Server.IsChipRoom > 0 && usermanager.IsNewbie(userId, sc.gameId) {
  31. data, _ = json.Marshal(sc.levelMgr.NewbieLevels())
  32. } else {
  33. data, _ = json.Marshal(sc.levelMgr.Levels())
  34. }
  35. sc.sendMessage(userId, sc.levelMgr.MsgId(), string(data))
  36. }
  37. func (sc *Slotcommon) sendUnlockBet(userId int) {
  38. if config.Server.IsChipRoom > 0 {
  39. sc.sendMessage(userId, Msg_Unlock_Bet, "")
  40. }
  41. }