PlayerMessageProcessor.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * CGameHandler.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../../lib/GameConstants.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class CGHeroInstance;
  14. class CGTownInstance;
  15. class CConnection;
  16. class MetaString;
  17. VCMI_LIB_NAMESPACE_END
  18. class CGameHandler;
  19. class PlayerMessageProcessor
  20. {
  21. CGameHandler * gameHandler;
  22. void executeCheatCode(const std::string & cheatName, PlayerColor player, ObjectInstanceID currObj, const std::vector<std::string> & arguments );
  23. bool handleCheatCode(const std::string & cheatFullCommand, PlayerColor player, ObjectInstanceID currObj);
  24. bool handleHostCommand(PlayerColor player, const std::string & message);
  25. void cheatGiveSpells(PlayerColor player, const CGHeroInstance * hero);
  26. void cheatBuildTown(PlayerColor player, const CGTownInstance * town);
  27. void cheatGiveArmy(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
  28. void cheatGiveMachines(PlayerColor player, const CGHeroInstance * hero);
  29. void cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
  30. void cheatLevelup(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
  31. void cheatExperience(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
  32. void cheatMovement(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
  33. void cheatResources(PlayerColor player, std::vector<std::string> words);
  34. void cheatVictory(PlayerColor player);
  35. void cheatDefeat(PlayerColor player);
  36. void cheatMapReveal(PlayerColor player, bool reveal);
  37. void cheatPuzzleReveal(PlayerColor player);
  38. void cheatMaxLuck(PlayerColor player, const CGHeroInstance * hero);
  39. void cheatMaxMorale(PlayerColor player, const CGHeroInstance * hero);
  40. void cheatFly(PlayerColor player, const CGHeroInstance * hero);
  41. public:
  42. PlayerMessageProcessor(CGameHandler * gameHandler);
  43. /// incoming NetPack handling
  44. void playerMessage(PlayerColor player, const std::string & message, ObjectInstanceID currObj);
  45. /// Send message to specific client with "System" as sender
  46. void sendSystemMessage(std::shared_ptr<CConnection> connection, const MetaString & message);
  47. void sendSystemMessage(std::shared_ptr<CConnection> connection, const std::string & message);
  48. /// Send message to all players with "System" as sender
  49. void broadcastSystemMessage(MetaString message);
  50. void broadcastSystemMessage(const std::string & message);
  51. /// Send message from specific player to all other players
  52. void broadcastMessage(PlayerColor playerSender, const std::string & message);
  53. template <typename Handler> void serialize(Handler &h)
  54. {
  55. }
  56. };