Commit a41b9076edc3c510531286f00685898c8aec6736

Authored by zhouhaihai
1 parent 79d6af45

增加羁绊方法

Showing 2 changed files with 29 additions and 0 deletions   Show diff stats
src/adv/AdvBattle.lua
@@ -43,6 +43,8 @@ function Battle:initPlayer() @@ -43,6 +43,8 @@ function Battle:initPlayer()
43 end 43 end
44 end 44 end
45 end 45 end
  46 + local activeRelation = self.adv.owner:getHeroActiveRelation()
  47 + -- todo
46 player.hp = hp 48 player.hp = hp
47 player.atk = tonumber(string.format("%0.0f", player.hp * 0.1)) --todo 系数是临时的 49 player.atk = tonumber(string.format("%0.0f", player.hp * 0.1)) --todo 系数是临时的
48 player.def = 0 50 player.def = 0
src/models/RolePlugin.lua
@@ -517,6 +517,33 @@ function RolePlugin.bind(Role) @@ -517,6 +517,33 @@ function RolePlugin.bind(Role)
517 -- self:log("gmAction",{desc = "heartWarning", count = heartWarning}) 517 -- self:log("gmAction",{desc = "heartWarning", count = heartWarning})
518 -- end 518 -- end
519 end 519 end
  520 +
  521 + function Role:getHeroActiveRelation(heros)
  522 + local relations = {}
  523 + for _, id in pairs(heros or {}) do
  524 + local hero = self.heros[id]
  525 + if hero then
  526 + local job = csvdb["unitCsv"][hero:getProperty("type")].job
  527 + relations[job] = (relations[job] or 0) + 1
  528 + end
  529 + end
  530 + if not next(relations) then return {} end
  531 + local result = {}
  532 + for _, data in ipairs(csvdb["unit_relationCsv"]) do
  533 + local ok = true
  534 + for typ, count in pairs(data.relation:toNumMap()) do
  535 + if (relations[typ] or 0) < count then
  536 + ok = false
  537 + end
  538 + end
  539 + if ok then
  540 + for attr, value in pairs(data.effect:toNumMap()) do
  541 + result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value
  542 + end
  543 + end
  544 + end
  545 + return result
  546 + end
520 end 547 end
521 548
522 return RolePlugin 549 return RolePlugin
523 \ No newline at end of file 550 \ No newline at end of file