Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- networking::Connection Server::playerToConnection(std::string player) {
- //perhaps there is a hash like data structure to map connections to player names and vice verse?
- return playerMap.at(player);
- }
- std::string Server::kickPlayer(std::string player) {
- //map the player name and or id to a connection object?
- //Connection con = playerToConnection(player);
- return "So you don't like " + player + " very much, do you?\n";
- }
- std::string Server::mutePlayer(std::string player) {
- return player + " is annoying\n";
- }
- void Server::endGame() {
- }
- void Server::resetGame() {
- }
- std::string Server::whisperToPlayer(std::string player){
- return "Whispering to " + player;
- }
- std::string Server::handleCommand(std::string command) {
- //splice string
- std::istringstream temp(command);
- std::vector<std::string> cmd_args(std::istream_iterator<std::string>{temp},
- std::istream_iterator<std::string>());
- std::string result;
- if(cmd_args.size() == 2){
- if(cmd_args[0] == "kick"){ //kick player
- result = kickPlayer(cmd_args[1]);
- } else if (cmd_args[0] == "mute") { //mute player
- result = mutePlayer(cmd_args[1]);
- } else if (cmd_args[0] == "whisper") { //whisper to a player
- result = whisperToPlayer(cmd_args[1]);
- } else {
- result = "";
- }
- } else if(cmd_args.size() == 1) { //end the game
- if (command == "endgame") {
- endGame();
- result = "Want to end the game";
- } else if (command == "resetgame"){ //reset the game
- resetGame();
- result = "Want to reset the game";
- }
- }
- else {
- result = "";
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement