public override void CreateGame() { InitializeBoard(); AssignStartingPlayer(); BoardPopulator.SelectTerritories(); BoardPopulator.DeployArmies(); var play = new PlayerTurn(); play.GamePlay(); }
public static void CreateGame() { InitializeBoard(); AssignStartingPlayer(); MenuBuilder.GameSetupOptions(); //Move these to a new method depening on gamesetup option BoardPopulator.SelectTerritories(); BoardPopulator.DeployArmies(); }
private static Territory ChooseAttacker() { var territory = new Territory(); var confirmed = false; while (confirmed == false) { var player = GameBoard.GetBoard().CurrentPlayer; Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn."); Console.Write("\n\tPlease select the territory you want to "); Colour.SouthAmericaRed("attack with.\n"); MapBuilder.ShowEntireWorld(); Console.WriteLine("\n\tEnter 43 to return to menu."); var option = GameEngine.UserInputTest("\t(1-43)>", "\tInvalid input, please try again!", 1, 43); if (option != 43) { territory = BoardPopulator.FindTerritory(option); if (territory.Occupant != player.Name) { Console.WriteLine("\tTerritory is occupied by another player."); Console.WriteLine("\tPress any key to retry...."); Console.ReadKey(); } else if (territory.Armies < 2) { Console.WriteLine("\tTerritory must have at least 2 armies to attack with."); Console.WriteLine("\tPress any key to retry...."); Console.ReadKey(); } else { confirmed = true; } } else { confirmed = true; } } return(territory); }
private static Territory ChooseDefender(Territory attacker) { var territory = new Territory(); var confirmed = false; while (confirmed == false) { Console.Clear(); var player = GameBoard.GetBoard().CurrentPlayer; Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn."); Console.Write("\n\tPlease select the territory you want to "); Colour.SouthAmericaRed("Attack.\n"); var numberMap = MapBuilder.ShowTerritoriesNeighbours(attacker); var highest = numberMap.Count + 1; Console.WriteLine("\tTo return to the main menu, enter " + highest); var prompt = "\n\t(1-" + highest + ")>"; var option = GameEngine.UserInputTest(prompt, "\tInvalid input, please try again!", 1, highest); if (option == highest) { confirmed = true; } else { int result; numberMap.TryGetValue(option, out result); territory = BoardPopulator.FindTerritory(result); if (territory != null && territory.Occupant != player.Name) { confirmed = true; } else { Console.WriteLine("\tCannot attack a territory which you occupy!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } } } return(territory); }
public void Populate() { var confirmed = false; while (confirmed == false) { var armyCount = GameBoard.GetBoard().GetPlayerByIndex(0).Armies; BoardPopulator.AutoPopulate(); MapBuilder.ShowEntireWorld(); Console.WriteLine("\n\t=========================="); Console.WriteLine("\t1. Confirm board layout"); Console.WriteLine("\t2. Change board layout"); Console.WriteLine("\t3. Quit Game"); Console.WriteLine("\t=========================="); var option = GameEngine.UserInputTest("\t(1-3)>", "\tInvalid input, please try again!", 1, 3); switch (option) { case 1: confirmed = true; break; case 2: GameEngine.Timer("Building new board"); Console.WriteLine("\r\tPress any key to continue."); Console.ReadKey(); foreach (var player in GameBoard.GetBoard().GetPlayerList()) { player.Armies = armyCount; } break; case 3: Console.Clear(); Console.WriteLine("\tThank you and goodbye!\n\tPress any key to exit......."); Console.ReadKey(); Environment.Exit(0); break; default: Console.WriteLine("Error"); break; } } }
private static Territory PickSupplerTerritory() { var territory = new Territory(); var confirmed = false; while (confirmed == false) { var player = GameBoard.GetBoard().CurrentPlayer; Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn."); Console.Write("\n\tPlease select the territory you want to "); Colour.SouthAmericaRed("Move Troops From.\n"); MapBuilder.ShowEntireWorld(); var option = GameEngine.UserInputTest("\n\t(1-42)>", "\tInvalid input, please try again!", 1, 42); territory = BoardPopulator.FindTerritory(option); if (territory.Occupant != player.Name) { Console.WriteLine("\tTerritory is occupied by another player."); Console.WriteLine("\tPress any key to retry...."); Console.ReadKey(); } else if (territory.Armies == 1) { Console.WriteLine("\tTerritory must have more than 1 army."); Console.WriteLine("\tPress any key to retry...."); Console.ReadKey(); } else { confirmed = true; } } return(territory); }
public static void DeployTroops(Player player) { while (player.Armies > 0) { Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Colour.PrintPlayer(player.Colour, "\t" + player.Name); Console.WriteLine(" , add one or more army units to a territory you occupy"); Console.Write("\tYou have "); Colour.PrintPlayer(player.Colour, player.Armies.ToString()); Console.Write(" armies left to deploy"); MapBuilder.ShowEntireWorld(); var isPlayersTerritory = false; while (isPlayersTerritory == false) { var selection = GameEngine.UserInputTest("\n\tEnter territory number (1-42)>", "\tInvalid selection!", 1, 42); var country = BoardPopulator.FindTerritory(selection); if (country.Occupant == player.Name) { var troops = GameEngine.UserInputTest("\n\tEnter number of units you wish to send (1-" + player.Armies + ")>", "\tInvalid selection!", 1, player.Armies); country.Armies += troops; player.Armies -= troops; isPlayersTerritory = true; } else { Console.WriteLine("\tYou have selected a territory that is occupied by another player!\n"); } } } }
private static Territory PickReceiverTerritory(Territory supplier) { var territory = new Territory(); var confirmed = false; while (confirmed == false) { Console.Clear(); var player = GameBoard.GetBoard().CurrentPlayer; Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn."); Console.Write("\n\tPlease select the territory you want to "); Colour.SouthAmericaRed("Fortify.\n"); var numberMap = MapBuilder.ShowTerritoriesNeighbours(supplier); var option = GameEngine.UserInputTest("\n\t(Territory number)>", "\tInvalid input, please try again!", 1, numberMap.Count); int result; numberMap.TryGetValue(option, out result); territory = BoardPopulator.FindTerritory(result); if (territory != null && territory.Occupant == player.Name) { confirmed = true; } else { Console.WriteLine("\tCannot move troops into enemy territory!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } } return(territory); }