Commit 85ded2420393ebd8dad61ffdb753cda7bb24b540

Authored by zhouhaihai
1 parent 514590c2

丰富返回事件

src/GlobalVar.lua
... ... @@ -137,11 +137,15 @@ AdvBackEventType = {
137 137 Passive = 13, -- 獲得被動
138 138 TurnEnd = 14, -- 回合结束
139 139 Miss = 15, -- miss
140   - BattleBegin = 16, -- 战斗开始
  140 + Cost = 16, -- 消耗道具
141 141 Trap = 17, --陷阱
142 142 Layer = 18, --切换层
143 143 MapShow = 19, -- 展示地图
144 144 ChooseArtifact = 20, -- 等待选择神器
  145 + Use = 21, -- 使用道具
  146 + Potion = 22, -- 使用营养剂
  147 + Task = 23, --接收任务
  148 + Artifact = 24, --获得神器
145 149 }
146 150  
147 151 AdvScoreType = {
... ...
src/actions/AdvAction.lua
... ... @@ -308,6 +308,7 @@ function _M.useItemRpc(agent, data)
308 308 --消耗
309 309 if itemData["function"] == 0 or itemData["function"] == 1 then
310 310 adv:cost({[itemId] = count}, {})
  311 + adv:backUse({[itemId] = count})
311 312 end
312 313  
313 314 adv:checkAchievement(adv.AchievType.UseItem, count, itemId)
... ... @@ -345,6 +346,7 @@ function _M.usePotionRpc(agent, data)
345 346  
346 347 potionBag[potionId] = own - 1
347 348 role:updateProperty({field = "potionBag", value = potionBag})
  349 + adv:pushBackEvent(AdvBackEventType.Potion, {id = potionId})
348 350 adv:afterRound()
349 351 adv:saveDB()
350 352 role:checkTaskEnter("AdvUsePotion")
... ... @@ -407,7 +409,7 @@ function _M.upArtifactRpc(agent, data)
407 409 local status = adv:artifactLevelUp(id)
408 410 if not status then return 5 end
409 411 adv:cost(cost, {})
410   -
  412 + adv:backCost(cost)
411 413 if status == 1 then -- 现在穿着呢。更新下
412 414 adv:saveDB()
413 415 end
... ...
src/adv/Adv.lua
... ... @@ -205,6 +205,7 @@ end
205 205 function Adv:awardArtifact(id, params)
206 206 if self:isHaveArtifact(id) then return end
207 207 self.owner:changeUpdates({{type = "advAFGet", field = id, value = 1}}, params.notNotify)
  208 + self:pushBackEvent(AdvBackEventType.Artifact, {id = id})
208 209 end
209 210  
210 211  
... ... @@ -492,7 +493,7 @@ local function clickOut(self, room, block, params)
492 493 if self:getCurMap():checkOver() then --检查是否可以出去了
493 494 if #self.mapStack > 1 then -- 处于夹层中
494 495 table.remove(self.mapStack) --退出夹层
495   - self:backLayer()
  496 + self:backLayer(-1)
496 497 else --处于底层
497 498  
498 499 local advPass = self.owner:getProperty("advPass")
... ... @@ -580,6 +581,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
580 581 -- 提交一个物品
581 582 [5] = function ()
582 583 if self:cost({[cond[2]] = cond[3]}, {}) then
  584 + self:backCost({[cond[2]] = cond[3]})
583 585 return true
584 586 end
585 587 end,
... ... @@ -745,7 +747,7 @@ local function clickTrader(self, room, block, params)
745 747 if (block.event.status or ""):getv(buyId, 0) == 1 then return end -- 买过了
746 748  
747 749 if not self:cost({[traderData.type] = block.event.shop[buyId][3]}, {}) then return end --不够
748   -
  750 + self:backCost({[traderData.type] = block.event.shop[buyId][3]})
749 751 local reward = self:award({[block.event.shop[buyId][1]] = block.event.shop[buyId][2]})
750 752 block.event.status = block.event.status:setv(buyId, 1)
751 753 self:checkTask(Adv.TaskType.Shop, 1, block.event.id)
... ... @@ -759,7 +761,7 @@ local function clickBuild(self, room, block, params)
759 761 local chooseData = csvdb["event_buildingCsv"][block.event.id]
760 762 local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build")
761 763 if not status then return end
762   -
  764 +
763 765 self:checkTask(Adv.TaskType.Build, 1, block.event.id)
764 766 self:checkAchievement(Adv.AchievType.Build, 1, block.event.id)
765 767  
... ... @@ -810,7 +812,7 @@ local function clickLayer(self, room, block, params)
810 812 self.battle:initMapEnemys(mapIdx)
811 813 self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId)
812 814 end
813   - self:backLayer()
  815 + self:backLayer(1)
814 816 return true
815 817 end
816 818  
... ... @@ -1111,7 +1113,8 @@ function Adv:enemyDead(enemy, escape)
1111 1113 local enemyId = block.event.id
1112 1114 local monsterData = csvdb["event_monsterCsv"][enemyId]
1113 1115 self:scoreChange(AdvScoreType.Kill, monsterData.type)
1114   - self.battle.player:addExp(monsterData.exp)
  1116 + local changeV = self.battle.player:addExp(monsterData.exp)
  1117 + self:backDead(enemyId, changeV)
1115 1118 if enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) then -- 掉落转为 click
1116 1119 local clickId = buff:effect()
1117 1120 block:updateEvent({
... ... @@ -1203,20 +1206,16 @@ function Adv:backBlockChange(roomId, blockId)
1203 1206 self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId})
1204 1207 end
1205 1208  
1206   -function Adv:backAtk(enemyId, receiver)
1207   - self:pushBackEvent(AdvBackEventType.Atk, {enemyId = enemyId, receiver = receiver})
1208   -end
1209   -
1210   -function Adv:backDead(enemyId)
1211   - self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId})
  1209 +function Adv:backDead(enemyId, exp)
  1210 + self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId, exp = exp})
1212 1211 end
1213 1212  
1214 1213 function Adv:backTrap()
1215 1214 self:pushBackEvent(AdvBackEventType.Trap, {})
1216 1215 end
1217 1216  
1218   -function Adv:backLayer()
1219   - self:pushBackEvent(AdvBackEventType.Layer, {})
  1217 +function Adv:backLayer(status)
  1218 + self:pushBackEvent(AdvBackEventType.Layer, {status = status})
1220 1219 end
1221 1220  
1222 1221 function Adv:backMapShow()
... ... @@ -1227,6 +1226,15 @@ function Adv:backChooseArtifact()
1227 1226 self:pushBackEvent(AdvBackEventType.ChooseArtifact, {})
1228 1227 end
1229 1228  
  1229 +function Adv:backCost(items)
  1230 + self:pushBackEvent(AdvBackEventType.Cost, {items = items})
  1231 +end
  1232 +
  1233 +function Adv:backUse(items)
  1234 + self:pushBackEvent(AdvBackEventType.Use, {items = items})
  1235 +end
  1236 +
  1237 +
1230 1238 function Adv:scoreChange(scoreType, pms)
1231 1239 local cutTypes = {}
1232 1240 local score = 0
... ...
src/adv/AdvPlayer.lua
... ... @@ -415,7 +415,6 @@ function BaseObject:hurt(value, releaser, params)
415 415 end
416 416  
417 417 self.isDead = true
418   - self.battle.adv:backDead(self.id)
419 418 end
420 419 self:triggerPassive(Passive.HURT_PERCENT_SELF, {value = value / self.hpMax})
421 420 for _, team in ipairs(self:getTeam(1, true)) do
... ... @@ -580,6 +579,7 @@ function Player:addExp(value)
580 579 end
581 580 self.level = level
582 581 self.exp = newExp
  582 + return value
583 583 end
584 584 --vtype 0/1 值/%
585 585 function Player:addBaseAttr(attr, value, vtype)
... ... @@ -611,6 +611,7 @@ end
611 611  
612 612 --cType 0 or nil 值 1 百分比
613 613 function Player:changeSp(value, cType)
  614 + local oldSp = self.sp
614 615 cType = cType or 0
615 616 if cType == 0 then
616 617 self.sp = self.sp + value
... ... @@ -618,7 +619,7 @@ function Player:changeSp(value, cType)
618 619 self.sp = self.sp + self.sp * value / 100
619 620 end
620 621 self.sp = math.floor(math.min(self.spMax, math.max(0, self.sp)))
621   - self.battle.adv:pushBackEvent(AdvBackEventType.SpChange)
  622 + self.battle.adv:pushBackEvent(AdvBackEventType.SpChange, {change = self.sp - oldSp})
622 623 end
623 624  
624 625 -- 重新计算 魔法上限
... ...
src/adv/AdvTask.lua
... ... @@ -118,6 +118,7 @@ function AdvTask.bind(Adv)
118 118 end
119 119  
120 120 advTaskChange.t = true
  121 + self:pushBackEvent(AdvBackEventType.Task, {id = taskId})
121 122 return true
122 123 end
123 124 end
... ...