1. /*
  2. *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3. *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4. *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5. *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6. * http://emudevs.com
  7. */
  8. class VotePointSystem
  9. {
  10. public:
  11. VotePointSystem();
  12. ~VotePointSystem();
  13. bool GetPlayerAccount(uint32 acctId) const { return acctId == accountId; }
  14. bool LoadFromDB(Field* fields);
  15. void SaveToDB(SQLTransaction& trans) const;
  16. uint32 Points() const { return votePoints; }
  17. uint32 GetAccountId() const { return accountId; }
  18. private:
  19. uint32 accountId;
  20. uint32 votePoints;
  21. };
  22. class VotePointSystemMgr
  23. {
  24. private:
  25. VotePointSystemMgr();
  26. ~VotePointSystemMgr();
  27. public:
  28. static VotePointSystemMgr* GetInstance()
  29. {
  30. static VotePointSystemMgr instance;
  31. return &instance;
  32. }
  33. void LoadVoteSystem();
  34. typedef std::map<uint32, VotePointSystem*> VotePointList;
  35. VotePointSystem* GetPointsByAccountId(uint32 id)
  36. {
  37. for (VotePointList::const_iterator itr = _voteList.begin(); itr != _voteList.end(); ++itr)
  38. if (itr->second && itr->second->GetPlayerAccount(id))
  39. return itr->second;
  40. return NULL;
  41. }
  42. void SaveToList(VotePointSystem* voteSystem);
  43. protected:
  44. VotePointList _voteList;
  45. };
  46. #define sVoteSystemMgr VotePointSystemMgr::GetInstance()

VotePoints.h Header file!