OpenXcom  1.0
Open-source clone of the original X-Com
SoldierDiary.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 <yaml-cpp/yaml.h>
21 #include "BattleUnit.h"
22 #include "SavedGame.h"
23 #include "../Mod/Mod.h"
24 
25 namespace OpenXcom
26 {
27 
28 class Mod;
29 struct BattleUnitKills;
30 
35 {
36 private:
37  std::string _type, _noun;
38  int _decorationLevel;
39  bool _isNew;
40 public:
42  SoldierCommendations(const YAML::Node& node);
44  SoldierCommendations(std::string commendationName, std::string noun = "noNoun");
48  void load(const YAML::Node& node);
50  YAML::Node save() const;
52  std::string getType() const;
54  std::string getNoun() const;
56  std::string getDecorationLevelName(int skipCounter) const;
58  std::string getDecorationDescription() const;
60  int getDecorationLevelInt() const;
62  bool isNew() const;
64  void makeOld();
66  // Sets _isNew to true.
67  void addDecoration();
68 };
69 
71 {
72 private:
73  std::vector<SoldierCommendations*> _commendations;
74  std::vector<BattleUnitKills*> _killList;
75  std::vector<int> _missionIdList;
76  int _daysWoundedTotal, _totalShotByFriendlyCounter, _totalShotFriendlyCounter, _loneSurvivorTotal, _monthsService, _unconciousTotal, _shotAtCounterTotal,
77  _hitCounterTotal, _ironManTotal, _longDistanceHitCounterTotal, _lowAccuracyHitCounterTotal, _shotsFiredCounterTotal, _shotsLandedCounterTotal,
78  _shotAtCounter10in1Mission, _hitCounter5in1Mission, _timesWoundedTotal, _KIA, _allAliensKilledTotal, _allAliensStunnedTotal,
79  _woundsHealedTotal, _allUFOs, _allMissionTypes, _statGainTotal, _revivedUnitTotal, _wholeMedikitTotal, _braveryGainTotal, _bestOfRank, _MIA,
80  _martyrKillsTotal, _postMortemKills, _slaveKillsTotal, _bestSoldier, _revivedSoldierTotal, _revivedHostileTotal, _revivedNeutralTotal;
81  bool _globeTrotter;
82  void manageModularCommendations(std::map<std::string, int> &nextCommendationLevel, std::map<std::string, int> &modularCommendations, std::pair<std::string, int> statTotal, int criteria);
83  void awardCommendation(const std::string& type, const std::string& noun = "noNoun");
84 public:
86  SoldierDiary();
88  ~SoldierDiary();
90  void load(const YAML::Node& node, const Mod *mod);
92  YAML::Node save() const;
94  void updateDiary(BattleUnitStatistics*, std::vector<MissionStatistics*>*, Mod*);
96  std::map<std::string, int> getAlienRankTotal();
98  std::map<std::string, int> getAlienRaceTotal();
100  std::map<std::string, int> getWeaponTotal();
102  std::map<std::string, int> getWeaponAmmoTotal();
104  std::map<std::string, int> getRegionTotal(std::vector<MissionStatistics*>*) const;
106  std::map<std::string, int> getCountryTotal(std::vector<MissionStatistics*>*) const;
108  std::map<std::string, int> getTypeTotal(std::vector<MissionStatistics*>*) const;
110  std::map<std::string, int> getUFOTotal(std::vector<MissionStatistics*>*) const;
112  int getKillTotal() const;
114  int getMissionTotal() const;
116  int getWinTotal(std::vector<MissionStatistics*>*) const;
118  int getStunTotal() const;
120  int getPanickTotal() const;
122  int getControlTotal() const;
124  int getDaysWoundedTotal() const;
126  std::vector<SoldierCommendations*> *getSoldierCommendations();
128  bool manageCommendations(Mod*, std::vector<MissionStatistics*>*);
130  void addMonthlyService();
132  int getMonthsService() const;
134  std::vector<int> &getMissionIdList();
136  std::vector<BattleUnitKills*> &getKills();
140  void awardBestOfRank(int score);
142  void awardBestOverall(int score);
144  void awardPostMortemKill(int kills);
146  int getShotsFiredTotal() const;
148  int getShotsLandedTotal() const;
150  int getAccuracy() const;
152  int getTrapKillTotal(Mod*) const;
154  int getReactionFireKillTotal(Mod*) const;
156  int getTerrorMissionTotal(std::vector<MissionStatistics*>*) const;
158  int getNightMissionTotal(std::vector<MissionStatistics*>*) const;
160  int getNightTerrorMissionTotal(std::vector<MissionStatistics*>*) const;
162  int getBaseDefenseMissionTotal(std::vector<MissionStatistics*>*) const;
164  int getAlienBaseAssaultTotal(std::vector<MissionStatistics*>*) const;
166  int getImportantMissionTotal(std::vector<MissionStatistics*>*) const;
168  int getScoreTotal(std::vector<MissionStatistics*>*) const;
170  int getValiantCruxTotal(std::vector<MissionStatistics*>*) const;
172  int getLootValueTotal(std::vector<MissionStatistics*>*) const;
173 };
174 
175 }
~SoldierCommendations()
Cleans up the commendation.
Definition: SoldierDiary.cpp:1223
int getScoreTotal(std::vector< MissionStatistics *> *) const
Get the total score.
Definition: SoldierDiary.cpp:1142
std::string getType() const
Get commendation name.
Definition: SoldierDiary.cpp:1256
Definition: SoldierDiary.h:70
int getImportantMissionTotal(std::vector< MissionStatistics *> *) const
Get the total number of important missions.
Definition: SoldierDiary.cpp:1117
void addDecoration()
Increment decoration level.
Definition: SoldierDiary.cpp:1322
int getPanickTotal() const
Get the total number of psi panicks.
Definition: SoldierDiary.cpp:833
void load(const YAML::Node &node)
Loads the commendation information from YAML.
Definition: SoldierDiary.cpp:1231
SoldierDiary()
Construct a diary.
Definition: SoldierDiary.cpp:32
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
std::string getDecorationLevelName(int skipCounter) const
Get the commendation&#39;s decoration level&#39;s name.
Definition: SoldierDiary.cpp:1274
std::string getDecorationDescription() const
Get the commendation&#39;s decoration description.
Definition: SoldierDiary.cpp:1285
int getWinTotal(std::vector< MissionStatistics *> *) const
Get the total number of wins.
Definition: SoldierDiary.cpp:791
void load(const YAML::Node &node, const Mod *mod)
Load a diary.
Definition: SoldierDiary.cpp:61
int getShotsLandedTotal() const
Get the total number of shots landed on target.
Definition: SoldierDiary.cpp:934
int getAlienBaseAssaultTotal(std::vector< MissionStatistics *> *) const
Get the total number of alien base assaults.
Definition: SoldierDiary.cpp:1092
void updateDiary(BattleUnitStatistics *, std::vector< MissionStatistics *> *, Mod *)
Update the diary statistics.
Definition: SoldierDiary.cpp:176
int getTerrorMissionTotal(std::vector< MissionStatistics *> *) const
Get the total number of terror missions.
Definition: SoldierDiary.cpp:991
std::vector< SoldierCommendations * > * getSoldierCommendations()
Get the solder&#39;s commendations.
Definition: SoldierDiary.cpp:255
void makeOld()
Set the commendation newness to false.
Definition: SoldierDiary.cpp:1313
int getValiantCruxTotal(std::vector< MissionStatistics *> *) const
Get the Valiant Crux total.
Definition: SoldierDiary.cpp:1164
std::map< std::string, int > getCountryTotal(std::vector< MissionStatistics *> *) const
Get the list of missions, mapped by country.
Definition: SoldierDiary.cpp:699
int getControlTotal() const
Get the total number of psi mind controls.
Definition: SoldierDiary.cpp:851
int getShotsFiredTotal() const
Get the total number of shots fired.
Definition: SoldierDiary.cpp:926
int getTrapKillTotal(Mod *) const
Get the total number of trap kills.
Definition: SoldierDiary.cpp:952
void awardOriginalEightCommendation()
Award special commendation to the original 8 soldiers.
Definition: SoldierDiary.cpp:893
void awardBestOfRank(int score)
Award post-humous best-of rank commendation.
Definition: SoldierDiary.cpp:902
std::string getNoun() const
Get commendation noun.
Definition: SoldierDiary.cpp:1265
int getMonthsService() const
Get the total months in service.
Definition: SoldierDiary.cpp:885
SoldierCommendations(const YAML::Node &node)
Creates a new commendation and loads its contents from YAML.
Definition: SoldierDiary.cpp:1208
std::map< std::string, int > getAlienRaceTotal()
Get the list of kills, mapped by race.
Definition: SoldierDiary.cpp:635
~SoldierDiary()
Deconstruct a diary.
Definition: SoldierDiary.cpp:45
void awardBestOverall(int score)
Award post-humous best overall commendation.
Definition: SoldierDiary.cpp:910
int getReactionFireKillTotal(Mod *) const
Get the total number of reaction fire kills.
Definition: SoldierDiary.cpp:971
int getAccuracy() const
Get the soldier&#39;s accuracy.
Definition: SoldierDiary.cpp:942
bool isNew() const
Get the newness of the commendation.
Definition: SoldierDiary.cpp:1305
int getDaysWoundedTotal() const
Get the total number of days wounded.
Definition: SoldierDiary.cpp:869
int getStunTotal() const
Get the total number of stuns.
Definition: SoldierDiary.cpp:815
int getKillTotal() const
Get the total number of kills.
Definition: SoldierDiary.cpp:764
int getLootValueTotal(std::vector< MissionStatistics *> *) const
Get the loot value total.
Definition: SoldierDiary.cpp:1186
int getNightMissionTotal(std::vector< MissionStatistics *> *) const
Get the total number of night missions.
Definition: SoldierDiary.cpp:1017
std::vector< int > & getMissionIdList()
Get the mission id list.
Definition: SoldierDiary.cpp:604
std::map< std::string, int > getTypeTotal(std::vector< MissionStatistics *> *) const
Get the list of missions, mapped by type.
Definition: SoldierDiary.cpp:721
int getNightTerrorMissionTotal(std::vector< MissionStatistics *> *) const
Get the total number of night terror missions.
Definition: SoldierDiary.cpp:1042
Container for battle unit statistics.
Definition: BattleUnitStatistics.h:305
YAML::Node save() const
Saves the commendation information to YAML.
Definition: SoldierDiary.cpp:1243
void addMonthlyService()
Increment the soldier&#39;s service time.
Definition: SoldierDiary.cpp:877
int getDecorationLevelInt() const
Get the commendation&#39;s decoration level&#39;s int.
Definition: SoldierDiary.cpp:1296
void awardPostMortemKill(int kills)
Award post-humous kills commendation.
Definition: SoldierDiary.cpp:918
std::map< std::string, int > getAlienRankTotal()
Get the list of kills, mapped by rank.
Definition: SoldierDiary.cpp:622
std::map< std::string, int > getWeaponTotal()
Get the list of kills, mapped by weapon used.
Definition: SoldierDiary.cpp:648
bool manageCommendations(Mod *, std::vector< MissionStatistics *> *)
Manage commendations, return true if a medal is awarded.
Definition: SoldierDiary.cpp:265
std::map< std::string, int > getUFOTotal(std::vector< MissionStatistics *> *) const
Get the list of missions, mapped by UFO.
Definition: SoldierDiary.cpp:743
std::map< std::string, int > getWeaponAmmoTotal()
Get the list of kills, mapped by weapon ammo used.
Definition: SoldierDiary.cpp:662
std::vector< BattleUnitKills * > & getKills()
Get the kill list.
Definition: SoldierDiary.cpp:613
int getBaseDefenseMissionTotal(std::vector< MissionStatistics *> *) const
Get the total number of base defense missions.
Definition: SoldierDiary.cpp:1067
Each entry will be its own commendation.
Definition: SoldierDiary.h:34
int getMissionTotal() const
Get the total number of missions.
Definition: SoldierDiary.cpp:782
std::map< std::string, int > getRegionTotal(std::vector< MissionStatistics *> *) const
Get the list of missions, mapped by region.
Definition: SoldierDiary.cpp:677
YAML::Node save() const
Save a diary.
Definition: SoldierDiary.cpp:126
Definition: BaseInfoState.cpp:40