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;
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(const YAML::Node& node);
88  SoldierDiary();
90  ~SoldierDiary();
92  void load(const YAML::Node& node);
94  YAML::Node save() const;
96  void updateDiary(BattleUnitStatistics*, std::vector<MissionStatistics*>*, Mod*);
98  std::map<std::string, int> getAlienRankTotal();
100  std::map<std::string, int> getAlienRaceTotal();
102  std::map<std::string, int> getWeaponTotal();
104  std::map<std::string, int> getWeaponAmmoTotal();
106  std::map<std::string, int> getRegionTotal(std::vector<MissionStatistics*>*) const;
108  std::map<std::string, int> getCountryTotal(std::vector<MissionStatistics*>*) const;
110  std::map<std::string, int> getTypeTotal(std::vector<MissionStatistics*>*) const;
112  std::map<std::string, int> getUFOTotal(std::vector<MissionStatistics*>*) const;
114  int getKillTotal() const;
116  int getMissionTotal() const;
118  int getWinTotal(std::vector<MissionStatistics*>*) const;
120  int getStunTotal() const;
122  int getPanickTotal() const;
124  int getControlTotal() const;
126  int getDaysWoundedTotal() const;
128  std::vector<SoldierCommendations*> *getSoldierCommendations();
130  bool manageCommendations(Mod*, std::vector<MissionStatistics*>*);
132  void addMonthlyService();
134  int getMonthsService() const;
136  std::vector<int> &getMissionIdList();
138  std::vector<BattleUnitKills*> &getKills();
140  void awardOriginalEightCommendation();
142  void awardBestOfRank(int score);
144  void awardBestOverall(int score);
146  void awardPostMortemKill(int kills);
148  int getShotsFiredTotal() const;
150  int getShotsLandedTotal() const;
152  int getAccuracy() const;
154  int getTrapKillTotal(Mod*) const;
156  int getReactionFireKillTotal(Mod*) const;
158  int getTerrorMissionTotal(std::vector<MissionStatistics*>*) const;
160  int getNightMissionTotal(std::vector<MissionStatistics*>*) const;
162  int getNightTerrorMissionTotal(std::vector<MissionStatistics*>*) const;
164  int getBaseDefenseMissionTotal(std::vector<MissionStatistics*>*) const;
166  int getAlienBaseAssaultTotal(std::vector<MissionStatistics*>*) const;
168  int getImportantMissionTotal(std::vector<MissionStatistics*>*) const;
170  int getScoreTotal(std::vector<MissionStatistics*>*) const;
172  int getValiantCruxTotal(std::vector<MissionStatistics*>*) const;
174  int getLootValueTotal(std::vector<MissionStatistics*>*) const;
175 };
176 
177 }
~SoldierCommendations()
Cleans up the commendation.
Definition: SoldierDiary.cpp:1205
std::string getType() const
Get commendation name.
Definition: SoldierDiary.cpp:1238
Definition: SoldierDiary.h:70
void addDecoration()
Increment decoration level.
Definition: SoldierDiary.cpp:1304
void load(const YAML::Node &node)
Loads the commendation information from YAML.
Definition: SoldierDiary.cpp:1213
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:1256
std::string getDecorationDescription() const
Get the commendation&#39;s decoration description.
Definition: SoldierDiary.cpp:1267
void makeOld()
Set the commendation newness to false.
Definition: SoldierDiary.cpp:1295
std::string getNoun() const
Get commendation noun.
Definition: SoldierDiary.cpp:1247
SoldierCommendations(const YAML::Node &node)
Creates a new commendation and loads its contents from YAML.
Definition: SoldierDiary.cpp:1190
bool isNew() const
Get the newness of the commendation.
Definition: SoldierDiary.cpp:1287
Container for battle unit statistics.
Definition: BattleUnitStatistics.h:304
YAML::Node save() const
Saves the commendation information to YAML.
Definition: SoldierDiary.cpp:1225
int getDecorationLevelInt() const
Get the commendation&#39;s decoration level&#39;s int.
Definition: SoldierDiary.cpp:1278
Each entry will be its own commendation.
Definition: SoldierDiary.h:34
Definition: BaseInfoState.cpp:40