public static void SelectHeroClass(Dictionary <string, string> playerNamesAndHeroes) { Dictionary <string, string> tempDict = new Dictionary <string, string>(); foreach (var player in playerNamesAndHeroes) { tempDict.Add(player.Key, TypesOfMenu.HeroClassSelectMenu(player.Key, player.Value)); } foreach (var player in tempDict) { if (Constants.MageRoles.Contains(player.Value)) { CreateMage(player.Key, player.Value); } else if (Constants.WarriorRoles.Contains(player.Value)) { CreateWarrior(player.Key, player.Value); } else { CreatePriest(player.Key, player.Value); } } playerNamesAndHeroes = tempDict; Combat.ArrangeTeams(players); }
public static void TypeNames(string action) { var counter = 0; if (action == MenuActions.DUEL.ToString()) { counter = 2; } else if (action == MenuActions.ARENA.ToString()) { counter = 4; } var playerNames = new List <string>(); Console.Clear(); Console.WriteLine(Constants.GameTitle); Console.WriteLine(); for (int i = 0; i < counter; i++) { Console.WriteLine($"ENTER NAME FOR PLAYER{i + 1}"); var name = Console.ReadLine().Trim(); try { validator = new Validator(); validator.NameValidator(name); if (!playerNames.Contains(name)) { playerNames.Add(name); } else { Console.WriteLine("Player's name must be unique!"); i--; } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); i--; } } TypesOfMenu.HeroSelectMenu(playerNames); }
public static void PlayerTurn(Hero player) { if (player.StunnedDuration <= 0 && player.Health > 0) { var action = TypesOfMenu.ActionsMenu(player); while (!CheckForEnoughManaOrRage(player, action) || action.IsOnCooldown()) { var key = new ConsoleKeyInfo(); while (key.Key != ConsoleKey.Enter) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(Constants.GameTitle); if (action.IsOnCooldown()) { Console.WriteLine($"{action.Name} is on cooldown right now! Select a different action!"); } else if (!CheckForEnoughManaOrRage(player, action)) { Console.WriteLine($"{action.Name} CANNOT BE CAST DUE TO INSUFFICIENT ENERGY!"); } Console.WriteLine("-- PRESS ENTER TO CONTINUE TO ACTION MENU --"); key = Console.ReadKey(); } action = TypesOfMenu.ActionsMenu(player); } ActionGetter.GetTypeOfAction(action, player, firstTeam, secondTeam); } else if (player.Health > 0) { var key = new ConsoleKeyInfo(); while (key.Key != ConsoleKey.Enter) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(Constants.GameTitle); Console.WriteLine($"{player.Name} is stunned right now. Proceeding to next player"); Console.WriteLine("-- PRESS ENTER TO CONTINUE TO NEXT PLAYER --"); key = Console.ReadKey(); } player.StunnedDuration--; } }
public static void Main() { TypesOfMenu.StartMenu(); }
public void DoAction(string action) { if (action == MenuActions.NEW.ToString()) { TypesOfMenu.NewGameMenu(); } else if (action == MenuActions.INSTRUCTIONS.ToString()) { InstructionsWriter.WriteInstructions(); TypesOfMenu.StartMenu(); } else if (action == MenuActions.BEERS.ToString()) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ENTER PLAYER'S NAME TO RECEIVE HIS BEER EARNINGS:"); Battle4BeersDbContext db = new Battle4BeersDbContext(); var nameReader = Console.ReadLine(); var player = db.Players.FirstOrDefault(p => p.Name == nameReader); var key = new ConsoleKeyInfo(); while (key.Key != ConsoleKey.Enter) { if (player != null) { var namesWithBeers = new SortedDictionary <string, int>(); foreach (var beer in player.BeersToBeTaken) { var loserName = beer.Loser.Name; if (!namesWithBeers.ContainsKey(loserName)) { namesWithBeers[loserName] = 0; } namesWithBeers[loserName]++; } if (namesWithBeers.Count > 0) { foreach (var nameWithBeers in namesWithBeers.Reverse()) { if (nameWithBeers.Value <= 1) { Console.WriteLine($"----- {nameWithBeers.Key} owns {nameWithBeers.Value} beer -----"); } else { Console.WriteLine($"----- {nameWithBeers.Key} owns {nameWithBeers.Value} beers -----"); } } } else { Console.WriteLine("Player has not earned any beers yet!"); } } else { Console.WriteLine("Player does not exist!"); Pause(3); } Console.WriteLine("...PRESS ENTER TO GO BACK TO MAIN MENU..."); key = Console.ReadKey(); } TypesOfMenu.StartMenu(); } //--> TERMINATES PROGRAM <-- else if (action == MenuActions.QUIT.ToString()) { Environment.Exit(0); } else if (action == MenuActions.DUEL.ToString() || action == MenuActions.ARENA.ToString()) { CharacterCreation.TypeNames(action); } }