Refactor code for fancy printing, make instructions clearer

This commit is contained in:
Chris Proctor
2023-07-11 15:41:03 -04:00
parent c6f9f5cc41
commit 4e2abe1775
9 changed files with 165 additions and 121 deletions

View File

@@ -1,17 +1,21 @@
# This is a Python file. You can run it by typing "python ghost.py"
import sys
from pathlib import Path
sys.path.append('../../../..')
from fancy_printing import print_fancy
GHOST_GIVES_KEY = [
"You enter the cramped galley and notice a sad, lonely ghost wandering around. You always wondered if you would be afraid of ghosts, but somehow this feels completely normal. The ghost begins to speak.",
"'It has been a long while since I have seen anybody down here,' she says. 'I would like to give you a gift. Here's a key.'"
]
GHOST_IS_BORED = [
"The ghost glances over at you. 'I hope you find some use for that key.'"
]
KEY = " Even in the faint light of your lamp, the key has a golden gleam.\n\n"
if Path("key.txt").exists():
print(" The ghost glances over at you. 'I hope you find some use for that key.'")
print_fancy(GHOST_IS_BORED)
else:
print(" You enter the cramped galley and notice a sad, lonely ghost wandering")
print(" around. You always wondered if you would be afraid of ghosts, but")
print(" somehow this feels completely normal. The ghost begins to speak.")
print("")
print(" 'It has been a long while since I have seen anybody down here,' she says")
print(" 'I would like to give you a gift. Here's a key.'")
with open("key.txt", "w") as keyfile:
keyfile.write(" Even in the faint light of your lamp, the key has a golden gleam.\n")
print_fancy(GHOST_GIVES_KEY)
Path("key.txt").write_text(KEY)