Commit f60b89b10ed18dadfce852dbe69fefbb659ab093

Authored by zhouhaihai
1 parent 760ed660

奖励副本

src/ProtocolCode.lua
... ... @@ -76,8 +76,10 @@ actionCodes = {
76 76 Hang_roleFormatRpc = 255,
77 77 Hang_getRewardRpc = 256,
78 78 Hang_quickRpc = 257,
79   - -- Hang_getRewardItemRpc = 258,
80   - -- Hang_getRewardCoinRpc = 259,
  79 + Hang_bonusFormatRpc = 258,
  80 + Hang_buyBonusCountRpc = 259,
  81 + Hang_startBonusBattleRpc = 260,
  82 + Hang_endBonusBattleRpc = 261,
81 83  
82 84 Diner_updateProperty = 300,
83 85 Diner_addSellRpc = 301,
... ...
src/actions/AdvAction.lua
... ... @@ -113,6 +113,7 @@ function _M.startAdvRpc( agent, data )
113 113  
114 114 role:getAdvData():initByChapter(chapterId, layer)
115 115 role:checkTaskEnter("AdvStart", {id = chapterId})
  116 + role:checkTaskEnter("AdvStartSelf", {id = chapterId})
116 117 SendPacket(actionCodes.Adv_startAdvRpc, '')
117 118 return true
118 119 end
... ...
src/actions/CarAction.lua
... ... @@ -87,7 +87,7 @@ function _M.equipUpRpc( agent, data )
87 87 role:costItems(cost)
88 88 role:addEquip(typ, lv, -costCount)
89 89 role:addEquip(typ, nextLv ,count)
90   - role:checkTaskEnter("EquipUp", {})
  90 + role:checkTaskEnter("EquipUp", {count = count})
91 91 SendPacket(actionCodes.Car_equipUpRpc, '')
92 92 return true
93 93 end
... ...
src/actions/DinerAction.lua
... ... @@ -221,6 +221,9 @@ function _M.expediteSellRpc( agent, data )
221 221 role.dinerData:notifyUpdateProperty("expedite", count+1)
222 222 for k, v in pairs(reward:toNumMap()) do
223 223 role:addItem({itemId = k,count = v})
  224 + if k == ItemId.Gold then
  225 + role:checkTaskEnter("FoodSellGold", {count = v})
  226 + end
224 227 end
225 228  
226 229 role.dinerData:popularAdd(popular)
... ...
src/actions/GmAction.lua
... ... @@ -245,6 +245,14 @@ function _M.advt(role, pms)
245 245 return "成功"
246 246 end
247 247  
  248 +table.insert(helpDes, {"冒险队等级增加", "advl", "通关次数"})
  249 +function _M.advl(role, pms)
  250 + local winCount = tonum(pms.pm1)
  251 + winCount = math.max(0, winCount)
  252 + role:checkAdvLvByAddWin(winCount)
  253 + return "成功"
  254 +end
  255 +
248 256 table.insert(helpDes, {"挂机清除" , "idlec"})
249 257 function _M.idlec(role, pms)
250 258 role:updateProperty({field = "hangTeam", value = {}})
... ...
src/actions/HangAction.lua
... ... @@ -69,12 +69,12 @@ function _M.startRpc( agent, data )
69 69 local msg = MsgPack.unpack(data)
70 70 local carbonId = msg.carbonId
71 71 local carbonData = csvdb["idle_battleCsv"][carbonId]
72   - if not carbonData then return end
  72 + if not carbonData then return 1 end
73 73  
74 74 local hangPass = role:getProperty("hangPass")
75 75  
76 76 for _, preCarbonId in ipairs(carbonData.prepose:toArray(true, "=")) do
77   - if not hangPass[preCarbonId] then return end
  77 + if not hangPass[preCarbonId] then return 2 end
78 78 end
79 79  
80 80 if checkReward(role) then
... ... @@ -333,6 +333,9 @@ function _M.quickRpc(agent , data)
333 333 end
334 334  
335 335 reward = role:award(reward)
  336 + if reward[ItemId.Gold] then
  337 + role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
  338 + end
336 339 role:checkTaskEnter("HangQuick")
337 340 SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({
338 341 reward = reward
... ... @@ -340,4 +343,103 @@ function _M.quickRpc(agent , data)
340 343 return true
341 344 end
342 345  
  346 +function _M.bonusFormatRpc(agent , data)
  347 + local role = agent.role
  348 + local msg = MsgPack.unpack(data)
  349 + local bTeam = role:getProperty("bTeam")
  350 + for slot, heroId in pairs(msg.heros) do
  351 + if not role.heros[heroId] then
  352 + return
  353 + end
  354 + end
  355 + table.clear(bTeam)
  356 + bTeam.heros = {}
  357 + for slot, heroId in pairs(msg.heros) do
  358 + bTeam.heros[slot] = heroId
  359 + end
  360 + bTeam.leader = msg.leader
  361 +
  362 + role:updateProperty({field = "bTeam", value = bTeam})
  363 + SendPacket(actionCodes.Hang_bonusFormatRpc, '')
  364 + return true
  365 +end
  366 +
  367 +function _M.buyBonusCountRpc(agent, data)
  368 + local role = agent.role
  369 + local msg = MsgPack.unpack(data)
  370 +
  371 + local count = msg.count
  372 + local btype = msg.type
  373 +
  374 + if math.illegalNum(btype, 1, 2) then return 0 end
  375 +
  376 + local bonusC = role.dailyData:getProperty("bonusC")
  377 + bonusC[btype] = bonusC[btype] or {c = 0, b = 0}
  378 + local lastCount = globalCsv.bonus_daily_buy_count - bonusC[btype]["b"]
  379 + if math.illegalNum(count, 1, lastCount) then return 1 end
  380 +
  381 + if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return end
  382 +
  383 + role:costItems({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count})
  384 + bonusC[btype]["b"] = bonusC[btype]["b"] + 1
  385 + bonusC[btype]["c"] = bonusC[btype]["c"] - 1
  386 +
  387 + role.dailyData:updateProperty({field = "bonusC", value = bonusC})
  388 +
  389 + SendPacket(actionCodes.Hang_buyBonusCountRpc, '')
  390 + return true
  391 +end
  392 +
  393 +function _M.startBonusBattleRpc(agent, data)
  394 + local role = agent.role
  395 + local msg = MsgPack.unpack(data)
  396 + local id = msg.id
  397 +
  398 + local bonusData = csvdb["bonus_battleCsv"][id]
  399 + if not bonusData then return 1 end
  400 + local hangPass = role:getProperty("hangPass")
  401 + if not hangPass[bonusData.unlock] then return 2 end
  402 +
  403 + if not next(role:getProperty("bTeam")) then return 3 end
  404 +
  405 + local bonusC = role.dailyData:getProperty("bonusC")
  406 + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0}
  407 + if globalCsv.bonus_daily_count - bonusC[bonusData.type]["c"] <= 0 then return 4 end
  408 + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1
  409 + role.dailyData:updateProperty({field = "bonusC", value = bonusC})
  410 +
  411 +
  412 + role.__bonusBattleCache = {
  413 + key = tostring(math.random()),
  414 + id = id,
  415 + }
  416 + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
  417 + return true
  418 +end
  419 +
  420 +function _M.endBonusBattleRpc(agent, data)
  421 + local role = agent.role
  422 + local msg = MsgPack.unpack(data)
  423 + local id = msg.id
  424 + local key = msg.key
  425 + local starNum = msg.starNum
  426 + if not role.__bonusBattleCache then return 1 end
  427 +
  428 + if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then return 2 end
  429 + local bonusData = csvdb["bonus_battleCsv"][id]
  430 +
  431 + local reward
  432 + if starNum and starNum > 0 then
  433 + reward = role:award(bonusData.reward)
  434 + role:checkTaskEnter("BonusPass", {id = id})
  435 + end
  436 +
  437 + SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({
  438 + starNum = starNum,
  439 + reward = reward}))
  440 + return true
  441 +end
  442 +
  443 +
  444 +
343 445 return _M
344 446 \ No newline at end of file
... ...
src/actions/RoleAction.lua
... ... @@ -532,7 +532,7 @@ function _M.achiveRpc(agent, data)
532 532 local achiveT = role:getProperty("achiveT")
533 533 local achiveV = role:getProperty("achiveV")
534 534  
535   - if achiveV[taskId] == -1 then return end
  535 + if achiveV[taskId] then return end
536 536  
537 537 local curStatus = achiveT[achiveTask.type] or 0
538 538 local maxc = achiveTask.condition1
... ... @@ -544,7 +544,7 @@ function _M.achiveRpc(agent, data)
544 544 local reward = role:award(achiveTask.reward)
545 545  
546 546 role:changeUpdates({
547   - { type = "achiveV", field = taskId, value = -1 }
  547 + { type = "achiveV", field = taskId, value = skynet.timex() }
548 548 })
549 549  
550 550 SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack({reward = reward}))
... ...
src/adv/Adv.lua
... ... @@ -174,20 +174,7 @@ function Adv:over(success, isAllPass)
174 174 end
175 175  
176 176 -- 冒险队等级升一下子
177   - local advL = self.owner:getProperty("advL")
178   - local oldL = advL[1]
179   - advL[2] = (advL[2] or 0) + 1
180   - for level = ((advL[1] or 0) + 1), #csvdb["adv_rankCsv"] do
181   - local ldata = csvdb["adv_rankCsv"][level]
182   - if ldata.unlock <= advL[2] then
183   - advL[1] = level
184   - self.owner:award(ldata.reward)
185   - end
186   - end
187   - if advL[1] > oldL then
188   - self.owner:checkTaskEnter("AdvLevel", {level = advL[1]})
189   - end
190   - self.owner:updateProperty("advL", advL)
  177 + self.owner:checkAdvLvByAddWin()
191 178  
192 179 if self.owner:isFuncOpen(FuncOpenType.AdvWheelSurf) then
193 180 self.owner._advWheelSurfCount = 0 -- 抽奖进行次数
... ...
src/models/Daily.lua
... ... @@ -14,7 +14,8 @@ Daily.schema = {
14 14 advElC = {"number", 0}, -- 无尽次数(消耗体力)
15 15 advBC = {"number", 0}, -- 冒险次数购买次数(冒险体力购买次数)
16 16 advElBC = {"number", 0}, -- 无尽次数购买次数(冒险体力购买次数)
17   - advWs = {"table", {}}, -- 冒险队工坊
  17 + advWs = {"table", {}}, -- 冒险队工坊
  18 + bonusC = {"table", {}} -- 奖励副本 次数 {[type] = {c = 0, b = 0}}
18 19 }
19 20  
20 21 function Daily:updateProperty(params)
... ... @@ -54,6 +55,7 @@ function Daily:data()
54 55 advElC = self:getProperty("advElC"),
55 56 advElBC = self:getProperty("advElBC"),
56 57 advWs = self:getProperty("advWs"),
  58 + bonusC = self:getProperty("bonusC"),
57 59 }
58 60 end
59 61  
... ...
src/models/Role.lua
... ... @@ -63,6 +63,7 @@ Role.schema = {
63 63 hangInfo = {"table", {}}, -- 当前挂机信息
64 64 hangBag = {"table", {}}, -- 背包
65 65 hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限
  66 + bTeam = {"table", {}}, -- 奖励副本队伍
66 67  
67 68 potionBag = {"table", {}}, -- 营养剂背包
68 69  
... ... @@ -211,6 +212,7 @@ function Role:data()
211 212 hangInfo = self:getProperty("hangInfo"),
212 213 hangBag = self:getProperty("hangBag"),
213 214 hangBagLimit = self:getProperty("hangBagLimit"),
  215 + bTeam = self:getProperty("bTeam"),
214 216  
215 217 potionBag = self:getProperty("potionBag"),
216 218 storyB = self:getProperty("storyB"),
... ...
src/models/RolePlugin.lua
... ... @@ -793,6 +793,24 @@ function RolePlugin.bind(Role)
793 793 return player.format
794 794 end
795 795 end
  796 +
  797 + function Role:checkAdvLvByAddWin(winCount)
  798 + winCount = winCount or 1
  799 + local advL = self:getProperty("advL")
  800 + local oldL = advL[1]
  801 + advL[2] = (advL[2] or 0) + winCount
  802 + for level = ((advL[1] or 0) + 1), #csvdb["adv_rankCsv"] do
  803 + local ldata = csvdb["adv_rankCsv"][level]
  804 + if ldata.unlock <= advL[2] then
  805 + advL[1] = level
  806 + self:award(ldata.reward)
  807 + end
  808 + end
  809 + if advL[1] > oldL then
  810 + self:checkTaskEnter("AdvLevel", {level = advL[1]})
  811 + end
  812 + self:updateProperty({field = "advL", value = advL})
  813 + end
796 814 end
797 815  
798 816 return RolePlugin
799 817 \ No newline at end of file
... ...
src/models/RoleTask.lua
... ... @@ -16,7 +16,7 @@ local TaskType = {
16 16 --装备相关
17 17 AddEquip = 101, -- 获得装备 - equipId rarity
18 18 SaleEquip = 102, -- 出售装备 - count
19   - EquipUp = 103, -- 装备强化
  19 + EquipUp = 103, -- 装备强化 - count
20 20  
21 21 -- 符文(零件)相关
22 22 RuneUp = 201, -- 符文强化
... ... @@ -30,6 +30,7 @@ local TaskType = {
30 30 HangQuick = 303, -- 快速挂机
31 31 HangBattle = 304, -- 挂机战斗 - id
32 32 HangGetGold = 305, -- 挂机获得齿轮 - count
  33 + BonusPass = 306, -- 奖励副本通关 - id
33 34  
34 35 -- 冒险相关
35 36 AdvPass = 401, -- 冒险通过关 - id level score
... ... @@ -40,6 +41,7 @@ local TaskType = {
40 41 AdvOverTask = 406, -- 完成任务 - id
41 42 AdvOpenBlock = 407, -- 打开地块 - id
42 43 AdvUsePotion = 408, -- 使用营养剂
  44 + AdvStartSelf = 409, -- 手动冒险 - id
43 45  
44 46 --爬塔相关
45 47 TowerPass = 501, -- 爬塔通关 - level
... ... @@ -75,6 +77,9 @@ local TaskType = {
75 77 WeChat = 1009, -- 关注微信
76 78 WeBlog = 1010, -- 关注微博
77 79 SignIn = 1011, -- 签到
  80 + GetFriendP = 1012, -- 获得友情点 - count
  81 + ShopAll = 1013, -- 在任意商店购买
  82 +
78 83 }
79 84  
80 85 local function v(value)
... ... @@ -119,9 +124,14 @@ local CommonListener = {
119 124 [TaskType.FoodMGet] = {{v(16)}},
120 125 [TaskType.HeroLevelUp] = {{v(17)}},
121 126 [TaskType.Wake] = {{v(18)}},
122   - [TaskType.EquipUp] = {{v(19)}},
  127 + [TaskType.EquipUp] = {{v(19), f("count")}},
123 128 [TaskType.GiveFriendP] = {{v(20)}},
124 129 [TaskType.UnionBoss] = {{v(21)}},
  130 + [TaskType.GetFriendP] = {{v(22), f("count")}},
  131 + [TaskType.BonusPass] = {{v(23)}},
  132 + [TaskType.AdvStartSelf] = {{v(24)}},
  133 + [TaskType.ShopAll] = {{v(25)}},
  134 + [TaskType.RuneUp] = {{v(26)}},
125 135 }
126 136 }
127 137  
... ... @@ -158,7 +168,7 @@ local AchievListener = {
158 168 [TaskType.DrawHero] = {{v(29), f("count"), f("pool")}},
159 169 [TaskType.AddEquip] = {{v(30), f("rarity")}, {v(34), 1, f("rarity")}},
160 170 [TaskType.AddRune] = {{v(31), f("rarity")}, {v(35), 1, f("rarity")}},
161   - [TaskType.EquipUp] = {{v(32)}},
  171 + [TaskType.EquipUp] = {{v(32), f("count")}},
162 172 [TaskType.RuneUp] = {{v(33)}},
163 173 [TaskType.AddUnion] = {{v(36)}},
164 174 [TaskType.AddFriend] = {{v(37), f("count")}},
... ...