mardi 5 mai 2020

Function creates the same digit everytime?

This is a small thing i am working on, but for some reason it creates the same output. I am very very new to coding, so it might be bad or it might be a silly mistake but if someone can let me know, that would be good. Most of the code is repeated but i thought i should include most of it incase they are the problem.

public static void FireMinigame()
        {
            int FireAttempts = 3;
            Console.WriteLine("Press any key to play the game. You have " + FireAttempts + " tries.");
            Console.Read();
                TryAgain: Console.WriteLine("You will see random numbers appear");
                Thread.Sleep(2000);
                Random generator = new Random();
                int r = generator.Next(100, 1000);
                Console.ForegroundColor = GetRandomConsoleColor();
                Console.WriteLine(r);
                Thread.Sleep(1750);
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                ClearCurrentConsoleLine();
            Narrating();
                Console.WriteLine("Please type the numbers you just saw");
                string answer = Console.ReadLine();
                int answerint = Int32.Parse(answer);
                if (answerint == r)
                {
                    Console.WriteLine("The symbol gloes green. Thats probably a good thing. Another panel opens. It feels more menacing.");
                int FireAttempts2 = 3;
                Console.WriteLine("Press any key to play the game. You have " + FireAttempts2 + " tries.");
                Console.Read();
            TryAgain2: Console.WriteLine("You will see random numbers appear");
                Thread.Sleep(2000);
                Random generator2 = new Random();
                int r2 = generator2.Next(10000, 100000);
                Console.ForegroundColor = GetRandomConsoleColor();
                Console.WriteLine(r);
                Thread.Sleep(1750);
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                ClearCurrentConsoleLine();
                Narrating();
                Console.WriteLine("Please type the numbers you just saw");
                string answer2 = Console.ReadLine();
                int answerint2 = Int32.Parse(answer);
                if (answerint2 == r2)
                {
                    Console.WriteLine("The symbol gloes green. Sweet, more of this probably good thing. Another panel opens. It feels even more menacing. The kanji even starts to hover around it.");
                        int FireAttempts3 = 3;
                        Console.WriteLine("Press any key to play the game. You have " + FireAttempts3 + " tries.");
                        Console.Read();
                        TryAgain3: Console.WriteLine("You will see random numbers appear");
                        Thread.Sleep(2000);
                        Random generator3 = new Random();
                        int r3 = generator3.Next(10000, 100000);
                        Console.ForegroundColor = GetRandomConsoleColor();
                        Console.WriteLine(r);
                        Thread.Sleep(1750);
                        Console.SetCursorPosition(0, Console.CursorTop - 1);
                        ClearCurrentConsoleLine();
                        Narrating();
                        Console.WriteLine("Please type the numbers you just saw");
                        string answer3 = Console.ReadLine();
                        int answerint3 = Int32.Parse(answer);
                        if (answerint3 == r3)
                        {
                            Console.WriteLine("The wall begins to crumble, revealing a new path.");
                        }
                        else if (FireAttempts3 == 0)
                        {
                            Console.WriteLine("\nYou have failed three times. The cave begins to crumble. You find yourself surrounded by rubble, with no way out. \nRocks block your escape and the heat gets even worse. Lava rises until the entire room is filled.");
                            Die();
                        }
                        else
                        {
                            FireAttempts3--;
                            Console.WriteLine("That is incorrect, you have" + FireAttempts3 + "more tries.");
                            Thread.Sleep(2000);
                            goto TryAgain3;
                        }
                }
                else if (FireAttempts2 == 0)
                {
                    Console.WriteLine("\nYou have failed three times. The cave begins to crumble. You find yourself surrounded by rubble, with no way out. \nRocks block your escape and the heat gets even worse. Lava rises until the entire room is filled.");
                    Die();
                }
                else
                {
                    FireAttempts2--;
                    Console.WriteLine("That is incorrect, you have" + FireAttempts2 + "more tries.");
                    Thread.Sleep(2000);
                    goto TryAgain2;
                }
            }
                else if (FireAttempts == 0)
                {
                    Console.WriteLine("\nYou have failed three times. The cave begins to crumble. You find yourself surrounded by rubble, with no way out. \nRocks block your escape and the heat gets even worse. Lava rises until the entire room is filled.");
                    Die();
                }
                else
                {
                    FireAttempts--;
                    Console.WriteLine("That is incorrect, you have" + FireAttempts + "more tries.");
                    Thread.Sleep(2000);
                    goto TryAgain;
                }
        }



Aucun commentaire:

Enregistrer un commentaire