public void Run() { while (true) { var input = reader.ReadLine().Split(); if (input[0] == "Exit") { Environment.Exit(0); } try { if (input[0] == "AddPlayer") { writer.WriteLine(controller.AddPlayer(input[1])); } else if (input[0] == "AddGun") { writer.WriteLine(controller.AddGun(input[1], input[2])); } else if (input[0] == "AddGunToPlayer") { writer.WriteLine(controller.AddGunToPlayer(input[1])); } else if (input[0] == "Fight") { writer.WriteLine(controller.Fight()); } } catch (Exception ex) { writer.WriteLine(ex.Message); writer.WriteLine(ex.ToString()); } } }
private string ProcessCommand(string[] args) { string command = args[0]; string result = null; switch (command) { case "AddPlayer": result = _controller.AddPlayer(args[1]); break; case "AddGun": result = _controller.AddGun(args[1], args[2]); break; case "AddGunToPlayer": result = _controller.AddGunToPlayer(args[1]); break; case "Fight": result = _controller.Fight(); break; case "Exit": _isRunning = false; Environment.Exit(0); break; } return(result); }
public void Run() { while (true) { var input = reader.ReadLine().Split(); if (input[0] == "Exit") { Environment.Exit(0); } try { string result = string.Empty; if (input[0] == "AddPlayer") { string username = input[1]; result = controller.AddPlayer(username); } else if (input[0] == "AddGun") { string type = input[1]; string name = input[2]; result = controller.AddGun(type, name); } else if (input[0] == "AddGunToPlayer") { string username = input[1]; result = controller.AddGunToPlayer(username); } else if (input[0] == "Fight") { result = controller.Fight(); } writer.WriteLine(result); } catch (Exception ex) { writer.WriteLine(ex.Message); } } }
public void Run() { while (true) { var input = reader.ReadLine().Split(); if (input[0] == "Exit") { Environment.Exit(0); } try { if (input[0] == "AddPlayer") { string name = input[1]; Console.WriteLine(controller.AddPlayer(name)); } else if (input[0] == "AddGun") { string gunType = input[1]; string gunName = input[2]; Console.WriteLine(controller.AddGun(gunType, gunName)); } else if (input[0] == "AddGunToPlayer") { string name = input[1]; Console.WriteLine(controller.AddGunToPlayer(name)); } else if (input[0] == "Fight") { Console.WriteLine(controller.Fight()); } } catch (Exception ex) { writer.WriteLine(ex.Message); } } }