OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Soldier.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_SOLDIER_H
20 #define OPENXCOM_SOLDIER_H
21 
22 #include <string>
23 #include <yaml-cpp/yaml.h>
24 #include "../Ruleset/Unit.h"
25 #include "../Ruleset/StatString.h"
26 
27 namespace OpenXcom
28 {
29 
30 enum SoldierRank { RANK_ROOKIE, RANK_SQUADDIE, RANK_SERGEANT, RANK_CAPTAIN, RANK_COLONEL, RANK_COMMANDER};
31 enum SoldierGender { GENDER_MALE, GENDER_FEMALE };
32 enum SoldierLook { LOOK_BLONDE, LOOK_BROWNHAIR, LOOK_ORIENTAL, LOOK_AFRICAN };
33 
34 class Craft;
35 class SoldierNamePool;
36 class Ruleset;
37 class RuleSoldier;
38 class Armor;
39 class Language;
40 class EquipmentLayoutItem;
41 class SoldierDeath;
42 class SavedGame;
43 
49 class Soldier
50 {
51 private:
52  std::wstring _name;
53  int _id, _improvement;
54  RuleSoldier *_rules;
55  UnitStats _initialStats, _currentStats;
56  SoldierRank _rank;
57  Craft *_craft;
58  SoldierGender _gender;
59  SoldierLook _look;
60  int _missions, _kills, _recovery;
61  bool _recentlyPromoted, _psiTraining;
62  Armor *_armor;
63  std::vector<EquipmentLayoutItem*> _equipmentLayout;
64  SoldierDeath *_death;
65  std::wstring _statString;
66 public:
68  Soldier(RuleSoldier *rules, Armor *armor, const std::vector<SoldierNamePool*> *names = 0, int id = 0);
70  ~Soldier();
72  void load(const YAML::Node& node, const Ruleset *rule, SavedGame *save);
74  YAML::Node save() const;
76  std::wstring getName(bool statstring = false, unsigned int maxLength = 20) const;
78  void setName(const std::wstring &name);
80  Craft *getCraft() const;
82  void setCraft(Craft *craft);
84  std::wstring getCraftString(Language *lang) const;
86  std::string getRankString() const;
88  int getRankSprite() const;
90  SoldierRank getRank() const;
92  void promoteRank();
94  int getMissions() const;
96  int getKills() const;
98  SoldierGender getGender() const;
100  SoldierLook getLook() const;
102  RuleSoldier *getRules() const;
104  int getId() const;
106  void addMissionCount();
108  void addKillCount(int count);
114  bool isPromoted();
116  Armor *getArmor() const;
118  void setArmor(Armor *armor);
120  int getWoundRecovery() const;
122  void setWoundRecovery(int recovery);
124  void heal();
126  std::vector<EquipmentLayoutItem*> *getEquipmentLayout();
128  void trainPsi();
130  void trainPsi1Day();
132  bool isInPsiTraining();
134  void setPsiTraining();
136  int getImprovement();
138  SoldierDeath *getDeath() const;
140  void die(SoldierDeath *death);
142  void calcStatString(const std::vector<StatString *> &statStrings, bool psiStrengthEval);
143 };
144 
145 }
146 
147 #endif
void addKillCount(int count)
Add a kill to the counter.
Definition: Soldier.cpp:371
bool isPromoted()
Get whether the unit was recently promoted.
Definition: Soldier.cpp:396
Represents a craft stored in a base.
Definition: Craft.h:44
UnitStats * getInitStats()
Get pointer to initial stats.
Definition: Soldier.cpp:379
int getRankSprite() const
Gets a sprite version of the soldier's rank.
Definition: Soldier.cpp:277
void addMissionCount()
Add a mission to the counter.
Definition: Soldier.cpp:363
void setPsiTraining()
set the psi training status
Definition: Soldier.cpp:530
SoldierLook getLook() const
Gets the soldier's look.
Definition: Soldier.cpp:336
void setCraft(Craft *craft)
Sets the soldier's craft.
Definition: Soldier.cpp:215
Stores info about a soldier's death.
Definition: SoldierDeath.h:33
void trainPsi1Day()
Trains a soldier's psionic abilities (anytimePsiTraining option).
Definition: Soldier.cpp:490
std::vector< EquipmentLayoutItem * > * getEquipmentLayout()
Gets the soldier's equipment-layout.
Definition: Soldier.cpp:457
RuleSoldier * getRules() const
Gets soldier rules.
Definition: Soldier.cpp:345
Armor * getArmor() const
Gets the soldier armor.
Definition: Soldier.cpp:407
UnitStats * getCurrentStats()
Get pointer to current stats.
Definition: Soldier.cpp:387
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
bool isInPsiTraining()
Returns whether the unit is in psi training or not.
Definition: Soldier.cpp:522
void trainPsi()
Trains a soldier's psychic stats.
Definition: Soldier.cpp:465
SoldierGender getGender() const
Gets the soldier's gender.
Definition: Soldier.cpp:327
int getWoundRecovery() const
Gets the soldier's wound recovery time.
Definition: Soldier.cpp:425
void setArmor(Armor *armor)
Sets the soldier armor.
Definition: Soldier.cpp:416
SoldierDeath * getDeath() const
Gets the soldier death info.
Definition: Soldier.cpp:548
void heal()
Heals wound recoveries.
Definition: Soldier.cpp:448
void die(SoldierDeath *death)
Kills the soldier.
Definition: Soldier.cpp:557
void setWoundRecovery(int recovery)
Sets the soldier's wound recovery time.
Definition: Soldier.cpp:434
Contains strings used throughout the game for localization.
Definition: Language.h:42
Set of rules and stats for a game.
Definition: Ruleset.h:69
void calcStatString(const std::vector< StatString * > &statStrings, bool psiStrengthEval)
Calculate statString.
Definition: Soldier.cpp:579
void load(const YAML::Node &node, const Ruleset *rule, SavedGame *save)
Loads the soldier from YAML.
Definition: Soldier.cpp:97
std::string getRankString() const
Gets a string version of the soldier's rank.
Definition: Soldier.cpp:250
void setName(const std::wstring &name)
Sets the soldier's name.
Definition: Soldier.cpp:197
Represents a specific type of armor.
Definition: Armor.h:36
Represents a soldier hired by the player.
Definition: Soldier.h:49
This struct holds some plain unit attribute data together.
Definition: Unit.h:32
SoldierRank getRank() const
Gets the soldier's rank.
Definition: Soldier.cpp:287
int getMissions() const
Gets the soldier's missions.
Definition: Soldier.cpp:309
Represents the creation data for a specific type of unit.
Definition: RuleSoldier.h:33
int getId() const
Gets the soldier's unique ID.
Definition: Soldier.cpp:355
YAML::Node save() const
Saves the soldier to YAML.
Definition: Soldier.cpp:134
~Soldier()
Cleans up the soldier.
Definition: Soldier.cpp:82
Craft * getCraft() const
Gets the soldier's craft.
Definition: Soldier.cpp:206
std::wstring getCraftString(Language *lang) const
Gets the soldier's craft string.
Definition: Soldier.cpp:227
int getKills() const
Gets the soldier's kills.
Definition: Soldier.cpp:318
std::wstring getName(bool statstring=false, unsigned int maxLength=20) const
Gets the soldier's name.
Definition: Soldier.cpp:174
Soldier(RuleSoldier *rules, Armor *armor, const std::vector< SoldierNamePool * > *names=0, int id=0)
Creates a new soldier.
Definition: Soldier.cpp:43
int getImprovement()
returns this soldier's psionic improvement score for this month.
Definition: Soldier.cpp:539
void promoteRank()
Increase the soldier's military rank.
Definition: Soldier.cpp:295