static string[] teams = { "Mercedes", "Red Bull", "Ferrari", "McLaren", "Aston Martin", "Alpine", "AlphaTauri", "Alfa Romeo", "Haas", "Williams" };
static string[] tyreCompounds = { "Hard", "Medium", "Soft" };
static string[] weatherConditions = { "Sunny", "Rainy", "Cloudy" };
static int currentLap = 1;
static int position = 10;
static Random random = new Random();
Console.WriteLine("Welcome to the Formula 1 Racing Game!");
string team = SelectTeam();
string tyreCompound = SelectTyreCompound();
Console.WriteLine($"You have selected {team} with {tyreCompound} tyres.");
while (currentLap <= laps && fuel > 0 && tyreWear < 100)
string weather = weatherConditions[random.Next(weatherConditions.Length)];
Console.WriteLine($"Lap {currentLap}/{laps} - Weather: {weather}");
Console.WriteLine("Choose your action: drive, pit stop, check status");
Console.Write("Enter action: ");
string action = Console.ReadLine().ToLower();
Drive(tyreCompound, weather);
Console.WriteLine("Invalid action. Please enter drive, pit stop, or check status.");
Console.WriteLine("You have run out of fuel. Race over.");
else if (tyreWear >= 100)
Console.WriteLine("Your tyres are too worn out. Race over.");
Console.WriteLine("Congratulations! You have finished the race.");
static string SelectTeam()
Console.WriteLine("Select your team:");
for (int i = 0; i < teams.Length; i++)
Console.WriteLine($"{i + 1}. {teams[i]}");
Console.Write("Enter team number: ");
int teamIndex = int.Parse(Console.ReadLine()) - 1;
static string SelectTyreCompound()
Console.WriteLine("Select your tyre compound:");
for (int i = 0; i < tyreCompounds.Length; i++)
Console.WriteLine($"{i + 1}. {tyreCompounds[i]}");
Console.Write("Enter tyre compound number: ");
int tyreIndex = int.Parse(Console.ReadLine()) - 1;
return tyreCompounds[tyreIndex];
static void Drive(string tyreCompound, string weather)
int distance = random.Next(10, 30);
int fuelConsumed = random.Next(5, 15);
int wear = tyreCompound == "Hard" ? random.Next(1, 5) : tyreCompound == "Medium" ? random.Next(5, 10) : random.Next(10, 20);
Console.WriteLine("The rain is causing extra tyre wear.");
Console.WriteLine($"You drove {distance} miles, used {fuelConsumed} fuel, and your tyres wore by {wear}.");
if (random.Next(100) < 20)
Console.WriteLine("You overtook a driver! Your new position is " + position);
else if (random.Next(100) < 20)
Console.WriteLine("You were overtaken by a driver. Your new position is " + position);
Console.WriteLine("You made a pit stop. Fuel refilled and tyres changed.");
static void CheckStatus()
Console.WriteLine($"Lap: {currentLap}/{laps}, Fuel: {fuel}, Tyre Wear: {tyreWear}, Pit Stops: {pitStops}, Position: {position}");