Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string playerChoice()
- {
- Console.WriteLine("Do you want to Attack or Defend?");
- string playerchoice = Console.ReadLine();
- return playerchoice;
- }
- public void MonsterEncouter()
- {
- Random random = new Random();
- int randomNumber = random.Next(1, 101);
- int playerHealth = random.Next(50, 101);
- int playerAttack = random.Next(10, 31);
- string userInput = "";
- if (randomNumber >= 1 && randomNumber <= 24)
- {
- Console.WriteLine("You've run into a goblin, an easy enemy");
- Console.WriteLine("Its HP is: " + randomNumber);
- Console.WriteLine("Your HP is: " + playerHealth);
- Console.WriteLine("Let the battle begin!");
- Console.ReadLine();
- }
- else if (randomNumber >= 25 && randomNumber <= 49)
- {
- Console.WriteLine("You've run into a dire wolf, a bit tough enemy");
- Console.WriteLine("It's HP is: " + randomNumber);
- Console.WriteLine("Your HP is: " + playerHealth);
- Console.WriteLine("Let the battle begin!");
- Console.ReadLine();
- }
- else if (randomNumber >= 50 && randomNumber <= 74)
- {
- Console.WriteLine("You've run into an orc, a hard enemy");
- Console.WriteLine("It's HP is: " + randomNumber);
- Console.WriteLine("Your HP is: " + playerHealth);
- Console.WriteLine("Let the battle begin!");
- Console.ReadLine();
- }
- else
- {
- Console.WriteLine("You've run into a giant, a very hard enemy");
- Console.WriteLine("It's HP is: " + randomNumber);
- Console.WriteLine("Your HP is: " + playerHealth);
- Console.WriteLine("Let the battle begin!");
- Console.ReadLine();
- }
- {
- userInput = playerChoice();
- if (userInput == "Attack")
- {
- while (userInput == "Attack" && playerHealth > 0 && randomNumber > 0)
- {
- Console.WriteLine("You attacked the beast!");
- Console.WriteLine("You've dealt " + playerAttack + " damage");
- randomNumber -= playerAttack;
- Console.WriteLine("It's HP is: " + randomNumber);
- Console.WriteLine();
- {
- Console.ReadLine();
- Console.WriteLine("It fought back! It dealt " + playerAttack);
- playerHealth -= playerAttack;
- Console.WriteLine("You have " + playerHealth + " HP left");
- Console.WriteLine();
- userInput = playerChoice();
- }
- }
- if (randomNumber <= 0)
- {
- Console.WriteLine();
- Console.WriteLine("The monster has been slain!");
- Console.WriteLine("Congratulations!");
- Console.ReadLine();
- }
- if (playerHealth <= 0)
- {
- Console.WriteLine();
- Console.WriteLine("You have been slain!");
- Console.WriteLine("You lose");
- Console.ReadLine();
- }
- }
- else if (userInput == "Defend")
- {
- while (userInput == "Defend" && playerHealth > 0 && randomNumber > 0)
- {
- Console.WriteLine("You are ready to defend!");
- Console.WriteLine("The monster attacked!");
- playerHealth -= 1;
- Console.WriteLine("You blocked it's attacked and only lost 1 HP");
- Console.WriteLine("You now have: " + playerHealth + " HP");
- Console.WriteLine();
- userInput = playerChoice();
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement