public OtherTeamPlayer OpponentFighterOptions(OtherTeamPlayer otherTeamPlayer, List <OtherTeamPlayer> otherTeamPlayers) { int number = 0; int displayNumber = 1; foreach (OtherTeamPlayer index in otherTeamPlayers) { if (number == 0) { Console.WriteLine($" {otherTeamPlayers[number].Team}"); } else if (otherTeamPlayers[number].Team != otherTeamPlayers[number - 1].Team) { Console.WriteLine($" {otherTeamPlayers[number].Team}"); } if (displayNumber < 10) { Console.Write($" {displayNumber}. "); displayNumber++; } else { Console.Write($"{displayNumber}. "); displayNumber++; } otherTeamPlayer.TeamStatDisplay(index); number++; } int playerChoice = Convert.ToInt32(Console.ReadLine()) - 1; return(otherTeamPlayers[playerChoice]); }
public void FightOutcome(Player player, OtherTeamPlayer otherTeamPlayer) { string displayName = player.NameRandomizer(player); List <string> midFightBanter = new List <string> { "It's on!!!", "The fists are flying!", "He's getting some help from his teammates!", "They're holding him back!", "The refs are gonna let them go for a bit!", "The crowd is on their feet!" }; List <string> victoryBanter = new List <string> { $"{displayName} gets the better of it! He's off to the box with a smile on his face.", $"A decisive victory for {displayName}!" }; List <string> defeatBanter = new List <string> { $"Ouch! {otherTeamPlayer.Name} knocks {displayName} down to the ice!", "The Jackets did not get the better of this fight..." }; Random random = new Random(); int randomMidFight = random.Next(6); int randomVictory = random.Next(2); int randomDefeat = random.Next(2); Console.WriteLine("The gloves are off!"); Console.ReadLine(); Console.WriteLine(midFightBanter[randomMidFight]); Console.ReadLine(); if (player.FightStamina >= otherTeamPlayer.FightStamina) { Console.WriteLine(victoryBanter[randomVictory]); Console.ReadLine(); } else { Console.WriteLine(defeatBanter[randomDefeat]); Console.ReadLine(); } player.FightStamina -= 31; player.PenaltyTime += 6; }
static void Main(string[] args) { Player player = new Player(); List <Player> blueJacketsRoster = new List <Player>(); player.BlueJacketsRoster(blueJacketsRoster); OtherTeamPlayer otherTeamPlayer = new OtherTeamPlayer(); List <OtherTeamPlayer> playersToFight = new List <OtherTeamPlayer>(); otherTeamPlayer.PlayersFromOtherTeams(playersToFight); MenuOptions menuOptions = new MenuOptions(); bool refreshMenu = true; while (refreshMenu) { Console.Clear(); Console.WriteLine("IT'S HOCKEY TIME IN AMERICA!!!!!\nPlay hockey with the Columbus Blue Jackets!\n"); int currentScore = menuOptions.CalculateScore(blueJacketsRoster); int currentPenaltyTime = menuOptions.CalculateTotalPenaltyTime(blueJacketsRoster); Console.WriteLine($"Score: {currentScore}"); Console.WriteLine("Choose your option:"); Console.WriteLine(" 1. Shoot at the goal"); Console.WriteLine(" 2. Defend a shot"); Console.WriteLine(" 3. Start a fight"); Console.WriteLine(" 4. Serve your time in the penalty box"); Console.WriteLine(" 5. Add a player"); Console.WriteLine(" 6. Instructions"); Console.WriteLine(" 7. Quit"); if (currentScore >= 10) { Console.WriteLine("\nCongratulations!!! You win!!!"); break; } if (currentPenaltyTime > 10) { Console.WriteLine("\nYou took too many penalties... You lose..."); break; } string userChoice = Console.ReadLine(); bool ineligiblePlayer = true; switch (userChoice) { case "1": while (ineligiblePlayer) { Console.Clear(); Console.WriteLine("Choose your player to take a shot!"); Player shootingPlayer = menuOptions.ShooterOptions(player, blueJacketsRoster); if (shootingPlayer.PenaltyTime > 0) { Console.WriteLine("You can't pick him! He's in the penalty box!"); Console.ReadLine(); } else { ineligiblePlayer = false; Console.WriteLine($"{shootingPlayer.Name} takes the puck down the ice!"); Console.ReadLine(); menuOptions.ShotOptions(shootingPlayer); } } break; case "2": while (ineligiblePlayer) { Console.Clear(); Console.WriteLine("Choose which defenseman to make a play or goalie to defend the net!"); Player defensePlayer = menuOptions.DefenseOptions(player, blueJacketsRoster); if (defensePlayer.PenaltyTime > 0) { Console.WriteLine("You can't pick him! He's in the penalty box!"); Console.ReadLine(); } else { ineligiblePlayer = false; Console.WriteLine($"The offense is coming down the ice toward {defensePlayer.Name}."); Console.ReadLine(); menuOptions.DefenseOptions(defensePlayer); } } break; case "3": while (ineligiblePlayer) { Console.Clear(); Console.WriteLine("Choose your fighter:"); Player fightingPlayer = menuOptions.FighterOptions(player, blueJacketsRoster); if (fightingPlayer.PenaltyTime > 0) { Console.WriteLine("You can't pick him! He's in the penalty box!"); Console.ReadLine(); } else { ineligiblePlayer = false; Console.Clear(); Console.WriteLine("Choose which player to fight:"); OtherTeamPlayer playerToFight = menuOptions.OpponentFighterOptions(otherTeamPlayer, playersToFight); menuOptions.FightOutcome(fightingPlayer, playerToFight); } } break; case "4": Console.Clear(); Console.WriteLine("Choose a player whose penalty time you want to reduce:"); Player penalizedPlayer = menuOptions.PenalizedOptions(player, blueJacketsRoster); if (penalizedPlayer.Name != null) { Console.WriteLine($"\n{penalizedPlayer.Name}'s time in the box has been served."); } penalizedPlayer.PenaltyTime = 0; Console.ReadLine(); break; case "5": Console.Clear(); Console.WriteLine("Add a player. What's their first name?"); string newPlayerFirstName = Console.ReadLine(); Console.WriteLine("What's their last name?"); string newPlayerLastName = Console.ReadLine(); string newPlayerName = newPlayerFirstName + " " + newPlayerLastName; Console.WriteLine("What position?"); Console.WriteLine(" 1. Goalie (GK)"); Console.WriteLine(" 2. Defenseman (DE)"); Console.WriteLine(" 3. Center (C)"); Console.WriteLine(" 4. Left Wing (LW)"); Console.WriteLine(" 5. Right Wing (RW)"); bool invalidPostition = true; string newPlayerPosition = null; while (invalidPostition) { newPlayerPosition = Console.ReadLine(); switch (newPlayerPosition) { case "1": newPlayerPosition = "GK"; invalidPostition = false; break; case "2": newPlayerPosition = "DE"; invalidPostition = false; break; case "3": newPlayerPosition = "C "; invalidPostition = false; break; case "4": newPlayerPosition = "LW"; invalidPostition = false; break; case "5": newPlayerPosition = "RW"; invalidPostition = false; break; default: Console.WriteLine("Hey, that's not an option!"); break; } } Console.WriteLine("What's their number?"); string newPlayerNumber = Console.ReadLine(); blueJacketsRoster.Add(new Player(newPlayerName, newPlayerNumber, newPlayerPosition)); int rosterCount = blueJacketsRoster.Count; Console.WriteLine($"Okay, {blueJacketsRoster[rosterCount - 1].Name} is ready to take to the ice."); Console.ReadLine(); break; case "6": menuOptions.Instructions(); break; case "7": refreshMenu = false; break; default: Console.Clear(); break; } if (userChoice == "1" || userChoice == "2" || userChoice == "3" || userChoice == "4") { foreach (Player playerStats in blueJacketsRoster) { playerStats.PenaltyTime--; playerStats.FightStamina++; } } } }
public void TeamStatDisplay(OtherTeamPlayer otherTeamPlayer) { Console.WriteLine($"{otherTeamPlayer.Position} {otherTeamPlayer.Number} {otherTeamPlayer.Name}"); }