/// <summary> /// Execute incomming commands on host player. /// </summary> /// <param name="command">The command to execute.</param> /// <param name="arguments">Additional arguments to the command.</param> /// <returns>Returns the command results.</returns> private string ExecuteCommandsLocally(ERemoteCommand command, string arguments) { Hider hider = this as Hider; switch (command) { case ERemoteCommand.StartGame: StartGame(); break; case ERemoteCommand.EndGame: EndGame(); break; case ERemoteCommand.GuessRoom: return(hider?.CheckRoom(arguments).ToString()); case ERemoteCommand.AddPoints: AddPoints(int.Parse(arguments)); break; case ERemoteCommand.GetMap: return(JsonConvert.SerializeObject(hider?.Map)); case ERemoteCommand.GetPosition: return(JsonConvert.SerializeObject(hider?.GetPosition())); default: return(string.Empty); } return(string.Empty); }
/// <summary> /// Execute incomming commands on remote /// </summary> /// <param name="player">The remote player.</param> /// <param name="command">The command to send.</param> /// <param name="arguments">Additional arguments to send.</param> /// <returns>Returns the command results.</returns> private string ExecuteRemoteCommands(Player player, string command, string arguments) { if (!Enum.TryParse(command, out ERemoteCommand remoteCommand)) { return(string.Empty); } Hider hider = player as Hider; switch (remoteCommand) { case ERemoteCommand.StartGame: player.StartGame(); break; case ERemoteCommand.EndGame: player.EndGame(); break; case ERemoteCommand.GuessRoom: return(hider?.CheckRoom(arguments).ToString()); case ERemoteCommand.AddPoints: player.AddPoints(int.Parse(arguments)); break; case ERemoteCommand.GetMap: return(JsonConvert.SerializeObject(hider?.Map)); case ERemoteCommand.GetPosition: return(JsonConvert.SerializeObject(hider?.GetPosition())); default: return(string.Empty); } return(string.Empty); }