Commit e10edb5f2060abce65b7b9f28733a17a0d504b37
1 parent
1bd8f8ee
冒险事件新
Showing
2 changed files
with
38 additions
and
40 deletions
Show diff stats
src/adv/Adv.lua
| @@ -340,19 +340,6 @@ function Block:open(adv, room) | @@ -340,19 +340,6 @@ function Block:open(adv, room) | ||
| 340 | self.event.effect[3] = reward[2] | 340 | self.event.effect[3] = reward[2] |
| 341 | end | 341 | end |
| 342 | end | 342 | end |
| 343 | - --抉择点 | ||
| 344 | - randomFunc[AdvEventType.Choose] = function() | ||
| 345 | - local data = csvdb["event_chooseCsv"][self.event.id] | ||
| 346 | - self.event.effect = {} | ||
| 347 | - for i = 1, 2 do | ||
| 348 | - self.event.effect[i] = data["button".. i .."effect"]:toArray(true, "=") | ||
| 349 | - if self.event.effect[i][1] == 1 then --获得某道具 | ||
| 350 | - local reward = csvdb["event_dropCsv"][self.event.effect[i][2]]["range"]:randWeight(true) | ||
| 351 | - self.event.effect[i][2] = reward[1] | ||
| 352 | - self.event.effect[i][3] = reward[2] | ||
| 353 | - end | ||
| 354 | - end | ||
| 355 | - end | ||
| 356 | if self.event then -- 随机出具体的事件 | 343 | if self.event then -- 随机出具体的事件 |
| 357 | if randomFunc[self.event.etype] then | 344 | if randomFunc[self.event.etype] then |
| 358 | randomFunc[self.event.etype]() | 345 | randomFunc[self.event.etype]() |
| @@ -757,23 +744,32 @@ local function clickChoose(self, room, block, params) | @@ -757,23 +744,32 @@ local function clickChoose(self, room, block, params) | ||
| 757 | assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) | 744 | assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id) |
| 758 | if cond[1] and not checkCond[cond[1]]() then return end | 745 | if cond[1] and not checkCond[cond[1]]() then return end |
| 759 | local clearBlock = true | 746 | local clearBlock = true |
| 760 | - local effect = block.event.effect[choose] | ||
| 761 | - local doEffect = { | ||
| 762 | - [1] = function() -- 获得某道具N个 | ||
| 763 | - self:backReward(self:award({[effect[2]] = effect[3]}, {})) | ||
| 764 | - end, | ||
| 765 | - [2] = function() --获得冒险buff | ||
| 766 | - self.battle.player:addBuff(effect[2]) | ||
| 767 | - end, | ||
| 768 | - [3] = function() --发现怪物 | ||
| 769 | - self:addNewMonsterRand(effect[2], {room, block}) | ||
| 770 | - clearBlock = false | ||
| 771 | - end, | ||
| 772 | - [4] = function() --无事发生 | 747 | + local effects = chooseData["button".. choose .."effect"]:toTableArray(true) |
| 748 | + for _, effect in ipairs(effects) do | ||
| 749 | + if effect[1] == 1 then | ||
| 750 | + local reward = csvdb["event_dropCsv"][effect[2]]["range"]:randWeight(true) | ||
| 751 | + effect[2] = reward[1] | ||
| 752 | + effect[3] = reward[2] | ||
| 773 | end | 753 | end |
| 774 | - } | ||
| 775 | - assert(doEffect[effect[1]], "error effect, event_chooseCsv id :" .. block.event.id) | ||
| 776 | - doEffect[effect[1]]() | 754 | + |
| 755 | + local doEffect = { | ||
| 756 | + [1] = function() -- 获得某道具N个 | ||
| 757 | + self:backReward(self:award({[effect[2]] = effect[3]}, {})) | ||
| 758 | + end, | ||
| 759 | + [2] = function() --获得冒险buff | ||
| 760 | + self.battle.player:addBuff(effect[2]) | ||
| 761 | + end, | ||
| 762 | + [3] = function() --发现怪物 | ||
| 763 | + self:addNewMonsterRand(effect[2], {room, block}) | ||
| 764 | + clearBlock = false | ||
| 765 | + end, | ||
| 766 | + [4] = function() --无事发生 | ||
| 767 | + end | ||
| 768 | + } | ||
| 769 | + assert(doEffect[effect[1]], "error effect, event_chooseCsv id :" .. block.event.id) | ||
| 770 | + doEffect[effect[1]]() | ||
| 771 | + end | ||
| 772 | + | ||
| 777 | if clearBlock then | 773 | if clearBlock then |
| 778 | room:clearBEvent(block) | 774 | room:clearBEvent(block) |
| 779 | end | 775 | end |
| @@ -797,7 +793,7 @@ local function clickTrader(self, room, block, params) | @@ -797,7 +793,7 @@ local function clickTrader(self, room, block, params) | ||
| 797 | if not block.event.shop or not block.event.shop[buyId] then return end | 793 | if not block.event.shop or not block.event.shop[buyId] then return end |
| 798 | if (block.event.status or ""):getv(buyId, 0) == 1 then return end -- 买过了 | 794 | if (block.event.status or ""):getv(buyId, 0) == 1 then return end -- 买过了 |
| 799 | 795 | ||
| 800 | - if not self:cost(traderData.type:toNumMap(), {}) then return end --不够 | 796 | + if not self:cost({[traderData.type] = block.event.shop[buyId][3]}, {}) then return end --不够 |
| 801 | 797 | ||
| 802 | local reward = self:award({[block.event.shop[buyId][1]] = block.event.shop[buyId][2]}, {}) | 798 | local reward = self:award({[block.event.shop[buyId][1]] = block.event.shop[buyId][2]}, {}) |
| 803 | block.event.status = block.event.status:setv(buyId, 1) | 799 | block.event.status = block.event.status:setv(buyId, 1) |
| @@ -827,7 +823,7 @@ local function clickBuild(self, room, block, params) | @@ -827,7 +823,7 @@ local function clickBuild(self, room, block, params) | ||
| 827 | end | 823 | end |
| 828 | } | 824 | } |
| 829 | assert(doEffect[effect[1]], "error effect, event_buildingCsv id :" .. block.event.id) | 825 | assert(doEffect[effect[1]], "error effect, event_buildingCsv id :" .. block.event.id) |
| 830 | - if not self:cost({[buildData.type] = 1}, {}) then return end | 826 | + if not self:cost(buildData.required:toNumMap(), {}) then return end |
| 831 | doEffect[effect[1]]() | 827 | doEffect[effect[1]]() |
| 832 | if clearBlock then | 828 | if clearBlock then |
| 833 | room:clearBEvent(block) | 829 | room:clearBEvent(block) |
| @@ -1075,12 +1071,14 @@ function Adv:scoreChange(scoreType, pms) | @@ -1075,12 +1071,14 @@ function Adv:scoreChange(scoreType, pms) | ||
| 1075 | end | 1071 | end |
| 1076 | 1072 | ||
| 1077 | function Adv:getScore() | 1073 | function Adv:getScore() |
| 1078 | - return math.floor(math.max( | ||
| 1079 | - (self.advInfo.score[AdvScoreType.Level] or 0) + | ||
| 1080 | - (self.advInfo.score[AdvScoreType.Block] or 0) + | ||
| 1081 | - (self.advInfo.score[AdvScoreType.Hurt] or 0), | ||
| 1082 | - 0) + (self.advInfo.score[AdvScoreType.Kill] or 0) + | ||
| 1083 | - (self.advInfo.score[AdvScoreType.Item] or 0)) | 1074 | + self.advInfo.score[AdvScoreType.Level] = math.floor(self.advInfo.score[AdvScoreType.Level] or 0) |
| 1075 | + self.advInfo.score[AdvScoreType.Block] = math.floor(self.advInfo.score[AdvScoreType.Block] or 0) | ||
| 1076 | + self.advInfo.score[AdvScoreType.Hurt] = math.max(math.floor(self.advInfo.score[AdvScoreType.Hurt] or 0), - (self.advInfo.score[AdvScoreType.Level] + self.advInfo.score[AdvScoreType.Block])) | ||
| 1077 | + self.advInfo.score[AdvScoreType.Kill] = math.floor(self.advInfo.score[AdvScoreType.Kill] or 0) | ||
| 1078 | + self.advInfo.score[AdvScoreType.Item] = math.floor(self.advInfo.score[AdvScoreType.Item] or 0) | ||
| 1079 | + | ||
| 1080 | + return self.advInfo.score[AdvScoreType.Level] + self.advInfo.score[AdvScoreType.Block] + self.advInfo.score[AdvScoreType.Hurt] | ||
| 1081 | + + self.advInfo.score[AdvScoreType.Kill] + self.advInfo.score[AdvScoreType.Item] | ||
| 1084 | end | 1082 | end |
| 1085 | 1083 | ||
| 1086 | function Adv:popBackEvents() | 1084 | function Adv:popBackEvents() |
src/adv/AdvPlayer.lua
| @@ -141,7 +141,7 @@ function BaseObject:reSetAttr(field) | @@ -141,7 +141,7 @@ function BaseObject:reSetAttr(field) | ||
| 141 | self[field] = self["_" .. field] --重置一下 | 141 | self[field] = self["_" .. field] --重置一下 |
| 142 | local fieldToBuff = {atk = Buff.IMMNUE_ATK, hit = Buff.HIT_CHANGE, miss = Buff.MISS_CHANGE, def = Buff.DEF_CHANGE} | 142 | local fieldToBuff = {atk = Buff.IMMNUE_ATK, hit = Buff.HIT_CHANGE, miss = Buff.MISS_CHANGE, def = Buff.DEF_CHANGE} |
| 143 | local effect = self:getCommonBuffEffect(fieldToBuff[field]) | 143 | local effect = self:getCommonBuffEffect(fieldToBuff[field]) |
| 144 | - self[field] = (self[field] + effect[0]) * (1 + effect[1]) | 144 | + self[field] = math.ceil((self[field] + effect[0]) * (1 + effect[1])) |
| 145 | local delta = self[field] - old | 145 | local delta = self[field] - old |
| 146 | if delta ~= 0 then | 146 | if delta ~= 0 then |
| 147 | if field == "atk" then | 147 | if field == "atk" then |
| @@ -223,7 +223,7 @@ function BaseObject:hurt(value, releaser, params) | @@ -223,7 +223,7 @@ function BaseObject:hurt(value, releaser, params) | ||
| 223 | end | 223 | end |
| 224 | end | 224 | end |
| 225 | 225 | ||
| 226 | - value = math.max(0, value) | 226 | + value = math.max(0, math.ceil(value)) |
| 227 | if value == 0 then return end | 227 | if value == 0 then return end |
| 228 | -- 反弹伤害 | 228 | -- 反弹伤害 |
| 229 | if params.hurtType ~= 3 and releaser and not releaser.isDead then | 229 | if params.hurtType ~= 3 and releaser and not releaser.isDead then |
| @@ -257,7 +257,7 @@ end | @@ -257,7 +257,7 @@ end | ||
| 257 | --恢复 | 257 | --恢复 |
| 258 | function BaseObject:recover(value, releaser, params) | 258 | function BaseObject:recover(value, releaser, params) |
| 259 | params = params or {} | 259 | params = params or {} |
| 260 | - value = math.max(0, value) | 260 | + value = math.max(0, math.ceil(value)) |
| 261 | self.hp = math.min(self.hpMax, self.hp + value) | 261 | self.hp = math.min(self.hpMax, self.hp + value) |
| 262 | self.battle.adv:backHpChange(self.id, value) | 262 | self.battle.adv:backHpChange(self.id, value) |
| 263 | end | 263 | end |