OpenXcom  1.0
Open-source clone of the original X-Com
RuleMissionScript.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 <string>
21 #include <vector>
22 #include <map>
23 #include <yaml-cpp/yaml.h>
24 #include "../Savegame/WeightedOptions.h"
25 
26 namespace OpenXcom
27 {
28 enum GenerationType { GEN_REGION, GEN_MISSION, GEN_RACE };
29 class WeightedOptions;
31 {
32 private:
33  std::string _type, _varName;
34  int _firstMonth, _lastMonth, _label, _executionOdds, _targetBaseOdds, _minDifficulty, _maxRuns, _avoidRepeats, _delay;
35  std::vector<int> _conditionals;
36  std::vector<std::pair<size_t, WeightedOptions*> > _regionWeights, _missionWeights, _raceWeights;
37  std::map<std::string, bool> _researchTriggers;
38  bool _useTable, _siteType;
39 public:
41  RuleMissionScript(const std::string &type);
45  void load(const YAML::Node& node);
47  std::string getType() const;
49  std::string getVarName() const;
51  std::set<std::string> getAllMissionTypes() const;
53  std::vector<std::string> getRegions(const int month) const;
55  std::vector<std::string> getMissionTypes(const int month) const;
57  int getFirstMonth() const;
59  int getLastMonth() const;
61  int getLabel() const;
63  int getExecutionOdds() const;
65  int getTargetBaseOdds() const;
67  int getMinDifficulty() const;
69  int getMaxRuns() const;
71  int getRepeatAvoidance() const;
73  int getDelay() const;
75  const std::vector<int> &getConditionals() const;
77  bool hasRaceWeights() const;
79  bool hasMissionWeights() const;
81  bool hasRegionWeights() const;
83  const std::map<std::string, bool> &getResearchTriggers() const;
85  bool getUseTable() const;
87  void setSiteType(const bool siteType);
89  bool getSiteType() const;
91  std::string generate(const size_t monthsPassed, const GenerationType type) const;
92 
93 };
94 
95 }
const std::vector< int > & getConditionals() const
Gets the list of conditions this command requires in order to run.
Definition: RuleMissionScript.cpp:191
const std::map< std::string, bool > & getResearchTriggers() const
Gets the research triggers that may apply to this command.
Definition: RuleMissionScript.cpp:223
~RuleMissionScript()
Deletes a mission script.
Definition: RuleMissionScript.cpp:38
bool hasRegionWeights() const
Does this command have region weights?
Definition: RuleMissionScript.cpp:215
void load(const YAML::Node &node)
Loads a mission script from yaml.
Definition: RuleMissionScript.cpp:58
std::string generate(const size_t monthsPassed, const GenerationType type) const
Generates either a region, a mission, or a race based on the month.
Definition: RuleMissionScript.cpp:317
std::vector< std::string > getRegions(const int month) const
Gets a list of the regions in this command&#39;s region weights for a given month.
Definition: RuleMissionScript.cpp:290
std::vector< std::string > getMissionTypes(const int month) const
Gets a list of the mission types in this command&#39;s mission weights for a given month.
Definition: RuleMissionScript.cpp:265
int getExecutionOdds() const
Gets the odds of this command executing.
Definition: RuleMissionScript.cpp:143
void setSiteType(const bool siteType)
Sets this script to a terror mission type command or not.
Definition: RuleMissionScript.cpp:334
bool hasMissionWeights() const
Does this command have mission weights?
Definition: RuleMissionScript.cpp:207
bool getSiteType() const
Checks if this is a terror-type mission or not.
Definition: RuleMissionScript.cpp:342
std::string getVarName() const
Gets the name of the variable to use for keeping track of... things.
Definition: RuleMissionScript.cpp:239
bool getUseTable() const
Delete this mission from the table? stops it coming up again in random selection, but NOT if a missio...
Definition: RuleMissionScript.cpp:231
int getFirstMonth() const
Gets the first month this command will run.
Definition: RuleMissionScript.cpp:119
int getLastMonth() const
Gets the last month this command will run.
Definition: RuleMissionScript.cpp:127
int getMinDifficulty() const
Gets the minimum difficulty for this command to run.
Definition: RuleMissionScript.cpp:159
int getLabel() const
Gets the label of this command, used for conditionals.
Definition: RuleMissionScript.cpp:135
int getTargetBaseOdds() const
Gets the odds of this mission targetting an xcom base.
Definition: RuleMissionScript.cpp:151
Definition: RuleMissionScript.h:30
std::string getType() const
Gets the name of the script command.
Definition: RuleMissionScript.cpp:111
int getDelay() const
Gets the number of minutes to delay spawning of the first wave of this mission, overrides the spawn d...
Definition: RuleMissionScript.cpp:183
std::set< std::string > getAllMissionTypes() const
Gets a complete and unique list of all the mission types contained within this command.
Definition: RuleMissionScript.cpp:247
int getRepeatAvoidance() const
Gets how many previous mission sites to keep track of (to avoid using them again) ...
Definition: RuleMissionScript.cpp:175
RuleMissionScript(const std::string &type)
Creates a new mission script.
Definition: RuleMissionScript.cpp:29
int getMaxRuns() const
Gets the maximum number of times to run a command with this varName.
Definition: RuleMissionScript.cpp:167
Definition: BaseInfoState.cpp:40
bool hasRaceWeights() const
Does this command have raceWeights?
Definition: RuleMissionScript.cpp:199