Commit 6732f756a424c34a98e24e787f796f15edde31cc
1 parent
286a8f95
玩家升级
Showing
2 changed files
with
27 additions
and
2 deletions
Show diff stats
src/adv/Adv.lua
| ... | ... | @@ -604,7 +604,7 @@ function Adv:enemyDead(roomId, blockId, escape) |
| 604 | 604 | local enemyId = block.event.id |
| 605 | 605 | local monsterData = csvdb["event_monsterCsv"][enemyId] |
| 606 | 606 | self:scoreChange(AdvScoreType.Kill, monsterData.type) |
| 607 | - | |
| 607 | + self.battle.player:addExp(monsterData.exp) | |
| 608 | 608 | local item = block.event.item |
| 609 | 609 | if not item then |
| 610 | 610 | local dropData = csvdb["event_dropCsv"][monsterData.dropid] | ... | ... |
src/adv/AdvPlayer.lua
| ... | ... | @@ -431,7 +431,32 @@ function Player:initData(data) |
| 431 | 431 | end |
| 432 | 432 | |
| 433 | 433 | function Player:addExp(value) |
| 434 | - -- todo | |
| 434 | + local newExp = self.exp + value | |
| 435 | + local level = self.level | |
| 436 | + if level >= #csvdb["adv_levelCsv"] then return end | |
| 437 | + while true do | |
| 438 | + local curData = csvdb["adv_levelCsv"][level] | |
| 439 | + if newExp < curData.exp then break end | |
| 440 | + level = level + 1 | |
| 441 | + newExp = newExp - curData.exp | |
| 442 | + if level >= #csvdb["adv_levelCsv"] then break end | |
| 443 | + end | |
| 444 | + local delta = level - self.level | |
| 445 | + if delta > 0 then | |
| 446 | + local baseAttr = csvdb["adv_unitCsv"][self.battle.adv.chapterId] | |
| 447 | + for _, attr in pairs(AttsEnumEx) do | |
| 448 | + if baseAttr[attr] then | |
| 449 | + self[attr] = self[attr] + baseAttr[attr] * self.growth * delta | |
| 450 | + if attr == "hp" then | |
| 451 | + self.hpMax = self.hpMax + baseAttr[attr] * self.growth * delta | |
| 452 | + else | |
| 453 | + self["_" .. attr] = self["_" .. attr] + baseAttr[attr] * self.growth * delta | |
| 454 | + end | |
| 455 | + end | |
| 456 | + end | |
| 457 | + end | |
| 458 | + self.level = level | |
| 459 | + self.exp = newExp | |
| 435 | 460 | end |
| 436 | 461 | |
| 437 | 462 | --cType 0 or nil 值 1 百分比 | ... | ... |