示例#1
0
        static Character GamePlayEvent2(Character chara, int enemyDamage)
        {
            int enemyHP = 100;

            while (true)
            {
                bool fight = ActionPlay();
                int  roll  = RandomRoll();
                switch (fight)
                {
                case true:
                    if (roll == 0)
                    {
                        Console.WriteLine("U landed a critical strike and killed you opponent");

                        enemyHP = 0;
                        ShowHP(chara, enemyHP);
                    }
                    else if (roll > chara.GetStrenght())
                    {
                        Console.WriteLine($"You rolled {roll} and recieved {enemyDamage} Damage ");
                        chara.SetHealth(-enemyDamage);
                        ShowHP(chara, enemyHP);
                    }

                    else
                    {
                        Console.WriteLine($"You rolled {roll} and struck the bandit for {20 * (chara.GetStrenght() - roll)}");
                        enemyHP -= (20 * (chara.GetStrenght() - roll));
                        ShowHP(chara, enemyHP);
                    }
                    break;

                case false:
                    if (roll == 0)
                    {
                        Console.WriteLine($"You have run away and run in to a healer and gained 100HP");
                        chara.SetHealth(100);
                        ShowHP(chara, enemyHP);
                    }
                    else if (roll > chara.GetAgility())
                    {
                        Console.WriteLine("You failed to get away and recieved 10 Damage");
                        chara.SetHealth(-10);
                        ShowHP(chara, enemyHP);
                    }

                    else
                    {
                        Console.WriteLine($"You have run away and healed for 40hp");
                        chara.SetHealth(40);
                        ShowHP(chara, enemyHP);
                    }
                    break;
                }
                if (chara.GetHealth() < 1)
                {
                    Console.WriteLine("You lose");
                    return(chara);
                }
                else if (enemyHP < 1)
                {
                    Console.WriteLine($"You won and have {chara.GetHealth()} HP left");
                    return(chara);
                }
            }
        }