-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathh2ngm2n.py
209 lines (182 loc) · 5.85 KB
/
h2ngm2n.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
import os
from asciimatics.effects import Cycle, Stars
from asciimatics.renderers import FigletText
from asciimatics.scene import Scene
from asciimatics.screen import Screen
def sieunhangao():
def end():
print("\nPlay again?\n")
while True:
user_input = (input("(y/N): "))
user_input = (user_input).lower()
if user_input == "y":
print(sieunhangao())
if user_input == "n":
Screen.wrapper(didit)
print("Goodbye:D!")
exit()
else:
print("Please re-enter! y(Yes) or N (No).")
def didit(screen):
screen.clear()
screen.print_at("Goodbye:D!", int(screen.width / 2 - 3),
int(screen.height / 2))
screen.refresh()
screen.wait_for_input(1)
def banner():
print("""
( ( ) ) : ( )
)\ )\ ((. ())) ( ( )\ ((.
((_) ((_)) ))\ ()(()))\)\ ((_)) ))\
| |_ (|_ )((_))/ _` |_((_) (|_ )((_))
| \ / / | ' \)__. | ' \ / / | ' \)
|_||_| /___||_||_|___/|_|_|_| /___||_||_|
""")
print(" # made with Python")
return ""
def batdau():
os.system('cls' if os.name == 'nt' else 'clear')
print(banner())
print(
"Welcome to H6ngmaN2p! Let's see what you will type.\n\nPlayer 1 turn.\n"
)
print("""
o
_ 0 .-----\-----. ,_0 _
o' / \ |\ \ \ \ `o
__|\___|_`-----\-----`__ /|____
/ | | | | \
| |
""")
random_tu = input(
"Type secret word(can't add line spacing and capital letters): "
).replace(" ", "")
random_tu = random_tu.lower()
sokytu = len(random_tu)
os.system('cls' if os.name == 'nt' else 'clear')
print(banner())
print(
"Welcome to H6ngmaN2p! Let's see what you will type.\n\nPlayer 1 turn.\n"
)
print("Your secret word :", random_tu)
print("""
o
_ 0 .-----\-----. ,_0 _
o' / \ |\ \ \ \ `o
__|\___|_`-----\-----`__ /|____
/ | | | | \
| |
""")
while True:
mang = (input("\nEnter the number of incorrect guesses: "))
if mang.isnumeric():
mang = int(mang)
break
else:
print("Please re-enter! Only number.")
# mang = (input("Enter the number of incorrect guesses: "))
# if mang.isdigit():
# mang = int(mang)
else:
print("Only number.")
quit()
if mang == 0:
print("Can't be 0.")
quit()
os.system('cls' if os.name == 'nt' else 'clear')
print(banner())
print(
"Welcome to H6ngmaN2p! Let's see what you will type.\n\nPlayer 1 turn.\n"
)
print("Your secret word :", random_tu)
print("Total number of wrong guesses : ", mang, "\n")
print("Type not if you don't want to give suggestions .")
print("""
o
_ 0 .-----\-----. ,_0 _
o' / \ |\ \ \ \ `o
__|\___|_`-----\-----`__ /|____
/ | | | | \
| |
""")
goiy = input("\nGive suggestions: ")
space2 = []
for i in range(sokytu):
space2.append('_')
os.system('cls' if os.name == 'nt' else 'clear')
print(banner())
print("Welcome to Hangman! Let's see if you can guess this word!\n")
print("Player 2 turn.\n")
print("You have", mang, "incorrect guesses left.", "\n")
print("Your word is...")
print(' '.join(space2))
print("\nSuggestion : ", goiy)
print("""
o
_ 0 .-----\-----. ,_0 _
o' / \ |\ \ \ \ `o
__|\___|_`-----\-----`__ /|____
/ | | | | \
| |
""")
while ('_' in space2) and (mang > 0):
# print("see if there is an error: ", random_tu)
chon = input("\nGuess a letter: ")
chon = chon.lower()
os.system('cls' if os.name == 'nt' else 'clear')
for i, kytu in enumerate(random_tu):
if chon == kytu:
space2[i] = kytu
print(banner())
print("Welcome to Hangman! Let's see if you can guess this word!\n")
print("Player 2 turn.\n")
print(' '.join(space2))
if goiy == "not":
print("\nNo suggestions at all!")
else:
print("\nSuggestion : ", goiy)
if len(chon) == 1:
if chon in random_tu:
print("\nYes! The letter", chon, "is part of the secret word.")
else:
mang -= 1
print("\nNo! The letter", chon, "is not part of the secret word.")
else:
print("\nPlease input only 1 letter.")
print("\nYou have", mang, "incorrect guesses left.", "\n")
print("""
o
_ 0 .-----\-----. ,_0 _
o' / \ |\ \ \ \ `o
__|\___|_`-----\-----`__ /|____
/ | | | | \
| |
""")
if mang == 0:
print("Player 1 won!")
print("The secret word: ", random_tu)
else:
print("Player 2 won!")
print(end())
print(batdau())
def doit(screen):
effects = [
Cycle(screen, FigletText("Welcome to", font='big'),
int(screen.height / 2 - 8)),
Cycle(screen, FigletText("H2NGM2N!", font='big'),
int(screen.height / 2 + 3)),
Stars(screen, 200)
]
screen.play([
Scene(effects, int(screen.width / 2)),
Scene(effects,
int(screen.width / 2) + 1)
],
repeat=False)
screen.clear()
screen.print_at("Made by Dam Duc Huy", int(screen.width / 2 - 3),
int(screen.height / 2))
screen.refresh()
screen.wait_for_input(1)
Screen.wrapper(doit)
print(sieunhangao())