19 #ifndef OPENXCOM_RULESET_H
20 #define OPENXCOM_RULESET_H
25 #include <yaml-cpp/yaml.h>
26 #include "../Savegame/GameTime.h"
32 class SoldierNamePool;
36 class RuleBaseFacility;
38 class RuleCraftWeapon;
47 class ArticleDefinition;
50 class RuleManufacture;
52 class AlienDeployment;
54 class RuleAlienMission;
72 std::vector<SoldierNamePool*> _names;
73 std::map<std::string, RuleCountry*> _countries;
74 std::map<std::string, RuleRegion*> _regions;
75 std::map<std::string, RuleBaseFacility*> _facilities;
76 std::map<std::string, RuleCraft*> _crafts;
77 std::map<std::string, RuleCraftWeapon*> _craftWeapons;
78 std::map<std::string, RuleItem*> _items;
79 std::map<std::string, RuleUfo*> _ufos;
80 std::map<std::string, RuleTerrain*> _terrains;
81 std::map<std::string, MapDataSet*> _mapDataSets;
82 std::map<std::string, RuleSoldier*> _soldiers;
83 std::map<std::string, Unit*> _units;
84 std::map<std::string, AlienRace*> _alienRaces;
85 std::map<std::string, AlienDeployment*> _alienDeployments;
86 std::map<std::string, Armor*> _armors;
87 std::map<std::string, ArticleDefinition*> _ufopaediaArticles;
88 std::map<std::string, RuleInventory*> _invs;
89 std::map<std::string, RuleResearch *> _research;
90 std::map<std::string, RuleManufacture *> _manufacture;
91 std::map<std::string, UfoTrajectory *> _ufoTrajectories;
92 std::map<std::string, RuleAlienMission *> _alienMissions;
93 std::map<std::string, MCDPatch *> _MCDPatches;
94 std::vector<std::pair<std::string, ExtraSprites *> > _extraSprites;
95 std::vector<std::pair<std::string, ExtraSounds *> > _extraSounds;
96 std::map<std::string, ExtraStrings *> _extraStrings;
97 std::vector<StatString*> _statStrings;
98 int _costSoldier, _costEngineer, _costScientist, _timePersonnel, _initialFunding;
99 YAML::Node _startingBase;
101 std::vector<std::string> _countriesIndex, _regionsIndex, _facilitiesIndex, _craftsIndex, _craftWeaponsIndex, _itemsIndex, _invsIndex, _ufosIndex;
102 std::vector<std::string> _aliensIndex, _deploymentsIndex, _armorsIndex, _ufopaediaIndex, _researchIndex, _manufactureIndex, _MCDPatchesIndex;
103 std::vector<std::string> _alienMissionsIndex, _terrainIndex, _extraSpritesIndex, _extraSoundsIndex, _extraStringsIndex;
104 std::vector<std::vector<int> > _alienItemLevels;
105 int _modIndex, _facilityListOrder, _craftListOrder, _itemListOrder, _researchListOrder, _manufactureListOrder, _ufopaediaListOrder, _invListOrder;
106 std::vector<std::string> _psiRequirements;
108 void loadFile(
const std::string &filename);
110 void loadFiles(
const std::string &dirname);
112 template <
typename T>
113 T *
loadRule(
const YAML::Node &node, std::map<std::string, T*> *map, std::vector<std::string> *index = 0,
const std::string &key =
"type");
120 void load(
const std::string &source);
124 const std::vector<SoldierNamePool*> &
getPools()
const;
152 const std::vector<std::string> &
getUfosList()
const;
216 std::vector<std::pair<std::string, ExtraSprites *> >
getExtraSprites()
const;
218 std::vector<std::pair<std::string, ExtraSounds *> >
getExtraSounds()
const;
228 const std::vector<std::string> &
getInvsList ()
const;
ArticleDefinition * getUfopaediaArticle(const std::string &name) const
Gets Ufopaedia article definition.
Definition: Ruleset.cpp:951
RuleSoldier * getSoldier(const std::string &name) const
Gets soldier unit rules.
Definition: Ruleset.cpp:826
const std::vector< std::string > & getCraftsList() const
Gets the available crafts.
Definition: Ruleset.cpp:710
std::vector< std::string > getPsiRequirements() const
Gets the research-requirements for Psi-Lab (it's a cache for psiStrengthEval)
Definition: Ruleset.cpp:1320
Ruleset()
Creates a blank ruleset.
Definition: Ruleset.cpp:73
const std::vector< std::string > & getBaseFacilitiesList() const
Gets the available facilities.
Definition: Ruleset.cpp:689
const std::vector< std::string > & getUfopaediaList() const
Gets the available articles.
Definition: Ruleset.cpp:962
int getEngineerCost() const
Gets the cost of an engineer.
Definition: Ruleset.cpp:921
RuleItem * getItem(const std::string &id) const
Gets the ruleset for an item type.
Definition: Ruleset.cpp:741
const std::vector< std::string > & getItemsList() const
Gets the available items.
Definition: Ruleset.cpp:754
std::map< std::string, ExtraStrings * > getExtraStrings() const
Gets the list of external Strings.
Definition: Ruleset.cpp:1179
void load(const std::string &source)
Loads a ruleset from the given source.
Definition: Ruleset.cpp:200
RuleCraftWeapon * getCraftWeapon(const std::string &id) const
Gets the ruleset for a craft weapon type.
Definition: Ruleset.cpp:720
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
const City * locateCity(double lon, double lat) const
Gets the city at the specified coordinates.
Definition: Ruleset.cpp:1115
const std::vector< std::string > & getAlienRacesList() const
Gets the available alien races.
Definition: Ruleset.cpp:859
SavedGame * newSave() const
Generates the starting saved game.
Definition: Ruleset.cpp:567
RuleUfo * getUfo(const std::string &id) const
Gets the ruleset for a UFO type.
Definition: Ruleset.cpp:764
int getPersonnelTime() const
Gets the transfer time of personnel.
Definition: Ruleset.cpp:941
Unit * getUnit(const std::string &name) const
Gets generated unit rules.
Definition: Ruleset.cpp:837
const YAML::Node & getStartingBase()
Gets the Defined starting base.
Definition: Ruleset.cpp:1142
std::vector< StatString * > getStatStrings() const
Gets the list of StatStrings.
Definition: Ruleset.cpp:1188
const std::vector< std::string > & getTerrainList() const
Gets the available terrains.
Definition: Ruleset.cpp:785
const std::vector< std::string > & getInvsList() const
Returns the sorted list of inventories.
Definition: Ruleset.cpp:991
RuleTerrain * getTerrain(const std::string &name) const
Gets terrains for battlescape games.
Definition: Ruleset.cpp:795
RuleCountry * getCountry(const std::string &id) const
Gets the ruleset for a country type.
Definition: Ruleset.cpp:636
Soldier * genSoldier(SavedGame *save) const
Generates a new soldier.
Definition: Ruleset.cpp:1330
const RuleAlienMission * getAlienMission(const std::string &id) const
Gets the ruleset for a specific alien mission.
Definition: Ruleset.cpp:1074
const std::vector< SoldierNamePool * > & getPools() const
Gets the pool list for soldier names.
Definition: Ruleset.cpp:626
Represents a specific type of item.
Definition: RuleItem.h:41
Armor * getArmor(const std::string &name) const
Gets armor rules.
Definition: Ruleset.cpp:890
Set of rules and stats for a game.
Definition: Ruleset.h:69
Represents a specific race "family", or a "main race" if you wish.
Definition: AlienRace.h:35
RuleBaseFacility * getBaseFacility(const std::string &id) const
Gets the ruleset for a facility type.
Definition: Ruleset.cpp:678
Holds information about a specific trajectory.
Definition: UfoTrajectory.h:49
RuleCraft * getCraft(const std::string &id) const
Gets the ruleset for a craft type.
Definition: Ruleset.cpp:699
const std::vector< std::string > & getArmorsList() const
Gets the available armors.
Definition: Ruleset.cpp:901
Stores the current ingame time/date according to GMT.
Definition: GameTime.h:40
Represents a specific type of armor.
Definition: Armor.h:36
Represents a soldier hired by the player.
Definition: Soldier.h:49
std::vector< OpenXcom::RuleBaseFacility * > getCustomBaseFacilities() const
Gets facilities for custom bases.
Definition: Ruleset.cpp:1043
const std::vector< std::string > & getDeploymentsList() const
Gets the available alien deployments.
Definition: Ruleset.cpp:880
int getSoldierCost() const
Gets the cost of a soldier.
Definition: Ruleset.cpp:911
AlienDeployment * getDeployment(const std::string &name) const
Gets deployment rules.
Definition: Ruleset.cpp:869
const std::vector< std::string > & getUfosList() const
Gets the available UFOs.
Definition: Ruleset.cpp:775
Represents a specific type of craft.
Definition: RuleCraft.h:38
Represents one research project.
Definition: RuleResearch.h:40
std::vector< std::pair< std::string, ExtraSprites * > > getExtraSprites() const
Gets the list of external Sprites.
Definition: Ruleset.cpp:1162
RuleRegion * getRegion(const std::string &id) const
Gets the ruleset for a region type.
Definition: Ruleset.cpp:657
Represents a city of the world.
Definition: City.h:32
std::map< std::string, RuleInventory * > * getInventories()
Gets the inventory list.
Definition: Ruleset.cpp:971
Stores fixed information about a mission type.
Definition: RuleAlienMission.h:61
ArticleDefinition is the base class for all article types.
Definition: ArticleDefinition.h:49
T * loadRule(const YAML::Node &node, std::map< std::string, T * > *map, std::vector< std::string > *index=0, const std::string &key="type")
Loads a ruleset element.
Definition: Ruleset.cpp:522
RuleResearch * getResearch(const std::string &id) const
Gets the ruleset for a specific research project.
Definition: Ruleset.cpp:1001
An MCD data Patch.
Definition: MCDPatch.h:31
void loadFile(const std::string &filename)
Loads a ruleset from a YAML file.
Definition: Ruleset.cpp:214
void sortLists()
Sorts all our lists according to their weight.
Definition: Ruleset.cpp:1303
Represents the information needed to manufacture an object.
Definition: RuleManufacture.h:32
AlienRace * getAlienRace(const std::string &name) const
Gets alien race rules.
Definition: Ruleset.cpp:848
Represents the creation data for a specific type of unit.
Definition: RuleSoldier.h:33
const std::vector< std::string > & getCraftWeaponsList() const
Gets the available craft weapons.
Definition: Ruleset.cpp:731
const std::vector< std::vector< int > > & getAlienItemLevels() const
Gets the alien item level table.
Definition: Ruleset.cpp:1133
MapDataSet * getMapDataSet(const std::string &name)
Gets mapdatafile for battlescape games.
Definition: Ruleset.cpp:806
Represents a specific type of Alien Deployment.
Definition: AlienDeployment.h:55
const std::vector< std::string > & getManufactureList() const
Gets the list of all manufacture projects.
Definition: Ruleset.cpp:1031
void loadFiles(const std::string &dirname)
Loads all ruleset files from a directory.
Definition: Ruleset.cpp:503
Represents a specific type of UFO.
Definition: RuleUfo.h:37
Represents a specific funding country.
Definition: RuleCountry.h:33
int getScientistCost() const
Gets the cost of a scientist.
Definition: Ruleset.cpp:931
Represents a specific type of Battlescape Terrain.
Definition: RuleTerrain.h:41
const std::vector< std::string > & getCountriesList() const
Gets the available countries.
Definition: Ruleset.cpp:647
RuleInventory * getInventory(const std::string &id) const
Gets the ruleset for a specific inventory.
Definition: Ruleset.cpp:981
MCDPatch * getMCDPatch(const std::string name) const
Gets an MCDPatch.
Definition: Ruleset.cpp:1152
Represents a specific region of the world.
Definition: RuleRegion.h:65
const std::vector< std::string > & getResearchList() const
Gets the list of all research projects.
Definition: Ruleset.cpp:1011
RuleManufacture * getManufacture(const std::string &id) const
Gets the ruleset for a specific manufacture project.
Definition: Ruleset.cpp:1021
Represents a Terrain Map Datafile.
Definition: MapDataSet.h:40
const std::vector< std::string > & getRegionsList() const
Gets the available regions.
Definition: Ruleset.cpp:668
const UfoTrajectory * getUfoTrajectory(const std::string &id) const
Gets a specific UfoTrajectory.
Definition: Ruleset.cpp:1063
const std::vector< std::string > & getAlienMissionList() const
Gets the list of all alien missions.
Definition: Ruleset.cpp:1084
~Ruleset()
Cleans up the ruleset.
Definition: Ruleset.cpp:92
Represents a specific type of craft weapon.
Definition: RuleCraftWeapon.h:35
std::vector< std::pair< std::string, ExtraSounds * > > getExtraSounds() const
Gets the list of external Sounds.
Definition: Ruleset.cpp:1171
Represents the static data for a unit that is generated on the battlescape, this includes: HWPs...
Definition: Unit.h:50
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:44
Represents a specific type of base facility.
Definition: RuleBaseFacility.h:35