| 619 | } |
| 620 | |
| 621 | void SkillManager::buildRandomPendingSkillsForSeat(std::vector<SkillType>& skills, |
| 622 | const Seat* seat) |
| 623 | { |
| 624 | const std::vector<SkillType>& skillNotAllowed = seat->getSkillNotAllowed(); |
| 625 | std::vector<const SkillDef*> availableSkills; |
| 626 | // We consider as done skills already done for the given seat as well as the skills |
| 627 | // already pending |
| 628 | std::vector<SkillType> doneSkills = seat->getSkillDone(); |
| 629 | doneSkills.insert(doneSkills.begin(), skills.begin(), skills.end()); |
| 630 | // We fill availableSkills with all the skills that are not already done and |
| 631 | // that can be researched |
| 632 | for(const SkillDef* skill : getSkillManager().mSkills) |
| 633 | { |
| 634 | if(skill == nullptr) |
| 635 | continue; |
| 636 | |
| 637 | SkillType resType = skill->mSkill->getType(); |
| 638 | // We do not consider skills already pending or done |
| 639 | if(std::find(doneSkills.begin(), doneSkills.end(), resType) != doneSkills.end()) |
| 640 | continue; |
| 641 | |
| 642 | if(skill->mSkill->dependsOn(skillNotAllowed)) |
| 643 | continue; |
| 644 | |
| 645 | availableSkills.push_back(skill); |
| 646 | doneSkills.push_back(resType); |
| 647 | } |
| 648 | |
| 649 | // Now, availableSkills only contains skills that can be done (but unsorted). |
| 650 | // We need to shuffle that and fill skills. |
| 651 | doneSkills = seat->getSkillDone(); |
| 652 | std::random_shuffle(availableSkills.begin(), availableSkills.end()); |
| 653 | for(const SkillDef* skill : availableSkills) |
| 654 | { |
| 655 | // Since buildDependencies guarantees to not add duplicate skills, it is safe |
| 656 | // to call it for every skill not already done |
| 657 | skill->mSkill->buildDependencies(doneSkills, skills); |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | void SkillManager::listAllSkills(const std::function<void(const std::string&, const std::string&, |
| 662 | const std::string&, SkillType)>& func) |
nothing calls this directly
no test coverage detected