OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::Soldier Class Reference

Represents a soldier hired by the player. More...

#include <Soldier.h>

Public Member Functions

 Soldier (RuleSoldier *rules, Armor *armor, const std::vector< SoldierNamePool * > *names=0, int id=0)
 Creates a new soldier. More...
 
 ~Soldier ()
 Cleans up the soldier.
 
void load (const YAML::Node &node, const Ruleset *rule, SavedGame *save)
 Loads the soldier from YAML. More...
 
YAML::Node save () const
 Saves the soldier to YAML. More...
 
std::wstring getName (bool statstring=false, unsigned int maxLength=20) const
 Gets the soldier's name. More...
 
void setName (const std::wstring &name)
 Sets the soldier's name. More...
 
CraftgetCraft () const
 Gets the soldier's craft. More...
 
void setCraft (Craft *craft)
 Sets the soldier's craft. More...
 
std::wstring getCraftString (Language *lang) const
 Gets the soldier's craft string. More...
 
std::string getRankString () const
 Gets a string version of the soldier's rank. More...
 
int getRankSprite () const
 Gets a sprite version of the soldier's rank. More...
 
SoldierRank getRank () const
 Gets the soldier's rank. More...
 
void promoteRank ()
 Increase the soldier's military rank.
 
int getMissions () const
 Gets the soldier's missions. More...
 
int getKills () const
 Gets the soldier's kills. More...
 
SoldierGender getGender () const
 Gets the soldier's gender. More...
 
SoldierLook getLook () const
 Gets the soldier's look. More...
 
RuleSoldiergetRules () const
 Gets soldier rules. More...
 
int getId () const
 Gets the soldier's unique ID. More...
 
void addMissionCount ()
 Add a mission to the counter.
 
void addKillCount (int count)
 Add a kill to the counter.
 
UnitStatsgetInitStats ()
 Get pointer to initial stats.
 
UnitStatsgetCurrentStats ()
 Get pointer to current stats.
 
bool isPromoted ()
 Get whether the unit was recently promoted. More...
 
ArmorgetArmor () const
 Gets the soldier armor. More...
 
void setArmor (Armor *armor)
 Sets the soldier armor. More...
 
int getWoundRecovery () const
 Gets the soldier's wound recovery time. More...
 
void setWoundRecovery (int recovery)
 Sets the soldier's wound recovery time. More...
 
void heal ()
 Heals wound recoveries. More...
 
std::vector
< EquipmentLayoutItem * > * 
getEquipmentLayout ()
 Gets the soldier's equipment-layout. More...
 
void trainPsi ()
 Trains a soldier's psychic stats. More...
 
void trainPsi1Day ()
 Trains a soldier's psionic abilities (anytimePsiTraining option). More...
 
bool isInPsiTraining ()
 Returns whether the unit is in psi training or not. More...
 
void setPsiTraining ()
 set the psi training status More...
 
int getImprovement ()
 returns this soldier's psionic improvement score for this month. More...
 
SoldierDeathgetDeath () const
 Gets the soldier death info. More...
 
void die (SoldierDeath *death)
 Kills the soldier. More...
 
void calcStatString (const std::vector< StatString * > &statStrings, bool psiStrengthEval)
 Calculate statString. More...
 

Detailed Description

Represents a soldier hired by the player.

Soldiers have a wide variety of stats that affect their performance during battles.

Constructor & Destructor Documentation

OpenXcom::Soldier::Soldier ( RuleSoldier rules,
Armor armor,
const std::vector< SoldierNamePool * > *  names = 0,
int  id = 0 
)

Creates a new soldier.

Initializes a new soldier, either blank or randomly generated.

Parameters
rulesSoldier ruleset.
armorSoldier armor.
namesList of name pools for soldier generation.
idPointer to unique soldier id for soldier generation.

Member Function Documentation

void OpenXcom::Soldier::calcStatString ( const std::vector< StatString * > &  statStrings,
bool  psiStrengthEval 
)

Calculate statString.

Calculates the soldier's statString.

Parameters
statStringsList of statString rules.
psiStrengthEvalAre psi stats available?
void OpenXcom::Soldier::die ( SoldierDeath death)

Kills the soldier.

Kills the soldier in the Geoscape.

Parameters
deathPointer to death data.
Armor * OpenXcom::Soldier::getArmor ( ) const

Gets the soldier armor.

Returns the unit's current armor.

Returns
Pointer to armor data.
Craft * OpenXcom::Soldier::getCraft ( ) const

Gets the soldier's craft.

Returns the craft the soldier is assigned to.

Returns
Pointer to craft.
std::wstring OpenXcom::Soldier::getCraftString ( Language lang) const

Gets the soldier's craft string.

Returns the soldier's craft string, which is either the soldier's wounded status, the assigned craft name, or none.

Parameters
langLanguage to get strings from.
Returns
Full name.
SoldierDeath * OpenXcom::Soldier::getDeath ( ) const

Gets the soldier death info.

Returns the soldier's death details.

Returns
Pointer to death data. NULL if no death has occured.
std::vector< EquipmentLayoutItem * > * OpenXcom::Soldier::getEquipmentLayout ( )

Gets the soldier's equipment-layout.

Returns the list of EquipmentLayoutItems of a soldier.

Returns
Pointer to the EquipmentLayoutItem list.
SoldierGender OpenXcom::Soldier::getGender ( ) const

Gets the soldier's gender.

Returns the soldier's gender.

Returns
Gender.
int OpenXcom::Soldier::getId ( ) const

Gets the soldier's unique ID.

Returns the soldier's unique ID.

Each soldier can be identified by its ID. (not it's name)

Returns
Unique ID.
int OpenXcom::Soldier::getImprovement ( )

returns this soldier's psionic improvement score for this month.

Returns
score
int OpenXcom::Soldier::getKills ( ) const

Gets the soldier's kills.

Returns the soldier's amount of kills.

Returns
Kills.
SoldierLook OpenXcom::Soldier::getLook ( ) const

Gets the soldier's look.

Returns the soldier's look.

Returns
Look.
int OpenXcom::Soldier::getMissions ( ) const

Gets the soldier's missions.

Returns the soldier's amount of missions.

Returns
Missions.
std::wstring OpenXcom::Soldier::getName ( bool  statstring = false,
unsigned int  maxLength = 20 
) const

Gets the soldier's name.

Returns the soldier's full name (and, optionally, statString).

Parameters
statstringAdd stat string?
maxLengthRestrict length to a certain value.
Returns
Soldier name.
SoldierRank OpenXcom::Soldier::getRank ( ) const

Gets the soldier's rank.

Returns the soldier's military rank.

Returns
Rank enum.
int OpenXcom::Soldier::getRankSprite ( ) const

Gets a sprite version of the soldier's rank.

Returns a graphic representation of the soldier's military rank.

Note
THE MEANING OF LIFE
Returns
Sprite ID for rank.
std::string OpenXcom::Soldier::getRankString ( ) const

Gets a string version of the soldier's rank.

Returns a localizable-string representation of the soldier's military rank.

Returns
String ID for rank.
RuleSoldier * OpenXcom::Soldier::getRules ( ) const

Gets soldier rules.

Returns the soldier's rules.

Returns
rulesoldier
int OpenXcom::Soldier::getWoundRecovery ( ) const

Gets the soldier's wound recovery time.

Returns the amount of time until the soldier is healed.

Returns
Number of days.
void OpenXcom::Soldier::heal ( )

Heals wound recoveries.

Heals soldier wounds.

bool OpenXcom::Soldier::isInPsiTraining ( )

Returns whether the unit is in psi training or not.

returns whether or not the unit is in psi training

Returns
true/false
bool OpenXcom::Soldier::isPromoted ( )

Get whether the unit was recently promoted.

Returns the unit's promotion status and resets it.

Returns
True if recently promoted, False otherwise.
void OpenXcom::Soldier::load ( const YAML::Node &  node,
const Ruleset rule,
SavedGame save 
)

Loads the soldier from YAML.

Loads the soldier from a YAML file.

Parameters
nodeYAML node.
ruleGame ruleset.
savePointer to savegame.
YAML::Node OpenXcom::Soldier::save ( ) const

Saves the soldier to YAML.

Saves the soldier to a YAML file.

Returns
YAML node.
void OpenXcom::Soldier::setArmor ( Armor armor)

Sets the soldier armor.

Changes the unit's current armor.

Parameters
armorPointer to armor data.
void OpenXcom::Soldier::setCraft ( Craft craft)

Sets the soldier's craft.

Assigns the soldier to a new craft.

Parameters
craftPointer to craft.
void OpenXcom::Soldier::setName ( const std::wstring &  name)

Sets the soldier's name.

Changes the soldier's full name.

Parameters
nameSoldier name.
void OpenXcom::Soldier::setPsiTraining ( )

set the psi training status

toggles whether or not the unit is in psi training

void OpenXcom::Soldier::setWoundRecovery ( int  recovery)

Sets the soldier's wound recovery time.

Changes the amount of time until the soldier is healed.

Parameters
recoveryNumber of days.
void OpenXcom::Soldier::trainPsi ( )

Trains a soldier's psychic stats.

Trains a soldier's Psychic abilities after 1 month.

void OpenXcom::Soldier::trainPsi1Day ( )

Trains a soldier's psionic abilities (anytimePsiTraining option).

Trains a soldier's Psychic abilities after 1 day.

(anytimePsiTraining option)


The documentation for this class was generated from the following files: