예제 #1
0
        public StartFight(Player player, PlayerStats playerstats, Random rand, TestDummy testdummy, MobStats mobstats)
        {
            if (player.GetClass == "Warrior")
            {
            }
            //test
            Warrior playerclass = new Warrior();

            double dead = 0;

            Console.WriteLine("****************************************");
            Console.WriteLine("\nA fight has begun!");

            while (playerstats.GetHealth > dead && mobstats.GetHealth > dead)
            {
                //PlayerAttacks
                playerclass.Attack(playerstats, rand, testdummy, mobstats);

                if (playerstats.GetHealth <= dead)
                {
                    Console.WriteLine("You died. Your adventure is over.");
                }

                Thread.Sleep(5);
                testdummy.Attack(mobstats, player, rand, playerstats, testdummy);
                if (mobstats.GetHealth <= dead)
                {
                    Console.WriteLine("\nCongratulations, you defeated the enemy!");
                }

                Console.WriteLine(player.GetName + ": " + playerstats.GetTotalHealth + "/" + playerstats.GetHealth
                                  + "\n" + testdummy.GetName + ": " + mobstats.GetTotalHealth + "/" + mobstats.GetHealth);
            }
            Console.WriteLine("****************************************");
        }
예제 #2
0
        static void Main(string[] args)
        {
            Credits  cred = new Credits();
            MainMenu menu = new MainMenu();
            Random   rand = new Random();
            string   userInput;

            userInput = Console.ReadLine();
            while (userInput != "10")
            {
                switch (userInput)
                {
                case "1":     //START GAME
                    CharacterCreation newChar     = new CharacterCreation();
                    MobDesign         mob         = new MobDesign();
                    PlayerStats       playerstats = new PlayerStats(newChar);
                    _ = new Inventory(newChar, playerstats);
                    Player    player    = new Player(newChar, playerstats);
                    TestDummy testdummy = new TestDummy();
                    MobStats  mobstats  = new MobStats(mob);
                    _ = new StartFight(player, playerstats, rand, testdummy, mobstats);

                    //to reduce clutter, when testing, exit
                    Console.WriteLine("END OF CASE 1, EXITING");
                    Environment.Exit(0);
                    break;

                case "2":     //LOAD GAME
                    Console.WriteLine("Option 2 Works\n");
                    break;

                case "3":     //OPTIONS
                    Console.WriteLine("Option 3 Works\n");
                    break;

                case "7":
                    _ = new Help();
                    break;

                case "8":
                    cred.PrintCredits();
                    break;

                case "9":
                    //Quit
                    Console.WriteLine("Ending Session...");
                    cred.PrintCredits();
                    _ = new Quit();

                    break;

                default:
                    Console.WriteLine("\nInvalid Option |" + userInput + "|" + "\n" + "Try again\n");
                    break;
                }
                menu.CallMenu();
                userInput = Console.ReadLine();
            }
        }
예제 #3
0
        public void Attack(MobStats mobstats, Player player, Random rand, PlayerStats playerstats, TestDummy testdummy)
        {
            int mobInput;

            mobInput = rand.Next(1, 2);
            switch (Convert.ToString(mobInput))
            {
            case "1":
                Melee();
                break;

            default:
                Attack(mobstats, player, rand, playerstats, testdummy);
                break;
            }
            void Melee()
            {
                mobstats.RandomBaseMeleeDamage();
                int totalCritChance = mobstats.GetCritChance;
                int critChance      = rand.Next(0, 101);

                if (critChance <= totalCritChance)
                {
                    double crit = mobstats.GetMeleeDamage * 2;
                    playerstats.GetHealth -= crit;
                    if (playerstats.GetHealth < 0)
                    {
                        playerstats.GetHealth = 0;
                        Console.WriteLine(testdummy.GetName + " CRITICALLY damaged " + player.GetName + " for " + crit +
                                          ".");
                    }
                    else
                    {
                        Console.WriteLine(testdummy.GetName + " CRITICALLY damaged " + player.GetName + " for " + crit +
                                          ".");
                    }
                }

                else
                {
                    playerstats.GetHealth -= mobstats.GetMeleeDamage;
                    if (playerstats.GetHealth < 0)
                    {
                        playerstats.GetHealth = 0;
                        Console.WriteLine(testdummy.GetName + " damaged " + player.GetName + " for " + mobstats.GetMeleeDamage +
                                          ".");
                    }
                    else
                    {
                        Console.WriteLine(testdummy.GetName + " damaged " + player.GetName + " for " + mobstats.GetMeleeDamage +
                                          ".");
                    }
                }
            }
        }
예제 #4
0
        public void Attack(PlayerStats playerstats, Random rand, TestDummy testdummy, MobStats mobstats)
        {
            string userInput;

            Console.WriteLine("\nChoose an attack: " + "\n(1) Mighty Slash" + "\n(2) Heaving Blow" + "\n\n\n\n\n(5)Flee");
            userInput = Console.ReadLine();
            switch (userInput)
            {
            case "1":
                OutputDamage();
                break;

            case "2":
                HeavingBlow(playerstats, mobstats);
                break;

            case "5":
                Console.WriteLine("Fleeing. Too hard for you?");
                Environment.Exit(0);
                break;

            default:
                Console.WriteLine("Unknown ability.");
                Attack(playerstats, rand, testdummy, mobstats);
                break;
            }

            void OutputDamage()
            {
                playerstats.RandomBaseMeleeDamage();
                int totalCritChance = playerstats.GetCritChance;
                int critChance      = rand.Next(0, 101);

                if (critChance <= totalCritChance)
                {
                    double crit = playerstats.GetMeleeDamage * 2;
                    mobstats.GetHealth -= crit;
                    if (mobstats.GetHealth < 0)
                    {
                        mobstats.GetHealth = 0;
                        Console.WriteLine("\nYou CRITICALLY damaged " + testdummy.GetName + " for " + crit +
                                          ".");
                    }
                    else
                    {
                        Console.WriteLine("\nYou CRITICALLY damaged " + testdummy.GetName + " for " + crit +
                                          ".");
                    }
                }

                else
                {
                    mobstats.GetHealth -= playerstats.GetMeleeDamage;
                    if (mobstats.GetHealth < 0)
                    {
                        mobstats.GetHealth = 0;
                        Console.WriteLine("\nYou damaged " + testdummy.GetName + " for " + playerstats.GetMeleeDamage +
                                          ".");
                    }
                    else
                    {
                        Console.WriteLine("\nYou damaged " + testdummy.GetName + " for " + playerstats.GetMeleeDamage +
                                          ".");
                    }
                }
            }
        }