File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 5
5
# Existing code (is_valid_word, is_valid_move, word_list)
6
6
7
7
# Additional features
8
+
9
+
8
10
def get_word_length_difficulty (difficulty ):
9
11
if difficulty == "Easy" :
10
12
return 3
@@ -15,9 +17,11 @@ def get_word_length_difficulty(difficulty):
15
17
else :
16
18
raise ValueError ("Invalid difficulty level." )
17
19
20
+
18
21
def get_random_letter ():
19
22
return random .choice (string .ascii_lowercase )
20
23
24
+
21
25
def get_hint (prev_word ):
22
26
# Simple hint: Suggest a valid word with one letter change from prev_word
23
27
for _ in range (10 ): # Try 10 times to find a hint
@@ -26,6 +30,7 @@ def get_hint(prev_word):
26
30
return new_word
27
31
return None # Return None if a hint can't be found
28
32
33
+
29
34
def word_chain_game ():
30
35
# Existing code
31
36
@@ -104,14 +109,17 @@ def check_time_elapsed(start_time, max_time):
104
109
105
110
# Check if player's word is too short for the difficulty level
106
111
if len (new_word ) < word_length_required :
107
- print (f"Word should be at least { word_length_required } letters long for { difficulty } difficulty." )
112
+ print (
113
+ f"Word should be at least { word_length_required } letters long for { difficulty } difficulty." )
108
114
print ("You lose this round." )
109
115
break
110
116
111
117
# Check if the game should end
112
118
if player_turn > 1 and not is_valid_move (chain [- 2 ], chain [- 1 ]):
113
- print (f"Game over! { player_name } cannot find a valid word. { player_name } wins!" )
119
+ print (
120
+ f"Game over! { player_name } cannot find a valid word. { player_name } wins!" )
114
121
break
115
122
123
+
116
124
if __name__ == "__main__" :
117
125
word_chain_game ()
You can’t perform that action at this time.
0 commit comments