From 6dc482bb38240b1978e1693f64999702694a51f8 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Wed, 26 Feb 2020 20:49:00 +0800 Subject: [PATCH] 中继层完成, 新增两个冒险物品使用效果 --- src/GlobalVar.lua | 4 +++- src/actions/AdvAction.lua | 14 +++++--------- src/adv/Adv.lua | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------ src/adv/AdvBattle.lua | 2 +- src/adv/AdvMap.lua | 26 ++++++++++++++++++++++++++ src/models/RolePlugin.lua | 4 ++++ 6 files changed, 98 insertions(+), 23 deletions(-) diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 2349b3b..310aef4 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -106,6 +106,9 @@ AdvSpecialStage = { [6] = "InOut", [7] = "Diner" } + +AdvCodeRandomStage = 10 -- 一些功能需要代码强行随机事件 随机到这个地块类型上面 + --客户端需要知道这个 AdvEventType = { -- 特殊事件(地块决定) @@ -117,7 +120,6 @@ AdvEventType = { InOut = -6, -- 出入口集合体 Diner = -7, -- 料理台 - -- 普通事件(随机) Choose = 1, --选择点 Drop = 2, --物品掉落点 diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index e873156..b048ff1 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -315,15 +315,6 @@ function _M.useItemRpc(agent, data) if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end if not adv:cost({[itemId] = count}, {}, true) then return true end - local status = true - for i = 1, count do - status = status and adv:doActive(itemData.effect, target) -- target - if not status then - break - end - end - if not status then return end - --消耗 if itemData["function"] == 0 or itemData["function"] == 1 then adv:cost({[itemId] = count}, {}) @@ -331,6 +322,11 @@ function _M.useItemRpc(agent, data) end adv:checkAchievement(adv.AchievType.UseItem, count, itemId) + + for i = 1, count do + adv:doActive(itemData.effect, target) -- target + end + adv:afterRound() adv:saveDB() diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 79f50ab..96aab12 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -150,6 +150,13 @@ function Adv:forceOver(notNotify) self:clear() local advTeam = self.owner:getProperty("advTeam") advTeam.player = nil + + local reward = self.owner:getProperty("advItems"):toNumMap() + for itemId, count in pairs(reward) do + reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败 + end + self.owner:award(reward) + self.owner:updateProperties({ advInfo = {}, advTeam = advTeam, @@ -389,11 +396,20 @@ function Adv:haveComboAF(id) return false end -function Adv:artifactLevelUp(id) +function Adv:artifactLevelUp(id, level) + level = level or 1 local advAFGet = self.owner:getProperty("advAFGet") + if not advAFGet[id] then return end local advAFWear = self.owner:getProperty("advAFWear") + + local newLv = advAFGet[id] + for i = 1, level do + if not self.owner:isArtifactOpen(id, self:isEndless(), newLv + 1) then break end + newLv = newLv + 1 + end + if newLv == advAFGet[id] then return end + local status = 0 - local newLv = advAFGet[id] + 1 if advAFWear[id] then -- 穿着呢 local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]] local newData = csvdb["adv_artifactCsv"][id][newLv] @@ -450,16 +466,29 @@ function Adv:getCurFloorData() return (csvdb["adv_chapter_floorCsv"][chapter] or {})[self.level] end ---关卡通关,非层 score < 0 失败 -function Adv:over(success, isAllPass) +--关卡结束 +function Adv:over(success, rewardRatio) + if success then + rewardRatio = rewardRatio or 100 + else + rewardRatio = rewardRatio or globalCsv.adv_fail_reward_ratio + end local score = self:getScore() local scoreInfo = self.score - local reward + self.battle.player:triggerPassive(Passive.ADV_OVER, {score = score, level = self.level}) + + + local reward = self.owner:getProperty("advItems"):toNumMap() + for itemId, count in pairs(reward) do + reward[itemId] = math.ceil(count * rewardRatio / 100) + end + reward = self.owner:award(reward) + if success then - reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap()) self.owner:checkTaskEnter("AdvPass", {id = self.chapterId, level = self.level, score = score}) - if isAllPass then + local chapterData = csvdb["adv_chapterCsv"][self.chapterId].limitlevel + if not self:isEndless() and self.level >= chapterData then self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId}) end @@ -630,10 +659,9 @@ local function clickOut(self, room, block, params) self:checkAchievement(Adv.AchievType.OverWin, 1, self.level) self:checkAdvUnlock(2, self.level) - local levellimit = csvdb["adv_chapterCsv"][self.chapterId].limitlevel - if not self:isEndless() and (self.level >= levellimit or not self.owner:advChapterIsOpen(self.chapterId, self.level + 1)) then --关卡结束 - self:over(true, not self:isEndless() and self.level >= levellimit) + if not self:isEndless() and (self.level >= csvdb["adv_chapterCsv"][self.chapterId].limitlevel or not self.owner:advChapterIsOpen(self.chapterId, self.level + 1)) then --关卡结束 + self:over(true) else self.battle.player:triggerPassive(Passive.DOWN_LAYER) local curFloorData = self:getCurFloorData() @@ -656,8 +684,7 @@ local function clickOut(self, room, block, params) end local function clickExit(self, room, block, params) - local levellimit = csvdb["adv_chapterCsv"][self.chapterId].limitlevel - self:over(true, not self:isEndless() and self.level >= levellimit) + self:over(true) return true end @@ -1222,7 +1249,27 @@ function Adv:doActive(activeId, target) return true end + --10: 立刻结算 按比例返还 + doActiveEffect[10] = function(_, rewardRatio) + self:over(true, rewardRatio) + return true + end + --11: 随机提升一个未满级神器等级,配置提升等级 + doActiveEffect[11] = function(_, level) + local advAFGet = self.owner:getProperty("advAFGet") + local pool = {} + for id_, lv in pairs(advAFGet) do + if self.owner:isArtifactOpen(id_, self:isEndless(), lv + 1) then + table.insert(pool, id_) + end + end + if #pool > 0 then + local idx = math.randomInt(1, #pool) + self:artifactLevelUp(pool[idx], level) + end + return true + end for _, effect in ipairs(activeData.effect:toArray()) do local cur = effect:toArray(true, "=") diff --git a/src/adv/AdvBattle.lua b/src/adv/AdvBattle.lua index 24932ac..aa9421b 100644 --- a/src/adv/AdvBattle.lua +++ b/src/adv/AdvBattle.lua @@ -91,7 +91,7 @@ function Battle:initPlayer() for _, hero in pairs(attrs) do player[attrName] = (player[attrName] or 0) + hero[attrName] end - player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) + player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) * (globalCsv.adv_battle_attr_ratio[attrName] or 1) player.growth[attrName] = player[attrName] * 0.025 player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1) end diff --git a/src/adv/AdvMap.lua b/src/adv/AdvMap.lua index 6d858a7..6dc066e 100644 --- a/src/adv/AdvMap.lua +++ b/src/adv/AdvMap.lua @@ -336,6 +336,11 @@ createMap = function(self, mapId, isEnter, isNewRelay) end end + local function giveEvent(roomId, blockId, eventType, eventId) + local event = {etype = eventType, id = eventId} + mapInfo.rooms[roomId]["event"][blockId] = event + end + local stagePool = {["global"] = {}} for roomId, roomName in pairs(mapData["rooms"]) do @@ -360,6 +365,27 @@ createMap = function(self, mapId, isEnter, isNewRelay) end end end + + -- 随机功能需要强制随机的东西 + if self.adv.isRelay and isNewRelay then + local relayData = self.adv:isHaveRelay() + if relayData then + local choose = relayData.choose:toArray(true, "=") + local lastCount = stagePool["global"][AdvCodeRandomStage] and #stagePool["global"][AdvCodeRandomStage] or 0 + if lastCount <= 0 then break end + for _, chooseId in pairs(choose) do + local idx = math.randomInt(1, lastCount) + local cur = stagePool["global"][AdvCodeRandomStage][idx] + + giveEvent(cur["room"], cur["block"], AdvEventType.Choose, chooseId) + + table.remove(stagePool["global"][AdvCodeRandomStage], idx) + lastCount = lastCount - 1 + stagePool[cur["room"]][stageType][cur["block"]] = nil + end + end + end + -- 全地图事件 优先级高 for stageType, events in pairs(mapData["events"]) do for _, event in ipairs(events) do diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index b9227be..bac9567 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -797,11 +797,15 @@ function RolePlugin.bind(Role) advOverTime = self.advOverTime, })) end + -- 路过的中继层重置掉 + local advRelay = self:getProperty("advRelay") + advRelay[-1] = nil -- 清掉冒险手册 self:updateProperties({ advEAchiev = {}, advElM = 0, advElS = nowSeason, + advRelay = advRelay, }, notNotify) end end -- libgit2 0.21.2