simplematch.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package simplematch
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/micros/matches/handler/matchbase"
  5. )
  6. func Run() {
  7. log.Release("simplematch.Run")
  8. getMatchManager().run()
  9. getHistoryManager().run()
  10. }
  11. func Dump(param1, param2 string) {
  12. if param1 == "history" {
  13. getHistoryManager().dump(param2)
  14. return
  15. }
  16. getMatchManager().dump(param1, param2)
  17. }
  18. // 接口
  19. // 创建比赛,返回比赛ID
  20. func CreateMatch(userId int, gameId int, gameRule string, totalUserCount int, target int, tableUserCount int, enrollFee int,
  21. prize int, playTimeout int, eleminateByScore bool, winnerCount int) (int, string) {
  22. return getMatchManager().createMatch(userId, gameId, gameRule, totalUserCount, target,
  23. tableUserCount, enrollFee, prize, playTimeout, eleminateByScore, winnerCount)
  24. }
  25. func EnrollMatch(userId int, nickname string, faceId int, faceUrl string, matchNo int) (int, string) {
  26. ok, errMsg := getMatchManager().enrollMatch(userId, nickname, faceId, faceUrl, matchNo)
  27. if ok {
  28. return 1, errMsg
  29. }
  30. return 0, errMsg
  31. }
  32. func EnrollMatchWithInitialScore(userId int, nickname string, faceId int, faceUrl string, matchNo int, score int) (int, string) {
  33. ok, errMsg := getMatchManager().enrollMatchWithInitialScore(userId, nickname, faceId, faceUrl, matchNo, score)
  34. if ok {
  35. return 1, errMsg
  36. }
  37. return 0, errMsg
  38. }
  39. func CloseMatch(userId int, matchNo int) (int, string) {
  40. ok, errMsg := getMatchManager().closeMatchByOwner(userId, matchNo)
  41. if ok {
  42. return 1, errMsg
  43. }
  44. return 0, errMsg
  45. }
  46. func DismissMatch(matchNo int) {
  47. getMatchManager().dismissMatch(matchNo)
  48. }
  49. func QuitMatch(userId int, matchNo int) bool {
  50. return getMatchManager().quitMatch(userId, matchNo)
  51. }
  52. func GetMatchInfo(matchNo int) string {
  53. return getMatchManager().getMatchInfo(matchNo)
  54. }
  55. func GetUserMatches(userId int) string {
  56. return getMatchManager().getUserMatches(userId)
  57. }
  58. func GetMatchConfigs() string {
  59. return getMatchManager().getMatchConfigs()
  60. }
  61. func Flush() {
  62. getHistoryManager().forceFlush()
  63. }
  64. func GetEnrolledMatch(userId int) string {
  65. return getMatchManager().getEnrolledMatch(userId)
  66. }
  67. func GetMatchHistory(userId int) string {
  68. return getHistoryManager().getHistory(userId)
  69. }
  70. func GetMatchInstance(matchNo int) matchbase.MatchInstance {
  71. return getMatchManager().getMatchInstance(matchNo)
  72. }