* Get the list of RuleResearch which can be researched in a Base. * @param projects the list of ResearchProject which are available. * @param ruleset the game Ruleset * @param base a pointer to a Base */
| 952 | * @param base a pointer to a Base |
| 953 | */ |
| 954 | void SavedGame::getAvailableResearchProjects (std::vector<RuleResearch *> & projects, const Ruleset * ruleset, Base * base) const |
| 955 | { |
| 956 | const std::vector<const RuleResearch *> & discovered(getDiscoveredResearch()); |
| 957 | std::vector<std::string> researchProjects = ruleset->getResearchList(); |
| 958 | const std::vector<ResearchProject *> & baseResearchProjects = base->getResearch(); |
| 959 | std::vector<const RuleResearch *> unlocked; |
| 960 | for(std::vector<const RuleResearch *>::const_iterator it = discovered.begin (); it != discovered.end (); ++it) |
| 961 | { |
| 962 | for(std::vector<std::string>::const_iterator itUnlocked = (*it)->getUnlocked ().begin (); itUnlocked != (*it)->getUnlocked ().end (); ++itUnlocked) |
| 963 | { |
| 964 | unlocked.push_back(ruleset->getResearch(*itUnlocked)); |
| 965 | } |
| 966 | } |
| 967 | for(std::vector<std::string>::const_iterator iter = researchProjects.begin (); iter != researchProjects.end (); ++iter) |
| 968 | { |
| 969 | RuleResearch *research = ruleset->getResearch(*iter); |
| 970 | if (!isResearchAvailable(research, unlocked, ruleset)) |
| 971 | { |
| 972 | continue; |
| 973 | } |
| 974 | std::vector<const RuleResearch *>::const_iterator itDiscovered = std::find(discovered.begin (), discovered.end (), research); |
| 975 | |
| 976 | bool liveAlien = ruleset->getUnit(research->getName()) != 0; |
| 977 | |
| 978 | if (itDiscovered != discovered.end ()) |
| 979 | { |
| 980 | if (!liveAlien) |
| 981 | { |
| 982 | continue; |
| 983 | } |
| 984 | else |
| 985 | { |
| 986 | bool cull = true; |
| 987 | if (research->getGetOneFree().size() != 0) |
| 988 | { |
| 989 | for (std::vector<std::string>::const_iterator ohBoy = research->getGetOneFree().begin(); ohBoy != research->getGetOneFree().end(); ++ohBoy) |
| 990 | { |
| 991 | std::vector<const RuleResearch *>::const_iterator more_iteration = std::find(discovered.begin (), discovered.end (), ruleset->getResearch(*ohBoy)); |
| 992 | if (more_iteration == discovered.end ()) |
| 993 | { |
| 994 | cull = false; |
| 995 | break; |
| 996 | } |
| 997 | } |
| 998 | } |
| 999 | std::vector<std::string>::const_iterator leaderCheck = std::find(research->getUnlocked().begin(), research->getUnlocked().end(), "STR_LEADER_PLUS"); |
| 1000 | std::vector<std::string>::const_iterator cmnderCheck = std::find(research->getUnlocked().begin(), research->getUnlocked().end(), "STR_CYDONIA_DEP"); |
| 1001 | |
| 1002 | bool leader ( leaderCheck != research->getUnlocked().end()); |
| 1003 | bool cmnder ( cmnderCheck != research->getUnlocked().end()); |
| 1004 | |
| 1005 | if (leader) |
| 1006 | { |
| 1007 | std::vector<const RuleResearch*>::const_iterator found = std::find(discovered.begin(), discovered.end(), ruleset->getResearch("STR_LEADER_PLUS")); |
| 1008 | if (found == discovered.end()) |
| 1009 | cull = false; |
| 1010 | } |
| 1011 |
no test coverage detected