|
require("game.proto.340.Require340")
|
|
require("game.currencyWish.CurrencyWishConst")
|
|
require("game.currencyWish.CurrencyWishModel")
|
|
require("game.currencyWish.CurrencyWishView")
|
|
require("game.currencyWish.CurrencyWishCriticalView")
|
|
|
|
CurrencyWishController = CurrencyWishController or BaseClass(BaseController, true)
|
|
local CurrencyWishController = CurrencyWishController
|
|
|
|
function CurrencyWishController:__init()
|
|
CurrencyWishController.Instance = self
|
|
self.model = CurrencyWishModel:getInstance()
|
|
self:AddEvents()
|
|
self:RegisterAllProtocal()
|
|
end
|
|
|
|
function CurrencyWishController:RegisterAllProtocal( )
|
|
self:RegisterProtocal(34000, "Handle34000")
|
|
self:RegisterProtocal(34001, "Handle34001")
|
|
self:RegisterProtocal(34002, "Handle34002")
|
|
end
|
|
|
|
function CurrencyWishController:AddEvents()
|
|
local function on_game_start()
|
|
self.model:Reset()
|
|
self:SendFmtToGame(34001)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.GAME_START, on_game_start)
|
|
|
|
local function req_currency_wish_info()
|
|
self:SendFmtToGame(34001)
|
|
end
|
|
self.model:Bind(CurrencyWishConst.REQ_CURRENCY_WISH_INFO, req_currency_wish_info)
|
|
|
|
local function req_do_currency_wish(type)
|
|
self:SendFmtToGame(34002, "c", type)
|
|
end
|
|
self.model:Bind(CurrencyWishConst.REQ_DO_CURRENCY_WISH, req_do_currency_wish)
|
|
|
|
local function on_open_currency_wish_view()
|
|
if not self.currency_wish_view then
|
|
self.currency_wish_view = CurrencyWishView.New()
|
|
end
|
|
self.currency_wish_view:Open()
|
|
end
|
|
GlobalEventSystem:Bind(CurrencyWishConst.OPEN_CURRENCY_WISH_VIEW, on_open_currency_wish_view)
|
|
|
|
local function on_ans_do_currency_wish(res_info)
|
|
self.model:Fire(CurrencyWishConst.REQ_CURRENCY_WISH_INFO)
|
|
if res_info and res_info.crit_rate and res_info.crit_rate > 1 then
|
|
self.currency_wish_critical_view = self.currency_wish_critical_view or CurrencyWishCriticalView.New()
|
|
self.currency_wish_critical_view:Open()
|
|
self.currency_wish_critical_view:SetData(res_info)
|
|
end
|
|
end
|
|
self.model:Bind(CurrencyWishConst.ANS_DO_CURRENCY_WISH, on_ans_do_currency_wish)
|
|
|
|
local function on_bag_red_update()
|
|
self.model:CheckRedDot(true)
|
|
self.model:Fire(CurrencyWishConst.UPDATE_CURRENCY_WISH_VIEW)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.UPDATE_BAG_RED, on_bag_red_update)
|
|
|
|
local function on_day_change()
|
|
self.model:Fire(CurrencyWishConst.REQ_CURRENCY_WISH_INFO)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.CHANE_DAY, on_day_change)
|
|
|
|
end
|
|
|
|
function CurrencyWishController:Handle34000()
|
|
local scmd = SCMD34000.New(true)
|
|
if scmd.errcode then
|
|
ErrorCodeShow(scmd.errcode)
|
|
end
|
|
end
|
|
|
|
-- ############## 查看信息 ##############
|
|
-- protocol=34001
|
|
-- {
|
|
-- c2s{
|
|
-- }
|
|
-- s2c{
|
|
-- luxury_rest_times:int8 //豪华当日剩余祈愿次数
|
|
-- luxurycool:int32 //豪华距离免费剩余冷却时间
|
|
-- expr_rest_times:int8 //经验当日剩余祈愿次数
|
|
-- }
|
|
-- }
|
|
function CurrencyWishController:Handle34001()
|
|
local scmd = SCMD34001.New(true)
|
|
-- print("Lizhijian:CurrencyWishController [start:80] ")
|
|
-- PrintTable(scmd)
|
|
-- print("Lizhijian:CurrencyWishController [end:80] ")
|
|
self.model:SetBaseInfo(scmd)
|
|
self.model:SetCurrencyWishCdTime()
|
|
self.model:CheckRedDot(true)
|
|
self.model:Fire(CurrencyWishConst.ANS_CURRENCY_WISH_INFO)
|
|
end
|
|
|
|
function CurrencyWishController:Handle34002()
|
|
local scmd = SCMD34002.New(true)
|
|
-- print("Lizhijian:CurrencyWishController [start:102] ")
|
|
-- PrintTable(scmd)
|
|
-- print("Lizhijian:CurrencyWishController [end:102] ")
|
|
self.model:Fire(CurrencyWishConst.ANS_DO_CURRENCY_WISH, scmd)
|
|
end
|