remote.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package actorRemote
  2. import (
  3. cherryApp "f1-game/internal/cherry_app"
  4. "f1-game/internal/constant"
  5. "math/rand"
  6. )
  7. var (
  8. GateUser = newGateUser()
  9. )
  10. var (
  11. CenterDev = newCenterDev()
  12. CenterOps = newCenterOps()
  13. CenterPlayer = newCenterPlayer()
  14. )
  15. var (
  16. PayOrder = newPayOrder()
  17. )
  18. var (
  19. GameOps = newGameOps()
  20. GamePlayer = newGamePlayer()
  21. GameMail = newGameMail()
  22. )
  23. var (
  24. Chat = newChat()
  25. )
  26. var (
  27. GenPool = newGenPool()
  28. )
  29. var (
  30. MapPlayer = newMapPlayer()
  31. )
  32. func payNodeID() string {
  33. list := cherryApp.Discovery().ListByType(constant.NodePay)
  34. listLen := len(list)
  35. if listLen < 1 {
  36. return ""
  37. }
  38. if listLen == 1 {
  39. return list[0].GetNodeID()
  40. }
  41. return list[rand.Intn(listLen)].GetNodeID()
  42. }
  43. func centerNodeID() string {
  44. member, found := cherryApp.Discovery().Random(constant.NodeCenter)
  45. if !found {
  46. return ""
  47. }
  48. return member.GetNodeID()
  49. }
  50. func chatNodeID(chatID int64) string {
  51. list := cherryApp.Discovery().ListByType(constant.NodeChat)
  52. listLen := len(list)
  53. if listLen < 1 {
  54. return ""
  55. }
  56. if listLen == 1 {
  57. return list[0].GetNodeID()
  58. }
  59. return list[chatID%int64(listLen)].GetNodeID()
  60. }