MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / time1Month

Method time1Month

src/Geoscape/GeoscapeState.cpp:1654–1745  ·  view source on GitHub ↗

* Takes care of any game logic that has to * run every game month, like funding. */

Source from the content-addressed store, hash-verified

1652 * run every game month, like funding.
1653 */
1654void GeoscapeState::time1Month()
1655{
1656 _game->getSavedGame()->addMonth();
1657
1658 int monthsPassed = _game->getSavedGame()->getMonthsPassed();
1659 bool newRetaliation = false;
1660
1661 // Determine alien mission for this month.
1662 determineAlienMissions();
1663 if (monthsPassed > 5)
1664 determineAlienMissions();
1665
1666 setupTerrorMission();
1667
1668 if (monthsPassed >= 14 - (int)(_game->getSavedGame()->getDifficulty())
1669 || _game->getSavedGame()->isResearched("STR_THE_MARTIAN_SOLUTION"))
1670 {
1671 newRetaliation = true;
1672 }
1673
1674 // Handle Psi-Training and initiate a new retaliation mission, if applicable
1675 bool psi = false;
1676 for(std::vector<Base*>::const_iterator b = _game->getSavedGame()->getBases()->begin(); b != _game->getSavedGame()->getBases()->end(); ++b)
1677 {
1678 if (newRetaliation)
1679 {
1680 for (std::vector<Region*>::iterator i = _game->getSavedGame()->getRegions()->begin(); i != _game->getSavedGame()->getRegions()->end(); ++i)
1681 {
1682 if ((*i)->getRules()->insideRegion((*b)->getLongitude(), (*b)->getLatitude()))
1683 {
1684 if (!_game->getSavedGame()->getAlienMission((*i)->getRules()->getType(), "STR_ALIEN_RETALIATION"))
1685 {
1686 const RuleAlienMission &rule = *_game->getRuleset()->getAlienMission("STR_ALIEN_RETALIATION");
1687 AlienMission *mission = new AlienMission(rule);
1688 mission->setId(_game->getSavedGame()->getId("ALIEN_MISSIONS"));
1689 mission->setRegion((*i)->getRules()->getType(), *_game->getRuleset());
1690 // get races for retaliation missions
1691 std::vector<std::string> races = _game->getRuleset()->getAlienRacesList();
1692 for (std::vector<std::string>::iterator i = races.begin(); i != races.end();)
1693 {
1694 if (_game->getRuleset()->getAlienRace(*i)->canRetaliate())
1695 {
1696 i++;
1697 }
1698 else
1699 {
1700 i = races.erase(i);
1701 }
1702 }
1703 size_t race = RNG::generate(0, races.size()-1);
1704 mission->setRace(races[race]);
1705 mission->start(150);
1706 _game->getSavedGame()->getAlienMissions().push_back(mission);
1707 newRetaliation = false;
1708 }
1709 break;
1710 }
1711 }

Callers

nothing calls this directly

Calls 15

generateFunction · 0.85
percentFunction · 0.85
addMonthMethod · 0.80
getSavedGameMethod · 0.80
getMonthsPassedMethod · 0.80
getDifficultyMethod · 0.80
isResearchedMethod · 0.80
getBasesMethod · 0.80
getRegionsMethod · 0.80
insideRegionMethod · 0.80
setRegionMethod · 0.80
canRetaliateMethod · 0.80

Tested by

no test coverage detected