Commit f4c65591354382ead8213749c1896f334e7e59a5

Authored by zhouhaihai
1 parent 8da953a7

抽奖

@@ -52,6 +52,7 @@ FuncOpenType = { @@ -52,6 +52,7 @@ FuncOpenType = {
52 AdvRelay = 3, -- 中继开放 52 AdvRelay = 3, -- 中继开放
53 AdvArtifact = 4, -- 神器开放 53 AdvArtifact = 4, -- 神器开放
54 AdvWS = 6, -- 工坊解锁 54 AdvWS = 6, -- 工坊解锁
  55 + AdvWheelSurf = 7, -- 抽奖解锁
55 } 56 }
56 57
57 TypeIsFunc = {} 58 TypeIsFunc = {}
src/ProtocolCode.lua
@@ -41,6 +41,7 @@ actionCodes = { @@ -41,6 +41,7 @@ actionCodes = {
41 Adv_buyAdvCountRpc = 160, 41 Adv_buyAdvCountRpc = 160,
42 Adv_finishTaskRpc = 161, 42 Adv_finishTaskRpc = 161,
43 Adv_workshopRpc = 162, 43 Adv_workshopRpc = 162,
  44 + Adv_wheelSurfRpc = 163,
44 45
45 Hero_loadInfos = 201, 46 Hero_loadInfos = 201,
46 Hero_updateProperty = 202, 47 Hero_updateProperty = 202,
src/actions/AdvAction.lua
@@ -362,5 +362,40 @@ function _M.workshopRpc(agent, data) @@ -362,5 +362,40 @@ function _M.workshopRpc(agent, data)
362 return true 362 return true
363 end 363 end
364 364
  365 +function _M.wheelSurfRpc(agent, data)
  366 + local role = agent.role
  367 + local msg = MsgPack.unpack(data)
  368 + if not role:isFuncOpen(FuncOpenType.AdvWheelSurf) then return end
  369 + if not role._advWheelSurfCount then return end
  370 +
  371 + local drawData = csvdb["adv_wheelsurfCsv"][role:getFuncLv(FuncOpenType.AdvWheelSurf)]
  372 + if not drawData then return end
  373 +
  374 + local costs = drawData.cost:toArray(true, "=")
  375 + local maxt = math.max(#costs, drawData.time)
  376 +
  377 + if role._advWheelSurfCount >= maxt then
  378 + role._advWheelSurfCount = nil
  379 + return
  380 + end
  381 +
  382 + local cost = costs[role._advWheelSurfCount + 1]
  383 + if cost > 0 then
  384 + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return end
  385 + role:costItems({[ItemId.Diamond] = cost})
  386 + end
  387 +
  388 + role._advWheelSurfCount = role._advWheelSurfCount + 1
  389 + if role._advWheelSurfCount >= maxt then
  390 + role._advWheelSurfCount = nil
  391 + end
  392 +
  393 + local gift = drawData.pool:randWeight(true)
  394 +
  395 + local reward = role:award({[gift[1]] = gift[2]})
  396 + SendPacket(actionCodes.Adv_wheelSurfRpc, MsgPack.pack({reward = reward}))
  397 + return true
  398 +end
  399 +
365 400
366 return _M 401 return _M
367 \ No newline at end of file 402 \ No newline at end of file
@@ -49,6 +49,8 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify) @@ -49,6 +49,8 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify)
49 self.lastEnemyId = 1 49 self.lastEnemyId = 1
50 self.mapStack = {1} -- 最后一个为当前的地图 50 self.mapStack = {1} -- 最后一个为当前的地图
51 51
  52 + self.owner._advWheelSurfCount = nil -- 抽奖进行次数
  53 +
52 -- 随机出地图 54 -- 随机出地图
53 local mapId = self:randomMapId(chapterId, level) 55 local mapId = self:randomMapId(chapterId, level)
54 self.maps = {} 56 self.maps = {}
@@ -157,6 +159,9 @@ function Adv:over(success) @@ -157,6 +159,9 @@ function Adv:over(success)
157 if success then 159 if success then
158 reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap()) 160 reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap())
159 self.owner:checkTaskEnter(self.owner.TaskType.AdvPass, {id = self.chapterId}) 161 self.owner:checkTaskEnter(self.owner.TaskType.AdvPass, {id = self.chapterId})
  162 + if self.owner:isFuncOpen(FuncOpenType.AdvWheelSurf) then
  163 + self.owner._advWheelSurfCount = 0 -- 抽奖进行次数
  164 + end
160 end 165 end
161 self:clear() 166 self:clear()
162 167