Update app.py
Browse files
app.py
CHANGED
@@ -64,18 +64,19 @@ class WordGame:
|
|
64 |
self.attempts = 3
|
65 |
self.target_word = random.choice(words)
|
66 |
print(f"New target word: {self.target_word}")
|
|
|
67 |
|
68 |
def check_input_for_word(self, string):
|
69 |
-
if self.target_word in string:
|
70 |
print(f"The player input the target word and the task was reset.")
|
71 |
self.generate_task()
|
72 |
self.points -= 1
|
73 |
-
self.update_status(message="You input the target word yourself, so you lost one point and the game reset.")
|
74 |
-
return
|
75 |
|
76 |
else:
|
77 |
print(f"The player did not input the target word, so that's good.")
|
78 |
-
return
|
79 |
|
80 |
|
81 |
def check_output_for_word(self, string):
|
@@ -128,7 +129,7 @@ def respond(
|
|
128 |
|
129 |
print("message:")
|
130 |
print(message)
|
131 |
-
|
132 |
|
133 |
for val in history:
|
134 |
if val[0]:
|
@@ -156,8 +157,13 @@ def respond(
|
|
156 |
#yield response
|
157 |
print("response:")
|
158 |
print(response)
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
161 |
return response
|
162 |
|
163 |
|
|
|
64 |
self.attempts = 3
|
65 |
self.target_word = random.choice(words)
|
66 |
print(f"New target word: {self.target_word}")
|
67 |
+
return self.target_word
|
68 |
|
69 |
def check_input_for_word(self, string):
|
70 |
+
if self.target_word in string.lower():
|
71 |
print(f"The player input the target word and the task was reset.")
|
72 |
self.generate_task()
|
73 |
self.points -= 1
|
74 |
+
#self.update_status(message="You input the target word yourself, so you lost one point and the game reset.")
|
75 |
+
return True
|
76 |
|
77 |
else:
|
78 |
print(f"The player did not input the target word, so that's good.")
|
79 |
+
return False
|
80 |
|
81 |
|
82 |
def check_output_for_word(self, string):
|
|
|
129 |
|
130 |
print("message:")
|
131 |
print(message)
|
132 |
+
|
133 |
|
134 |
for val in history:
|
135 |
if val[0]:
|
|
|
157 |
#yield response
|
158 |
print("response:")
|
159 |
print(response)
|
160 |
+
if game.check_input_for_word(message):
|
161 |
+
response = response + " \n\n---\n\n You input the word and lost one point!"
|
162 |
+
else:
|
163 |
+
output_check_result = game.check_output_for_word(response)
|
164 |
+
response = response + " \n\n---\n\n" + output_check_result
|
165 |
+
|
166 |
+
response = response + "\n" + game.update_status()
|
167 |
return response
|
168 |
|
169 |
|