Achievements.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef ACHIEVEMENTS_H_
  17. #define ACHIEVEMENTS_H_
  18. #include "../../common/types.h"
  19. #include "../../common/Mutex.h"
  20. #include "../Items/Items.h"
  21. #include <map>
  22. #include <vector>
  23. using namespace std;
  24. struct AchievementRewards
  25. {
  26. int32 achievement_id;
  27. string reward;
  28. };
  29. struct AchievementRequirements
  30. {
  31. int32 achievement_id;
  32. string name;
  33. int32 qty_req;
  34. };
  35. struct AchievementUpdateItems
  36. {
  37. int32 achievement_id;
  38. int32 item_update;
  39. };
  40. class Achievement {
  41. public:
  42. Achievement();
  43. Achievement(Achievement *in);
  44. virtual ~Achievement();
  45. void SetID(int32 id) {this->id = id;}
  46. void SetTitle(const char *title) {strncpy(this->title, title, sizeof(this->title));}
  47. void SetUncompletedText(const char *uncompleted_text) {strncpy(this->uncompleted_text, uncompleted_text, sizeof(this->uncompleted_text));}
  48. void SetCompletedText(const char *completed_text) {strncpy(this->completed_text, completed_text, sizeof(this->completed_text));}
  49. void SetCategory(const char *category) {strncpy(this->category, category, sizeof(this->category));}
  50. void SetExpansion(const char *expansion) {strncpy(this->expansion, expansion, sizeof(this->expansion));}
  51. void SetIcon(int16 icon) {this->icon = icon;}
  52. void SetPointValue(int32 point_value) {this->point_value = point_value;}
  53. void SetQtyReq(int32 qty_req) {this->qty_req = qty_req;}
  54. void SetHide(bool hide) {this->hide = hide;}
  55. void SetUnknown3a(int32 unknown3a) {this->unknown3a = unknown3a;}
  56. void SetUnknown3b(int32 unknown3b) {this->unknown3b = unknown3b;}
  57. void AddAchievementRequirement(struct AchievementRequirements *requirements);
  58. void AddAchievementReward(struct AchievementRewards *reward);
  59. int32 GetID() {return id;}
  60. const char * GetTitle() {return title;}
  61. const char * GetUncompletedText() {return uncompleted_text;}
  62. const char * GetCompletedText() {return completed_text;}
  63. const char * GetCategory() {return category;}
  64. const char * GetExpansion() {return expansion;}
  65. int16 GetIcon() {return icon;}
  66. int32 GetPointValue() {return point_value;}
  67. int32 GetQtyReq() {return qty_req;}
  68. bool GetHide() {return hide;}
  69. int32 GetUnknown3a() {return unknown3a;}
  70. int32 GetUnknown3b() {return unknown3b;}
  71. vector<struct AchievementRequirements *> * GetRequirements() {return &requirements;}
  72. vector<struct AchievementRewards *> * GetRewards() {return &rewards;}
  73. private:
  74. int32 id;
  75. char title[512];
  76. char uncompleted_text[512];
  77. char completed_text[512];
  78. char category[32];
  79. char expansion[32];
  80. int16 icon;
  81. int32 point_value;
  82. int32 qty_req;
  83. bool hide;
  84. int32 unknown3a;
  85. int32 unknown3b;
  86. vector<struct AchievementRequirements *> requirements;
  87. vector<struct AchievementRewards *> rewards;
  88. };
  89. class AchievementUpdate {
  90. public:
  91. AchievementUpdate();
  92. AchievementUpdate(AchievementUpdate *in);
  93. virtual ~AchievementUpdate();
  94. void SetID(int32 id) {this->id = id;}
  95. void SetCompletedDate(int32 completed_date) {this->completed_date = completed_date;}
  96. void AddAchievementUpdateItems(struct AchievementUpdateItems *update_items);
  97. int32 GetID() {return id;}
  98. int32 GetCompletedDate() {return completed_date;}
  99. vector<struct AchievementUpdateItems *> * GetUpdateItems() {return &update_items;}
  100. private:
  101. int32 id;
  102. int32 completed_date;
  103. vector<struct AchievementUpdateItems *> update_items;
  104. };
  105. class MasterAchievementList {
  106. public:
  107. MasterAchievementList();
  108. virtual ~MasterAchievementList();
  109. bool AddAchievement(Achievement *achievement);
  110. Achievement * GetAchievement(int32 achievement_id);
  111. void ClearAchievements();
  112. int32 Size();
  113. void CreateMasterAchievementListPacket();
  114. EQ2Packet * GetAchievementPacket() { return m_packetsCreated ? masterPacket : 0;}
  115. EQ2Packet *masterPacket;
  116. private:
  117. Mutex mutex_achievements;
  118. map<int32, Achievement *> achievements;
  119. bool m_packetsCreated;
  120. };
  121. class PlayerAchievementList {
  122. public:
  123. PlayerAchievementList();
  124. virtual ~PlayerAchievementList();
  125. bool AddAchievement(Achievement *achievement);
  126. Achievement * GetAchievement(int32 achievement_id);
  127. void ClearAchievements();
  128. int32 Size();
  129. map<int32, Achievement *> * GetAchievements() {return &achievements;}
  130. private:
  131. map<int32, Achievement *> achievements;
  132. };
  133. class PlayerAchievementUpdateList {
  134. public:
  135. PlayerAchievementUpdateList();
  136. virtual ~PlayerAchievementUpdateList();
  137. bool AddAchievementUpdate(AchievementUpdate *achievement_update);
  138. void ClearAchievementUpdates();
  139. int32 Size();
  140. map<int32, AchievementUpdate *> * GetAchievementUpdates() {return &achievement_updates;}
  141. private:
  142. map<int32, AchievementUpdate *> achievement_updates;
  143. };
  144. #endif