-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
163 lines (144 loc) · 7.1 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
namespace RockPaperScissors
{
class TheProgram
{
static void Main(string[] arg)
{
string Input1Player, Input2Player;
int RandomInt;
int Score1 = 0;
int Score2 = 0;
bool Play = true;
while (Play)
{
Score1 = 0; Score2 = 0;
while (Score1 < 3 && Score2 < 3)
{
System.Console.Write("Choose, A move. Rock || Paper || Scissors: ");
Input1Player = Console.ReadLine();
Input1Player = Input1Player.ToUpper();
System.Random GetRand = new System.Random();
RandomInt = GetRand.Next(1, 4);
string[] Choses = new string[] { "ROCK", "PAPER", "SCISSORS" };
switch (RandomInt)
{
case 1:
Input2Player = Choses[RandomInt - 1];
System.Console.WriteLine("The AI has chosen a {0}", Choses[RandomInt - 1]);
if (Input1Player == Choses[RandomInt - 1])
{
System.Console.ForegroundColor = System.ConsoleColor.Gray;
System.Console.WriteLine("GG. Is a Draw");
System.Console.ForegroundColor = System.ConsoleColor.White;
}
else if (Input1Player == Choses[RandomInt])
{
System.Console.ForegroundColor = System.ConsoleColor.Green;
System.Console.WriteLine("Player wins!!");
System.Console.ForegroundColor = System.ConsoleColor.White;
Score1++;
}
else if (Input1Player == Choses[RandomInt + 1])
{
System.Console.ForegroundColor = System.ConsoleColor.Red;
System.Console.WriteLine("AI wins!!");
System.Console.ForegroundColor = System.ConsoleColor.White;
Score2++;
}
System.Console.WriteLine("Player = {0}, AI = {1}", Score1, Score2);
break;
case 2:
Input2Player = Choses[RandomInt - 1];
System.Console.WriteLine("The AI has chosen a {0}", Choses[RandomInt - 1]);
if (Input1Player == Choses[RandomInt - 1])
{
System.Console.ForegroundColor = System.ConsoleColor.Gray;
System.Console.WriteLine("GG. Is a Draw");
System.Console.ForegroundColor = System.ConsoleColor.White;
}
else if (Input1Player == Choses[RandomInt])
{
System.Console.ForegroundColor = System.ConsoleColor.Green;
System.Console.WriteLine("Player wins!!");
System.Console.ForegroundColor = System.ConsoleColor.White;
Score1++;
}
else if (Input1Player == Choses[RandomInt - 2])
{
System.Console.ForegroundColor = System.ConsoleColor.Red;
System.Console.WriteLine("AI wins!!");
System.Console.ForegroundColor = System.ConsoleColor.White;
Score2++;
}
System.Console.WriteLine("Player = {0}, AI = {1}", Score1, Score2);
break;
case 3:
Input2Player = Choses[RandomInt - 1];
System.Console.WriteLine("The AI has chosen a {0}", Choses[RandomInt - 1]);
if (Input1Player == Choses[RandomInt - 1])
{
System.Console.ForegroundColor = System.ConsoleColor.Gray;
System.Console.WriteLine("GG. Is a Draw");
System.Console.ForegroundColor = System.ConsoleColor.White;
}
else if (Input1Player == Choses[RandomInt - 3])
{
System.Console.ForegroundColor = System.ConsoleColor.Green;
System.Console.WriteLine("Player wins!!");
System.Console.ForegroundColor = System.ConsoleColor.White;
Score1++;
}
else if (Input1Player == Choses[RandomInt - 2])
{
System.Console.ForegroundColor = System.ConsoleColor.Red;
System.Console.WriteLine("AI wins!!");
System.Console.ForegroundColor = System.ConsoleColor.White;
Score2++;
}
System.Console.WriteLine("Player = {0}, AI = {1}", Score1, Score2);
break;
default:
System.Console.WriteLine("Somefing went worong.");
break;
}
}
if (Score1 == 3)
{
System.Console.ForegroundColor = System.ConsoleColor.Green;
System.Console.WriteLine("Player has won. Nice");
System.Console.ForegroundColor = System.ConsoleColor.White;
}
else if (Score2 == 3)
{
System.Console.ForegroundColor = System.ConsoleColor.Red;
System.Console.WriteLine("AI has won. Not good");
System.Console.ForegroundColor = System.ConsoleColor.White;
}
else
{
}
while (true)
{
System.Console.WriteLine("Play again? [Y/n]");
string PlayGame = "y";
PlayGame = System.Console.ReadLine();
PlayGame = PlayGame.ToUpper();
if (PlayGame == "Y")
{
Play = true;
break;
}
else if (PlayGame == "N")
{
Play = false;
break;
}
else
{
System.Console.WriteLine("Wrong input");
}
}
}
}
}
}