-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
122 lines (118 loc) · 4.49 KB
/
main.py
File metadata and controls
122 lines (118 loc) · 4.49 KB
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
from random import randrange
import sys
from pip._vendor.six import print_
loop = True
while loop:
gameloop = False
menuloop = True
mainloop = True
while mainloop:
print('\n\n\n-----------------------------------------')
print('----------Rock, paper, scissors----------')
print('-----------------------------------------')
print('Welcome player!')
print('Press enter to start!')
print('For tutorial type tut to the console!')
menuloop = True
while menuloop:
inp = input()
if inp == 'exit':
sys.exit()
elif inp == 'tut':
print("\n\n----Tutorial----\nFirst you need to go to the main menu(press enter).\nWhen you are ready to start the game press enter in the main menu.\nType in the number of games you'd like to play.\nThen the game starts. First you need to type in rock, paper or scissors. The robot will choose randomly.\nThe computer will decide who won the round.\nIf you are ready for the next round, than press enter.\nIf you don't want to finish the game than type stop and press enter. This will bring you back to the main menu.\nTo exit the application completely type exit and press enter.\n\nPress enter to go back to the main menu!")
inp = input()
if inp == 'exit':
sys.exit()
else:
menuloop = False
elif inp == '':
startloop = True
while startloop:
print('How many rounds would you like to play?')
rounds = input()
if not rounds.isdigit():
if rounds == "exit":
sys.exit()
elif rounds == "stop":
startloop = False
menuloop = False
mainloop = False
continue
print('Please enter an integer!')
else:
gameloop = True
menuloop = False
mainloop = False
startloop = False
else:
print('Unknown command')
round = 0
plyscore = 0
botscore = 0
while gameloop:
round += 1
rounds = int(rounds)
if round > rounds:
if plyscore > botscore:
print('\n\n\nCongratulations, you won!\nFinal score: ',plyscore,'-',botscore)
elif plyscore == botscore:
print("\n\n\nIt's a draw!\nFinal score: ",plyscore,'-',botscore)
else:
print("\n\n\nYou lost!\nFinal score: ", botscore, '-', plyscore)
print('Press enter to go back to the main menu!')
input()
gameloop = False
continue
if round == 1:
print('First round:',round,'/',rounds)
elif round == rounds:
ex = input()
if ex == 'exit':
sys.exit()
elif ex == 'stop':
gameloop = False
validate = False
iscont = True
continue
print('Last round! ',round,'/',rounds)
else:
ex = input()
if ex == 'exit':
sys.exit()
elif ex == 'stop':
gameloop = False
validate = False
iscont = True
continue
print('Next round:',round,'/',rounds)
iscont = False
validate = True
while validate:
user = input()
if user == 'exit':
sys.exit()
if user == 'stop':
gameloop = False
validate = False
iscont = True
continue
num = randrange(1, 3)
arr = ['rock', 'paper', 'scissors']
if user not in arr:
print('Please give a valid input!')
else:
validate = False
if iscont:
continue
print('robot: ', arr[num-1])
usrnum = arr.index(user) + 1
if usrnum == num:
plyscore += 1
botscore += 1
print('Round draw!')
elif (usrnum == 1 and num == 3) or (usrnum == 2 and num == 1) or (usrnum == 3 and num == 2):
plyscore += 1
print('Round won!')
else:
botscore += 1
print('Round lost!')