-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththe game
157 lines (151 loc) Β· 4.44 KB
/
the game
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
/*Rock, paper, scissors, lizard π¦, spok π
cin => user try
random number => computer try
scissors cuts paper
paper covers rock
rock crushes lizard
lizard poisons spok
spok smashes scissors
scissors decapitate lizard
lizard eats paper
paper disproves spok
spok vaporizes rock
rock crushes scissors
*/
#include <iostream>
#include <stdlib.h>
int main(){
int guess;
std::string comp;
//Say hello!
std::cout << "====================\n";
std::cout << "rock paper scissors lizard spock!\n";
std::cout << "====================\n";
std::cout << "1) β\n";
std::cout << "2) β\n";
std::cout << "3) βοΈ\n";
std::cout << "4) π¦\n";
std::cout << "5) π\n";
std::cout << "shoot! ";
//user input conversion
int userNum = 0;
std::string user;
std::cin >> userNum;
switch(userNum){
case 1:
user = "β";
break;
case 2:
user = "β";
break;
case 3:
user = "βοΈ";
break;
case 4:
user = "π¦";
break;
case 5:
user = "π";
break;
// std::cout << "4) π¦\n";
// std::cout << "5) π\n";
default:
std::cout<< "ERROR";
break;
}
//Computer shot
srand(time(0));
guess = rand() % 5 + 1;
//Computer conversion
switch(guess){
case 1:
comp = "β";
break;
case 2:
comp = "β";
break;
case 3:
comp = "βοΈ";
break;
case 4:
comp = "π¦";
break;
case 5:
comp = "π";
break;
default:
std::cout<< "ERROR";
break;
}
// logic
if(user == "βοΈ"){
if(comp == "β"){std::cout<<"comp shot: β\n rock crushes scissors\n";
std::cout<<"Comp win";}
else if(comp == "β"){std::cout<<"comp shot: β\nscissors cuts paper\n";
std::cout<<"User win";}
else if(comp == "π¦"){
std::cout<<"comp shot: π¦\nScissors decapitate Lizard.\n";
std::cout<<"User win";}
else if(comp == "π"){
std::cout<<"comp shot: π\nSpock smashes Scissors\n";
std::cout<<"comp win";}
else {std::cout<<"comp shot: βοΈ\n";
std::cout<<"Draw";}
}
else if(user == "β"){
if(comp == "β"){std::cout<<"comp shot: β\nPaper covers Rock\n";
std::cout<<"Comp win";}
else if(comp == "βοΈ"){std::cout<<"comp shot: βοΈ\nrock crushes scissors\n";
std::cout<<"User win";}
else if(comp == "π¦"){
std::cout<<"comp shot: π¦\nRock crushes Lizard.\n";
std::cout<<"User win";}
else if(comp == "π"){
std::cout<<"comp shot: π\nRock crushes Lizard.\n";
std::cout<<"comp win";}
else {std::cout<<"comp shot: β\n";
std::cout<<"Draw";}
}
else if(user == "β"){
if(comp == "β"){std::cout<<"comp shot: β\nPaper covers Rock\n";
std::cout<<"User win";}
else if(comp == "βοΈ"){std::cout<<"comp shot: βοΈ\nscissors cuts paper\n";
std::cout<<"comp win";}
else if(comp == "π¦"){
std::cout<<"comp shot: π¦\nLizard eats Paper\n";
std::cout<<"comp win";}
else if(comp == "π"){
std::cout<<"comp shot: π\nPaper disproves Spock.\n";
std::cout<<"user win";}
else {std::cout<<"comp shot: β\n";
std::cout<<"Draw";}
}
else if(user == "π¦"){
if(comp == "β"){std::cout<<"comp shot: β\nRock crushes Lizard.\n";
std::cout<<"comp win";}
else if(comp == "βοΈ"){std::cout<<"comp shot: βοΈ\nScissors decapitate Lizard.\n";
std::cout<<"comp win";}
else if(comp == "β"){
std::cout<<"comp shot: β\nLizard eats Paper\n";
std::cout<<"User win";}
else if(comp == "π"){
std::cout<<"comp shot: π\nLizard poisons Spock.\n";
std::cout<<"user win";}
else {std::cout<<"comp shot: π¦\n";
std::cout<<"Draw";}
}
else if(user == "π"){
if(comp == "β"){std::cout<<"comp shot: β\nSpock vaporizes Rock.\n";
std::cout<<"User win";}
else if(comp == "βοΈ"){std::cout<<"comp shot: βοΈ\nSpock smashes Scissors.\n";
std::cout<<"User win";}
else if(comp == "β"){
std::cout<<"comp shot: β\nPaper disproves Spock.\n";
std::cout<<"comp win";}
else if(comp == "π¦"){
std::cout<<"comp shot: π¦\nLizard poisons Spock.\n";
std::cout<<"comp win";}
else {std::cout<<"comp shot: π\n";
std::cout<<"Draw";}
}
}