BF2MC-Matchmaker
clan.h
1 #ifndef BATTLEFIELD_CLAN_H
2 #define BATTLEFIELD_CLAN_H
3 
4 #include <string>
5 #include <cstdint>
6 #include <map>
7 #include <unordered_map>
8 
17 struct MYSQL_TIME;
18 
19 namespace Battlefield
20 {
29  class Clan;
30 
37  typedef std::vector<Battlefield::Clan> Clans;
38 
46  typedef std::map<int, Battlefield::Clan> RankClans;
47 
53  class Clan
54  {
55  public:
62  enum class Regions : uint8_t
63  {
64  America = 0x1,
65  Europe = 0x2,
66  Asia = 0x3,
67  Unknown = 0xf
68  };
69 
76  enum class Ranks
77  {
78  Leader = 0x0,
79  Co_Leader = 0x1,
80  Member = 0x2,
81  Unknown = 0xf
82  };
83 
84  private:
85  int _clanid = -1;
86  std::string _name = "";
87  std::string _tag = "";
88  std::string _homepage = "";
89  std::string _info = "";
91  uint32_t _score = 0;
92  uint32_t _wins = 0;
93  uint32_t _losses = 0;
94  uint32_t _draws = 0;
95  std::string _created_at = "";
96  bool _disable = false;
97  std::map<int, Ranks> _ranks;
99  public:
107  static const int ELO_WEIGHT = 25;
108 
115  static const int ELO_MAX_RANGE = 1000;
116 
117  typedef bool (Battlefield::Clan::*SetterFunc)(const std::string&);
118 
119  static std::unordered_map<std::string, SetterFunc> SetterMap;
120 
121  public:
122  int GetClanId() const { return this->_clanid; }
123  std::string GetName() const { return this->_name; }
124  std::string GetTag() const { return this->_tag; }
125  std::string GetHomepage() const { return this->_homepage; }
126  std::string GetInfo() const { return this->_info; }
127  uint8_t GetRegion() const { return static_cast<uint8_t>(this->_region); }
128  Regions GetRegionEnum() const { return this->_region; }
129  uint32_t GetScore() const { return this->_score; }
130  uint32_t GetWins() const { return this->_wins; }
131  uint32_t GetLosses() const { return this->_losses; }
132  uint32_t GetDraws() const { return this->_draws; }
133  std::string GetCreatedAt() const { return this->_created_at; }
134  bool IsDisabled() const { return this->_disable; }
135  const std::map<int, Ranks> GetRanks() const { return this->_ranks; }
136 
137  bool SetClanId(int clanid);
138  bool SetClanId(const std::string& clanid);
139  bool SetName(const std::string& name);
140  bool SetTag(const std::string& tag);
141  bool SetHomepage(const std::string& homepage);
142  bool SetInfo(const std::string& info);
143  bool SetRegion(Battlefield::Clan::Regions region);
144  bool SetRegion(uint8_t int_region);
145  bool SetRegion(const std::string& region);
146  bool SetScore(uint32_t score);
147  bool SetWins(uint32_t wins);
148  bool SetLosses(uint32_t losses);
149  bool SetDraws(uint32_t draws);
150  bool SetCreatedAt(MYSQL_TIME created_at);
151  bool SetDisable(bool disable);
152  bool SetDisable(uint8_t disable);
153  void AddRank(int profileid, Ranks rank);
154  void AddRank(int profileid, uint8_t int_rank);
155  Ranks GetRank(int profileid) const;
156 
165  void useExample();
166 
167  /*
168  Static
169  */
179  static Ranks convertRank(const std::string& rank);
180 
190  static Ranks convertRank(uint8_t int_rank);
191 
201  static Regions convertRegion(const std::string& str_region);
202 
212  static Regions convertRegion(uint8_t int_region);
213  };
214 }
215 
216 #endif // BATTLEFIELD_CLAN_H
Represents a clan in the Battlefield game.
Definition: clan.h:54
std::string _created_at
Definition: clan.h:95
uint32_t _wins
Definition: clan.h:92
uint32_t _losses
Definition: clan.h:93
std::string _info
Definition: clan.h:89
static const int ELO_MAX_RANGE
The maximum range for clan battles.
Definition: clan.h:115
bool _disable
Definition: clan.h:96
static Regions convertRegion(const std::string &str_region)
Converts a string representation of a region to its corresponding enum value.
std::string _name
Definition: clan.h:86
uint32_t _draws
Definition: clan.h:94
std::string _tag
Definition: clan.h:87
static Ranks convertRank(const std::string &rank)
Converts a string representation of a rank to its corresponding enum value.
std::map< int, Ranks > _ranks
Definition: clan.h:97
uint32_t _score
Definition: clan.h:91
Regions _region
Definition: clan.h:90
Regions
Represents the regions associated with clans.
Definition: clan.h:63
void useExample()
Performs an example operation using the Clan class.
Ranks
Represents the ranks within a clan.
Definition: clan.h:77
std::string _homepage
Definition: clan.h:88
static const int ELO_WEIGHT
The Elo score weight for clan battles.
Definition: clan.h:107