Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. networking::Connection Server::playerToConnection(std::string player) {
  2. //perhaps there is a hash like data structure to map connections to player names and vice verse?
  3. return playerMap.at(player);
  4. }
  5.  
  6. std::string Server::kickPlayer(std::string player) {
  7. //map the player name and or id to a connection object?
  8. //Connection con = playerToConnection(player);
  9. return "So you don't like " + player + " very much, do you?\n";
  10. }
  11.  
  12. std::string Server::mutePlayer(std::string player) {
  13. return player + " is annoying\n";
  14. }
  15.  
  16. void Server::endGame() {
  17. }
  18.  
  19. void Server::resetGame() {
  20. }
  21.  
  22. std::string Server::whisperToPlayer(std::string player){
  23. return "Whispering to " + player;
  24. }
  25.  
  26. std::string Server::handleCommand(std::string command) {
  27. //splice string
  28. std::istringstream temp(command);
  29.  
  30. std::vector<std::string> cmd_args(std::istream_iterator<std::string>{temp},
  31. std::istream_iterator<std::string>());
  32. std::string result;
  33.  
  34. if(cmd_args.size() == 2){
  35. if(cmd_args[0] == "kick"){ //kick player
  36. result = kickPlayer(cmd_args[1]);
  37. } else if (cmd_args[0] == "mute") { //mute player
  38. result = mutePlayer(cmd_args[1]);
  39. } else if (cmd_args[0] == "whisper") { //whisper to a player
  40. result = whisperToPlayer(cmd_args[1]);
  41. } else {
  42. result = "";
  43. }
  44. } else if(cmd_args.size() == 1) { //end the game
  45. if (command == "endgame") {
  46. endGame();
  47. result = "Want to end the game";
  48.  
  49. } else if (command == "resetgame"){ //reset the game
  50. resetGame();
  51. result = "Want to reset the game";
  52. }
  53. }
  54. else {
  55. result = "";
  56. }
  57. return result;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement