-
Notifications
You must be signed in to change notification settings - Fork 0
/
[C Y O N]rockpaperscissor.py
135 lines (123 loc) · 4.19 KB
/
[C Y O N]rockpaperscissor.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
import random
import getpass
import os
def vsuser():
skorPlayerOne=0
skorPlayerTwo=0
playerOne=input("Nama pemain-1 :")
playerTwo=input("Nama pemain-2 :")
os.system('clear')
print("=============================\n\n")
print(
'''
Tips : input akan disembunyikan untuk menjaga kerahasiaan
Masukkan G untuk GUNTING, K untuk KERTAS dan B untuk BATU
'''
)
while skorPlayerOne<skor:
print(playerOne+" : ",skorPlayerOne)
print(playerTwo+" : ",skorPlayerTwo)
if skorPlayerTwo==skor:
break
tanganPlayerOne=getpass.getpass(playerOne+" Giliranmu :")
tanganPlayerTwo=getpass.getpass(playerTwo+" Giliranmu :")
tanganPlayerOne=tanganPlayerOne.upper()
tanganPlayerTwo=tanganPlayerTwo.upper()
if tanganPlayerOne==tanganPlayerTwo:
print("Seri")
elif tanganPlayerOne=="B":
if tanganPlayerTwo=="G":
print(tanganPlayerOne+" vs "+tanganPlayerTwo +":" +playerOne+" Menang")
skorPlayerOne+=1
else:
print(tanganPlayerTwo+" vs "+tanganPlayerOne +":" +playerTwo+" Menang")
skorPlayerTwo+=1
elif tanganPlayerOne=="G":
if tanganPlayerTwo=="K":
print(tanganPlayerOne+" vs "+tanganPlayerTwo +":" +playerOne+" Menang")
skorPlayerOne+=1
else:
print(tanganPlayerTwo+" vs "+tanganPlayerOne +":" +playerTwo+" Menang")
skorPlayerTwo+=1
elif tanganPlayerOne=="K":
if tanganPlayerTwo=="B":
print(tanganPlayerOne+" vs "+tanganPlayerTwo +":" +playerOne+" Menang")
skorPlayerOne+=1
else:
print(tanganPlayerTwo+" vs "+tanganPlayerOne +":" +playerTwo+" Menang")
skorPlayerTwo+=1
os.system('cls')
print("======================")
print("Permainan Selesai")
print("======================")
print(playerOne,skorPlayerOne)
print(playerTwo,skorPlayerTwo)
if skorPlayerOne>skorPlayerTwo:
print("==="+playerOne+" Menang === ")
else:
print("=== "+playerTwo+" Menang === ")
def botuser():
user=0
bot=0
while user<skor:
print("==================")
print("skor user : ",user)
print("skor bot : ",bot)
print("==================")
if bot==skor:
break
randomize=random.randrange(0,3)
botPilih=gbk[randomize]
userPilih=input("Pilih apa hayo : ")
userPilih=userPilih.upper()
if userPilih==gbk[randomize] :
print(userPilih + " vs "+ botPilih +" = seri")
elif userPilih==gbk[2]:
if botPilih==gbk[1]:
print(userPilih +" vs " + botPilih + "= Anda menang" )
user+=1
else:
print(botPilih +" vs "+ userPilih +"= Bot menang" )
bot+=1
elif userPilih==gbk[0]:
if botPilih==gbk[2]:
print(userPilih +" vs "+ botPilih +"= Anda menang" )
user+=1
else:
print(botPilih +" vs "+ userPilih +"= Bot menang" )
bot+=1
elif userPilih==gbk[1]:
if botPilih==gbk[0]:
print(userPilih +" vs "+ botPilih + "= Anda menang" )
user+=1
else:
print(botPilih +" vs "+ userPilih +"= Bot menang" )
bot+=1
os.system('cls')
print("=================")
print("Permainan Selesai")
print("Bot : ",bot)
print("User : ",user)
if user>bot:
print("Anda menang")
else:
print("Bot Menang. Goodluck next time")
#main_program
gbk = ["GUNTING","BATU","KERTAS"]
print("Suit : Batu, Gunting Kertas")
print("___________________________\n")
print("1. User vs User")
print("2. User Vs Bot")
print("3. Keluar")
pilihan=int(input("Pilih mode yang anda inginkan : "))
if pilihan==3:
print("Terima kasih telah bermain")
exit();
skor=int(input("Skor yang ingin diraih : "))
if pilihan==1:
vsuser()
elif pilihan==2:
botuser()
else:
print("Input salah")
exit()