源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.6 KiB

  1. -- require("game.proto.425.Require425")
  2. require("game.adventureBook.AdventureBookView")
  3. require("game.adventureBook.AdventureBookDetailView")
  4. require("game.adventureBook.AdventureBookItem")
  5. require("game.adventureBook.AdventureBookDetailItem")
  6. require("game.adventureBook.AdventureBookModel")
  7. AdventureBookController = AdventureBookController or BaseClass(BaseController)
  8. function AdventureBookController:__init()
  9. AdventureBookController.Instance = self
  10. self.model = AdventureBookModel:getInstance()
  11. self:RegisterAllProtocals()
  12. self:InitEvent()
  13. end
  14. function AdventureBookController:RegisterAllProtocals()
  15. -- self:RegisterProtocal(42500,"handler42500") --错误码
  16. -- self:RegisterProtocal(42501,"handler42501") --未激活的冒险之书
  17. -- self:RegisterProtocal(42502,"handler42502") --冒险之书信息列表
  18. -- self:RegisterProtocal(42503,"handler42503") --激活冒险之书
  19. -- self:RegisterProtocal(42504,"handler42504") --更新冒险之书信息
  20. end
  21. function AdventureBookController:InitEvent()
  22. --打开界面
  23. local function open_func(bool, type)
  24. if not self.AdventureBookView then
  25. self.AdventureBookView = AdventureBookView.New()
  26. end
  27. if bool then
  28. if not self.AdventureBookView:HasOpen() then
  29. self.AdventureBookView:Open(type)
  30. end
  31. else
  32. if self.AdventureBookView:HasOpen() then
  33. self.AdventureBookView:Close()
  34. end
  35. end
  36. end
  37. GlobalEventSystem:Bind(EventName.OPEN_ADVENTURE_BOOK_VIEW, open_func)
  38. local function open_detail_func(type, subtype,is_close)
  39. if is_close then
  40. if self.AdventureBookDetailView then
  41. self.AdventureBookDetailView:Close()
  42. return
  43. end
  44. end
  45. if not self.AdventureBookDetailView then
  46. self.AdventureBookDetailView = AdventureBookDetailView.New()
  47. end
  48. if not self.AdventureBookDetailView:HasOpen() then
  49. self.AdventureBookDetailView:Open(type, subtype)
  50. end
  51. end
  52. self.model:Bind(AdventureBookModel.UPDATE_ADVENTURE_BOOK_DETAIL_VIEW, open_detail_func)
  53. -- local function onGameStart()
  54. -- self.model:Fire(AdventureBookModel.REQUEST_PROTOCAL, 42501)
  55. -- self.model:Fire(AdventureBookModel.REQUEST_PROTOCAL, 42502, AdventureBookType.MAP)
  56. -- end
  57. -- GlobalEventSystem:Bind(EventName.GAME_START, onGameStart)
  58. -- local function requset_func(...)
  59. -- local args = {...}
  60. -- if args[1] == 42502 then
  61. -- self:SendFmtToGame(args[1], "c", args[2])
  62. -- elseif args[1] == 42503 then
  63. -- self:SendFmtToGame(args[1], "cc", args[2], args[3])
  64. -- else
  65. -- self:SendFmtToGame(args[1])
  66. -- end
  67. -- end
  68. -- self.model:Bind(AdventureBookModel.REQUEST_PROTOCAL, requset_func)
  69. end
  70. function AdventureBookController:handler42500()
  71. local scmd = SCMD42500.New(true)
  72. ErrorCodeShow(scmd.error_code, scmd.args)
  73. end
  74. function AdventureBookController:handler42501()
  75. local scmd = SCMD42501.New(true)
  76. self.model:SetUnActiveList(scmd.list)
  77. end
  78. function AdventureBookController:handler42502()
  79. local scmd = SCMD42502.New(true)
  80. self.model:SetBookInfo(scmd)
  81. self.model:Fire(AdventureBookModel.UPDATE_ADVENTURE_BOOK_INFO, scmd.type)
  82. end
  83. function AdventureBookController:handler42503()
  84. local scmd = SCMD42503.New(true)
  85. if scmd.error_code == 1 then
  86. self.model:RemoveActiveBook(scmd.type, scmd.subtype)
  87. local cfg = Config.Adventurebook[scmd.type.."@"..scmd.subtype]
  88. if cfg then
  89. local attr = ErlangParser:GetInstance():Parse(cfg.attr)
  90. if attr then
  91. GlobalEventSystem:Fire(EventName.OPEN_UPGRADE_SHOW_VIEW, 8, 1, "adv_text_"..scmd.type.."_"..scmd.subtype, "activate_book_"..scmd.type.."_"..scmd.subtype, GetFighting(attr), nil, cfg.attr)
  92. end
  93. end
  94. else
  95. ErrorCodeShow(scmd.error_code)
  96. end
  97. end
  98. function AdventureBookController:handler42504()
  99. local scmd = SCMD42504.New(true)
  100. self.model:UpdateBookInfo(scmd.update_list)
  101. end