Commit 60ef966ec3cd1462a62743e952baf57a602a11ff

Authored by zhangqijia
2 parents 25ec4b29 e28973d5

Merge branch 'cn/develop' into cn/publish/zhaolu

# Conflicts:
#	src/actions/GmAction.lua
#	src/actions/HangAction.lua
#	src/models/Daily.lua
src/GlobalVar.lua
... ... @@ -156,6 +156,7 @@ ItemId = {
156 156 AdvPower = 4701, -- 拾荒体力
157 157 CrisisScore = 8010, -- 积分
158 158 MonthCard = 31000, --兑换月卡的物品
  159 + TreasureMap = 861, --藏宝图
159 160 }
160 161  
161 162 TimeReset = {
... ...
src/actions/HangAction.lua
... ... @@ -1200,19 +1200,20 @@ end
1200 1200 function _M.takeTreasureRpc(agent, data)
1201 1201 local role = agent.role
1202 1202 local extraCount = role.dailyData:getProperty("treasureExtraCount") --每日发现额外宝藏使用次数(累计),隔天清零
1203   - local mapCount = role.dailyData:getProperty("treasureMapCount")
1204 1203 local baseExtra = role.dailyData:getProperty("treasureBaseExtra")
1205 1204  
1206 1205 if extraCount >= globalCsv.idle_treasure_extra_limie then return 1 end
1207   - if mapCount <= 0 then return 2 end
1208 1206  
1209   - baseExtra = baseExtra + globalCsv.idle_treasure_base_extra
  1207 + local cost ={[ItemId.TreasureMap] = 1}
  1208 + if not role:checkItemEnough(cost) then return 2 end
1210 1209  
  1210 + baseExtra = baseExtra + globalCsv.idle_treasure_base_extra
1211 1211 local tmpTreasure, treasureListExtra = role.dailyData:getTreasureExtra(baseExtra)
1212 1212 if not tmpTreasure then return 3 end
1213 1213  
  1214 + if not role:costItems(cost, {log = {desc = "TreasureMap", int1 = ItemId.TreasureMap, int2 = 1}}) then return 4 end
  1215 +
1214 1216 role.dailyData:updateProperty({field = "treasureExtraCount", delta = 1})
1215   - role.dailyData:updateProperty({field = "treasureMapCount", value = mapCount - 1})
1216 1217 role.dailyData:updateProperty({field = "treasureBaseExtra", value = baseExtra})
1217 1218  
1218 1219 SendPacket(actionCodes.Hang_takeTreasureRpc, MsgPack.pack({treasureListExtra = treasureListExtra, treasure = tmpTreasure}))
... ... @@ -1226,10 +1227,9 @@ function _M.treasureMapRpc(agent,data)
1226 1227 local cost ={[ItemId.Jade] = globalCsv.idle_treasure_buy * count}
1227 1228 if not role:checkItemEnough(cost) then return 1 end
1228 1229 if not role:costItems(cost, {log = {desc = "treasureMap", int1 = count}}) then return 2 end
1229   - role.dailyData:updateProperty({field = "treasureMapCount", delta = count})
1230 1230  
1231   - local treasureMapCount = role.dailyData:getProperty("treasureMapCount")
1232   - SendPacket(actionCodes.Hang_treasureMapRpc, MsgPack.pack({mapCount = treasureMapCount}))
  1231 + local reward, change = role:award({[ItemId.TreasureMap] = count}, {log = {desc = "TreasureMap", int1 = ItemId.TreasureMap, int2 = count}})
  1232 + SendPacket(actionCodes.Hang_treasureMapRpc, MsgPack.pack(role:packReward(reward, change)))
1233 1233 return true
1234 1234 end
1235 1235  
... ...
src/models/Daily.lua
... ... @@ -38,7 +38,6 @@ Daily.schema = {
38 38 treasureList = {"table", {}}, --挂机图鉴
39 39  
40 40 treasureListExtra = {"table", {}}, --额外宝藏,挂机图鉴扩展功能
41   - treasureMapCount = {"number", 0}, --宝藏图,消耗一张宝藏图可以发现一次额外宝藏
42 41 treasureExtraCount = {"number", 0}, --每日发现额外宝藏使用次数(累计),隔天清零
43 42 treasureBaseExtra = {"number", 0}, --额外宝藏资源值
44 43  
... ... @@ -131,7 +130,6 @@ function Daily:data()
131 130 treasureBase = self:getProperty("treasureBase"),
132 131 treasureList = self:getProperty("treasureList"),
133 132 treasureListExtra = self:getProperty("treasureListExtra"),
134   - treasureMapCount = self:getProperty("treasureMapCount"),
135 133 treasureExtraCount = self:getProperty("treasureExtraCount"),
136 134 treasureBaseExtra = self:getProperty("treasureBaseExtra"),
137 135 chatTimes = self:getProperty("chatTimes"),
... ...
src/models/DailyPlugin.lua
... ... @@ -20,26 +20,31 @@ function DailyPlugin.bind(Daily)
20 20 end
21 21  
22 22 --CD
23   - function Daily:checkTreasureExpired(treasureAttr, treasureList)
  23 + function Daily:checkTreasureExpired(treasureAttr, treasureList, isExtra)
24 24 local curInfo = treasureList[treasureAttr.id]
  25 + local now = skynet.timex()
25 26 if curInfo then
26 27 -- check finish
27 28 if curInfo["expire_time"] then
28 29 if curInfo.cool_time > 1 then
29   - if skynet.timex() >= curInfo["expire_time"] then
  30 + if now >= curInfo["expire_time"] then
30 31 treasureList[treasureAttr.id] = nil
31 32 curInfo = clone(treasureAttr)
32   - elseif skynet.timex() >= curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却
  33 + elseif now >= curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却
33 34 curInfo = nil
34 35 else
35 36 curInfo = clone(treasureAttr)
36 37 end
37 38 else
38   - if skynet.timex() >= curInfo["expire_time"] then
  39 + if now >= curInfo["expire_time"] then
39 40 treasureList[treasureAttr.id] = nil
40 41 end
41 42 curInfo = clone(treasureAttr)
42 43 end
  44 + else
  45 + if isExtra then
  46 + curInfo = nil
  47 + end
43 48 end
44 49 else
45 50 curInfo = clone(treasureAttr)
... ... @@ -48,19 +53,23 @@ function DailyPlugin.bind(Daily)
48 53 return curInfo
49 54 end
50 55  
51   - --绑定通关关卡
  56 + --绑定通关关卡 每日宝藏
52 57 function Daily:checkChapters(treasureList, treasureListOther)
53 58 local chapters = {}
54 59 local tmp_chapters = {}
55 60  
  61 + --不可以绑定的关卡
  62 + --1. 正在挖宝,未挖到
  63 + --2. 已经挖到宝藏,但未领取
  64 + --3. 正在挂机
56 65 for _, curInfo in pairs(treasureList or {}) do
57   - if curInfo["expire_time"] or not curInfo["end_time"] then
  66 + if (not curInfo["expire_time"] and curInfo["end_time"]) then
58 67 tmp_chapters[curInfo.chapter_id] = curInfo
59 68 end
60 69 end
61 70  
62 71 for _, curInfo in pairs(treasureListOther or {}) do
63   - if curInfo["expire_time"] or not curInfo["end_time"] then
  72 + if (not curInfo["expire_time"] and curInfo["end_time"]) then
64 73 tmp_chapters[curInfo.chapter_id] = curInfo
65 74 end
66 75 end
... ... @@ -69,10 +78,42 @@ function DailyPlugin.bind(Daily)
69 78 for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do
70 79 if chapter_id ~= hangInfo.carbonId then
71 80 if self.owner:checkHangPass(chapter_id) then
72   - if next(tmp_chapters) and not tmp_chapters[chapter_id] then
73   - chapters[chapter_id] = val
74   - else
75   - chapters[chapter_id] = val
  81 + if not tmp_chapters[chapter_id] then
  82 + chapters[chapter_id] = {treasure_weight=val.treasure_weight}
  83 + end
  84 + end
  85 + end
  86 +
  87 + end
  88 + return chapters
  89 + end
  90 +
  91 + --绑定通关关卡 额外宝藏
  92 + function Daily:checkChaptersExtra(treasureList, treasureListOther)
  93 + local chapters = {}
  94 + local tmp_chapters = {}
  95 +
  96 + --不可以绑定的关卡
  97 + --1. 未过期(未挖,在挖,未领)
  98 + --2. 正在挂机
  99 + for _, curInfo in pairs(treasureList or {}) do
  100 + if not curInfo["expire_time"] then
  101 + tmp_chapters[curInfo.chapter_id] = curInfo
  102 + end
  103 + end
  104 +
  105 + for _, curInfo in pairs(treasureListOther or {}) do
  106 + if not curInfo["expire_time"] then
  107 + tmp_chapters[curInfo.chapter_id] = curInfo
  108 + end
  109 + end
  110 +
  111 + local hangInfo = self.owner:getProperty("hangInfo") or {}
  112 + for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do
  113 + if chapter_id ~= hangInfo.carbonId then
  114 + if self.owner:checkHangPass(chapter_id) then
  115 + if not tmp_chapters[chapter_id] then
  116 + chapters[chapter_id] = {treasure_weight=val.treasure_weight}
76 117 end
77 118 end
78 119 end
... ... @@ -130,7 +171,7 @@ function DailyPlugin.bind(Daily)
130 171  
131 172 --只抓一个 额外宝藏
132 173 function Daily:getOneTreasureExtra(treasureList, tmpTreasure, treasureBase, treasureListOther)
133   - local chapters = self:checkChapters(treasureList, treasureListOther)
  174 + local chapters = self:checkChaptersExtra(treasureList, treasureListOther)
134 175 if not chapters or not next(chapters) then return end
135 176  
136 177 --扣除在挖宝列表里未过期宝藏的资源值
... ... @@ -177,14 +218,15 @@ function DailyPlugin.bind(Daily)
177 218 function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId, treasureBase)
178 219 if not curInfo then return nil end
179 220  
  221 + local now = skynet.timex()
180 222 local treasure = nil
181 223 --开始挖宝关卡ID=挂机关卡ID
182 224 if chapterId == curInfo.chapter_id then
183 225 --开始挖宝
184 226 if not curInfo["end_time"] then
185   - curInfo["end_time"] = skynet.timex() + curInfo.working_time
  227 + curInfo["end_time"] = now + curInfo.working_time
186 228 else
187   - if skynet.timex() >= curInfo["end_time"] then
  229 + if now >= curInfo["end_time"] then
188 230 if curInfo.cool_time > 1 then
189 231 --宝藏冷却时间
190 232 if not curInfo["expire_time"] then
... ... @@ -192,11 +234,11 @@ function DailyPlugin.bind(Daily)
192 234 treasureBase = treasureBase - curInfo["treasure_value"]
193 235  
194 236 treasure = treasureList[curInfo.id]
195   - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay
  237 + curInfo["expire_time"] = now + curInfo.cool_time * oneDay
196 238 end
197 239 else
198 240 --已经领取宝藏 检索宝藏冷却时间
199   - if skynet.timex() >= curInfo["expire_time"] then
  241 + if now >= curInfo["expire_time"] then
200 242 treasureList[curInfo.id] = nil
201 243 end
202 244 end
... ... @@ -213,7 +255,7 @@ function DailyPlugin.bind(Daily)
213 255 else
214 256 --已经开始挖宝
215 257 if curInfo["end_time"] then
216   - if skynet.timex() >= curInfo["end_time"] then
  258 + if now >= curInfo["end_time"] then
217 259 if curInfo.cool_time > 1 then
218 260 --宝藏冷却时间
219 261 if not curInfo["expire_time"] then
... ... @@ -221,12 +263,12 @@ function DailyPlugin.bind(Daily)
221 263 treasureBase = treasureBase - curInfo["treasure_value"]
222 264  
223 265 treasure = treasureList[curInfo.id]
224   - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay
  266 + curInfo["expire_time"] = now + curInfo.cool_time * oneDay
225 267 end
226 268  
227 269 else
228 270 --已经领取宝藏 检索宝藏冷却时间
229   - if skynet.timex() >= curInfo["expire_time"] then
  271 + if now >= curInfo["expire_time"] then
230 272 treasureList[curInfo.id] = nil
231 273 end
232 274 end
... ... @@ -267,13 +309,14 @@ function DailyPlugin.bind(Daily)
267 309  
268 310 --宝藏图鉴
269 311 function Daily:getTreasureList()
270   - local tmpcsv = csvdb["idle_treasureCsv"]
271 312 local treasureList = self:getProperty("treasureList") or {} --挖宝列表 过期删除 领取奖励删除 跨天更新
272 313 local treasureListExtra = self:getProperty("treasureListExtra") or {} --额外宝藏列表 过期删除 领取奖励删除 跨天更新
  314 +
  315 + --获取宝藏列表(与额外宝藏逻辑不同) 进行随机获取宝藏
273 316 local tmpTreasure = {}
274 317 local treasureBase = globalCsv.idle_treasure_base + self.owner:getBnousTreasureBaseMaximum()
275   - for _, val in pairs(tmpcsv) do
276   - if self:checkUnlock(val) == true then
  318 + for _, val in pairs(csvdb["idle_treasureCsv"]) do
  319 + if self:checkUnlock(val) then
277 320 local treasure = self:checkTreasureExpired(val, treasureList)
278 321 if treasure then
279 322 table.insert(tmpTreasure, treasure)
... ... @@ -328,26 +371,26 @@ function DailyPlugin.bind(Daily)
328 371 --宝藏功能优化——增加"发现宝藏"功能
329 372 function Daily:buyTreasureExtra(treasureList)
330 373 local boughtTreasure = {}
331   - local treasureBase = self:getProperty("treasureExtraBase")
  374 + local treasureBase = self:getProperty("treasureBaseExtra")
332 375 for id, val in pairs(treasureList) do
333 376 if treasureBase >= val.treasure_value then
334 377 boughtTreasure[id] = val
335 378 treasureBase = treasureBase - val.treasure_value
336 379 end
337 380 end
338   - self:updateProperty({field = "treasureExtraBase", value = treasureBase})
  381 + self:updateProperty({field = "treasureBaseExtra", value = treasureBase})
339 382 return boughtTreasure
340 383 end
341 384  
342 385 function Daily:getTreasureExtra(tmpBaseExtra)
343   - local tmpcsv = csvdb["idle_treasureCsv"]
344 386 local treasureList = self:getProperty("treasureList") or {} --挖宝列表 过期删除 领取奖励删除 跨天更新
345 387 local treasureListExtra = self:getProperty("treasureListExtra") or {} --额外宝藏 过期删除 领取奖励删除 跨天更新
346 388  
  389 + --获取宝藏列表(排除未过期的宝藏) 进行随机获取宝藏
347 390 local tmpTreasure = {}
348   - for _, val in pairs(tmpcsv) do
  391 + for _, val in pairs(csvdb["idle_treasureCsv"]) do
349 392 if self:checkUnlock(val) then
350   - local treasure = self:checkTreasureExpired(val, treasureListExtra)
  393 + local treasure = self:checkTreasureExpired(val, treasureListExtra, true)
351 394 if treasure then
352 395 table.insert(tmpTreasure, treasure)
353 396 end
... ...
src/models/RoleLog.lua
... ... @@ -179,6 +179,8 @@ local ItemReason = {
179 179 CapsuleCoinCost = 1413, --抽扭蛋机消耗
180 180  
181 181 worldLine = 1500, --世界线积分
  182 +
  183 + TreasureMap = 1600, --藏宝图
182 184 }
183 185  
184 186  
... ...