Commit ec87b4a59f7a8ec32c37de8a85668fea0d77b21b

Authored by zhouahaihai
1 parent 32bca13b

冒险 完善

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