Commit 386cd4c145a170f4695c8eba4cbf6daefb0b6495

Authored by zhangqijia
1 parent 5db4c63a

feat: 狩猎祭,增加重置扭蛋机协议

Activity_resetGachakonRpc = 676, --狩猎祭,重制扭蛋机
src/ProtocolCode.lua
... ... @@ -247,7 +247,7 @@ actionCodes = {
247 247 Activity_actCalendaTaskRpc = 655,
248 248 Activity_actPaySignRpc = 656,
249 249 Activity_exchangeRpc = 657,
250   - Activity_gachakonRpc = 658,
  250 + Activity_gachakonRpc = 658, --狩猎祭 抽扭蛋机
251 251 Activity_hangDropRpc = 659,
252 252 Activity_startBattleRpc = 660,
253 253 Activity_endBattleRpc = 661,
... ... @@ -265,6 +265,7 @@ actionCodes = {
265 265 Activity_returnerTaskRpc = 673,
266 266 Activity_actNewUserTaskRpc = 674,
267 267 Activity_buyBattleTicketRpc = 675,
  268 + Activity_resetGachakonRpc = 676, --狩猎祭,重制扭蛋机
268 269  
269 270 Radio_startQuestRpc = 700,
270 271 Radio_finishQuestRpc = 701,
... ...
src/actions/ActivityAction.lua
... ... @@ -479,6 +479,20 @@ function _M.gachakonRpc(agent, data)
479 479 return true
480 480 end
481 481  
  482 +function _M.resetGachakonRpc(agent, data)
  483 + local role = agent.role
  484 + local msg = MsgPack.unpack(data)
  485 + local actid = msg.actid
  486 +
  487 + if not role.activity:isOpenById(actid, "Gachakon") then return 1 end
  488 +
  489 + if role.activity:isResetById(actid, "Gachakon") then return 2 end
  490 + role.activity:resetActDataById(actid)
  491 +
  492 + SendPacket(actionCodes.Activity_resetGachakonRpc, MsgPack.pack({}))
  493 + return true
  494 +end
  495 +
482 496 function _M.hangDropRpc(agent, data)
483 497 local role = agent.role
484 498 local msg = MsgPack.unpack(data)
... ...
src/models/Activity.lua
... ... @@ -93,6 +93,8 @@ Activity.schema = {
93 93  
94 94 act34 = {"table", {}}, -- 战令记录{unlock = 1, freeR = "", payR = "", lvl = 10, sum = 100}
95 95 act36 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1}
  96 +
  97 + reset20 = {"number", 1}, -- 重置扭蛋机
96 98 }
97 99  
98 100 function Activity:data()
... ... @@ -121,6 +123,8 @@ function Activity:data()
121 123  
122 124 act34 = self:getProperty("act34"),
123 125 act36 = self:getProperty("act36"),
  126 +
  127 + reset20 = self:getProperty("reset20")
124 128 }
125 129 end
126 130  
... ... @@ -207,6 +211,24 @@ function Activity:isOpenById(id, activityType)
207 211 return self._isOpen[id]
208 212 end
209 213  
  214 +function Activity:isResetById(id, activityType)
  215 + activityType = checkActivityType(activityType)
  216 + local cfg = csvdb["activity_ctrlCsv"][id]
  217 + if not cfg then return false end
  218 + if activityType ~= 0 and cfg.showType ~= activityType then return false end
  219 + return self:getResetData(activityType) == 0
  220 +end
  221 +
  222 +function Activity:getResetData(actType)
  223 + actType = checkActivityType(actType)
  224 + return self:getProperty("reset" .. actType)
  225 +end
  226 +
  227 +function Activity:updateResetData(actType, reset)
  228 + actType = checkActivityType(actType)
  229 + self:updateProperty({field = "reset" .. actType, value = reset})
  230 +end
  231 +
210 232 function Activity:getActData(actType)
211 233 actType = checkActivityType(actType)
212 234 return self:getProperty("act" .. actType)
... ... @@ -756,8 +778,14 @@ activityFunc[Activity.ActivityType.Gachakon] = {
756 778 self:updateActData(actType, {}, not notify)
757 779 end,
758 780 ["crossDay"] = function(self, actType, notify)
  781 + self:updateResetData(actType, 1)
759 782 self:updateActData(actType, {}, not notify)
760 783 end,
  784 + ["reset"] = function(self, actType)
  785 + if self:getResetData(actType) == 0 then return end
  786 + self:updateResetData(actType, 0)
  787 + self:updateActData(actType, {})
  788 + end
761 789 }
762 790  
763 791 -- 活动卡池
... ... @@ -865,6 +893,15 @@ function Activity:refreshWeekData(notify)
865 893 end
866 894 end
867 895  
  896 +function Activity:resetActDataById(actId)
  897 + local actData = csvdb["activity_ctrlCsv"][actId]
  898 + if not actData then return end
  899 + local actType = actData.showType
  900 + if activityFunc[actType] and activityFunc[actType]['reset'] then
  901 + activityFunc[actType]["reset"](self, actType)
  902 + end
  903 +end
  904 +
868 905 function Activity:checkActivity(notNotify, activityType, ...)
869 906 if not activityType then return end
870 907 if not self:isOpen(activityType) then return end
... ...