added sea monster chase

This commit is contained in:
Jacob Wolf 2019-08-19 18:49:29 +08:00
parent e21c628596
commit d77fd9de40
4 changed files with 92 additions and 3 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
bag
treasure.png
key.txt
key.txt

View File

@ -0,0 +1 @@
2019-08-19 18:48:22.004554

View File

@ -1,6 +1,29 @@
# This is a Python program. You should run it by typing "chest.py"
from urllib.request import urlretrieve
import threading
import datetime
def treasure():
print(" something shining brightly from within, so bright you can't")
print(" quite make out what it is.\n")
def monster1():
print(" *rumble* *rumble* *rumble* \n")
print(" You look around the reef, but nothing seems out of place.\n")
def monster2():
print(" *rumble* *rumble* *rumble* \n")
print(" A SEA MONSTER APPEARS FROM THE REEF! \n")
print(" Without looking you grab the treasure from the chest.")
print(" Quick, use mkdir to make a \"bag\" directory and mv to")
print(" hide the treasure in the bag. ")
print(" Then get back to the surface ASAP! The moster is coming! \n")
print(" Don't forget to take your treasure bag with you!")
now = datetime.datetime.now()
with open(".timer", "w") as keyfile:
keyfile.write(str(now))
secret = "318"
@ -10,8 +33,14 @@ print(" In fact, the code dials turn smoothly. Try entering a code.")
guess = input(" > ")
if guess == secret:
print(" The chest snaps open, releasing several huge air bubbles.")
print(" You look into the chest and see...")
print(" The chest snaps open, releasing several huge air bubbles.")
print(" You look into the chest and see...\n")
urlretrieve("http://chrisproctor.net/images/fork.png", "treasure.png")
timer1 = threading.Timer(1.0, treasure)
timer2 = threading.Timer(3.0, monster1)
timer3 = threading.Timer(5.0, monster2)
timer1.start()
timer2.start()
timer3.start()
else:
print(" nothing happens. Maybe next time.")

59
end.py Normal file
View File

@ -0,0 +1,59 @@
from pathlib import Path
from datetime import datetime
from datetime import timedelta
import subprocess
def reset():
with open("./bag/treasure.png", "w") as keyfile:
keyfile.write("lost")
print(" You are swimming as fast as you can towards the boat but you can")
print(" feel the water begin to pull you back as the sea monster opens its")
print(" giant mouth.")
print(" You kick with all your might, sure that you are about to breath your")
print(" last breath.")
print(" ")
print(" ")
print(" Suddenly... The treasure bag slips out of your hand!")
print(" It swirls down through the water and into the mouth of the sea monster.")
print(" The beast's mouth snaps closed and it jets away into the depth of the")
print(" ocean, taking with it the treasure.")
print(" You are safe... but will you attempt the dive again?")
def win():
print(" You are swimming as fast as you can towards the boat but you can")
print(" feel the water begin to pull you back as the sea monster opens its")
print(" giant mouth.")
print(" You kick with all your might, sure that you are about to breath your")
print(" last breath.")
print(" ")
print(" ")
print(" Suddenly... A hand appears!")
print(" You made it to the boat and the crew pulls you into the boat, just in")
print(" time to avoid the sea monster's vicious maw.")
print(" You're safe at last!")
print(" Now you can finally show off the treasure you risked your life for...")
now = datetime.now()
if not Path("adventure/seafloor/coral_reef/.timer").exists():
print(" It seems you are not yet ready to end your adventure. More secrets")
print(" await you in the ocean's depths.")
else:
if not Path("./bag/treasure.png").exists():
print(" You forgot your treasure bag! Hurry back to get it before the sea monster")
print(" hides it away forever!")
else:
with open ("adventure/seafloor/coral_reef/.timer", "r") as timerFile:
timeChestOpenedAsList=timerFile.readlines()
timeChestOpened = datetime.strptime(('').join(timeChestOpenedAsList), '%Y-%m-%d %H:%M:%S.%f')
if timeChestOpened + timedelta(seconds=60) < now:
reset()
else:
win()