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 44 /** 45 * Represents a soldier hired by the player. 46 * Soldiers have a wide variety of stats that affect 47 * their performance during battles. 48 */ 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: 67 /// Creates a new soldier. 68 Soldier(RuleSoldier *rules, Armor *armor, const std::vector<SoldierNamePool*> *names = 0, int id = 0); 69 /// Cleans up the soldier. 70 ~Soldier(); 71 /// Loads the soldier from YAML. 72 void load(const YAML::Node& node, const Ruleset *rule, SavedGame *save); 73 /// Saves the soldier to YAML. 74 YAML::Node save() const; 75 /// Gets the soldier's name. 76 std::wstring getName(bool statstring = false, unsigned int maxLength = 20) const; 77 /// Sets the soldier's name. 78 void setName(const std::wstring &name); 79 /// Gets the soldier's craft. 80 Craft *getCraft() const; 81 /// Sets the soldier's craft. 82 void setCraft(Craft *craft); 83 /// Gets the soldier's craft string. 84 std::wstring getCraftString(Language *lang) const; 85 /// Gets a string version of the soldier's rank. 86 std::string getRankString() const; 87 /// Gets a sprite version of the soldier's rank. 88 int getRankSprite() const; 89 /// Gets the soldier's rank. 90 SoldierRank getRank() const; 91 /// Increase the soldier's military rank. 92 void promoteRank(); 93 /// Gets the soldier's missions. 94 int getMissions() const; 95 /// Gets the soldier's kills. 96 int getKills() const; 97 /// Gets the soldier's gender. 98 SoldierGender getGender() const; 99 /// Gets the soldier's look. 100 SoldierLook getLook() const; 101 /// Gets soldier rules. 102 RuleSoldier *getRules() const; 103 /// Gets the soldier's unique ID. 104 int getId() const; 105 /// Add a mission to the counter. 106 void addMissionCount(); 107 /// Add a kill to the counter. 108 void addKillCount(int count); 109 /// Get pointer to initial stats. 110 UnitStats *getInitStats(); 111 /// Get pointer to current stats. 112 UnitStats *getCurrentStats(); 113 /// Get whether the unit was recently promoted. 114 bool isPromoted(); 115 /// Gets the soldier armor. 116 Armor *getArmor() const; 117 /// Sets the soldier armor. 118 void setArmor(Armor *armor); 119 /// Gets the soldier's wound recovery time. 120 int getWoundRecovery() const; 121 /// Sets the soldier's wound recovery time. 122 void setWoundRecovery(int recovery); 123 /// Heals wound recoveries. 124 void heal(); 125 /// Gets the soldier's equipment-layout. 126 std::vector<EquipmentLayoutItem*> *getEquipmentLayout(); 127 /// Trains a soldier's psychic stats 128 void trainPsi(); 129 /// Trains a soldier's psionic abilities (anytimePsiTraining option). 130 void trainPsi1Day(); 131 /// Returns whether the unit is in psi training or not 132 bool isInPsiTraining(); 133 /// set the psi training status 134 void setPsiTraining(); 135 /// returns this soldier's psionic improvement score for this month. 136 int getImprovement(); 137 /// Gets the soldier death info. 138 SoldierDeath *getDeath() const; 139 /// Kills the soldier. 140 void die(SoldierDeath *death); 141 /// Calculate statString. 142 void calcStatString(const std::vector<StatString *> &statStrings, bool psiStrengthEval); 143 }; 144 145 } 146 147 #endif 148