private void ParseCommand(string cmdType, string[] methodArgs) { switch (cmdType) { case "JoinParty": Console.WriteLine(dungeonMaster.JoinParty(methodArgs)); break; case "AddItemToPool": Console.WriteLine(dungeonMaster.AddItemToPool(methodArgs)); break; case "PickUpItem": Console.WriteLine(dungeonMaster.PickUpItem(methodArgs)); break; case "UseItem": Console.WriteLine(dungeonMaster.UseItem(methodArgs)); break; case "UseItemOn": Console.WriteLine(dungeonMaster.UseItemOn(methodArgs)); break; case "GiveCharacterItem": Console.WriteLine(dungeonMaster.GiveCharacterItem(methodArgs)); break; case "GetStats": Console.WriteLine(dungeonMaster.GetStats()); break; case "Attack": Console.WriteLine(dungeonMaster.Attack(methodArgs)); break; case "Heal": Console.WriteLine(dungeonMaster.Heal(methodArgs)); break; case "EndTurn": Console.WriteLine(dungeonMaster.EndTurn(methodArgs)); break; case "IsGameOver": /*Console.WriteLine(*/ dungeonMaster.IsGameOver(); break; default: throw new NotImplementedException(); } }
public void Run() { var master = new DungeonMaster(); while (true) { try { var commandArgs = Console.ReadLine().Split(' ').ToList(); var currentCommand = commandArgs[0]; commandArgs.RemoveAt(0); switch (currentCommand) { case "JoinParty": Console.WriteLine(master.JoinParty(commandArgs.ToArray())); break; case "AddItemToPool": Console.WriteLine(master.AddItemToPool(commandArgs.ToArray())); break; case "PickUpItem": Console.WriteLine(master.PickUpItem(commandArgs.ToArray())); break; case "UseItem": Console.WriteLine(master.UseItem(commandArgs.ToArray())); break; case "UseItemOn": Console.WriteLine(master.UseItemOn(commandArgs.ToArray())); break; case "GiveCharacterItem": Console.WriteLine(master.GiveCharacterItem(commandArgs.ToArray())); break; case "GetStats": Console.WriteLine(master.GetStats()); break; case "Attack": Console.WriteLine(master.Attack(commandArgs.ToArray())); break; case "Heal": Console.WriteLine(master.Heal(commandArgs.ToArray())); break; case "EndTurn": Console.WriteLine(master.EndTurn(commandArgs.ToArray())); break; case "IsGameOver": Console.WriteLine(master.IsGameOver()); break; default: break; } if (master.IsGameOver()) { break; } } catch (ArgumentException argEx) { Console.WriteLine($"Parameter Error: {argEx.Message}"); } catch (InvalidOperationException invOpEx) { Console.WriteLine($"Invalid Operation: {invOpEx.Message}"); } catch (Exception e) { break; } } Console.WriteLine("Final stats:"); Console.WriteLine(master.GetStats()); }