Commit ec87b4a59f7a8ec32c37de8a85668fea0d77b21b
1 parent
32bca13b
冒险 完善
Showing
6 changed files
with
32 additions
and
4 deletions
Show diff stats
src/GlobalVar.lua
@@ -88,4 +88,5 @@ AdvBackEventType = { | @@ -88,4 +88,5 @@ AdvBackEventType = { | ||
88 | Next = 7, --进入下一层 | 88 | Next = 7, --进入下一层 |
89 | End = 8, -- 结束 | 89 | End = 8, -- 结束 |
90 | BlockChange = 9, -- 块改变 | 90 | BlockChange = 9, -- 块改变 |
91 | + PowerChange = 10, --体力改变 | ||
91 | } | 92 | } |
92 | \ No newline at end of file | 93 | \ No newline at end of file |
src/ProtocolCode.lua
@@ -27,6 +27,7 @@ actionCodes = { | @@ -27,6 +27,7 @@ actionCodes = { | ||
27 | Adv_clickBlockRpc = 153, | 27 | Adv_clickBlockRpc = 153, |
28 | Adv_useItemRpc = 154, | 28 | Adv_useItemRpc = 154, |
29 | Adv_useSkillRpc = 155, | 29 | Adv_useSkillRpc = 155, |
30 | + Adv_exitAdvRpc = 156, | ||
30 | 31 | ||
31 | Hero_loadInfos = 201, | 32 | Hero_loadInfos = 201, |
32 | Hero_updateProperty = 202, | 33 | Hero_updateProperty = 202, |
src/actions/AdvAction.lua
@@ -86,6 +86,16 @@ function _M.useSkillRpc(agent, data) | @@ -86,6 +86,16 @@ function _M.useSkillRpc(agent, data) | ||
86 | end | 86 | end |
87 | 87 | ||
88 | 88 | ||
89 | +--退出 | ||
90 | +function _M.exitAdvRpc(agent, data) | ||
91 | + local role = agent.role | ||
92 | + -- local msg = MsgPack.unpack(data) | ||
93 | + local adv = role:getAdvData() | ||
94 | + local status = adv:exit() -- target {roomId = 1, blockId = 1} 选择的目标 | ||
95 | + SendPacket(actionCodes.Adv_exitAdvRpc, MsgPack.pack({events = adv:popBackEvents()})) | ||
96 | + return true | ||
97 | +end | ||
98 | + | ||
89 | 99 | ||
90 | 100 | ||
91 | return _M | 101 | return _M |
92 | \ No newline at end of file | 102 | \ No newline at end of file |
src/adv/Adv.lua
@@ -98,7 +98,7 @@ local function randomAdvMap(role, chapterId, level, notNotify) | @@ -98,7 +98,7 @@ local function randomAdvMap(role, chapterId, level, notNotify) | ||
98 | local advInfo = role:getProperty("advInfo") | 98 | local advInfo = role:getProperty("advInfo") |
99 | local lastMapId = advInfo.mapId --非同一层不连续随出同一张类似的地图 | 99 | local lastMapId = advInfo.mapId --非同一层不连续随出同一张类似的地图 |
100 | local lastChapterId = advInfo.chapter | 100 | local lastChapterId = advInfo.chapter |
101 | - local power = advInfo.power or 0 --体力 | 101 | + local power = advInfo.power or 100 --体力 |
102 | local pool = {} | 102 | local pool = {} |
103 | for _, mapId in ipairs(raw_pool) do | 103 | for _, mapId in ipairs(raw_pool) do |
104 | local temp = csvdb["mapCsv"][mapId] | 104 | local temp = csvdb["mapCsv"][mapId] |
@@ -442,6 +442,11 @@ function Adv:over(success) | @@ -442,6 +442,11 @@ function Adv:over(success) | ||
442 | self:backEnd(score) | 442 | self:backEnd(score) |
443 | end | 443 | end |
444 | 444 | ||
445 | +function Adv:exit() | ||
446 | + self:over(-1) | ||
447 | + self:saveDB() | ||
448 | +end | ||
449 | + | ||
445 | function Adv:getMapInfo() | 450 | function Adv:getMapInfo() |
446 | if not next(self.advInfo) then return end | 451 | if not next(self.advInfo) then return end |
447 | return csvdb["mapCsv"][self.advInfo.mapId] | 452 | return csvdb["mapCsv"][self.advInfo.mapId] |
@@ -935,6 +940,7 @@ function Adv:changePower(value, cType) | @@ -935,6 +940,7 @@ function Adv:changePower(value, cType) | ||
935 | self.advInfo.power = self.advInfo.power + self.advInfo.power * value | 940 | self.advInfo.power = self.advInfo.power + self.advInfo.power * value |
936 | end | 941 | end |
937 | self.advInfo.power = math.floor(math.max(0, self.advInfo.power)) | 942 | self.advInfo.power = math.floor(math.max(0, self.advInfo.power)) |
943 | + self:pushBackEvent(AdvBackEventType.PowerChange) | ||
938 | end | 944 | end |
939 | 945 | ||
940 | function Adv:pushBackEvent(btype, params) | 946 | function Adv:pushBackEvent(btype, params) |
@@ -978,6 +984,7 @@ function Adv:backAtk(enemyId, receiver) | @@ -978,6 +984,7 @@ function Adv:backAtk(enemyId, receiver) | ||
978 | self:pushBackEvent(AdvBackEventType.Atk, {enemyId = enemyId, receiver = receiver}) | 984 | self:pushBackEvent(AdvBackEventType.Atk, {enemyId = enemyId, receiver = receiver}) |
979 | end | 985 | end |
980 | 986 | ||
987 | + | ||
981 | function Adv:popBackEvents() | 988 | function Adv:popBackEvents() |
982 | local events = self.backEvents | 989 | local events = self.backEvents |
983 | self.backEvents = {} | 990 | self.backEvents = {} |
src/adv/AdvBattle.lua
@@ -132,6 +132,14 @@ function Battle:afterRound() | @@ -132,6 +132,14 @@ function Battle:afterRound() | ||
132 | table.remove(self.enemys, i) | 132 | table.remove(self.enemys, i) |
133 | end | 133 | end |
134 | end | 134 | end |
135 | + | ||
136 | + if self.adv.advInfo.power > 0 then | ||
137 | + self.adv:changePower(-1) | ||
138 | + else | ||
139 | + self.player:hurt(self.player.hpMax / 10, nil, {hurtType = 4}) | ||
140 | + end | ||
141 | + | ||
142 | + | ||
135 | if self.player.isDead then | 143 | if self.player.isDead then |
136 | self.adv:over(-1) | 144 | self.adv:over(-1) |
137 | end | 145 | end |
src/adv/AdvPlayer.lua
@@ -160,7 +160,7 @@ function BaseObject:getInjuredValue(value) | @@ -160,7 +160,7 @@ function BaseObject:getInjuredValue(value) | ||
160 | end | 160 | end |
161 | 161 | ||
162 | --最终伤害 = [ 敌方攻击 * (1+伤害增加百分比-伤害减少百分比)*(1+受伤增加百分比-受伤减少百分比)+(伤害增加固定值-伤害增加固定值+受伤增加固定值-受伤增加固定值)]*(1+侍宠百分比)-侍宠固定值 | 162 | --最终伤害 = [ 敌方攻击 * (1+伤害增加百分比-伤害减少百分比)*(1+受伤增加百分比-受伤减少百分比)+(伤害增加固定值-伤害增加固定值+受伤增加固定值-受伤增加固定值)]*(1+侍宠百分比)-侍宠固定值 |
163 | --- params -- hurtType 1 普攻伤害 2 buff伤害 3 反弹伤害 | 163 | +-- params -- hurtType 1 普攻伤害 2 buff伤害 3 反弹伤害 4 真实伤害 |
164 | --进入这个方法之前计算好释放者加成的伤害 | 164 | --进入这个方法之前计算好释放者加成的伤害 |
165 | function BaseObject:hurt(value, releaser, params) | 165 | function BaseObject:hurt(value, releaser, params) |
166 | params = params or {} | 166 | params = params or {} |
@@ -180,8 +180,9 @@ function BaseObject:hurt(value, releaser, params) | @@ -180,8 +180,9 @@ function BaseObject:hurt(value, releaser, params) | ||
180 | team:triggerPassive(Passive.TEAM_HURT, {trigger = releaser}) | 180 | team:triggerPassive(Passive.TEAM_HURT, {trigger = releaser}) |
181 | end | 181 | end |
182 | end | 182 | end |
183 | - | ||
184 | - value = self:getInjuredValue(value) --减伤计算 | 183 | + if not params.hurtType or params.hurtType ~= 4 then |
184 | + value = self:getInjuredValue(value) --减伤计算 | ||
185 | + end | ||
185 | if value == 0 then return end | 186 | if value == 0 then return end |
186 | 187 | ||
187 | -- 舍身和恃宠 | 188 | -- 舍身和恃宠 |