1
0
Fork 0

add basis for hint giving

This commit is contained in:
Lili (Tlapka) 2021-03-23 17:40:33 +01:00
parent 17a94bdf8c
commit 542860fede
2 changed files with 16 additions and 2 deletions

View File

@ -25,6 +25,8 @@ class HintGiver:
return self.hints[level][level+branch][hint_name] return self.hints[level][level+branch][hint_name]
def show_taken_hints(self, level, branch): def show_taken_hints(self, level, branch):
if not level+branch in self.hints_taken:
return []
return self.hints_taken[level+branch] return self.hints_taken[level+branch]
def is_hint_name(self, level, branch, hint_name): def is_hint_name(self, level, branch, hint_name):

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from adaptive_game_module.adaptive_game import Game from adaptive_game_module.adaptive_game import Game
from adaptive_game_module.hint_giver import HintGiver
import subprocess import subprocess
import os import os
@ -114,7 +115,7 @@ def game_loop():
print("Error number: {}, Error text: {}".format(err.errno, err.strerror)) print("Error number: {}, Error text: {}".format(err.errno, err.strerror))
print("(Most likely, `levels.yml` file couldn't be read.") print("(Most likely, `levels.yml` file couldn't be read.")
print("Make sure it is in the folder, and readable.") print("Make sure it is in the folder, and readable.")
hint_giver = HintGiver("resources/hints.yml")
print("Welcome to the adaptive game assistant.") print("Welcome to the adaptive game assistant.")
print("Basic commands are:") print("Basic commands are:")
print("(S)tart, (N)ext, (H)elp, (C)heck, (E)xit") print("(S)tart, (N)ext, (H)elp, (C)heck, (E)xit")
@ -176,7 +177,7 @@ def game_loop():
else: else:
print("Could not finish game.") print("Could not finish game.")
print("Make sure you are on the last level!") print("Make sure you are on the last level!")
elif command in ("i", "info"): elif command in ("i", "info", "information"):
game.print_info() game.print_info()
elif command in ("h", "help"): elif command in ("h", "help"):
print_help() print_help()
@ -196,6 +197,17 @@ def game_loop():
else: else:
print("Writing file...") print("Writing file...")
game.log_to_file("logs/game_log.yml") game.log_to_file("logs/game_log.yml")
elif command in ("t", "hint"):
if hint_giver.show_taken_hints("level" + str(game.level), game.branch) != []:
print("Hints taken in current level:")
for hint in hint_giver.show_taken_hints("level" + str(game.level), game.branch):
print("{}: {}".format(hint, hint_giver.take_hint(level, branch, hint)))
print("Choose which hint to take:")
print("0: (cancel, take no hint)")
i = 1
for hint in hint_giver.show_possible_hints("level" + str(game.level), game.branch):
print("{}: {}".format(i, hint))
i += 1
else: else:
print("Unknown command. Enter another command or try (H)elp.") print("Unknown command. Enter another command or try (H)elp.")