Commit 916096edc14926fb6b999571986eb0b1c013b0d4
1 parent
b176d7d3
神器效果
Showing
4 changed files
with
148 additions
and
10 deletions
Show diff stats
src/adv/Adv.lua
... | ... | @@ -205,10 +205,7 @@ function Adv:randomMapId(chapterId, level) |
205 | 205 | return |
206 | 206 | end |
207 | 207 | if AdvCommon.isEndless(chapterId) then |
208 | - level = level % chapterData.limitlevel | |
209 | - if level == 0 then | |
210 | - level = chapterData.limitlevel | |
211 | - end | |
208 | + level = AdvCommon.getEndlessDataLv(chapterId, level) | |
212 | 209 | else |
213 | 210 | if level > chapterData.limitlevel then |
214 | 211 | error("level overflow!") |
... | ... | @@ -261,11 +258,14 @@ function Adv:award(gift, params) |
261 | 258 | end |
262 | 259 | local origin = items:getv(itemId, 0) |
263 | 260 | local nums = origin + count |
261 | + if csvdb["adv_artifactCsv"][itemId] then | |
262 | + nums = self:checkArtifact(itemId, origin, count, nums) | |
263 | + end | |
264 | 264 | if nums <= 0 then |
265 | 265 | items = items:delk(itemId) |
266 | 266 | nums = 0 |
267 | 267 | else |
268 | - items = items:incrv(itemId, count) | |
268 | + items = items:setv(itemId, nums) | |
269 | 269 | end |
270 | 270 | end |
271 | 271 | |
... | ... | @@ -273,6 +273,116 @@ function Adv:award(gift, params) |
273 | 273 | return tgift |
274 | 274 | end |
275 | 275 | |
276 | + | |
277 | +function Adv:delArtifactEffect(effectType, effects) | |
278 | + if effectType == 1 then | |
279 | + for _, id in ipairs(effects:toArray(true, "=")) do | |
280 | + self.battle.player:delPassiveById(id) | |
281 | + end | |
282 | + elseif effectType == 2 then | |
283 | + for _, id in ipairs(effects:toArray(true, "=")) do | |
284 | + self.battle.player:delBuffById(id) | |
285 | + end | |
286 | + end | |
287 | +end | |
288 | + | |
289 | +function Adv:addArtifactEffect(effectType, effects) | |
290 | + if effectType == 1 then | |
291 | + for _, id in ipairs(effects:toArray(true, "=")) do | |
292 | + self.battle.player:addPassive({id = id}) | |
293 | + end | |
294 | + elseif effectType == 2 then | |
295 | + for _, id in ipairs(effects:toArray(true, "=")) do | |
296 | + self.battle.player:addBuff(id) | |
297 | + end | |
298 | + end | |
299 | +end | |
300 | +-- 检查神器 | |
301 | +function Adv:checkArtifact(itemId, origin, count, nums) | |
302 | + local artifactData = csvdb["adv_artifactCsv"][itemId] | |
303 | + if count == 0 or not artifactData then return nums end | |
304 | + local advItems = self.owner:getProperty("advItems") | |
305 | + if count < 0 then --删除 | |
306 | + nums = 0 | |
307 | + local curData = artifactData[origin] | |
308 | + if curData then | |
309 | + -- 删除自己的效果 | |
310 | + self:delArtifactEffect(curData.type, curData.effect) | |
311 | + | |
312 | + --删除组合效果 | |
313 | + if curData.comboId ~= 0 then | |
314 | + local comboLv = advItems:getv(curData.comboId, 0) | |
315 | + if comboLv ~= 0 then | |
316 | + --删除自己的组合效果 | |
317 | + if curData.comboType == 1 or curData.comboType == 2 then | |
318 | + self:delArtifactEffect(curData.comboType, curData.comboEffect) | |
319 | + elseif curData.comboType == 3 then | |
320 | + self:delArtifactEffect(curData.type, curData.comboEffect) | |
321 | + end | |
322 | + | |
323 | + -- 删除组合的组合效果 | |
324 | + local comboData = (csvdb["adv_artifactCsv"][curData.comboId] or {})[comboLv] | |
325 | + if comboData then | |
326 | + if comboData.comboType == 1 or comboData.comboType == 2 then | |
327 | + self:delArtifactEffect(comboData.comboType, comboData.comboEffect) | |
328 | + elseif comboData.comboType == 3 then | |
329 | + self:delArtifactEffect(comboData.type, comboData.comboEffect) | |
330 | + self:addArtifactEffect(comboData.type, comboData.effect) | |
331 | + end | |
332 | + end | |
333 | + end | |
334 | + end | |
335 | + end | |
336 | + else | |
337 | + nums = math.max(0, math.min(nums, #artifactData)) | |
338 | + if nums == origin then return nums end | |
339 | + if origin == 0 then --初始获得 | |
340 | + local curData = artifactData[nums] | |
341 | + local addSelfEffect = true | |
342 | + --查看是否有组合 | |
343 | + if curData.comboId ~= 0 then | |
344 | + local comboLv = advItems:getv(curData.comboId, 0) | |
345 | + if comboLv ~= 0 then | |
346 | + --自己的组合效果 | |
347 | + if curData.comboType == 1 or curData.comboType == 2 then | |
348 | + self:addArtifactEffect(curData.comboType, curData.comboEffect) | |
349 | + elseif curData.comboType == 3 then | |
350 | + self:addArtifactEffect(curData.type, curData.comboEffect) | |
351 | + addSelfEffect = false | |
352 | + end | |
353 | + | |
354 | + --对方的组合效果 | |
355 | + local comboData = (csvdb["adv_artifactCsv"][curData.comboId] or {})[comboLv] | |
356 | + if comboData then | |
357 | + if comboData.comboType == 1 or comboData.comboType == 2 then | |
358 | + self:addArtifactEffect(comboData.comboType, comboData.comboEffect) | |
359 | + elseif comboData.comboType == 3 then | |
360 | + self:delArtifactEffect(comboData.type, comboData.effect) | |
361 | + self:addArtifactEffect(comboData.type, comboData.comboEffect) | |
362 | + end | |
363 | + end | |
364 | + end | |
365 | + end | |
366 | + if addSelfEffect then | |
367 | + self:addArtifactEffect(curData.type, curData.effect) | |
368 | + end | |
369 | + else --升级 | |
370 | + local originData = artifactData[origin] | |
371 | + local curData = artifactData[nums] | |
372 | + | |
373 | + if originData then | |
374 | + self:delArtifactEffect(originData.type, originData.effect) | |
375 | + end | |
376 | + | |
377 | + if curData then | |
378 | + self:addArtifactEffect(curData.type, curData.effect) | |
379 | + end | |
380 | + end | |
381 | + end | |
382 | + return nums | |
383 | +end | |
384 | + | |
385 | + | |
276 | 386 | -- 消耗物品 优先冒险背包 --check 只是检查够不够 |
277 | 387 | function Adv:cost(item, params, check) |
278 | 388 | local items = self.owner:getProperty("advItems") |
... | ... | @@ -461,6 +571,7 @@ local function clickDrop(self, room, block, params) |
461 | 571 | local reward = {} |
462 | 572 | if not block.event.item then return end |
463 | 573 | local reward = self:award({[block.event.item[1]] = block.event.item[2]}) |
574 | + -- local reward = self:award({[5801] = 1}) | |
464 | 575 | block:clear() |
465 | 576 | self:backReward(reward) |
466 | 577 | return true | ... | ... |
src/adv/AdvCommon.lua
... | ... | @@ -51,4 +51,16 @@ function AdvCommon.isEndless(chapterId) |
51 | 51 | return math.floor(chapterId / 100) == 2 |
52 | 52 | end |
53 | 53 | |
54 | +function AdvCommon.getEndlessDataLv(chapterId, level) | |
55 | + local chapterData = csvdb["adv_chapterCsv"][chapterId] | |
56 | + if level > globalCsv.adv_endless_custom_layer then | |
57 | + level = (level - globalCsv.adv_endless_custom_layer) % chapterData.limitlevel | |
58 | + if level == 0 then | |
59 | + level = chapterData.limitlevel | |
60 | + end | |
61 | + level = level + globalCsv.adv_endless_custom_layer | |
62 | + end | |
63 | + return level | |
64 | +end | |
65 | + | |
54 | 66 | return AdvCommon |
55 | 67 | \ No newline at end of file | ... | ... |
src/adv/AdvMap.lua
... | ... | @@ -348,11 +348,7 @@ end |
348 | 348 | getEventLib = function(self, needEventType) -- needEventType 需要的事件 |
349 | 349 | local chapterId, level = self.adv.chapterId, self.adv.level |
350 | 350 | if AdvCommon.isEndless(chapterId) then |
351 | - local chapterData = csvdb["adv_chapterCsv"][chapterId] | |
352 | - level = level % chapterData.limitlevel | |
353 | - if level == 0 then | |
354 | - level = chapterData.limitlevel | |
355 | - end | |
351 | + level = AdvCommon.getEndlessDataLv(chapterId, level) | |
356 | 352 | end |
357 | 353 | local libsToType = { |
358 | 354 | ["event_monsterCsv"] = {AdvEventType.Monster, AdvEventType.BOSS, AdvEventType.Monster}, | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -118,6 +118,24 @@ function BaseObject:addBuff(buffId, releaser) |
118 | 118 | self.battle.adv:backBuff(self.id, buffId) |
119 | 119 | end |
120 | 120 | |
121 | +function BaseObject:delBuffById(bId) | |
122 | + for _, buff in ipairs(self.buffs) do | |
123 | + if not buff.isDel and buff.id == bId then | |
124 | + buff.isDel = true | |
125 | + return buff | |
126 | + end | |
127 | + end | |
128 | +end | |
129 | + | |
130 | +function BaseObject:delPassiveById(pId) | |
131 | + for _, passive in ipairs(self.passives) do | |
132 | + if not passive.isDel and passive.id == pId then | |
133 | + passive.isDel = true | |
134 | + return passive | |
135 | + end | |
136 | + end | |
137 | +end | |
138 | + | |
121 | 139 | function BaseObject:hadBuff(bType) |
122 | 140 | for _, buff in ipairs(self.buffs) do |
123 | 141 | if not buff.isDel and buff:getType() == bType then |
... | ... | @@ -134,6 +152,7 @@ function BaseObject:hadBuffById(bId) |
134 | 152 | end |
135 | 153 | end |
136 | 154 | |
155 | + | |
137 | 156 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 |
138 | 157 | function BaseObject:getCommonBuffEffect(bType) |
139 | 158 | local effect, count = {[0] = 0, [1] = 0}, 0 | ... | ... |