Exemple #1
0
        public GameEngine(player Gladiator, player Opponent, player Enemys, Statistics S, Equipment items, Slaughter Slaughtered)
        {
            var P1 = Gladiator;
            var P2 = Opponent;

            Random rnd = new Random();

            if (rnd.Next(0, 10) < 5)
            {
                P1 = Opponent;
                P2 = Gladiator;
            }
            while (true)
            {
                int choice;
                Gladiator.Damage = 0;
                Opponent.Damage  = 0;

                DisplayStartInfo(Gladiator, Opponent, Enemys);

                if (P1 == Gladiator)
                {
                    Console.WriteLine("-------------------------");
                    Console.WriteLine("Choose your strike method");
                    Console.WriteLine("1. Fist");
                    Console.WriteLine("2. Kick");
                    Console.WriteLine("3. Knee");
                    Console.WriteLine("-------------------------");

                    choice = Convert.ToInt32(Console.ReadLine());
                }
                else
                {
                    choice = rnd.Next(1, 3);
                }
                switch (choice)
                {
                case 1:
                    int s1 = P1.Fist();
                    Console.WriteLine($"Fist strike! Damage by {P1.Name}: {s1}");
                    Console.WriteLine();
                    P2.Health -= s1;
                    P1.Damage  = s1;
                    break;

                case 2:
                    int s2 = P1.Kick();
                    Console.WriteLine($"Kick strike! Damage by {P1.Name}: {s2}");
                    Console.WriteLine();
                    P2.Health -= s2;
                    P1.Damage  = s2;
                    break;

                case 3:
                    int s3 = P1.Knee();
                    Console.WriteLine($"Knee strike! Damage by {P1.Name}: {s3}");
                    Console.WriteLine();
                    P2.Health -= s3;
                    P1.Damage  = s3;
                    break;

                default:
                    break;
                }
                P1.Strikes++;
                Gladiator.TotalStrikes += Gladiator.Strikes;
                P1.FightDmg            += P1.Damage;
                P2.FightDmg            += P2.Damage;
                P1.TotalDmg            += P1.Damage;
                P2.TotalDmg            += P2.Damage;
                Enemys.TotalStrikes    += Opponent.Strikes;
                Enemys.TotalDmg        += Opponent.Damage;

                if (P2.Health <= 0)
                {
                    Console.WriteLine($"{P2.Name} slaughtered!");
                    P2.Health = 0;
                    P1.Wins++;
                    Console.WriteLine($"With {P1.Strikes} strikes!");
                    Console.WriteLine($"{P1.Name} has won {P1.Wins} times");
                    Console.WriteLine($"Total damage by {P1.Name} was {P1.FightDmg}");
                    Console.WriteLine($"{P2.Name} made damage by: {P2.FightDmg}");
                    if (Gladiator.Health <= 0)
                    {
                        S.msg = S.LosingMsg;
                        S.AddToList(Enemys.Round, Gladiator.Strikes, Gladiator.FightDmg, S.msg, Opponent.Name);
                        items.HaveArmor   = false;          // losing armor if beaten
                        items.HaveWeapon  = false;          // losing Weapon if beaten
                        items.UsingArmor  = false;          // losing armor if beaten
                        items.UsingWeapon = false;          // losing Weapon if beaten

                        S.Points -= 100;
                    }
                    else
                    {
                        if (Enemys.Round < 4)
                        {
                            S.Points += 100;
                        }
                        else if (Enemys.Round >= 8)
                        {
                            S.Points += 400;
                        }
                        else
                        {
                            S.Points += 200;
                        }
                        S.msg = S.VictoryMsg;
                        S.AddToList(Enemys.Round, Gladiator.Strikes, Gladiator.FightDmg, S.msg, Opponent.Name);
                        Gladiator.Health++;             // add 1 health for victory

                        if (Gladiator.Wins < 10)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Chose if u wanna try ur luck on a weapon or armor");
                            Console.WriteLine("1: For armor hunting");
                            Console.WriteLine("2: For weapon hunting");
                            Console.WriteLine("3: Hardcore, no weapon or amror hunt");
                            int itemChoise = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine();

                            switch (itemChoise)
                            {
                            case 1:
                                items.ArmorEquipemnt(Gladiator);
                                break;

                            case 2:
                                items.WeaponEquipment(Gladiator);
                                break;

                            default:
                                Console.WriteLine("brave warrior");
                                break;
                            }
                            Console.WriteLine();
                        }
                    }

                    Enemys.Wins       += Opponent.Wins;
                    Gladiator.FightDmg = 0;
                    Gladiator.Strikes  = 0;
                    Enemys.Round++;

                    if (P1 == Gladiator)
                    {
                        Gladiator.RemoveEnemy();
                        Slaughtered.AddToList(Opponent.Name);
                    }
                    else if (P2 == Gladiator || Gladiator.Health <= 0)
                    {
                        Gladiator.Health   = rnd.Next(10, 20);
                        Gladiator.Strenght = rnd.Next(5, 10);
                    }
                    break;
                }

                if (P1 == Gladiator)
                {
                    P1 = Opponent;
                    P2 = Gladiator;
                }
                else
                {
                    P1 = Gladiator;
                    P2 = Opponent;
                }
            }
        }
Exemple #2
0
        static void Main(String[] args)
        {
            Random     rnd              = new Random();
            Boolean    loop             = true;
            player     Enemys           = new player();
            Statistics S                = new Statistics();
            Equipment  items            = new Equipment();
            Slaughter  Slaughter        = new Slaughter();
            report     R                = new report();
            int        MinValueHealth   = 10;
            int        MaxValueHealth   = 20;
            int        MinValueStrength = 5;
            int        MaxValueStrength = 10;

            items.UsedArmor  = false;
            items.UsedWeapon = false;
            int j = 0;

            Console.WriteLine("------------------------------------------------------");
            Console.WriteLine("--------------- Welcome to the arena!! ---------------");
            Console.WriteLine("The challangers fights untill death, ppl place ur bets");
            Console.WriteLine("------------------------------------------------------");
            Console.WriteLine("---------------- Welcome to the game! ---------------- ");
            Console.Write("Please enter your name: ");

            string name = Console.ReadLine();

            Console.WriteLine($"Welcome {name}, lets see how strong you are today");
            Console.WriteLine("------------------------------------------------------");

            //Create Gladiator
            player Gladiator = new player(name, rnd.Next(MinValueHealth, MaxValueHealth), rnd.Next(MinValueStrength, MaxValueStrength), 0, 0, 0);

            Gladiator.EnemyNamelist(); // create list with enemys
            Enemys.Round        = 1;   //start counting rounds on 1. THIS should be redone.
            Gladiator.Advantage = 2;   // set advantage for Gladiator
            while (loop)
            {
                Console.WriteLine();

                if (Gladiator.EnemyNames.Count <= 0) //if enemylist is empty end game
                {                                    // Show stats!!!!
                    Console.WriteLine("------------------------------------------------------");
                    Console.WriteLine($"All Opponents has been beaten. You are the champion!!!!");
                    Console.WriteLine("------------------------------------------------------");
                    Console.WriteLine("----------- Game created by Daniel & Risto -----------");
                    Console.WriteLine();
                    Console.WriteLine("Press any key to quit");
                    Console.ReadKey();
                    R.CreateReport(Slaughter.Slaughtered, Gladiator.Name, S.Points);
                    break;      //break out of the game
                }

                if (Enemys.Round == 4)
                {
                    Gladiator.Advantage--;  //if
                }
                else if (Enemys.Round == 7)
                {
                    Gladiator.Advantage--;
                }
                int MaxHealthEnemy   = Gladiator.Health - Gladiator.Advantage;
                int MaxStrengthEnemy = Gladiator.Strenght - Gladiator.Advantage;

                if (Gladiator.Health - Gladiator.Advantage < MinValueHealth)
                {
                    MaxHealthEnemy = MinValueHealth + 1;
                }
                if (Gladiator.Strenght - Gladiator.Advantage < MinValueStrength)
                {
                    MaxStrengthEnemy = MinValueStrength + 1;
                }

                player Opponent = new player(Gladiator.EnemyNames[0].Name, rnd.Next(MinValueHealth, MaxHealthEnemy), rnd.Next(MinValueStrength, MaxStrengthEnemy), 0, 0, 0);     //Generate new opponent for each fight

                Console.WriteLine();
                if (S.Points == 0)
                {
                    Console.WriteLine("You have not earned any points yet! Start playing.");
                }
                else
                {
                    Console.WriteLine($"Have earned {S.Points} points");
                }
                Console.WriteLine($"Your health is: {Gladiator.Health}\tYour Strenght is: {Gladiator.Strenght}");
                Console.WriteLine();
                Console.WriteLine("Now where do we wanna send the gladiator??");
                Console.WriteLine("------------------------------------------------------");

                Console.WriteLine("Choise 1: Enter the arena and fight untill death");
                Console.WriteLine("Choise 2: Check stats from all fight");
                Console.WriteLine("Choise 3: Enemy list");
                Console.WriteLine("Choise 4: Statistics");
                Console.WriteLine("Choise 5: Armors and Weapons");
                Console.WriteLine("Choise 8: Delete Highscores");
                Console.WriteLine("Choise 9: Exit the game");
                Console.WriteLine("------------------------------------------------------");

                int choise = Convert.ToInt32(Console.ReadLine());

                switch (choise)
                {
                case 1:
                    _ = new GameEngine(Gladiator, Opponent, Enemys, S, items, Slaughter);
                    break;

                case 2:
                    Console.WriteLine();
                    Console.WriteLine($"Rounds played: {Enemys.Round - 1} ");           // for displaying correct amount of rounds
                    Console.WriteLine();
                    Console.WriteLine($"Gladiator wins: {Gladiator.Wins}");
                    Console.WriteLine($"Damage dealt by gladiator {Gladiator.TotalDmg}");
                    Console.WriteLine();
                    Console.WriteLine($"Opponent wins: {Enemys.Wins}");
                    Console.WriteLine($"Damage dealt by opponent {Enemys.TotalDmg}");

                    break;

                case 3:
                    Console.WriteLine();
                    Console.WriteLine($"Enemys left: {Gladiator.EnemyNames.Count}");
                    Console.WriteLine();

                    for (int i = 0; i < Gladiator.EnemyNames.Count; i++)
                    {
                        if (i == 0)
                        {
                            // needed when one enemy left to print Final Boss
                            if (Gladiator.EnemyNames[i].Level == 4)
                            {
                                Console.WriteLine("Final Boss:");
                            }
                            else
                            {
                                Console.WriteLine("Level " + Gladiator.EnemyNames[i].Level + ":");
                            }
                            Console.WriteLine(Gladiator.EnemyNames[i].Name);
                        }
                        else
                        {
                            if (Gladiator.EnemyNames[i].Level == Gladiator.EnemyNames[i - 1].Level)
                            {
                                Console.WriteLine(Gladiator.EnemyNames[i].Name);
                            }
                            else
                            {
                                // Print Final Boss for the 10th enemy
                                if (Gladiator.EnemyNames[i].Level == 4)
                                {
                                    Console.WriteLine("Final Boss:");
                                }
                                else
                                {
                                    Console.WriteLine("Level " + Gladiator.EnemyNames[i].Level + ":");
                                }
                                Console.WriteLine(Gladiator.EnemyNames[i].Name);
                            }
                        }
                    }

                    Console.WriteLine();
                    Console.WriteLine($"Enemys slaughtered: {Slaughter.Slaughtered.Count}");
                    foreach (var item in Slaughter.Slaughtered)
                    {
                        Console.WriteLine(item);
                    }
                    break;


                case 4:
                    S.DisplayStat();
                    break;

                case 5:
                    items.Display_A_W(Gladiator);
                    break;

                case 8:
                    R.DeleteSaves();
                    Console.WriteLine("Are uou sure? y/n?");
                    var a = Console.ReadLine();
                    if (a == "y")
                    {
                        Console.WriteLine("Highscores deleted!");
                    }
                    break;

                case 9:
                    loop = false;
                    R.CreateReport(Slaughter.Slaughtered, Gladiator.Name, S.Points);
                    break;

                default:
                    Console.WriteLine("You must choose a number between 1 - 5 or 9!");
                    break;
                }
            }
        }
Exemple #3
0
        public void Display_A_W(player Gladiator)
        {
            Console.WriteLine();
            Console.WriteLine($"Your Gladiator {Gladiator.Name}\nhas a health of {Gladiator.Health}\nand strenght of {Gladiator.Strenght}");
            Console.WriteLine();
            if (HaveArmor)
            {
                Console.WriteLine("You have Armor");
                if (UsingArmor)
                {
                    Console.WriteLine("Your Armor Points are {0}", Armor);
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("You are not using your Armor");
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("You have no Armor");
                Console.WriteLine();
            }

            if (HaveWeapon)
            {
                Console.WriteLine("You have a Weapon");
                if (UsingWeapon)
                {
                    Console.WriteLine("Your Weapon Points are {0}", Weapon);
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("You are not using your Weapon");
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("You have no Weapon");
                Console.WriteLine();
            }
            if (HaveArmor || HaveWeapon)
            {
                Console.WriteLine();
                Console.WriteLine("Change Armor or Weapons");
                Console.WriteLine();
                Console.WriteLine("1: Change Armor");
                Console.WriteLine("2: Change Weapon");
                Console.WriteLine("3: Return to main meny");
                var a = int.Parse(Console.ReadLine());

                if (a == 1)
                {
                    //armor
                    if (!HaveArmor)
                    {
                        Console.WriteLine("You have no armor");
                    }
                    else
                    {
                        if (UsingArmor)
                        {
                            Console.Write("Would you like to take it off? y/n? ");
                            var b = Console.ReadLine();
                            if (b == "y")
                            {
                                UsingArmor        = false;
                                Gladiator.Health -= Armor;
                            }
                            else
                            {
                                UsingArmor = true;
                            }
                        }
                        else
                        {
                            Console.Write("Would you like to put one on? y/n? ");
                            var b = Console.ReadLine();
                            if (b == "n")
                            {
                                UsingArmor = false;
                            }
                            else
                            {
                                UsingArmor        = true;
                                Gladiator.Health += Armor;
                            }
                        }
                    }
                }
                else if (a == 2)
                {
                    //weapons
                    if (!HaveWeapon)
                    {
                        Console.WriteLine("You have no weapon");
                    }
                    else
                    {
                        if (UsingWeapon)
                        {
                            Console.Write("Would you like to leave it? y/n? ");
                            var b = Console.ReadLine();
                            if (b == "y")
                            {
                                UsingWeapon         = false;
                                Gladiator.Strenght -= Weapon;
                            }
                            else
                            {
                                UsingWeapon = true;
                            }
                        }
                        else
                        {
                            Console.Write("Would you like to pick up a weapon? y/n? ");
                            var b = Console.ReadLine();
                            if (b == "n")
                            {
                                UsingWeapon = false;
                            }
                            else
                            {
                                UsingWeapon         = true;
                                Gladiator.Strenght += Weapon;
                            }
                        }
                    }
                }
            }
        }
Exemple #4
0
        public void ArmorEquipemnt(player Gladiator)
        {
            int rngArmor = rnd.Next(0, 4);

            if (HaveArmor)
            {
                Console.WriteLine("You already have Armor");
            }
            else
            {
                if (rngArmor < 2)
                {
                    Console.WriteLine("sorry no armor found this time");
                }
                if (rngArmor <= 4 && rngArmor >= 2)
                {
                    if (Armor >= 2)
                    {
                        Console.WriteLine("you already have a better armor than the one you found, better luck next time");
                        HaveArmor = true;
                    }
                    else
                    {
                        Armor = 2;
                        Console.WriteLine("grats u found a +{0} armor", Armor);
                        HaveArmor = true;
                        Console.Write("Would you like to put it on? y/n? ");
                        var a = Console.ReadLine();
                        if (a == "y")
                        {
                            UsingArmor        = true;
                            Gladiator.Health += Armor;
                        }
                        else
                        {
                            UsingArmor = false;
                        }
                    }
                }
                if (rngArmor == 5)
                {
                    Console.WriteLine("Grats u found the jackpot");
                    Armor = 4;
                    Console.WriteLine("You found a {0}", Armor);
                    HaveArmor = true;
                    Console.Write("Would you like to put it on? y/n? ");

                    var a = Console.ReadLine();
                    if (a == "y")
                    {
                        UsingArmor        = true;
                        Gladiator.Health += Armor;
                    }
                    else
                    {
                        UsingArmor = false;
                    }
                }
                if (!HaveArmor || !UsingArmor)
                {
                    Armor = 0;
                }
            }
            Console.WriteLine();
        }
Exemple #5
0
        public void WeaponEquipment(player Gladiator)
        {
            int rngWeapon = rnd.Next(0, 4);

            if (HaveWeapon)
            {
                Console.WriteLine("You already have a Weapon");
            }
            else
            {
                if (rngWeapon < 2)
                {
                    Console.WriteLine("sorry no weapon found this time");
                }
                if (rngWeapon <= 4 && rngWeapon >= 2)
                {
                    if (Weapon == 2)
                    {
                        Console.WriteLine("you already have a better weapon than the one you fund, better luck next time");
                        HaveWeapon = true;
                    }
                    else
                    {
                        Weapon = 2;
                        Console.WriteLine("grats u found a +{0} weapon", Weapon);
                        HaveWeapon = true;
                        Console.Write("Would you like to use it? y/n? ");
                        var a = Console.ReadLine();
                        if (a == "y")
                        {
                            UsingWeapon         = true;
                            Gladiator.Strenght += Weapon;
                        }
                        else
                        {
                            UsingWeapon = false;
                        }
                    }
                }
                if (rngWeapon == 5)
                {
                    Console.WriteLine("Grats u found the jackpot");
                    Weapon = 4;
                    Console.WriteLine("You found a {0}", Weapon);
                    HaveWeapon = true;
                    Console.Write("Would you like to use it? y/n? ");
                    var a = Console.ReadLine();
                    if (a == "y")
                    {
                        UsingWeapon         = true;
                        Gladiator.Strenght += Weapon;
                    }
                    else
                    {
                        UsingWeapon = false;
                    }
                }
                if (!HaveWeapon || !UsingWeapon)
                {
                    Armor = 0;
                }
            }
            Console.WriteLine();
        }