Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rnd = new Random();
- bool haslost = false;
- int p1hp = 100;
- int p1ar = 50;
- int p1at;
- int p2hp = 100;
- int p2ar = 50;
- int p2at;
- Console.WriteLine("Player 1 and Player 2 begin with 100 HP and 50 Armor" + "\n");
- Console.WriteLine("Begin?");
- Console.ReadLine();
- while (haslost == false)
- {
- p1at = rnd.Next(10, 20); //player 1 attacks
- Console.WriteLine("Player 1 hits for " + p1at + " Hit Points");
- if (p2ar > 0) //armor calculation and displays for player 2
- {
- p1at = p1at - 5;
- p2ar = p2ar - p1at;
- if (p2ar > 0)
- {
- Console.WriteLine("Player 2 has " + p2ar + " Armor left" + "\n");
- }
- else if (p2ar <= 0)
- {
- Console.WriteLine("Player 2 has no armor left" + "\n");
- }
- }
- else if (p2ar <= 0) //hp calculation and displays for player 2
- {
- p2hp = p2hp - p1at;
- if (p2hp > 0)
- {
- Console.WriteLine("Player 2 has " + p2hp + " HP left" + "\n");
- }
- else if (p2hp <= 0)
- {
- Console.WriteLine("Player 2 has no HP left" + "\n");
- }
- }
- if (p2hp <= 0) //player 1 wins
- {
- haslost = true;
- Console.WriteLine("Player 1 Wins");
- break;
- }
- p2at = rnd.Next(10, 20); //player 2 attacks
- Console.WriteLine("Player 2 hits for " + p2at + " Hit Points");
- if (p1ar > 0) //armor calculation and displays for player 1
- {
- p2at = p2at - 5;
- p1ar = p1ar - p2at;
- if (p1ar > 0)
- {
- Console.WriteLine("Player 1 has " + p1ar + " Armor left" + "\n");
- }
- else if (p1ar <= 0)
- {
- Console.WriteLine("Player 1 has no armor left" + "\n");
- }
- }
- else if (p1ar <= 0) //hp calculation and displays for player 1
- {
- p1hp = p1hp - p2at;
- if (p1hp > 0)
- {
- Console.WriteLine("Player 1 has " + p1hp + " HP left" + "\n");
- }
- else if (p1hp <= 0)
- {
- Console.WriteLine("Player 1 has no HP left" + "\n");
- }
- }
- if (p1hp <= 0) //player 2 wins
- {
- haslost = true;
- Console.WriteLine("Player 2 Wins");
- break;
- }
- Console.ReadLine();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment