gamesink.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package gamelogic
  2. import (
  3. "encoding/json"
  4. "bet24.com/servers/games/quickludo/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. //d, _ := json.Marshal(v)
  75. ret = append(ret, v.RoomName)
  76. }
  77. return ret
  78. }
  79. func (gs *gamesink) GetMinRoomCount(roomData string) int {
  80. for _, v := range config.Rooms.Rooms {
  81. if roomData == v.RoomName {
  82. return v.MinRoom
  83. }
  84. }
  85. return 0
  86. }
  87. func (gs *gamesink) IsChipRoom() bool {
  88. return config.Server.IsChipRoom > 0
  89. }
  90. func (ts *tablesink) OnBaseScoreChanged(baseScore int) {
  91. ts.roomInfo.BaseScore = baseScore
  92. d, _ := json.Marshal(ts.roomInfo.RoomInfoBase)
  93. ts.table.SendGameData(-1, CMD_ROOMINFO, string(d))
  94. }
  95. func (gs *gamesink) OnPlatformConfig(key string) {
  96. config.OnConfigChanged(key)
  97. }
  98. func (gs *gamesink) IsPrivateRoom() bool {
  99. return config.Server.IsPrivateRoom > 0
  100. }
  101. func (gs *gamesink) GetChairCount() int {
  102. return CHAIR_COUNT
  103. }
  104. func (gs *gamesink) GetRoomLevel(data string) int {
  105. return 0
  106. }
  107. func (gs *gamesink) GetVersionID() int {
  108. return config.Server.VersionID
  109. }