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); }
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"); } } } }
public static void SelectTerritories() { var board = GameBoard.GetBoard(); var selected = false; while (selected == false) { var player = board.CurrentPlayer; Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Colour.PrintPlayer(player.Colour, "\t" + player.Name); Console.WriteLine(" please select a territory you wish to occupy"); MapBuilder.ShowEntireWorld(); var selection = GameEngine.UserInputTest("\n\tEnter territory number (1-42)>", "\tInvalid selection!", 1, 42); var result = FindTerritory(selection); if (CheckIfOccupied(result, player) == false) { board.SetCurrentPlayer(); } if (CheckMapIsFull(board)) { selected = true; } } Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t==========================================="); Console.WriteLine("\tAll territories are now occupied."); Console.WriteLine("\tDeploy remaining armies to your territories."); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); }