public static void StartMenu() { Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Main Menu"); Console.WriteLine("\t1. Start New Game"); Console.WriteLine("\t2. Load Game"); 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: GameSetupOptions(); break; case 2: Game builder = new LoadedGame(); var risk = new Risk(); risk.Construct(builder); break; case 3: Console.WriteLine("\tThank you and goodbye!\n\tPress any key to exit......."); Console.ReadKey(); Environment.Exit(0); break; default: Console.WriteLine("Error"); break; } }
public static List <Player> CreatePlayers() { var playerList = new List <Player>(); _usedNames = new string[6]; _colourList = new Dictionary <int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 } }; Console.Clear(); Colour.SouthAmericaRed("\t\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Console.WriteLine("\tEnter the number of players"); var playersCount = GameEngine.UserInputTest("\t(2-6)>", "\tInvalid selection, please try again.\n", 2, 6); for (int player = 1; player <= playersCount; player++) { Console.Clear(); Colour.SouthAmericaRed("\t\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); var name = NameValidator(player); var colour = ColourPick(); var armies = 0; switch (playersCount) { case 2: armies = 40; break; case 3: armies = 35; break; case 4: armies = 30; break; case 5: armies = 25; break; case 6: armies = 20; break; } playerList.Add(new Player(name, armies, colour)); } return(playerList); }
private static void ArrangeBattle(Attack attack) { Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Battle Options"); Colour.PrintLand(attack.AttackingTerritory.Continent, "\n\t" + attack.AttackingTerritory.Name); Console.Write(", Occupied by "); Colour.PrintPlayer(attack.Attacker.Colour, attack.Attacker.Name); Console.Write(" is Attacking with "); Colour.SouthAmericaRed(attack.AttackingTerritory.Armies.ToString()); Console.Write(" armies."); Colour.PrintLand(attack.DefendingTerritory.Continent, "\n\t" + attack.DefendingTerritory.Name); Console.Write(", Occupied by "); Colour.PrintPlayer(attack.Defender.Colour, attack.Defender.Name); Console.Write(" is Defending with "); Colour.SouthAmericaRed(attack.DefendingTerritory.Armies.ToString()); Console.Write(" armies.\n"); var first = false; while (first == false) { Colour.PrintPlayer(attack.Attacker.Colour, "\n\t" + attack.Attacker.Name); var attackDie = GameEngine.UserInputTest("\n\tHow many Dice would you like to attack with (1-3) : ", "\tInvalid input, please try again!", 1, 3); if (CheckDieOption(attackDie, "attacker", attack.AttackingTerritory)) { attack.AttackDiceCount = attackDie; first = true; } } var second = false; while (second == false) { Colour.PrintPlayer(attack.Defender.Colour, "\n\t" + attack.Defender.Name); var defendDie = GameEngine.UserInputTest("\n\tHow many Dice would you like to to defend with (1-2) : ", "\tInvalid input, please try again!", 1, 2); if (CheckDieOption(defendDie, "defender", attack.DefendingTerritory)) { attack.DefendDiceCount = defendDie; second = true; } } }
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 static void PlayerTurnMenu() { var player = GameBoard.GetBoard().CurrentPlayer; var temp = false; while (temp == false) { Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Game Menu"); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn.\n"); Console.WriteLine("\t1. Return to game"); Console.WriteLine("\t2. Save Game"); Console.WriteLine("\t3. Quit Game"); Console.WriteLine("\t=========================="); var option = GameEngine.UserInputTest("\t(1-4)>", "\tInvalid input, please try again!", 1, 4); switch (option) { case 1: temp = true; break; case 2: var slot = SaveGameMenu("save"); if (slot != 7) { GameSaver.SaveGame(slot); } break; case 3: Console.WriteLine("\tThank you and goodbye!\n\tPress any key to exit......."); Console.ReadKey(); Environment.Exit(0); break; default: Console.WriteLine("Error"); break; } } }
public static int SaveGameMenu(string gameOption) { Console.Clear(); var meta = SaveGameMetaData.Meta; Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t==========================================="); Console.WriteLine("\t Save Menu"); Console.WriteLine("\t1. Slot 1 - " + meta.Save1Count + " Players...." + meta.Save1Date); Console.WriteLine("\t2. Slot 2 - " + meta.Save2Count + " Players...." + meta.Save2Date); Console.WriteLine("\t3. Slot 3 - " + meta.Save3Count + " Players...." + meta.Save3Date); Console.WriteLine("\t4. Slot 4 - " + meta.Save4Count + " Players...." + meta.Save4Date); Console.WriteLine("\t5. Slot 5 - " + meta.Save5Count + " Players...." + meta.Save5Date); Console.WriteLine("\t6. Slot 6 - " + meta.Save6Count + " Players...." + meta.Save6Date); Console.WriteLine("\t7. Return to previous Menu"); Console.WriteLine("\t=========================="); var option = GameEngine.UserInputTest("\t(1-7)>", "\tInvalid input, please try again!", 1, 7); switch (option) { case 1: return(1); case 2: return(2); case 3: return(3); case 4: return(4); case 5: return(5); case 6: return(6); case 7: return(7); default: Console.WriteLine("Error"); return(0); } }
public void BattleMenu() { var complete = false; while (complete == false) { var player = GameBoard.GetBoard().CurrentPlayer; Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Battle Menu"); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn.\n"); Console.WriteLine("\t1. Select territory to attack"); Console.WriteLine("\t2. Game Menu"); Console.WriteLine("\t3. Finish Fighting"); Console.WriteLine("\t=========================="); var option = GameEngine.UserInputTest("\t(1-3)>", "\tInvalid input, please try again!", 1, 3); switch (option) { case 1: var attack = BuildBattle(); if (attack.AttackingTerritory != null) { var unused = new WorldConquered(this); BeginBattle(attack); } break; case 2: GamePlayMenus.PlayerTurnMenu(); break; case 3: complete = true; break; default: Console.WriteLine("Error"); break; } } }
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; } } }
public static void DeployArmies() { var board = GameBoard.GetBoard(); var finished = 0; while (finished < board.GetPlayerList().Count) { var player = board.CurrentPlayer; Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Colour.PrintPlayer(player.Colour, "\t" + player.Name); Console.WriteLine(" , add one army unit 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 = FindTerritory(selection); if (country.Occupant == player.Name) { country.Armies += 1; player.Armies -= 1; isPlayersTerritory = true; } else { Console.WriteLine("\tYou have selected a territory that is occupied by another player!\n"); } } if (player.Armies == 0) { finished++; } board.SetCurrentPlayer(); } }
private static void MovementOrders(Territory supplier, Territory receiver) { 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.WriteLine("\n\tSelect the number of armies you wish to move from {0}, to fortify {1}?.", supplier.Name, receiver.Name); var armies = supplier.Armies - 1; var prompt = "\t(1-" + armies + ")>"; var option = GameEngine.UserInputTest(prompt, "\tInvalid input, please try again!", 1, armies); supplier.Armies -= option; receiver.Armies += option; }
public static int ColourPick() { var option = 0; var picked = false; while (picked == false) { Console.Clear(); Colour.SouthAmericaRed("\t\t **** Risk! ****\n"); Console.WriteLine("\t===================================="); Console.WriteLine("\tChoose your player colour"); Console.Write("\t1. "); Colour.NorthAmericaYellow("Yellow\n"); Console.Write("\t2. "); Colour.SouthAmericaRed("Red\n"); Console.Write("\t3. "); Colour.EuropeBlue("Blue\n"); Console.Write("\t4. "); Colour.AfricaMagenta("Magenta\n"); Console.Write("\t5. "); Colour.AsiaGreen("Green\n"); Console.Write("\t6. "); Colour.AustralasiaCyan("Cyan\n"); Console.WriteLine("\t=========================="); option = GameEngine.UserInputTest("\t(1-6)>", "\tInvalid input, please try again!", 1, 6); if (_colourList.ContainsKey(option)) { _colourList.Remove(option); picked = true; } else { Console.WriteLine("\tColour already in use, please choose a different colour."); Console.WriteLine("\tPress any key to continue..."); Console.ReadKey(); } } return(option); }
public static void FortificationMenu() { var complete = false; while (complete == false) { var player = GameBoard.GetBoard().CurrentPlayer; Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Fortification Menu"); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn.\n"); Console.WriteLine("\t1. Move Troops"); Console.WriteLine("\t2. Game Menu"); Console.WriteLine("\t3. End Turn"); Console.WriteLine("\t=========================="); var option = GameEngine.UserInputTest("\t(1-3)>", "\tInvalid input, please try again!", 1, 3); switch (option) { case 1: MoveTroops(); break; case 2: GamePlayMenus.PlayerTurnMenu(); break; case 3: complete = true; 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); }
private void TerritoryConquered(Attack attack) { Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Victory!"); Colour.PrintPlayer(attack.Attacker.Colour, "\t" + attack.Attacker.Name); Console.Write(", you have defeated all of the armies in "); Colour.PrintLand(attack.DefendingTerritory.Continent, attack.DefendingTerritory.Name); attack.DefendingTerritory.Occupant = attack.Attacker.Name; var landCount = CountPlayersTerritories(attack.Attacker); if (landCount == 42) { OnGameCompleted(); } if (attack.AttackingTerritory.Armies == 2) { Console.WriteLine("\n\tOne army has been moved to {0}.", attack.Defender.Name); attack.AttackingTerritory.Armies -= 1; attack.DefendingTerritory.Armies += 1; } else { Console.WriteLine("\n\tSelect the number of armies you wish to move from {0}, to occupy {1} with.", attack.AttackingTerritory.Name, attack.DefendingTerritory.Name); var armies = attack.AttackingTerritory.Armies - 1; var prompt = "\t(1-" + armies + ")>"; var option = GameEngine.UserInputTest(prompt, "\tInvalid input, please try again!", 1, armies); attack.AttackingTerritory.Armies -= option; attack.DefendingTerritory.Armies += option; } GameBoard.GetBoard().CurrentPlayer.ConqueredDuringTurn += 1; Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); CheckUserHasTerritories(attack.Defender, attack.Attacker); }
public static void GameSetupOptions() { Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Main Menu"); Console.WriteLine("\t1. Manual setup (players choose territories)"); Console.WriteLine("\t2. Quick Setup (Territories are assigned)"); 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: Game manualBuilder = new ManualGame(); var manualGame = new Risk(); manualGame.Construct(manualBuilder); break; case 2: Game quickBuilder = new QuickGame(); var quickGame = new Risk(); quickGame.Construct(quickBuilder); break; case 3: Console.WriteLine("\tThank you and goodbye!\n\tPress any key to exit......."); Console.ReadKey(); Environment.Exit(0); break; default: Console.WriteLine("Error"); break; } Console.ReadKey(); }
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); }
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(); }
public static int TradeMenu() { var player = GameBoard.GetBoard().CurrentPlayer; _cards = new PlayersCards(player.Cards); var doneTrading = false; while (doneTrading == false) { Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Card trade menu"); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn.\n"); if (player.Cards.Count > 6) { Colour.SouthAmericaRed("\tYou must trade at least one set of cards!\n"); } int infantryCount, cavalryCount, artillaryCount, wildCount; if (_cards.Infantry == null) { infantryCount = 0; } else { infantryCount = _cards.Infantry.Count; } if (_cards.Cavalry == null) { cavalryCount = 0; } else { cavalryCount = _cards.Cavalry.Count; } if (_cards.Artillary == null) { artillaryCount = 0; } else { artillaryCount = _cards.Artillary.Count; } if (_cards.Wild == null) { wildCount = 0; } else { wildCount = _cards.Wild.Count; } Console.WriteLine("\tInfantry cards = " + infantryCount); Console.WriteLine("\tCavalry cards = " + cavalryCount); Console.WriteLine("\tArtillary cards = " + artillaryCount); Console.WriteLine("\tWild cards = " + wildCount); Console.WriteLine("\n\t1. Play three of a kind"); Console.WriteLine("\t2. Play one of each"); Console.WriteLine("\t3. Play a wild card"); Console.WriteLine("\t4. Game Menu"); Console.WriteLine("\t5. Commence deployment of reinforcements"); Console.WriteLine("\t=========================="); var option = GameEngine.UserInputTest("\t(1-5)>", "\tInvalid input, please try again!", 1, 5); switch (option) { case 1: PlayThreeOfAKind(infantryCount, cavalryCount, artillaryCount, wildCount); break; case 2: PlayOneOfEach(infantryCount, cavalryCount, artillaryCount, wildCount); break; case 3: PlayWildCard(infantryCount, cavalryCount, artillaryCount, wildCount); break; case 4: GamePlayMenus.PlayerTurnMenu(); break; case 5: if (player.Cards.Count <= 6) { doneTrading = true; } else { Console.WriteLine("\tYou have more than 6 cards, You must trade some!"); } break; default: Console.WriteLine("\tError"); break; } } return(_armies); }
private static void PlayWildCard(int infantry, int cavalry, int artillery, int wild) { var done = false; while (done == false) { var usedCards = new List <Card>(); var player = GameBoard.GetBoard().CurrentPlayer; Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\tTrade a wild card menu"); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn.\n"); if (player.Cards.Count > 6) { Colour.SouthAmericaRed("\tYou must trade at least one set of cards!\n"); } Console.WriteLine("\tInfantry cards = " + infantry); Console.WriteLine("\tCavalry cards = " + cavalry); Console.WriteLine("\tArtillary cards = " + artillery); Console.WriteLine("\tWild cards = " + wild); Console.WriteLine("\n\t1. Play a wild card with two infantry cards"); Console.WriteLine("\t2. Play a wild card with two cavalry cards"); Console.WriteLine("\t3. Play a wild card with two artillery cards"); Console.WriteLine("\t4. Play a wild card with an infantry and cavalry card"); Console.WriteLine("\t5. Play a wild card with an infantry and artillary card"); Console.WriteLine("\t6. Play a wild card with a cavalry and artillery card"); Console.WriteLine("\t7. return to previous menu"); Console.WriteLine("\t=========================="); var option = GameEngine.UserInputTest("\t(1-7)>", "\tInvalid input, please try again!", 1, 7); switch (option) { case 1: if (infantry >= 2) { usedCards.Add(_cards.Wild[0]); _cards.Wild.RemoveAt(0); for (var index = 0; index <= 1; index++) { usedCards.Add(_cards.Infantry[0]); _cards.Infantry.RemoveAt(0); } wild -= 1; infantry -= 2; GameBoard.GetBoard().AddToUsedCardPile(usedCards); TradedCardValue(); Console.WriteLine("\tCards traded, Press any key to continue...."); Console.ReadKey(); } else { Console.WriteLine("\tYou do not have enough of that type of card!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } break; case 2: if (cavalry >= 3) { usedCards.Add(_cards.Wild[0]); _cards.Wild.RemoveAt(0); for (var index = 0; index <= 1; index++) { usedCards.Add(_cards.Cavalry[0]); _cards.Cavalry.RemoveAt(0); } wild -= 1; cavalry -= 2; GameBoard.GetBoard().AddToUsedCardPile(usedCards); TradedCardValue(); Console.WriteLine("\tCards traded, Press any key to continue...."); Console.ReadKey(); } else { Console.WriteLine("\tYou do not have enough of that type of card!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } break; case 3: if (artillery >= 3) { usedCards.Add(_cards.Wild[0]); _cards.Wild.RemoveAt(0); for (var index = 0; index <= 1; index++) { usedCards.Add(_cards.Artillary[0]); _cards.Artillary.RemoveAt(0); } wild -= 1; artillery -= 2; GameBoard.GetBoard().AddToUsedCardPile(usedCards); TradedCardValue(); Console.WriteLine("\tCards traded, Press any key to continue...."); Console.ReadKey(); } else { Console.WriteLine("\tYou do not have enough of that type of card!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } break; case 4: if (infantry >= 1 && cavalry >= 1) { usedCards.Add(_cards.Wild[0]); _cards.Wild.RemoveAt(0); usedCards.Add(_cards.Infantry[0]); _cards.Infantry.RemoveAt(0); usedCards.Add(_cards.Cavalry[0]); _cards.Cavalry.RemoveAt(0); wild -= 1; infantry -= 1; cavalry -= 1; GameBoard.GetBoard().AddToUsedCardPile(usedCards); TradedCardValue(); Console.WriteLine("\tCards traded, Press any key to continue...."); Console.ReadKey(); } else { Console.WriteLine("\tYou do not have enough of those types of card!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } break; case 5: if (infantry >= 1 && artillery >= 1) { usedCards.Add(_cards.Wild[0]); _cards.Wild.RemoveAt(0); usedCards.Add(_cards.Infantry[0]); _cards.Infantry.RemoveAt(0); usedCards.Add(_cards.Artillary[0]); _cards.Artillary.RemoveAt(0); wild -= 1; infantry -= 1; artillery -= 1; GameBoard.GetBoard().AddToUsedCardPile(usedCards); TradedCardValue(); Console.WriteLine("\tCards traded, Press any key to continue...."); Console.ReadKey(); } else { Console.WriteLine("\tYou do not have enough of those types of card!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } break; case 6: if (cavalry >= 1 && artillery >= 1) { usedCards.Add(_cards.Wild[0]); _cards.Wild.RemoveAt(0); usedCards.Add(_cards.Cavalry[0]); _cards.Cavalry.RemoveAt(0); usedCards.Add(_cards.Artillary[0]); _cards.Artillary.RemoveAt(0); wild -= 1; cavalry -= 1; artillery -= 1; GameBoard.GetBoard().AddToUsedCardPile(usedCards); TradedCardValue(); Console.WriteLine("\tCards traded, Press any key to continue...."); Console.ReadKey(); } else { Console.WriteLine("\tYou do not have enough of those types of card!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } break; case 7: done = true; break; default: Console.WriteLine("\tError"); break; } } }
private static void PlayOneOfEach(int infantry, int cavalry, int artillery, int wild) { var done = false; while (done == false) { var usedCards = new List <Card>(); var player = GameBoard.GetBoard().CurrentPlayer; Console.Clear(); Colour.SouthAmericaRed("\t **** Risk! ****\n"); Console.WriteLine("\t=========================="); Console.WriteLine("\t Trade one of each menu"); Console.Write("\tCurrently "); Colour.PrintPlayer(player.Colour, player.Name + "'s"); Console.Write(" turn.\n"); if (player.Cards.Count > 6) { Colour.SouthAmericaRed("\tYou must trade at least one set of cards!\n"); } Console.WriteLine("\tInfantry cards = " + infantry); Console.WriteLine("\tCavalry cards = " + cavalry); Console.WriteLine("\tArtillary cards = " + artillery); Console.WriteLine("\tWild cards = " + wild); Console.WriteLine("\n\t1. Play one of each card"); Console.WriteLine("\t2. return to previous menu"); Console.WriteLine("\t=========================="); var option = GameEngine.UserInputTest("\t(1-2)>", "\tInvalid input, please try again!", 1, 2); switch (option) { case 1: if (infantry >= 1 && cavalry >= 1 && artillery >= 1) { usedCards.Add(_cards.Infantry[0]); _cards.Infantry.RemoveAt(0); usedCards.Add(_cards.Cavalry[0]); _cards.Cavalry.RemoveAt(0); usedCards.Add(_cards.Artillary[0]); _cards.Artillary.RemoveAt(0); artillery -= 1; cavalry -= 1; artillery -= 1; GameBoard.GetBoard().AddToUsedCardPile(usedCards); TradedCardValue(); Console.WriteLine("\tCards traded, Press any key to continue...."); Console.ReadKey(); } else { Console.WriteLine("\tYou do not have enough of that type of card!"); Console.WriteLine("\tPress any key to continue...."); Console.ReadKey(); } break; case 2: done = true; break; default: Console.WriteLine("\tError"); break; } } }