Commit 47343863a009f732cb87bcfa1bb154f3516d1670

Authored by zhangqijia
1 parent bbaa6be7

fix: 天赋点自动升级,重置觉醒技能增加消耗品

1. 升级到五星,觉醒技能自动升级
2. 重置觉醒技能增加消耗品
3. 六星设置四星觉醒技,5星的觉醒技能自动升级
src/actions/HeroAction.lua
... ... @@ -151,6 +151,10 @@ function _M.wakeRpc(agent, data)
151 151 if curLevel == 3 then -- 解锁cg
152 152 role:checkTaskEnter("WakeCG", {heroType = typ})
153 153 end
  154 +
  155 + if curLevel >= 4 then --自动觉醒技能
  156 + hero:increGeniusTree()
  157 + end
154 158 hero:mylog({desc = "wake", int1 = hero:getProperty("wakeL")})
155 159  
156 160 role:log("hero_rise", {
... ... @@ -1292,8 +1296,6 @@ function _M.saveGeniusTreeRpc(agent, data)
1292 1296 genius = ""
1293 1297 end
1294 1298 hero:updateProperty({field="genius", value=genius})
1295   - print("genius:")
1296   - print(#genius)
1297 1299 SendPacket(actionCodes.Hero_saveGeniusTreeRpc, MsgPack.pack({genius = genius}))
1298 1300 return true
1299 1301 end
... ...
src/models/HeroPlugin.lua
... ... @@ -394,12 +394,10 @@ function HeroPlugin.bind(Hero)
394 394 local geniusTree = genius:toNumMap()
395 395 local tmpgenius = ""
396 396 for wakeL, val in pairs(geniusTree) do
397   - print("wakeL:")
398   - print(wakeL)
399 397 if wakeL < 4 then return maxWakeL end
400 398 if wakeL % 2 == 0 then
401 399 if geniusTree[wakeL+1] and geniusTree[wakeL+1] ~= val then
402   - return 0
  400 + return 0, 0, tmpgenius
403 401 end
404 402 end
405 403 maxWakeL = math.max(maxWakeL, wakeL)
... ... @@ -409,16 +407,44 @@ function HeroPlugin.bind(Hero)
409 407 tmpgenius = string.format("%s %s=%s", tmpgenius, tostring(wakeL), tostring(val))
410 408 end
411 409 end
412   - return tonumber(maxWakeL),tmpgenius
  410 + return tonumber(maxWakeL), tonumber(geniusTree[maxWakeL]), tmpgenius
  411 + end
  412 +
  413 + function Hero:increGeniusTree()
  414 + local genius = self:getProperty("genius")
  415 + local wakeL = self:getProperty("wakeL")
  416 + local maxWakeL, awake
  417 + maxWakeL, awake, genius = self:checkGeniusTree(genius)
  418 + if maxWakeL >= 4 and wakeL > maxWakeL and maxWakeL % 2 == 0 then
  419 + maxWakeL = maxWakeL + 1
  420 + if #genius == 0 then
  421 + genius = string.format("%s=%s", tostring(maxWakeL), tostring(awake))
  422 + else
  423 + genius = string.format("%s %s=%s", genius, tostring(maxWakeL), tostring(awake))
  424 + end
  425 + end
  426 + return genius
  427 + end
  428 +
  429 + function Hero:resetGeniusTree()
  430 + local unit_starTalent_reset = globalCsv["unit_starTalent_reset"]
  431 + local cost = unit_starTalent_reset:toNumMap()
  432 + if not self.owner:checkItemEnough(cost) then return false end
  433 +
  434 + self.owner:costItems(cost, {log = {desc = "heroGenius", int1 = self:getProperty("id"), int2 = self:getProperty("type")}})
  435 + return true
413 436 end
414 437  
415 438 function Hero:saveGeniusTree(wakeL, awake)
416 439 local genius = self:getProperty("genius")
417   - local tid = self:getProperty("type")
418   - if not wakeL and not awake then return "" end
  440 + local typ = self:getProperty("type")
  441 + local curWakeL = self:getProperty("wakeL")
  442 + if not wakeL or not awake then
  443 + if self:resetGeniusTree() == true then return "" end
  444 + return genius
  445 + end
419 446  
420   -
421   - local heroUnit = csvdb["unitCsv"][tid]
  447 + local heroUnit = csvdb["unitCsv"][typ]
422 448 if not heroUnit then return genius end
423 449 if not heroUnit.awake_1 or not heroUnit.awake_2 then return genius end
424 450  
... ... @@ -428,9 +454,16 @@ function HeroPlugin.bind(Hero)
428 454 genius = string.format("%s %s=%s", genius, tostring(wakeL), tostring(awake))
429 455 end
430 456  
431   - local maxWakeL, genius = self:checkGeniusTree(genius)
  457 + local maxWakeL
  458 + maxWakeL, _, genius = self:checkGeniusTree(genius)
432 459 if maxWakeL ~= wakeL then
433 460 genius = self:getProperty("genius")
  461 + else
  462 +
  463 + if curWakeL > maxWakeL and maxWakeL % 2 == 0 then --自动升一级,举例,6星设置4星觉醒技能。自动升级到5星
  464 + genius = string.format("%s %s=%s", genius, tostring(maxWakeL + 1), tostring(awake))
  465 + maxWakeL, _, genius = self:checkGeniusTree(genius)
  466 + end
434 467 end
435 468 return genius
436 469 end
... ...
src/models/RoleLog.lua
... ... @@ -136,6 +136,7 @@ local ItemReason = {
136 136 changeSpark = 1213, -- 穿戴火花
137 137 sparkLvlUp = 1214, -- 火花强化
138 138 sparkQualityUp = 1215, -- 火花升华
  139 + heroGenius = 1216, -- 英雄天赋点
139 140  
140 141 -- pvp
141 142 pvpCHead = 1301, -- pvp 跨服竞技场头像
... ...