forked from prashantmore277/rockpaperseiser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRock_Paper_Scissor.py
210 lines (171 loc) Β· 5.58 KB
/
Rock_Paper_Scissor.py
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#This code is only for the begginers
import random as rdm
import sys
#Define game function
def game():
print("Welcome to Rock Paper Scissor\n")
print("INFO :-")
Name = str(input("Your Name : "))
City = str(input("Your City : "))
print("\nGame Rules :")
print("1 ] R=Rock P=Paper S=Scissor\n2 ] Rock blends Scissor\n3 ] Paper covers Rock\n4 ] Scissor cuts Paper\n5 ] If Player won 1 point\n added in players account\n6 ] If Bot won 1 point goes\n in bots account\n7 ] For Tie one point add\n in both players account\n8 ] Total matches compalsory\n9 ] At end Winner will be annouced\n")
Count= 10
Your_score=0
Bot_score=0
print("~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score)
print("\n~~~~~~~~~~~~~~~~~~~~~~~~\n")
while (Count>0):
print("~~~~~~~~~~~~~~~~~~~~~~~\n")
Count-=1
print("Round No = ",10-Count)
print("\nYour choice :\n")
print("Rock = 1\nPaper = 2\nScissor = 3\n")
List2 = ["Rock","Paper","Scissor"]
P= int(input("Choose 1/2/3 = " ))
B =rdm.randint(1,3)
if(P==B):
print("\nYour choice :",List2[P-1])
print("Bot choice :",List2[B-1],"\n")
print("__________Tie__________\n")
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score,"\n")
elif(P==1 and B!=1 and B!=2 and B==3):
print("Your choice :",List2[P-1])
print("Bot choice :",List2[B-1])
print("\n____Winner Winner____")
print("\nRock blends Scissor\n")
Your_score += 1
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score,"\n")
elif (P==2 and B!=2 and B!=3 and B==1):
print("Your choice :",List2[P-1])
print("Bot choice :",List2[B-1])
print("\n")
print(" π€ π€ π€ π€ π€ π€ π€ π€ ")
print("_____Winner Winner_____")
print("\nPaper covers Rock\n")
Your_score += 1
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score,"\n")
elif(P==3 and B!=3 and B!=1 and B==2):
print("Your choice :",List2[P-1])
print("Bot choice :",List2[B-1])
print("\n")
print("_____Winner Winner_____")
print("\nScissor cuts Paper\n")
Your_score += 1
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score,"\n")
elif( P!=B ):
print("Your choice :",List2[P-1])
print("Bot choice :",List2[B-1])
print("\n")
print("____Ping Pong Looser____\n")
Bot_score += 1
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score,"\n")
print("Match Remaining :",Count,"\n")
print("~~~~~~~~~~~~~~~~~~~~~~~\n")
print("\n")
print("\n")
if(Your_score>Bot_score):
#print("~~~~~~~~~~~~~~~~~~~~~~\n")
print("~~~~~~~~~~~~~~~~~~~~~~\n")
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score,"\n")
status = "Congratulations - You WON !!"
print ("ππ",status,"ππ")
print("~~~~~~~~~~~~~~~~~~~~~~\n")
#print("~~~~~~~~~~~~~~~~~~~~~~\n")
if(Bot_score>Your_score):
#print("~~~~~~~~~~~~~~~~~~~~~~\n")
print("~~~~~~~~~~~~~~~~~~~~~~\n")
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score,"\n")
status = "Hard Luck - You Lost !!"
print ("π‘π‘",status,"π‘π‘")
print("~~~~~~~~~~~~~~~~~~~~~~\n")
#print("~~~~~~~~~~~~~~~~~~~~~~\n")
elif( Your_score==Bot_score ):
#print("~~~~~~~~~~~~~~~~~~~~~~\n")
print("~~~~~~~~~~~~~~~~~~~~~~\n")
print("Your Score : ",Your_score)
print("Bot Score : ",Bot_score,"\n")
status = "Oops Game Tied"
print ("ππ",status,"ππ")
#print("~~~~~~~~~~~~~~~~~~~~~~\n")
print("~~~~~~~~~~~~~~~~~~~~~~~~~\n")
# Create a record and save details of Game
with open("pygamerecord.txt","a") as R:
string= " "
string += ("\n")
string += str("\nRecord Details :")
string += str("\n")
string += str("My name is")+str(" ") + str(Name)
string += ("\n")
string += str("My city is")+ str(" ") + str(City)
string += ("\n")
string += str("Game Status")+ str(" ") + str(status)
string += ("\n")
string += ("~~~~~~~~~~~~~~~~~~~~~~~~~~~")
R.write(string)
menu()
# Define record function
def records():
f=open("pygamerecord.txt","rt")
RECORD=f.read()
print(RECORD)
f.close
menu()
# Define clear records function
def clear_records():
file = open("pygamerecord.txt","r+")
file. truncate()
file. close()
print("\nRecords Clear Successfully.....\n")
menu()
# Define Duplicate Records
def menu_dup_record():
print("\nDuplicate Records: \n1 ] Type 1 to Create ==> Winner Entry\n2 ] Type 2 to Create ==> Looser Entry\n3 ] Type 3 to Create ==> Tied Entry\n=>")
dup_record()
print("\nRecord added Successfully.......\n")
menu()
def dup_record():
Y=int(input())
list3=["Winner","Looser","Tied"]
with open("pygamerecord.txt","a") as R:
print("INFO :-")
Name = str(input("Your Name : "))
City = str(input("Your City : "))
string= " "
string += ("\n")
string += str("\nRecord Details :")
string += str("\n")
string += str("My name is")+str(" ") + str(Name)
string += ("\n")
string += str("My Age is")+ str(" ") +str(City)
string += ("\n")
string += str("Game Status")+ str(" ") +str(list3[Y-1])
string += ("\n")
string += ("~~~~~~~~~~~~~~~~~~~~~~~~~~~")
R.write(string)
# Define menu functionality
def menu():
Z=int(input("\nMain menu: \n1 ] Type 1 to open ==> GAME\n2 ] Type 2 to open ==> RECORDS\n3 ] Type 3 to open ==> CLEAR RECORDS\n4 ] Type 4 to open ==> Duplicate RECORDS\n5 ] Type 5 to exit ==> GAME\n\n=>"))
if (Z==1):
game()
if(Z==2):
records()
if(Z==3):
clear_records()
if(Z==4):
menu_dup_record()
if(Z==5):
sys.exit("Game Exited !!")
else:
print("/nPlease make valid choice...")
menu()
# Menu Function Call
menu()