Skip to content

Commit faccdd9

Browse files
authored
updates
1 parent 646b3b3 commit faccdd9

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

hangman.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,42 @@ def reset(): # resets vars for new round
1414

1515

1616
def start(): # start function
17-
global mode, autoSave
17+
global mode
1818
print('---< commands >---')
1919
print('enter any letter as your guess')
2020
print('enter !guess to guess the whole word')
2121
print('enter !used to see used letters')
22+
print('enter !save to save your stats')
2223
print('enter !end to give and end the game')
2324
print('=-=-=-=-=-=-=-=-=-=-=-=-=-=')
2425
reset()
2526
time.sleep(1)
26-
print('do you want to auto save results to a file?')
27-
print('enter y to continue\nenter any key to skip')
28-
option = input('enter your choice: ')
29-
if option == 'y':
30-
autoSave = True
31-
else:
32-
autoSave = False
33-
print('!normal is for normal mode | 12 lives, full word wrong -2 lives')
34-
print('!hard is for hard mode | longer words, 6 lives, full word wrong you die')
27+
print('!normal is for normal mode | lives: 12, word length any, guess wrong: -2 lives')
28+
print('!hard is for hard mode | lives: 6, word length > 6, guess wrong: death')
3529
mode = input('enter !normal or !hard: ')
3630
main()
3731

3832

3933
def again():
40-
global mode, attempts, endCondition
34+
global mode, attempts, endCondition, autoSave
4135
option = input('enter !save to save your results\nenter !play to play again\nenter !stop to stop\n')
42-
if option == '!play':
43-
reset()
44-
time.sleep(1)
45-
print('!normal is for normal mode | 12 lives, full word wrong -2 lives')
46-
print('!hard is for hard mode | longer words, 6 lives, full word wrong you die')
47-
mode = input('enter !normal or !hard: ')
48-
main()
49-
elif option == '!save' or autoSave is True:
50-
if autoSave is True:
51-
print('auto saved')
36+
if option == '!stop':
37+
exit()
38+
elif option == '!save': # needs auto save (function maybe)
5239
file = open('history', 'a')
5340
file.write('\n=-=-=-=-=-=-=-=-=-=-=-=-=-=\n')
5441
file.write(f'{endCondition}\n')
5542
file.write(
5643
f'word: {word[:-1]}\nmode: {mode[1:]}\nlives left: {lives}\nwrong letters: {attempts - lives}\nused letters: {len(used)}\n')
5744
file.write(f'used letter list: {used}\n')
5845
again()
46+
elif option == '!play':
47+
reset()
48+
time.sleep(1)
49+
print('!normal is for normal mode | lives: 12, word length any, guess wrong: -2 lives')
50+
print('!hard is for hard mode | lives: 6, word length > 6, guess wrong: death')
51+
mode = input('enter !normal or !hard: ')
52+
main()
5953
else:
6054
exit()
6155

@@ -114,6 +108,8 @@ def main():
114108

115109
if option == '!used':
116110
print(f'used letters: {used}')
111+
elif option == '!save':
112+
print('you can do that at the end of a round')
117113
elif option == '!end':
118114
print('are you sure you want to give up?')
119115
print('enter y to give up\nenter any key to skip')
@@ -196,3 +192,5 @@ def main():
196192
print('---< made by: cqb13 >---\n')
197193
time.sleep(1)
198194
start()
195+
196+
# make auto save that works

0 commit comments

Comments
 (0)