Ejemplo n.º 1
0
        public bool StealthCheck()
        {
            //roll a d20 to determing if the user successfully hides or sneaks
            bool    successfulCheck = false;
            DieRoll stealth         = new DieRoll(20);
            int     rollNumber      = stealth.RollDie() + this.Dex;

            if (rollNumber >= 13)
            {
                successfulCheck = true;
            }
            return(successfulCheck);
        }
Ejemplo n.º 2
0
        public void DealDamage(Enemy targetEnemy)
        {
            DieRoll d20                  = new DieRoll(20);
            DieRoll d12                  = new DieRoll(12);
            DieRoll d10                  = new DieRoll(10);
            DieRoll d8                   = new DieRoll(8);
            int     damageDealt          = 0;
            string  successfulHitMessage = $"You successfully hit the {targetEnemy.Name}.";
            string  damageDealtMessage   = "Damage Dealt: ";
            string  failedHitMessage     = $"You miss the {targetEnemy.Name}.";
            string  killMessage          = $"You have slain the {targetEnemy.Name}.";

            if (Class == "fighter")
            {
                Console.WriteLine($"You swing your longsword at the {targetEnemy.Name}");
                int d20Roll = d20.RollDie();
                if (d20Roll + this.Str > targetEnemy.Defense)
                {
                    damageDealt = d10.RollDie() + this.AtkPower;
                    Console.WriteLine($"{successfulHitMessage}  {damageDealtMessage} {damageDealt}.");
                    targetEnemy.TakeDamage(damageDealt);
                }
                else
                {
                    Console.WriteLine(failedHitMessage);
                }
                Console.WriteLine($"You swing your shortsword at the {targetEnemy.Name}");
                d20Roll = d20.RollDie();
                if (d20Roll + this.Str > targetEnemy.Defense)
                {
                    damageDealt = d8.RollDie() + this.SecondAtkPower;
                    Console.WriteLine($"{successfulHitMessage}  {damageDealtMessage} {damageDealt}.");
                    targetEnemy.TakeDamage(damageDealt);
                }
                else
                {
                    Console.WriteLine(failedHitMessage);
                }
                if (targetEnemy.Health <= 0)
                {
                    Console.WriteLine(killMessage);
                }
            }
            else if (Class == "barbarian")
            {
                Console.WriteLine($"You swing your axe at the {targetEnemy.Name}");
                int d20Roll = d20.RollDie();
                if (d20Roll + this.Str > targetEnemy.Defense)
                {
                    damageDealt = d12.RollDie() + this.AtkPower;
                    Console.WriteLine($"{successfulHitMessage}  {damageDealtMessage} {damageDealt}.");
                    targetEnemy.TakeDamage(damageDealt);
                }
                else
                {
                    Console.WriteLine(failedHitMessage);
                }
                if (targetEnemy.Health <= 0)
                {
                    Console.WriteLine(killMessage);
                }
            }
            else if (Class == "wizard")
            {
                Console.WriteLine("Would you like to use a spell? (y/n)");
                char yesOrNo = UserInput.InputKey();
                if (yesOrNo == 'y')
                {
                    bool choseSpell = false;
                    while (!choseSpell)
                    {
                        Console.WriteLine("Type the name of the spell you'd like to use or \"s\" to access your spellbook.");
                        string chosenSpell = UserInput.Input();
                        if (chosenSpell == "s")
                        {
                            Game.player1.PlayerSpellbook.AccessSpellbook();
                        }
                        else if (Game.player1.PlayerSpellbook.Spells[chosenSpell].IsAttackSpell)
                        {
                            int damage = Game.player1.PlayerSpellbook.AttackSpell(Game.player1.PlayerSpellbook.Spells[chosenSpell]);
                            choseSpell = true;
                            int d20Roll = d20.RollDie();
                            if (d20Roll + this.Int > targetEnemy.Defense)
                            {
                                damageDealt = damage + this.AtkPower;
                                Console.WriteLine($"{successfulHitMessage}  {damageDealtMessage} {damageDealt}.");
                                targetEnemy.TakeDamage(damageDealt);
                            }
                            else
                            {
                                Console.WriteLine(failedHitMessage);
                            }
                            if (targetEnemy.Health <= 0)
                            {
                                Console.WriteLine(killMessage);
                            }
                        }
                        else
                        {
                            Console.WriteLine("It seems you've chosen a non-attack spell.  Please choose a different spell.");
                        }
                    }
                }
            }
        }