gamesink.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package gamelogic
  2. import (
  3. "encoding/json"
  4. "bet24.com/servers/games/blitzludo/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) GetRoomList() string {
  32. // d, _ := json.Marshal(config.Rooms)
  33. // return string(d)
  34. // }
  35. func (gs *gamesink) GetCertFile() string {
  36. return config.Server.CertFile
  37. }
  38. func (gs *gamesink) GetKeyFile() string {
  39. return config.Server.KeyFile
  40. }
  41. func (gs *gamesink) GetServerAddr() string {
  42. return config.Rooms.Rooms[0].ServerIP
  43. }
  44. func (gs *gamesink) GetRobotCount() int {
  45. return config.Rooms.Rooms[0].RobotCount
  46. }
  47. func (gs *gamesink) GetRobotGoldLimit() (min, max int) {
  48. min = config.Rooms.Rooms[0].MinRobotGold
  49. max = config.Rooms.Rooms[0].MaxRobotGold
  50. return
  51. }
  52. func (gs *gamesink) GetRobotOnlineSec() int {
  53. return config.Rooms.Rooms[0].RobotOnlineSec
  54. }
  55. func (gs *gamesink) GetRoomDatas() []string {
  56. var ret []string
  57. for _, v := range config.Rooms.Rooms {
  58. //d, _ := json.Marshal(v)
  59. ret = append(ret, v.RoomName)
  60. }
  61. return ret
  62. }
  63. func (gs *gamesink) GetMinRoomCount(roomData string) int {
  64. for _, v := range config.Rooms.Rooms {
  65. if roomData == v.RoomName {
  66. return v.MinRoom
  67. }
  68. }
  69. return 0
  70. }
  71. func (gs *gamesink) IsChipRoom() bool {
  72. return config.Server.IsChipRoom > 0
  73. }
  74. func (ts *tablesink) OnBaseScoreChanged(baseScore int) {
  75. ts.roomInfo.BaseScore = baseScore
  76. d, _ := json.Marshal(ts.roomInfo.RoomInfoBase)
  77. ts.table.SendGameData(-1, CMD_ROOMINFO, string(d))
  78. }
  79. func (gs *gamesink) OnPlatformConfig(key string) {
  80. config.OnConfigChanged(key)
  81. }
  82. func (gs *gamesink) IsPrivateRoom() bool {
  83. return false
  84. }
  85. func (gs *gamesink) GetChairCount() int {
  86. return CHAIR_COUNT
  87. }
  88. func (gs *gamesink) GetRoomRobotCount(roomName string) int {
  89. for _, v := range config.Rooms.Rooms {
  90. if roomName == v.RoomName {
  91. return v.RobotCount
  92. }
  93. }
  94. return 0
  95. }
  96. func (gs *gamesink) GetRoomRobotGoldLimit(roomName string) (min, max int) {
  97. min = 0
  98. max = 0
  99. for _, v := range config.Rooms.Rooms {
  100. if roomName == v.RoomName {
  101. min = v.MinRobotGold
  102. max = v.MaxRobotGold
  103. break
  104. }
  105. }
  106. return
  107. }
  108. func (gs *gamesink) GetRoomLevel(data string) int {
  109. return 0
  110. }
  111. func (gs *gamesink) GetVersionID() int {
  112. return config.Server.VersionID
  113. }