9
3

Collections.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef COLLECTIONS_H_
  2. #define COLLECTIONS_H_
  3. #include "../../common/types.h"
  4. #include "../../common/Mutex.h"
  5. #include "../Items/Items.h"
  6. #include <map>
  7. #include <vector>
  8. using namespace std;
  9. struct CollectionItem {
  10. int32 item;
  11. int8 index;
  12. int8 found;
  13. };
  14. struct CollectionRewardItem {
  15. Item *item;
  16. int8 quantity;
  17. };
  18. class Collection {
  19. public:
  20. Collection();
  21. Collection(Collection *in);
  22. virtual ~Collection();
  23. void SetID(int32 id) {this->id = id;}
  24. void SetName(const char *name) {strncpy(this->name, name, sizeof(this->name));}
  25. void SetCategory(const char *category) {strncpy(this->category, category, sizeof(this->category));}
  26. void SetLevel(int8 level) {this->level = level;}
  27. void SetCompleted(bool completed) {this->completed = completed;}
  28. void SetSaveNeeded(bool save_needed) {this->save_needed = save_needed;}
  29. void AddCollectionItem(struct CollectionItem *collection_item);
  30. void AddRewardItem(struct CollectionRewardItem *reward_item);
  31. void AddSelectableRewardItem(struct CollectionRewardItem *reward_item);
  32. void SetRewardCoin(int64 reward_coin) {this->reward_coin = reward_coin;}
  33. void SetRewardXP(int64 reward_xp) {this->reward_xp = reward_xp;}
  34. bool NeedsItem(Item *item);
  35. struct CollectionItem * GetCollectionItemByItemID(int32 item_id);
  36. int32 GetID() {return id;}
  37. const char * GetName() {return name;}
  38. const char * GetCategory() {return category;}
  39. int8 GetLevel() {return level;}
  40. bool GetIsReadyToTurnIn();
  41. bool GetCompleted() {return completed;}
  42. bool GetSaveNeeded() {return save_needed;}
  43. vector<struct CollectionItem *> * GetCollectionItems() {return &collection_items;}
  44. vector<struct CollectionRewardItem *> * GetRewardItems() {return &reward_items;}
  45. vector<struct CollectionRewardItem *> * GetSelectableRewardItems() {return &selectable_reward_items;}
  46. int64 GetRewardCoin() {return reward_coin;}
  47. int64 GetRewardXP() {return reward_xp;}
  48. private:
  49. int32 id;
  50. char name[512];
  51. char category[512];
  52. int8 level;
  53. int64 reward_coin;
  54. int64 reward_xp;
  55. bool completed;
  56. bool save_needed;
  57. vector<struct CollectionItem *> collection_items;
  58. vector<struct CollectionRewardItem *> reward_items;
  59. vector<struct CollectionRewardItem *> selectable_reward_items;
  60. };
  61. class MasterCollectionList {
  62. public:
  63. MasterCollectionList();
  64. virtual ~MasterCollectionList();
  65. bool AddCollection(Collection *collection);
  66. Collection * GetCollection(int32 collection_id);
  67. void ClearCollections();
  68. int32 Size();
  69. bool NeedsItem(Item *item);
  70. Mutex * GetMutex() {return &mutex_collections;}
  71. map<int32, Collection *> * GetCollections() {return &collections;}
  72. private:
  73. Mutex mutex_collections;
  74. map<int32, Collection *> collections;
  75. };
  76. class PlayerCollectionList {
  77. public:
  78. PlayerCollectionList();
  79. virtual ~PlayerCollectionList();
  80. bool AddCollection(Collection *collection);
  81. Collection * GetCollection(int32 collection_id);
  82. void ClearCollections();
  83. int32 Size();
  84. bool NeedsItem(Item *item);
  85. bool HasCollectionsToHandIn();
  86. map<int32, Collection *> * GetCollections() {return &collections;}
  87. private:
  88. map<int32, Collection *> collections;
  89. };
  90. #endif