gamesink.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. package gamelogic
  2. import (
  3. "bet24.com/servers/games/baloot/config"
  4. "bet24.com/servers/insecureframe/frame"
  5. )
  6. func newGameSink() *gamesink {
  7. return new(gamesink)
  8. }
  9. type gamesink struct {
  10. }
  11. func (gs *gamesink) GetServerPort() int {
  12. return config.Server.ServerPort
  13. }
  14. func (gs *gamesink) GetGameID() int {
  15. return GAMEID
  16. }
  17. func (gs *gamesink) GetGameName() string {
  18. return GAME_NAME
  19. }
  20. func (gs *gamesink) GetRoomName() string {
  21. return config.Server.ServerName
  22. }
  23. func (gs *gamesink) CreateTableSink(table frame.Table, data string) frame.TableSink {
  24. return newTableSink(table, data)
  25. }
  26. func (gs *gamesink) GetOfflineSeconds() int64 {
  27. return config.Server.OfflineSeconds
  28. }
  29. func (gs *gamesink) GetCertFile() string {
  30. return config.Server.CertFile
  31. }
  32. func (gs *gamesink) GetKeyFile() string {
  33. return config.Server.KeyFile
  34. }
  35. func (gs *gamesink) GetServerAddr() string {
  36. return config.Rooms.Rooms[0].ServerIP
  37. }
  38. func (gs *gamesink) GetRobotCount() int {
  39. return config.Rooms.Rooms[0].RobotCount
  40. }
  41. func (gs *gamesink) GetRobotGoldLimit() (min, max int) {
  42. min = config.Rooms.Rooms[0].MinRobotGold
  43. max = config.Rooms.Rooms[0].MaxRobotGold
  44. return
  45. }
  46. func (gs *gamesink) GetRobotOnlineSec() int {
  47. return config.Rooms.Rooms[0].RobotOnlineSec
  48. }
  49. func (gs *gamesink) GetRoomDatas() []string {
  50. var ret []string
  51. for _, v := range config.Rooms.Rooms {
  52. ret = append(ret, v.RoomName)
  53. }
  54. return ret
  55. }
  56. func (gs *gamesink) GetMinRoomCount(roomData string) int {
  57. for _, v := range config.Rooms.Rooms {
  58. if roomData == v.RoomName {
  59. return v.MinRoom
  60. }
  61. }
  62. return 0
  63. }
  64. func (gs *gamesink) IsChipRoom() bool {
  65. return config.Server.IsChipRoom > 0
  66. }
  67. func (gs *gamesink) OnPlatformConfig(key string) {
  68. config.OnConfigChanged(key)
  69. }
  70. func (gs *gamesink) IsPrivateRoom() bool {
  71. return config.Server.IsPrivateRoom > 0
  72. }
  73. func (gs *gamesink) GetChairCount() int {
  74. return CHAIR_COUNT
  75. }
  76. func (gs *gamesink) GetRoomRobotCount(roomName string) int {
  77. for _, v := range config.Rooms.Rooms {
  78. if roomName == v.RoomName {
  79. return v.RobotCount
  80. }
  81. }
  82. return 0
  83. }
  84. func (gs *gamesink) GetRoomRobotGoldLimit(roomName string) (min, max int) {
  85. min = 0
  86. max = 0
  87. for _, v := range config.Rooms.Rooms {
  88. if roomName == v.RoomName {
  89. min = v.MinRobotGold
  90. max = v.MaxRobotGold
  91. break
  92. }
  93. }
  94. return
  95. }
  96. // GameSink_LadderRoom
  97. func (gs *gamesink) IsLadderRoom() bool {
  98. return config.Server.IsLadderRoom > 0
  99. }
  100. func (gs *gamesink) GetMinGold(roomName string) int {
  101. for _, v := range config.Rooms.Rooms {
  102. if roomName == v.RoomName {
  103. return v.MinGold
  104. }
  105. }
  106. return 0
  107. }
  108. func (gs *gamesink) GetMaxGold(roomName string) int {
  109. for _, v := range config.Rooms.Rooms {
  110. if roomName == v.RoomName {
  111. return v.MaxGold
  112. }
  113. }
  114. return 0
  115. }
  116. func (gs *gamesink) GetAdditionalPercent(roomName string) int {
  117. for _, v := range config.Rooms.Rooms {
  118. if roomName == v.RoomName {
  119. return v.AdditionalPercent
  120. }
  121. }
  122. return 0
  123. }
  124. func (gs *gamesink) GetBaseScore(roomName string) int {
  125. for _, v := range config.Rooms.Rooms {
  126. if roomName == v.RoomName {
  127. return v.BaseScore
  128. }
  129. }
  130. return 0
  131. }
  132. func (gs *gamesink) GetRoomLevel(data string) int {
  133. for _, v := range config.Rooms.Rooms {
  134. if data == v.RoomName {
  135. return v.LockLevel
  136. }
  137. }
  138. return 0
  139. }
  140. func (gs *gamesink) GetVersionID() int {
  141. return config.Server.VersionID
  142. }