forked from GitJeffPeters/luoa-coding-club-ms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
91 lines (91 loc) · 3.82 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
namespace ConsoleApp1;
abstract class Program
{
private static void Main(){
GameSystem();
}
private static void GameSystem(){
var keepPlaying = true;
while (keepPlaying)
{
Game();
Console.WriteLine("Would you like to start a new game? y/n (lower capitals)");
ConsoleKeyInfo cki = Console.ReadKey(); //wait for player to press a key
keepPlaying = cki.KeyChar == 'y'; //continue only if y was pressed
Console.WriteLine("\n");
}
}
private static void Game(){
Console.WriteLine("To play Rock Paper Scissors, enter your name");
var playerName = Console.ReadLine();
const string comSym = "[COMPUTER]";
Random aiRng = new();
var aiName = comSym + aiRng.Next(1, 1000000000);
string[] moves = {"Scissors", "Paper", "Rock"};
Random moveRng = new();
var move = moveRng.Next(moves.Length);
Console.WriteLine("Rock, Paper, Scissors, SHOOT!");
Console.WriteLine("\nEnter your move with the first letter being capital!");
var playerMove = Console.ReadLine();
var aiMove = $"{moves[move]}";
Console.WriteLine("You chose " + playerMove);
Console.WriteLine(aiName + " chose " + aiMove);
switch (aiMove)
{
case "Rock" when playerMove == "Scissors":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Rock beats Scissors, " + aiName + " wins!");
Console.Beep();
break;
case "Scissors" when playerMove == "Rock":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Rock beats Scissors, " + playerName + " wins!");
Console.Beep();
break;
case "Rock" when playerMove == "Paper":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Paper covers Rock, " + playerName + " wins!");
Console.Beep();
break;
case "Paper" when playerMove == "Rock":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Paper covers Rock, " + aiName + " wins!");
Console.Beep();
break;
case "Scissors" when playerMove == "Paper":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Scissors cut Paper, " + aiName + " wins!");
Console.Beep();
break;
case "Paper" when playerMove == "Scissors":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Scissors cut Paper, " + playerName + " wins!");
Console.Beep();
break;
case "Paper" when playerMove == "Paper":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Its a tie!");
Console.Beep();
break;
case "Scissors" when playerMove == "Scissors":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Its a tie!");
Console.Beep();
break;
case "Rock" when playerMove == "Rock":
Console.WriteLine("=============");
Console.WriteLine("=============");
Console.WriteLine("Its a tie!");
Console.Beep();
break;
}
}
}