Commit a8f91e83dfffc518ee1b4e5de4f608a9ccbbd262
1 parent
aaf6a9e6
羁绊
Showing
1 changed file
with
33 additions
and
11 deletions
Show diff stats
src/models/RolePlugin.lua
@@ -596,7 +596,7 @@ function RolePlugin.bind(Role) | @@ -596,7 +596,7 @@ function RolePlugin.bind(Role) | ||
596 | -- end | 596 | -- end |
597 | end | 597 | end |
598 | 598 | ||
599 | - function Role:getHeroActiveRelation(heros) | 599 | + function Role:getHeroActiveRelationData(heros) |
600 | local relations = {} | 600 | local relations = {} |
601 | for _, id in pairs(heros or {}) do | 601 | for _, id in pairs(heros or {}) do |
602 | local hero = self.heros[id] | 602 | local hero = self.heros[id] |
@@ -605,20 +605,42 @@ function RolePlugin.bind(Role) | @@ -605,20 +605,42 @@ function RolePlugin.bind(Role) | ||
605 | relations[job] = (relations[job] or 0) + 1 | 605 | relations[job] = (relations[job] or 0) + 1 |
606 | end | 606 | end |
607 | end | 607 | end |
608 | - if not next(relations) then return {} end | ||
609 | - local result = {} | 608 | + if not next(relations) then return nil end |
609 | + | ||
610 | + local curData = nil | ||
610 | for _, data in pairs(csvdb["unit_relationCsv"]) do | 611 | for _, data in pairs(csvdb["unit_relationCsv"]) do |
611 | - local ok = true | ||
612 | - for typ, count in pairs(data.relation:toNumMap()) do | ||
613 | - if (relations[typ] or 0) < count then | ||
614 | - ok = false | 612 | + local had = {} |
613 | + local isDone = true | ||
614 | + for _, count in pairs(data.relation:toArray(true, "=")) do | ||
615 | + local find = false | ||
616 | + for camp, _count in pairs(relations) do | ||
617 | + if count == _count and not had[camp] then | ||
618 | + had[camp] = true | ||
619 | + find = true | ||
620 | + break | ||
621 | + end | ||
615 | end | 622 | end |
616 | - end | ||
617 | - if ok then | ||
618 | - for attr, value in pairs(data.effect:toNumMap()) do | ||
619 | - result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | 623 | + if not find then |
624 | + isDone = false | ||
625 | + break | ||
620 | end | 626 | end |
621 | end | 627 | end |
628 | + if isDone then | ||
629 | + curData = data | ||
630 | + break | ||
631 | + end | ||
632 | + end | ||
633 | + return curData | ||
634 | + end | ||
635 | + | ||
636 | + function Role:getHeroActiveRelation(heros) | ||
637 | + local data = self:getHeroActiveRelationData(heros) | ||
638 | + local result = {} | ||
639 | + if not data then | ||
640 | + return result | ||
641 | + end | ||
642 | + for attr, value in pairs(data.effect:toNumMap()) do | ||
643 | + result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | ||
622 | end | 644 | end |
623 | return result | 645 | return result |
624 | end | 646 | end |