PlayerRegister.h 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <Text.h>
  3. #include <Array.h>
  4. #include <Writer.h>
  5. #include <Critical.h>
  6. Framework::Text randomSecret();
  7. class RegisteredPlayer : public Framework::ReferenceCounter
  8. {
  9. private:
  10. int id;
  11. Framework::Text name;
  12. Framework::Text secret;
  13. public:
  14. RegisteredPlayer(int id, Framework::Text name);
  15. RegisteredPlayer(Framework::StreamReader* zReader);
  16. int getId() const;
  17. Framework::Text getName() const;
  18. Framework::Text getSecret() const;
  19. void save(Framework::StreamWriter* zWriter) const;
  20. };
  21. class PlayerRegister : public Framework::ReferenceCounter
  22. {
  23. private:
  24. Framework::RCArray<RegisteredPlayer> players;
  25. Framework::Critical cs;
  26. Framework::Text path;
  27. public:
  28. PlayerRegister(Framework::Text worldPath);
  29. Framework::Text addPlayer(Framework::Text name);
  30. bool hasPlayer(Framework::Text name);
  31. int getPlayerId(Framework::Text name);
  32. bool checkSecret(Framework::Text name, Framework::Text secret);
  33. void save();
  34. };