static int PlayerChoiceMenu(int chosenCar, List <Car> cars, int checkedCars)
        {
            Console.Clear();
            string[] choices = { "check", "let go" };

            Console.WriteLine("Do you want to check or let the car go?\nCheck or Let Go");

            string playerChoice = Console.ReadLine();

            playerChoice = Klasser.IsTrueString(choices, playerChoice, "That is not an availalble choice!");

            bool foundContraband;

            if (playerChoice == choices[0])
            {
                foundContraband = cars[chosenCar].Examine();

                if (foundContraband.Equals(true))
                {
                    Klasser.WriteLine("There was a hidden contraband in the car!\nPress Enter", false);
                }
                else
                {
                    Klasser.WriteLine("There were no hidden contraband in the car! You paid the driver 10 dollar\nPress Enter", false);
                }
            }
            else
            {
                cars[chosenCar].AlreadyChecked = true;
                Klasser.WriteLine("You decided to trust the driver!", false);
            }
            return(checkedCars++);
        }
    } // check if the intake is an int

    public static string ChoiseCorrect(string[] correctAnswears) //Forces the user to write one of the correct answears
    {
        string answear    = "";
        bool   wrongInput = true;

        while (wrongInput == true)
        {
            answear = Console.ReadLine().ToLower().Trim();

            for (int i = 0; i < correctAnswears.Length; i++)
            {
                if (answear == correctAnswears[i])
                {
                    wrongInput = false;
                    break;
                }
            }

            if (wrongInput == true)
            {
                Klasser.WriteLine("Wrong input, Write something else", true);
            }
        }

        return(answear);
    } //Forces the user to write one of the correct answears
    } //Forces the user to write one of the correct answears

    public static string ChoiseIsNot(string[] wrongAnswears, string answear) //Forces the user to not write one of the wrong answears
    {
        bool whileAnswearWrong = true;

        while (whileAnswearWrong == true)
        {
            bool wrong = false;
            for (int i = 0; i < wrongAnswears.Length; i++)
            {
                if (answear == wrongAnswears[i])
                {
                    if (answear == "")
                    {
                        Klasser.WriteLine("You can't leave it blank!!", true);
                    }
                    else
                    {
                        Klasser.WriteLine("You can't write that!", true);
                    }

                    Klasser.Write("New name: ", true);
                    answear = Console.ReadLine();
                    wrong   = true;
                    break;
                }

                if (wrong == false)
                {
                    whileAnswearWrong = false;
                }
            }
        }
        return(answear);
    } //Forces the user to not write one of the wrong answears
        } //This block of code checks if the character missesor hit a attack

        public void PrintStats() //Prints the stats
        {
            Console.Clear();
            Klasser.WriteLine("Name: " + name + "\nHP: " + hp + "\nHit Chance: " + hitChance + "\nMax Damage: " + maxDamage + "\nMin Damage: " + minDamage + "\n \n(*Enter*)\n", false);

            return;
        } //Prints the stats
        } //This is the processor of the fight. It says which characters turn it is and after the fight the block says who won the fight

        public void FightMenues(Fighters player, Fighters enemy, bool isPlayer) //For the player this code block lets the player choose if they want to check their stats or attack
        {
            if (isPlayer == true)
            {
                Console.Clear();
                Klasser.WriteLine("Name: " + player.Name + "\nHp: " + player.Name + "\nEnemy Hp: " + enemy.Hp + "\n\nWhat do you want to do? \n1. Fight\n2. Check Status", true);
                string[] answears = { "1", "2", "fight", "check staus", "checkstatus" };

                string answear = Klasser.ChoiseCorrect(answears);

                Console.Clear();

                if (answear == answears[0] || answear == answears[2])
                {
                    DealDamage(player, enemy, true);
                }

                if (answear == answears[1] || answear == answears[3] || answear == answears[4])
                {
                    player.PrintStats();
                    FightMenues(player, enemy, true);
                }
            }
            else
            {
                DealDamage(player, enemy, false);
            }
        } //For the player this code block lets the player choose if they want to check their stats or attack
        //Preperations
        public void NameYourFighter(Fighters fighter) //This code block is for allowing the player rename their character
        {
            Console.Clear();
            Klasser.WriteLine("Name your fighter!", true);
            Klasser.Write("Name: ", true);
            string newName = Console.ReadLine();

            fighter.Name = newName;
        } //This code block is for allowing the player rename their character
Exemple #7
0
        static string PresentFighterKlass()
        {
            Console.Clear();
            Console.WriteLine("Choose a fighter klass");

            Klasser.WriteLine("Fighter 1: \nHp: High\nDamage: Medium\nHitchance: Low", false);
            Klasser.WriteLine("Fighter 2: \nHp: Medium\nDamage: Medium\nHitchance: Medium", false);
            Klasser.WriteLine("Fighter 3: \nHp: Low\nDamage: High\nHitchance: High", false);

            string choice = Console.ReadLine();


            return(choice);
        }
        } //This code block is for allowing the player rename their character

        public Fighters PresentFighterKlass(bool player) //This code block presents the three different fighter klass
        {
            if (player == false)
            {
                Console.Clear();
                Console.WriteLine("Choose a fighter klass");

                Klasser.WriteLine("\nFighter 1: \nHp: High\nDamage: Medium\nHitchance: Low", true);
                Klasser.WriteLine("\nFighter 2: \nHp: Medium\nDamage: Medium\nHitchance: Medium", true);
                Klasser.WriteLine("\nFighter 3: \nHp: Low\nDamage: High\nHitchance: High\n", true);
                Klasser.Write("Choose fighter: ", true);
            }

            return(chooseFighter(player));
        } //This code block presents the three different fighter klass
        static void Main(string[] args)
        {
            Random     rand         = new Random();
            int        day          = 1;
            int        nummerOfCars = 0;
            int        checkedCars  = 0;
            List <Car> cars         = new List <Car>();
            List <Car> resetCars    = new List <Car>()
            {
            };
            List <int> unCheckedCars = new List <int>();
            bool       wantToPlay    = true;

            Console.WriteLine("welcom to border patrol! You will be checking passing cars for contrabands!\nPress Enter");
            Console.ReadLine();

            while (wantToPlay)
            {
                nummerOfCars = rand.Next(1, 10);
                cars         = CreateCars(nummerOfCars, rand, cars);

                Klasser.WriteLine("Day " + day.ToString() + "\n You will check " + nummerOfCars + " cars today!", false);

                while (CheckIfAllCarsAreChecked(cars))
                {
                    PrintUnchecked(cars);

                    int math = nummerOfCars - checkedCars;
                    Console.WriteLine("Which car do you want to check? There are " + math.ToString() + " left out of " + nummerOfCars + "!");

                    string car       = Console.ReadLine();
                    int    chosenCar = Klasser.IsInt(car, "That is not a number or not an available number!", true, nummerOfCars) - 1;

                    while (cars[chosenCar].AlreadyChecked.Equals(true))
                    {
                        Console.WriteLine("You have already checked that car!");
                        car       = Console.ReadLine();
                        chosenCar = Klasser.IsInt(car, "That is not a number or not an available number!", true, nummerOfCars);
                    }
                    checkedCars = PlayerChoiceMenu(chosenCar, cars, checkedCars);
                    Console.Clear();
                }
                cars = resetCars;
                day++;
            }
        }
        static void Main(string[] args)
        {
            Fighters player = m.PresentFighterKlass(false); //The player gets to choose a fighter
            Fighters enemy  = m.PresentFighterKlass(true);  //The game randomises a fighter

            m.NameYourFighter(player);                      //Lets the player name their character
            player.PrintStats();                            //Prints the player's stats

            Console.Clear();

            Klasser.WriteLine("You'r oponent is ...\n\n(*Enter*)", false);

            enemy.PrintStats();              //Prints the enemy's stats

            m.AnitiateFight(player, enemy);  //This code block is for Anitiating the fight by randomise if the playeer or the enemy start the fight

            if (Klasser.restartGame == true) //After the fight, if the player wants to restart the game, the bool restartGame becomes true
            {
                Program.Main(args);
            } //After the fight, if the player wants to restart the game, the bool restartGame becomes true
        }
        } //For the player this code block lets the player choose if they want to check their stats or attack

        public void DealDamage(Fighters player, Fighters enemy, bool playerBool) //This code block is for dealing dammage between the player and the enemy. It randomise if the attack will hit or not. If it hit it randomises what kind of attack it was and where it hit.
        {
            Console.Clear();
            string[] attacks   = { "hook", "straight", "death stare", "roundhouse kick", "DDT" };
            string[] hit       = { "stomach", "knee", "shoulder", "liver", "Hand", "feet" };
            bool     playerHit = player.HitOrMiss();
            bool     enemyHit  = enemy.HitOrMiss();

            Thread.Sleep(200);

            if (playerHit == true && playerBool == true)
            {
                int damage = player.Damage;

                Klasser.WriteLine(player.Name + " hit a " + Klasser.RandString(attacks) + " on " + enemy.Name + "'s " + Klasser.RandString(hit) + " and dealt " + damage + " damage" + "\n\n(*Enter*)", false);

                enemy.Hp -= damage;
            }

            if (playerHit == false && playerBool == true)
            {
                Klasser.WriteLine(player.Name + " missed his attack\n\n(*Enter *)", false);
            }

            if (enemyHit == true && playerBool == false)
            {
                int damage = enemy.Damage;

                Klasser.WriteLine(enemy.Name + " hit a " + Klasser.RandString(attacks) + " on " + player.Name + "'s " + Klasser.RandString(hit) + " and dealt " + damage + " damage\n\n(*Enter*)", false);

                player.Hp -= damage;
            }

            if (enemyHit == false && playerBool == false)
            {
                Klasser.WriteLine(enemy.Name + " missed the attack\n\n(*Enter *)", false);
            }
        } //This code block is for dealing dammage between the player and the enemy. It randomise if the attack will hit or not. If it hit it randomises what kind of attack it was and where it hit.
        } //Randomise a number between 1-3 and convert it to a string

        public void AnitiateFight(Fighters player, Fighters enemy) //This code block is for Anitiating the fight by randomise if the playeer or the enemy start the fight
        {
            int  whoWillStart;
            bool playerStartFight;

            Console.Clear();
            Klasser.WriteLine("The fight will now commense! Todays fight is between " + player.Name + " versus " + enemy.Name + ".\n", true);

            whoWillStart = Klasser.RandInt(0, 1);

            if (whoWillStart == 0)
            {
                playerStartFight = true;
                Klasser.WriteLine(player.Name + " will start the fight.\n\n(*Enter*)", false);
            }
            else
            {
                playerStartFight = false;
                Klasser.WriteLine(enemy.Name + " will start the fight.\n\n(*Enter*)", false);
            }

            Fight(playerStartFight, player, enemy);
        } //This code block is for Anitiating the fight by randomise if the playeer or the enemy start the fight
        } //This code block is for dealing dammage between the player and the enemy. It randomise if the attack will hit or not. If it hit it randomises what kind of attack it was and where it hit.

        public void End(bool playerWon) //This code block resolvs the "after fight" and let the player choose if they want to restart the game
        {
            Console.Clear();

            if (playerWon == true)
            {
                Klasser.WriteLine("Perfekt round!", true);
            }
            else
            {
                Klasser.WriteLine("Better luck next time!", true);
            }

            Klasser.WriteLine("Would you like to play again? \n\n (Yes/No)", true);

            string[] answears = { "yes", "no" };

            string answear = Klasser.ChoiseCorrect(answears);

            if (answear == "yes")
            {
                Klasser.restartGame = true;
            }
        } //This code block resolvs the "after fight" and let the player choose if they want to restart the game
Exemple #14
0
        } //A method to deal damage to enemies

        public void PrintStats()
        {
            Klasser.WriteLine("Name: " + name + "\nHp: " + hp + "\nRace: " + race + "\nRace Ability: " + ability + "\nAbility: " + charact, false);
        } //A method that prints the characters stats