BF2MC-Matchmaker
playerstats.h
1 #ifndef BATTLEFIELD_PLAYERSTATS_H
2 #define BATTLEFIELD_PLAYERSTATS_H
3 
4 #include <cstdint>
5 #include <vector>
6 #include <battlefield.h>
7 #include <unordered_map>
8 
9 namespace Battlefield
10 {
11  class GameStatPlayer;
12 
17  {
18  private:
19  int32_t _score = 0;
20  uint32_t _ran = 1;
21  uint32_t _pph = 0;
22  uint32_t _kills = 0;
23  uint32_t _deaths = 0;
24  uint32_t _suicides = 0;
25  uint32_t _time = 0;
26  uint32_t _vehicles = 0;
27  uint32_t _lavd = 0;
28  uint32_t _mavd = 0;
29  uint32_t _havd = 0;
30  uint32_t _hed = 0;
31  uint32_t _pld = 0;
32  uint32_t _bod = 0;
33  uint32_t _k1 = 0;
34  uint32_t _s1 = 0;
35  uint32_t _k2 = 0;
36  uint32_t _s2 = 0;
37  uint32_t _k3 = 0;
38  uint32_t _s3 = 0;
39  uint32_t _k4 = 0;
40  uint32_t _s4 = 0;
41  uint32_t _k5 = 0;
42  uint32_t _s5 = 0;
43  uint32_t _tk = 0;
44  uint32_t _medals = 0;
45  uint32_t _ttb = 0;
46  uint32_t _mv = 0;
47  uint32_t _ngp = 0;
48  uint32_t _cflags = 0;
49  uint32_t _nflags = 0;
50  uint32_t _sflags = 0;
52  public:
53  typedef bool (Battlefield::PlayerStats::*SetterFunc)(uint32_t);
54 
55  static std::unordered_map<std::string, SetterFunc> SetterMap;
56 
57  public:
58  int32_t GetScore() const { return this->_score; }
59  uint32_t GetRank() const { return this->_ran; }
60  uint32_t GetPPH() const { return this->_pph; }
61  uint32_t GetKills() const { return this->_kills; }
62  uint32_t GetDeaths() const { return this->_deaths; }
63  uint32_t GetSuicides() const { return this->_suicides; }
64  uint32_t GetTime() const { return this->_time; }
65  uint32_t GetVehiclesDestroyed() const { return this->_vehicles; }
66  uint32_t GetLAVsDestroyed() const { return this->_lavd; }
67  uint32_t GetMAVsDestroyed() const { return this->_mavd; }
68  uint32_t GetHAVsDestroyed() const { return this->_havd; }
69  uint32_t GetHelicoptersDestroyed() const { return this->_hed; }
70  uint32_t GetPlanesDestroyed() const { return this->_pld; }
71  uint32_t GetBoatsDestroyed() const { return this->_bod; }
72  uint32_t GetKillsAssualtKit() const { return this->_k1; }
73  uint32_t GetSpawnsAssualtKit() const { return this->_s1; }
74  uint32_t GetKillsSniperKit() const { return this->_k2; }
75  uint32_t GetSpawnsSniperKit() const { return this->_s2; }
76  uint32_t GetKillsSpecialOpKit() const { return this->_k3; }
77  uint32_t GetSpawnsSpecialOpKit() const { return this->_s3; }
78  uint32_t GetKillsCombatEngineerKit() const { return this->_k4; }
79  uint32_t GetSpawnsCombatEngineerKit() const { return this->_s4; }
80  uint32_t GetKillsSupportKit() const { return this->_k5; }
81  uint32_t GetSpawnsSupportKit() const { return this->_s5; }
82  uint32_t GetTeamKills() const { return this->_tk; }
83  uint32_t GetMedals() const { return this->_medals; }
84  uint32_t GetTotalTopPlayer() const { return this->_ttb; }
85  uint32_t GetTotalVictories() const { return this->_mv; }
86  uint32_t GetTotalGameSessions() const { return this->_ngp; }
87  uint32_t GetCapturedFlags() const { return this->_cflags; }
88  uint32_t GetNeutralizedFlags() const { return this->_nflags; }
89  uint32_t GetSavedFlags() const { return this->_sflags; }
90 
91  double GetRatio() const;
92  double GetRatioAssualtKit() const;
93  double GetRatioSniperKit() const;
94  double GetRatioSpecialOpKit() const;
95  double GetRatioCombatEngineerKit() const;
96  double GetRatioSupportKit() const;
97 
98  bool SetScore(int32_t score);
99  bool SetRank(uint32_t ran);
100  bool SetRank(Ranks ran);
101  bool SetPPH(uint32_t pph);
102  bool SetKills(uint32_t kills);
103  bool SetDeaths(uint32_t kills);
104  bool SetSuicides(uint32_t suicides);
105  bool SetTime(uint32_t time);
106  bool SetVehiclesDestroyed(uint32_t vehicles);
107  bool SetLAVsDestroyed(uint32_t lavd);
108  bool SetMAVsDestroyed(uint32_t mavd);
109  bool SetHAVsDestroyed(uint32_t havd);
110  bool SetHelicoptersDestroyed(uint32_t hed);
111  bool SetBoatsDestroyed(uint32_t bod);
112  bool SetKillsAssualtKit(uint32_t kills);
113  bool SetDeathsAssualtKit(uint32_t deaths);
114  bool SetKillsSniperKit(uint32_t kills);
115  bool SetDeathsSniperKit(uint32_t deaths);
116  bool SetKillsSpecialOpKit(uint32_t kills);
117  bool SetDeathsSpecialOpKit(uint32_t deaths);
118  bool SetKillsCombatEngineerKit(uint32_t kills);
119  bool SetDeathsCombatEngineerKit(uint32_t deaths);
120  bool SetKillsSupportKit(uint32_t kills);
121  bool SetDeathsSupportKit(uint32_t deaths);
122  bool SetMedals(uint32_t medals);
123  bool SetMedals(Medals medals);
124  bool SetTotalTopPlayer(uint32_t total);
125  bool SetTotalVictories(uint32_t total);
126  bool SetTotalGameSessions(uint32_t total);
127  bool SetCapturedFlags(uint32_t cflags);
128  bool SetNeutralizedFlags(uint32_t nflags);
129  bool SetSavedFlags(uint32_t sflags);
130 
134  void Update(const Battlefield::GameStatPlayer& gsplayer);
135 
144  void useExample();
145 
146  private:
150  void _calcRank();
151 
155  void _calcNewPPH(uint32_t time, int32_t score);
156  };
157 }
158 
159 #endif // BATTLEFIELD_PLAYERSTATS_H
Represents a player's statistics in a game.
Definition: gamestat.h:146
Contains player status information.
Definition: playerstats.h:17
void useExample()
Performs an example operation using the PlayerStats class.
Definition: playerstats.cpp:31
void _calcNewPPH(uint32_t time, int32_t score)
Calculates the pph based on game time, game score and current player stats.
void _calcRank()
Calculates the rank based on score, points per hour (pph), and medals.
void Update(const Battlefield::GameStatPlayer &gsplayer)
Update player stats based on played game.