private static void ResetExhibitionGameData() { home.Score = 0; home.IsHome = false; home.IsUserTeam = false; away.Score = 0; away.IsUserTeam = false; List <Player> playerList = new List <Player>() { home.Center, home.Winger, home.Defenseman, away.Center, away.Winger, away.Defenseman, }; foreach (Player p in playerList) { p.HasPuck = false; } user = null; opponent = null; teammate = null; goalie = null; playerWithPuck = null; defendingPlayer = null; zone = Zones.neutral; }
private static string SetupShotAttempt() { goalie = (home.HasPuck ? away.Goalie : home.Goalie); if (user.HasPuck) { if (home.HasPuck) { TextFormat.UserHome(user.Name); Console.Write(" has an open shot on "); TextFormat.Away(goalie.Name); Console.WriteLine('.'); } else { TextFormat.UserAway(user.Name); Console.WriteLine($" has an open shot on {goalie}."); } Thread.Sleep(1000); return(DisplayUserChoices()); } else if (opponent.HasPuck) { if (home.HasPuck) { Console.Write($"{opponent.Name} has an open shot on "); TextFormat.Away(goalie.Name); Console.WriteLine('.'); } else { TextFormat.Away(opponent.Name); Console.WriteLine($" has an open shot on {goalie}."); } Thread.Sleep(1000); return(SelectAIChoice()); } else { Console.Write($"{teammate} has an open shot on "); TextFormat.Away(goalie.Name); Console.WriteLine('.'); Thread.Sleep(1000); return(SelectAIChoice()); } }
private static float ExecuteShotAttempt(Player player, Goalie goalie) { float offStat = player.Shooting; float defStat = goalie.Average; // Home ice advantage stat boost if (player.AssignedTeam.IsHome) { offStat += 2; } else { defStat += 2; } return(ExecutePlay(offStat, defStat)); }
private static float ExecuteShotAttempt(Player player, Goalie goalie, string shotLocation) { float offStat = player.Shooting; float defStat = 0; switch (shotLocation) { case "low stick": defStat = goalie.StickLow; break; case "low glove": defStat = goalie.GloveLow; break; case "high stick": defStat = goalie.StickHigh; break; case "high glove": defStat = goalie.GloveHigh; break; case "legs": defStat = goalie.BetweenLegs; break; } // Home ice advantage stat boost if (player.AssignedTeam.IsHome) { offStat += 2; } else { defStat += 2; } return(ExecutePlay(offStat, defStat)); }
private static string DisplayUserChoices() { #region Shot Attempt if (user.HasPuck && zone == Zones.goal) { Console.WriteLine("\nWhere will you shoot the puck?\n"); Console.WriteLine("1. Low stick side"); Console.WriteLine("2. Low glove side"); Console.WriteLine("3. High stick side"); Console.WriteLine("4. High glove side"); Console.WriteLine("5. Between the legs"); isShooting = true; do { input = ""; Console.Write("\nChoice: "); input = Console.ReadLine().ToLower(); Console.WriteLine(); if (home.IsUserTeam) { TextFormat.UserHome(user.Name); } else { TextFormat.UserAway(user.Name); } switch (input) { case "1": case "low stick": case "low stick side": Console.Write(" shoots for the low stick side!"); return("low stick"); case "2": case "low glove": case "low glove side": Console.Write(" shoots for the low glove side!"); return("low glove"); case "3": case "high stick": case "high stick side": Console.Write(" shoots for the high stick side!"); return("high st shoots for ick"); case "4": case "high glove": case "high glove side": Console.Write(" shoots for the high glove side!"); return("high glove"); case "5": case "legs": case "between legs": Console.Write(" shoots for between the goalie's legs!"); return("legs"); default: Console.WriteLine("Invalid selection. Please try again."); break; } } while (true); } #endregion #region Offense else if (user.HasPuck) { Console.WriteLine("How will you proceed?\n"); Console.WriteLine("1. Skate past the defender (Speed)"); Console.WriteLine("2. Power through the defender (Strength)"); Console.WriteLine("3. Deke past the defender (Stick Handling)"); if (zone != Zones.offensive) { Console.Write((user.OffAwareness >= 70 ? "4. Pass to a teammate (Off. Awareness 70+)\n" : "")); } else { Console.WriteLine("4. Shoot the puck (Shooting)"); Console.Write((user.OffAwareness >= 86 ? "5. Attempt a one-timer (Passing 87+)\n" : "")); } do { input = ""; Console.Write("\nChoice: "); input = Console.ReadLine().ToLower(); Console.WriteLine(); if (input.Equals("1") || input.Equals("speed")) { if (home.HasPuck) { TextFormat.UserHome(user.Name); Console.Write(" attempts to skate past "); TextFormat.Away(opponent.Name); } else { TextFormat.UserAway(user.Name); Console.Write($" attempts to skate past {opponent}"); } return("speed"); } else if (input.Equals("2") || input.Equals("strength")) { if (home.HasPuck) { TextFormat.UserHome(user.Name); Console.Write(" attempts to power through "); TextFormat.Away(opponent.Name); } else { TextFormat.UserAway(user.Name); Console.Write($" attempts to power through {opponent}"); } return("strength"); } else if (input.Equals("3") || input.Contains("stick") || input.Contains("handling")) { if (home.HasPuck) { TextFormat.UserHome(user.Name); Console.Write(" attempts to deke around "); TextFormat.Away(opponent.Name); } else { TextFormat.UserAway(user.Name); Console.Write($" attempts to deke around {opponent}"); } return("stickhandling"); } else if (zone != Zones.offensive && user.OffAwareness >= 70 && (input.Equals("4") || input.Contains("passing"))) { if (home.HasPuck) { TextFormat.UserHome(user.Name); } else { TextFormat.UserAway(user.Name); } Console.Write(" attempts a stretch pass"); return("passing"); } else if (zone == Zones.offensive && (input.Equals("4") || input.Contains("shooting"))) { if (home.HasPuck) { TextFormat.UserHome(user.Name); } else { TextFormat.UserAway(user.Name); } Console.Write(" shoots from the blue line!"); isShooting = true; goalie = home.IsUserTeam ? away.Goalie : home.Goalie; return("shooting"); } else if (zone == Zones.offensive && user.OffAwareness > 86 && (input.Equals("5") || input.Contains("passing"))) { if (home.HasPuck) { TextFormat.UserHome(user.Name); Console.Write(" sets up the one-timer"); do { teammate = PickRandomPlayer(home); } while (user.Name.Equals(teammate.Name)); } else { TextFormat.UserAway(user.Name); Console.Write(" sets up the one-timer"); do { teammate = PickRandomPlayer(away); } while (user.Name.Equals(teammate.Name)); } isShooting = true; return("one-timer"); } else { TextFormat.Error("Invalid selection. Please try again."); } } while (true); } #endregion #region Defense Console.WriteLine("How will you defend?\n"); Console.WriteLine("1. Poke check the puck carrier (Speed)"); Console.WriteLine("2. Check the puck carrier (Strength)"); Console.WriteLine("3. \"Pickpocket\" the puck carrier (Stick Handling)"); do { input = ""; Console.Write("\nChoice: "); input = Console.ReadLine().ToLower(); Console.WriteLine(); if (input.Equals("1") || input.Equals("speed")) { if (away.HasPuck) { TextFormat.UserHome(user.Name); Console.Write(" speeds up to poke check "); TextFormat.Away(opponent.Name); } else { TextFormat.UserAway(user.Name); Console.Write($" speeds up to poke check {opponent}"); } return("speed"); } else if (input.Equals("2") || input.Equals("strength")) { if (away.HasPuck) { TextFormat.UserHome(user.Name); Console.Write(" gets ready to check "); TextFormat.Away(opponent.Name); } else { TextFormat.UserAway(user.Name); Console.Write($" gets ready to check {opponent}"); } return("strength"); } else if (input.Equals("3") || input.Contains("stick") || input.Contains("handling")) { if (away.HasPuck) { TextFormat.UserHome(user.Name); Console.Write(" attempts to pick "); TextFormat.Away(opponent.Name + "'s"); Console.Write(" pocket"); } else { TextFormat.UserAway(user.Name); Console.Write($" attempts to pick {opponent}'s pocket"); } return("stickhandling"); } else { TextFormat.Error("Invalid selection. Please try again."); } } while (true); #endregion }
private static string SetupPlay() { goalie = playerWithPuck.AssignedTeam.IsHome ? away.Goalie : home.Goalie; if (user.HasPuck) { if (home.HasPuck) { if (opponent == null) { opponent = PickRandomPlayer(away); } TextFormat.UserHome(user.Name); if (zone == Zones.neutral) { Console.WriteLine(" has the puck in the neutral zone."); } else { Console.WriteLine($" has the puck in the {user.AssignedTeam}'s {zone} zone."); } Thread.Sleep(1000); TextFormat.Away(opponent.Name); Console.WriteLine(" is attempting to defend.\n"); } else { if (opponent == null) { opponent = PickRandomPlayer(home); } TextFormat.UserAway(user.Name); if (zone == Zones.neutral) { Console.WriteLine(" has the puck in the neutral zone."); } else { Console.Write(" has the puck in the "); TextFormat.Away(user.AssignedTeam.Name); Console.WriteLine($"'s {zone} zone."); } Thread.Sleep(1000); Console.WriteLine($"{opponent} is attempting to defend.\n"); } defendingPlayer = opponent; Thread.Sleep(1000); return(DisplayUserChoices()); } else if (opponent.HasPuck) { if (home.HasPuck) { if (zone == Zones.neutral) { Console.WriteLine($"{opponent} has the puck in the neutral zone."); } else { Console.Write($"{opponent} has the puck in the "); TextFormat.Away(user.AssignedTeam.Name); Console.WriteLine($"'s {zone} zone."); } Thread.Sleep(1000); TextFormat.UserAway(user.Name); Console.WriteLine(" is attempting to defend.\n"); } else { TextFormat.Away(opponent.Name); if (zone == Zones.neutral) { Console.WriteLine(" has the puck in the neutral zone."); } else { Console.WriteLine($" has the puck in the {user.AssignedTeam}'s {zone} zone."); } Thread.Sleep(1000); TextFormat.UserHome(user.Name); Console.WriteLine(" is attempting to defend.\n"); } defendingPlayer = user; Thread.Sleep(1000); return(DisplayUserChoices()); } else { // teammate if (home.HasPuck) { opponent = PickRandomPlayer(away); defendingPlayer = opponent; if (zone == Zones.neutral) { Console.WriteLine($"{playerWithPuck} has the puck in the neutral zone."); } else { Console.WriteLine($"{playerWithPuck} has the puck in the {home}'s {zone} zone."); } TextFormat.Away(defendingPlayer.Name); Console.WriteLine(" is attempting to defend.\n"); } else { opponent = PickRandomPlayer(home); defendingPlayer = opponent; TextFormat.Away(playerWithPuck.Name); if (zone == Zones.neutral) { Console.WriteLine(" has the puck in the neutral zone."); } else { Console.WriteLine($" has the puck in the {away}'s {zone} zone."); } Console.WriteLine($"{defendingPlayer} is attempting to defend.\n"); } Thread.Sleep(1000); return(SelectAIChoice()); } }