gamesink.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package gamelogic
  2. import (
  3. "encoding/json"
  4. "bet24.com/servers/games/spinplay/config"
  5. "bet24.com/servers/insecureframe/frame"
  6. )
  7. func newGameSink() *gamesink {
  8. gs := new(gamesink)
  9. return gs
  10. }
  11. type gamesink struct {
  12. }
  13. func (gs *gamesink) GetServerPort() int {
  14. return config.Server.ServerPort
  15. }
  16. func (gs *gamesink) GetGameID() int {
  17. return GAMEID
  18. }
  19. func (gs *gamesink) GetGameName() string {
  20. return GAME_NAME
  21. }
  22. func (gs *gamesink) GetRoomName() string {
  23. return config.Server.ServerName
  24. }
  25. func (gs *gamesink) CreateTableSink(table frame.Table, data string) frame.TableSink {
  26. return newTableSink(table, data)
  27. }
  28. func (gs *gamesink) GetOfflineSeconds() int64 {
  29. return config.Server.OfflineSeconds
  30. }
  31. func (gs *gamesink) GetRoomRobotCount(roomName string) int {
  32. for _, v := range config.Rooms.Rooms {
  33. if roomName == v.RoomName {
  34. return v.RobotCount
  35. }
  36. }
  37. return 0
  38. }
  39. func (gs *gamesink) GetRoomRobotGoldLimit(roomName string) (min, max int) {
  40. min = 0
  41. max = 0
  42. for _, v := range config.Rooms.Rooms {
  43. if roomName == v.RoomName {
  44. min = v.MinRobotGold
  45. max = v.MaxRobotGold
  46. break
  47. }
  48. }
  49. return
  50. }
  51. func (gs *gamesink) GetCertFile() string {
  52. return config.Server.CertFile
  53. }
  54. func (gs *gamesink) GetKeyFile() string {
  55. return config.Server.KeyFile
  56. }
  57. func (gs *gamesink) GetServerAddr() string {
  58. return config.Rooms.Rooms[0].ServerIP
  59. }
  60. func (gs *gamesink) GetRobotCount() int {
  61. return config.Rooms.Rooms[0].RobotCount
  62. }
  63. func (gs *gamesink) GetRobotGoldLimit() (min, max int) {
  64. min = config.Rooms.Rooms[0].MinRobotGold
  65. max = config.Rooms.Rooms[0].MaxRobotGold
  66. return
  67. }
  68. func (gs *gamesink) GetRobotOnlineSec() int {
  69. return config.Rooms.Rooms[0].RobotOnlineSec
  70. }
  71. func (gs *gamesink) GetRoomDatas() []string {
  72. var ret []string
  73. for _, v := range config.Rooms.Rooms {
  74. ret = append(ret, v.RoomName)
  75. }
  76. return ret
  77. }
  78. func (gs *gamesink) GetMinRoomCount(roomData string) int {
  79. for _, v := range config.Rooms.Rooms {
  80. if roomData == v.RoomName {
  81. return v.MinRoom
  82. }
  83. }
  84. return 0
  85. }
  86. func (gs *gamesink) IsChipRoom() bool {
  87. return config.Server.IsChipRoom > 0
  88. }
  89. func (ts *tablesink) OnBaseScoreChanged(baseScore int) {
  90. ts.roomInfo.BaseScore = baseScore
  91. d, _ := json.Marshal(ts.roomInfo.RoomInfoBase)
  92. ts.table.SendGameData(-1, CMD_ROOMINFO, string(d))
  93. }
  94. func (gs *gamesink) OnPlatformConfig(key string) {
  95. config.OnConfigChanged(key)
  96. }
  97. func (gs *gamesink) IsPrivateRoom() bool {
  98. return config.Server.IsPrivateRoom > 0
  99. }
  100. func (gs *gamesink) GetChairCount() int {
  101. return CHAIR_COUNT
  102. }
  103. func (gs *gamesink) GetRoomLevel(data string) int {
  104. var roomInfo config.RoomInfo
  105. json.Unmarshal([]byte(data), &roomInfo)
  106. for _, v := range config.Rooms.Rooms {
  107. if data == v.RoomName {
  108. return v.LockLevel
  109. }
  110. }
  111. return 0
  112. }
  113. func (gs *gamesink) GetVersionID() int {
  114. return config.Server.VersionID
  115. }