示例#1
0
 static void ShowHP(Character chara, int opponentHp)
 {
     Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine($"{chara.CharName}: {chara.GetHealth()}HP \n Enemy: {opponentHp}HP");
     Console.ForegroundColor = ConsoleColor.White;
 }
示例#2
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);
                }
            }
        }
示例#3
0
        static void UserUI(User user)
        {
            while (true)
            {
                Console.WriteLine($"Select: \n 1.Pick Character \n 2.Create Character \n 3.Log Out");
                switch (Console.ReadLine())
                {
                case "1":
                    user.ListCharacters();
                    Character picked = PickCharacter(user);
                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 1");
                        Console.WriteLine("Bandits attack you from nowhere. They seem vey dangerous");
                        picked = GamePlayEvent2(picked, 20);
                    }
                    else
                    {
                        Console.WriteLine("CHaracter is DEAD!");
                        break;
                    }

                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 2");
                        Console.WriteLine("You go back to the village");
                        Console.WriteLine("You bump the Guard he attacks");
                        picked = GamePlayEvent2(picked, 30);
                    }
                    else
                    {
                        Console.WriteLine($"Game Over ");
                        break;
                    }
                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 3");
                        Console.WriteLine("As you were walking around a land SHARK starts to chase you");
                        picked = GamePlayEvent2(picked, 50);
                    }
                    else
                    {
                        Console.WriteLine($"Game Over ");
                        break;
                    }
                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 4");
                        Console.WriteLine("You accidentally step on a rat. His friends are not happy. They attack...");
                        picked = GamePlayEvent2(picked, 10);
                    }
                    else
                    {
                        Console.WriteLine($"Game Over ");
                        break;
                    }
                    if (picked.GetHealth() > 0)
                    {
                        Console.WriteLine("Event 5");
                        Console.WriteLine("You find a huge rock. It comes alive somehow and tries to smash you..");
                        picked = GamePlayEvent2(picked, 30);
                    }
                    else
                    {
                        Console.WriteLine($"Game Over ");
                        break;
                    }
                    if (picked.GetHealth() > 0)
                    {
                        Console.BackgroundColor = ConsoleColor.Yellow;
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("CONGRATULATIONS YOU HAVE COMPLETED ALL THE CHALLENGES");
                        Console.BackgroundColor = ConsoleColor.White;
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("Go again?  (press Y to go again)");
                        switch (Console.ReadLine())
                        {
                        case "y":
                        case "Y":
                            continue;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("GAME OVER");
                    }

                    break;

                case "2":
                    Character createNew = createNewChar();
                    Console.WriteLine($"Created {createNew.GetInfo()}");
                    user.CreateCharacter(createNew);
                    continue;

                case "3":
                    Console.WriteLine("LogOut");
                    break;

                default:
                    continue;
                }
                break;
            }
        }