gamesink.go 2.7 KB

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