源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

105 行
3.6 KiB

  1. require("game.proto.340.Require340")
  2. require("game.currencyWish.CurrencyWishConst")
  3. require("game.currencyWish.CurrencyWishModel")
  4. require("game.currencyWish.CurrencyWishView")
  5. require("game.currencyWish.CurrencyWishCriticalView")
  6. CurrencyWishController = CurrencyWishController or BaseClass(BaseController, true)
  7. local CurrencyWishController = CurrencyWishController
  8. function CurrencyWishController:__init()
  9. CurrencyWishController.Instance = self
  10. self.model = CurrencyWishModel:getInstance()
  11. self:AddEvents()
  12. self:RegisterAllProtocal()
  13. end
  14. function CurrencyWishController:RegisterAllProtocal( )
  15. self:RegisterProtocal(34000, "Handle34000")
  16. self:RegisterProtocal(34001, "Handle34001")
  17. self:RegisterProtocal(34002, "Handle34002")
  18. end
  19. function CurrencyWishController:AddEvents()
  20. local function on_game_start()
  21. self.model:Reset()
  22. self:SendFmtToGame(34001)
  23. end
  24. GlobalEventSystem:Bind(EventName.GAME_START, on_game_start)
  25. local function req_currency_wish_info()
  26. self:SendFmtToGame(34001)
  27. end
  28. self.model:Bind(CurrencyWishConst.REQ_CURRENCY_WISH_INFO, req_currency_wish_info)
  29. local function req_do_currency_wish(type)
  30. self:SendFmtToGame(34002, "c", type)
  31. end
  32. self.model:Bind(CurrencyWishConst.REQ_DO_CURRENCY_WISH, req_do_currency_wish)
  33. local function on_open_currency_wish_view()
  34. if not self.currency_wish_view then
  35. self.currency_wish_view = CurrencyWishView.New()
  36. end
  37. self.currency_wish_view:Open()
  38. end
  39. GlobalEventSystem:Bind(CurrencyWishConst.OPEN_CURRENCY_WISH_VIEW, on_open_currency_wish_view)
  40. local function on_ans_do_currency_wish(res_info)
  41. self.model:Fire(CurrencyWishConst.REQ_CURRENCY_WISH_INFO)
  42. if res_info and res_info.crit_rate and res_info.crit_rate > 1 then
  43. self.currency_wish_critical_view = self.currency_wish_critical_view or CurrencyWishCriticalView.New()
  44. self.currency_wish_critical_view:Open()
  45. self.currency_wish_critical_view:SetData(res_info)
  46. end
  47. end
  48. self.model:Bind(CurrencyWishConst.ANS_DO_CURRENCY_WISH, on_ans_do_currency_wish)
  49. local function on_bag_red_update()
  50. self.model:CheckRedDot(true)
  51. self.model:Fire(CurrencyWishConst.UPDATE_CURRENCY_WISH_VIEW)
  52. end
  53. GlobalEventSystem:Bind(EventName.UPDATE_BAG_RED, on_bag_red_update)
  54. local function on_day_change()
  55. self.model:Fire(CurrencyWishConst.REQ_CURRENCY_WISH_INFO)
  56. end
  57. GlobalEventSystem:Bind(EventName.CHANE_DAY, on_day_change)
  58. end
  59. function CurrencyWishController:Handle34000()
  60. local scmd = SCMD34000.New(true)
  61. if scmd.errcode then
  62. ErrorCodeShow(scmd.errcode)
  63. end
  64. end
  65. -- ############## 查看信息 ##############
  66. -- protocol=34001
  67. -- {
  68. -- c2s{
  69. -- }
  70. -- s2c{
  71. -- luxury_rest_times:int8 //豪华当日剩余祈愿次数
  72. -- luxurycool:int32 //豪华距离免费剩余冷却时间
  73. -- expr_rest_times:int8 //经验当日剩余祈愿次数
  74. -- }
  75. -- }
  76. function CurrencyWishController:Handle34001()
  77. local scmd = SCMD34001.New(true)
  78. -- print("Lizhijian:CurrencyWishController [start:80] ")
  79. -- PrintTable(scmd)
  80. -- print("Lizhijian:CurrencyWishController [end:80] ")
  81. self.model:SetBaseInfo(scmd)
  82. self.model:SetCurrencyWishCdTime()
  83. self.model:CheckRedDot(true)
  84. self.model:Fire(CurrencyWishConst.ANS_CURRENCY_WISH_INFO)
  85. end
  86. function CurrencyWishController:Handle34002()
  87. local scmd = SCMD34002.New(true)
  88. -- print("Lizhijian:CurrencyWishController [start:102] ")
  89. -- PrintTable(scmd)
  90. -- print("Lizhijian:CurrencyWishController [end:102] ")
  91. self.model:Fire(CurrencyWishConst.ANS_DO_CURRENCY_WISH, scmd)
  92. end