Update app.py
Browse files
app.py
CHANGED
|
@@ -62,19 +62,30 @@ class WordGame:
|
|
| 62 |
def generate_task(self):
|
| 63 |
self.attempts = 3
|
| 64 |
self.target_word = random.choice(words)
|
|
|
|
| 65 |
|
| 66 |
def check_input_for_word(self, string):
|
| 67 |
if self.target_word in string:
|
|
|
|
| 68 |
self.generate_task()
|
| 69 |
else:
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
self.generate_task()
|
| 73 |
|
| 74 |
def check_output_for_word(self, string):
|
| 75 |
if self.target_word in string:
|
| 76 |
self.points += self.attempts
|
|
|
|
| 77 |
self.generate_task()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
|
| 80 |
game = WordGame()
|
|
|
|
| 62 |
def generate_task(self):
|
| 63 |
self.attempts = 3
|
| 64 |
self.target_word = random.choice(words)
|
| 65 |
+
print(f"New target word: {self.target_word}")
|
| 66 |
|
| 67 |
def check_input_for_word(self, string):
|
| 68 |
if self.target_word in string:
|
| 69 |
+
print(f"The player input the target word and the task was reset.")
|
| 70 |
self.generate_task()
|
| 71 |
else:
|
| 72 |
+
print(f"The player did not input the target word, so that's good.")
|
| 73 |
+
|
|
|
|
| 74 |
|
| 75 |
def check_output_for_word(self, string):
|
| 76 |
if self.target_word in string:
|
| 77 |
self.points += self.attempts
|
| 78 |
+
print(f"The player scored {self.attempts} points and has a total of {self.points}.")
|
| 79 |
self.generate_task()
|
| 80 |
+
else:
|
| 81 |
+
print("The response did not contain the word.")
|
| 82 |
+
self.attempts -= 1
|
| 83 |
+
print(f"Remaining attempts: {self.attempts}")
|
| 84 |
+
if self.attempts <= 0:
|
| 85 |
+
self.generate_task()
|
| 86 |
+
print(f"The player ran out of attempts.")
|
| 87 |
+
else:
|
| 88 |
+
print(f"The player has attempts left.")
|
| 89 |
|
| 90 |
|
| 91 |
game = WordGame()
|