ladder.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package ladder
  2. import (
  3. "bet24.com/log"
  4. pb "bet24.com/servers/micros/ladderservice/proto"
  5. )
  6. func Run() {
  7. getLadderConfig()
  8. getLadderManager()
  9. getConsecutiveMgr()
  10. }
  11. func Dump(cmd, param1 string) {
  12. switch cmd {
  13. case "config":
  14. getLadderConfig().dump()
  15. return
  16. case "con":
  17. getConsecutiveMgr().dump(param1)
  18. return
  19. case "user":
  20. getLadderManager().dumpUser(param1)
  21. case "room":
  22. getRoomManager().dump()
  23. case "cal":
  24. getLadderManager().dumpCal(param1)
  25. default:
  26. log.Release("ladder.Dump unhandled cmd %s", cmd)
  27. break
  28. }
  29. }
  30. func GetSystemLadderInfo() string {
  31. return getLadderConfig().getLadderInfo()
  32. }
  33. func GetUserConsecutiveWinCount(userId int, gameId int) int {
  34. if userId <= 0 {
  35. log.Release("ladder.GetUserConsecutiveWinCount userId == %d", userId)
  36. return 0
  37. }
  38. return getConsecutiveMgr().getUserConsecutiveWinCount(userId, gameId)
  39. }
  40. func GetUserLadderInfo(userId int) *pb.UserLadderInfo {
  41. if userId <= 0 {
  42. log.Release("ladder.GetUserLadderInfo userId == %d", userId)
  43. return nil
  44. }
  45. return getLadderManager().getUserLadderInfo(userId)
  46. }
  47. func AddUserScore(userId int, gameId int, score int, roomName string) (int, bool) {
  48. if userId <= 0 {
  49. log.Release("ladder.AddUserScore userId == %d", userId)
  50. return 0, false
  51. }
  52. return getLadderManager().addUserScore(userId, gameId, score, roomName)
  53. }
  54. func UseConsecutiveCard(userId int, gameId int) bool {
  55. if userId <= 0 {
  56. log.Release("ladder.UseConsecutiveCard userId == %d", userId)
  57. return false
  58. }
  59. if getConsecutiveMgr().removeLastLost(userId, gameId) {
  60. getLadderManager().refreshCurConWin(userId)
  61. return true
  62. }
  63. return false
  64. }
  65. func RegisterLadderRoom(roomInfo pb.GameRoomInfo) {
  66. getRoomManager().addRoom(roomInfo)
  67. }
  68. func DeregisterLadderRoom(serverAddr string) {
  69. log.Debug("DeregisterLadderRoom %s", serverAddr)
  70. getRoomManager().removeRooms(serverAddr)
  71. }
  72. func GetLadderRoomList() string {
  73. return getRoomManager().getRoomList()
  74. }
  75. func GetSettlementRecord(userId int) pb.SettlementRecord {
  76. return getLadderManager().getSettlementRecord(userId)
  77. }
  78. func GetHistoricalRecord(userId int) []pb.WinningStreak {
  79. return getLadderManager().getHistoricalRecord(userId)
  80. }
  81. func GetLadderRoomAdditionalPercent(gameId int, ruleName string) int {
  82. return getRoomManager().getRoomAdditionalPercent(gameId, ruleName)
  83. }