View difference between Paste ID: RW7cNbG9 and 9Fnu77Ma
SHOW: | | - or go back to the newest paste.
1
using System;
2
3
namespace ConsoleApp3
4
{
5
    class Program
6
    {
7
        static void Main(string[] args)
8
        {
9
            Random rnd = new Random();
10
11
            bool haslost = false;
12
13
            int p1hp = 100;
14
            int p1ar = 50;
15
            int p1at;
16
17
            int p2hp = 100;
18
            int p2ar = 50;
19
            int p2at;
20
21
            Console.WriteLine("Player 1 and Player 2 begin with 100 HP and 50 Armor" + "\n");
22
            Console.WriteLine("Begin?");
23
            Console.ReadLine();
24
25
            while (haslost == false)
26
27
            {
28
                p1at = rnd.Next(10, 20);       //player 1 attacks
29
30
                Console.WriteLine("Player 1 hits for " + p1at + " Hit Points");
31
32
                if (p2ar > 0)          //armor calculation and displays for player 2
33
                {
34
                    p1at = p1at - 5;
35
                    p2ar = p2ar - p1at;
36
                    
37
                    if (p2ar > 0)
38
                    {
39
                        Console.WriteLine("Player 2 has " + p2ar + " Armor left" + "\n");
40
                    }
41
42
                    else if (p2ar <= 0)
43
                    {
44
                        Console.WriteLine("Player 2 has no armor left" + "\n");
45
                    }
46
                }
47
48
                else if (p2ar <= 0)        //hp calculation and displays for player 2
49
                {
50
                    p2hp = p2hp - p1at;
51
52
                    if (p2hp > 0)
53
                    {
54
                        Console.WriteLine("Player 2 has " + p2hp + " HP left" + "\n");
55
                    }
56
57
                    else if (p2hp <= 0)
58
                    {
59
                        Console.WriteLine("Player 2 has no HP left" + "\n");
60
                    }
61
62
                }
63
64
                if (p2hp <= 0)     //player 1 wins
65
                {
66
                    haslost = true;
67
                    Console.WriteLine("Player 1 Wins");
68
                    break;
69
                }
70
71
                p2at = rnd.Next(10, 20);       //player 2 attacks
72
73
                Console.WriteLine("Player 2 hits for " + p2at + " Hit Points");
74
75
                if (p1ar > 0)         //armor calculation and displays for player 1
76
                {
77
                    p2at = p2at - 5;
78
                    p1ar = p1ar - p2at;
79
80
                    if (p1ar > 0)
81
                    {
82
                        Console.WriteLine("Player 1 has " + p1ar + " Armor left" + "\n");
83
                    }
84
85
                    else if (p1ar <= 0)
86
                    {
87
                        Console.WriteLine("Player 1 has no armor left" + "\n");
88
                    }
89
                }
90
91
                else if (p1ar <= 0)     //hp calculation and displays for player 1
92
                {
93
                    p1hp = p1hp - p2at;
94
95
                    if (p1hp > 0)
96
                    {
97
                        Console.WriteLine("Player 1 has " + p1hp + " HP left" + "\n");
98
                    }
99
100
                    else if (p1hp <= 0)
101
                    {
102
                        Console.WriteLine("Player 1 has no HP left" + "\n");
103
                    }
104
105
                }
106
107
                if (p1hp <= 0)      //player 2 wins
108
                {
109
                    haslost = true;
110
                    Console.WriteLine("Player 2 Wins");
111
                    break;
112
                }
113
114
                Console.ReadLine();
115
            }
116
        }
117
    }
118
}