OpenXcom  1.0
Open-source clone of the original X-Com
AlienStrategy.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <yaml-cpp/yaml.h>
21 #include "WeightedOptions.h"
22 
23 namespace OpenXcom
24 {
25 
26 class Mod;
27 
32 {
33 public:
35  AlienStrategy();
39  void init(const Mod *mod);
41  void load(const YAML::Node& node);
43  YAML::Node save() const;
45  std::string chooseRandomRegion(const Mod *mod);
47  std::string chooseRandomMission(const std::string &region) const;
49  bool removeMission(const std::string &region, const std::string &mission);
51  int getMissionsRun(const std::string &varName);
53  void addMissionRun(const std::string &varName);
55  void addMissionLocation(const std::string &varName, const std::string &regionName, int zoneNumber, int maximum);
57  bool validMissionLocation(const std::string &varName, const std::string &regionName, int zoneNumber);
59  bool validMissionRegion(const std::string &regionName);
60 private:
62  WeightedOptions _regionChances;
64  std::map<std::string, WeightedOptions*> _regionMissions;
65 
66  // Disable copy and assignments.
68  AlienStrategy &operator=(const AlienStrategy &);
69  std::map<std::string, int> _missionRuns;
70  std::map<std::string, std::vector<std::pair<std::string, int> > > _missionLocations;
71 
72 };
73 
74 }
Stores the information about alien strategy.
Definition: AlienStrategy.h:31
std::string chooseRandomMission(const std::string &region) const
Choose a random mission for a region.
Definition: AlienStrategy.cpp:145
~AlienStrategy()
Free resources used by the AlienStrategy.
Definition: AlienStrategy.cpp:42
void addMissionRun(const std::string &varName)
Increments the number of missions run labelled as "varName".
Definition: AlienStrategy.cpp:189
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
YAML::Node save() const
Saves the data to YAML.
Definition: AlienStrategy.cpp:98
int getMissionsRun(const std::string &varName)
Checks the number of missions run labelled as "varName".
Definition: AlienStrategy.cpp:178
bool validMissionLocation(const std::string &varName, const std::string &regionName, int zoneNumber)
Checks that a given mission location (city or whatever) isn&#39;t stored in our list of previously attack...
Definition: AlienStrategy.cpp:220
void load(const YAML::Node &node)
Loads the data from YAML.
Definition: AlienStrategy.cpp:71
void addMissionLocation(const std::string &varName, const std::string &regionName, int zoneNumber, int maximum)
Adds a mission location to our storage array.
Definition: AlienStrategy.cpp:203
std::string chooseRandomRegion(const Mod *mod)
Choose a random region for a regular mission.
Definition: AlienStrategy.cpp:119
void init(const Mod *mod)
Initialize values according to the rules.
Definition: AlienStrategy.cpp:55
bool removeMission(const std::string &region, const std::string &mission)
Remove a region and mission from the list of posibilities.
Definition: AlienStrategy.cpp:158
bool validMissionRegion(const std::string &regionName)
Checks that a given region appears in our strategy table.
Definition: AlienStrategy.cpp:240
Holds pairs of relative weights and IDs.
Definition: WeightedOptions.h:33
AlienStrategy()
Create an AlienStrategy with no data.
Definition: AlienStrategy.cpp:34
Definition: BaseInfoState.cpp:40