From 5ffdc0bbb2611a9cf0a2695ca42447a5427de5e2 Mon Sep 17 00:00:00 2001 From: LockeShor <75901583+LockeShor@users.noreply.github.com> Date: Sat, 19 Sep 2026 19:36:30 -0400 Subject: [PATCH] working demo --- page copy.html | 32 +++++++++++ page.html | 41 ++++++++++++++ server.py | 37 ++++++++++++ story copy.json | 46 +++++++++++++++ story.json | 148 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 304 insertions(+) create mode 100644 page copy.html create mode 100644 page.html create mode 100644 server.py create mode 100644 story copy.json create mode 100644 story.json diff --git a/page copy.html b/page copy.html new file mode 100644 index 0000000..0091ae7 --- /dev/null +++ b/page copy.html @@ -0,0 +1,32 @@ +
+ + +test
+ + + \ No newline at end of file diff --git a/page.html b/page.html new file mode 100644 index 0000000..008201b --- /dev/null +++ b/page.html @@ -0,0 +1,41 @@ + + + +test
+ + + \ No newline at end of file diff --git a/server.py b/server.py new file mode 100644 index 0000000..4d2fc3a --- /dev/null +++ b/server.py @@ -0,0 +1,37 @@ +import json +from flask import Flask, request, render_template + +app = Flask(__name__) + + +@app.route("/") +def game(): + gamecode = request.args.get('code')[:-1] + + #return open("page copy.html", "r").read() + #print(buildHTML(gamecode)) + + return buildHTML(gamecode) + + +def buildHTML(gamecode): + with open("story.json", "r") as f: + print("\n\n") + story = json.loads(f.read()) + nodeName = "start" + for action in gamecode: + nodeName = story[nodeName]["choices"][int(action) - 1]["next"] + print(action, nodeName) + info = story[nodeName] + currText = info["text"] + choices = "" + for i in range(len(info["choices"])): + choice = info["choices"][i] + choices += f"{(i + 1) * 10}: " + choice["text"] + "\\n" + print(str(request.user_agent) + "\n",currText,choices) + + with open('page.html', "r") as page: + return page.read().replace("{{CurrText}}", currText.replace('"', '\\"')).replace("{{Choices}}", choices.replace('"', '\\"')) + +if __name__ == '__main__': + app.run(debug=True, port=1387) diff --git a/story copy.json b/story copy.json new file mode 100644 index 0000000..2605ad1 --- /dev/null +++ b/story copy.json @@ -0,0 +1,46 @@ +{ + "start": { + "text": "You stare at the computer screen, wondering what it could mean. The words on the screen confuse you: \"aubrey is coming.\" A link below reads: \"hide\", or you can choose to decline.", + "choices": [ + { + "text": "Click the link", + "next": "click_link" + }, + { + "text": "Click \"decline\"", + "next": "death" + } + ] + }, + "click_link": { + "text": "SHES HERE! RUN", + "choices": [ + { + "text": "RUN", + "next": "escape" + }, + { + "text": "eh ill just wait here", + "next": "death" + } + ] + }, + "escape": { + "text": "You did it! you survived aubrey!!", + "choices": [ + { + "text": "return to start", + "next": "start" + } + ] + }, + "death": { + "text": "Aubrey got you. its over.", + "choices": [ + { + "text": "return to start", + "next": "start" + } + ] + } +} \ No newline at end of file diff --git a/story.json b/story.json new file mode 100644 index 0000000..b2611ff --- /dev/null +++ b/story.json @@ -0,0 +1,148 @@ +{ + "start": { + "text": "Willow wants water. She screams at the top of her lungs. What do you do?", + "choices": [ + { + "text": "Carefully open the room door and try to slip in.", + "next": "try_slip_door" + }, + { + "text": "Forget Willow is in there and open the door normally.", + "next": "forget_and_open" + } + ] + }, + "try_slip_door": { + "text": "Willow pokes her little head out, and tries to squeeze past your feet.", + "choices": [ + { + "text": "Punt her into the room.", + "next": "punt_willow" + }, + { + "text": "Gently grab her as you open the door.", + "next": "gentle_willow" + } + ] + } + , + "forget_and_open": { + "text": "Willow speeds past you and runs down the hallway at mach speed. She flies past you like a little racecar!", + "choices": [ + { + "text": "Shout \"WILLOW! GET BACK HERE\" and run after her.", + "next": "scream_after_her" + }, + { + "text": "Give up and walk into the room to grab her water bottle.", + "next": "get_water_bottle" + } + ] + }, + "punt_willow": { + "text": "She begins to visciously attack your toes. She rules this room, shes gonna force you to get water one way or another.", + "choices": [ + { + "text": "All hail willow and grab her bottle.", + "next": "hail_willow" + }, + { + "text": "This cat is crazy - run out of the room and slam the door shut, leaving her there", + "next": "leave_willow_crazy" + } + ] + }, + "gentle_willow": { + "text": "She snuggles into your arms and happily has paw-paw time.", + "choices": [ + { + "text": "Get her water bottle.", + "next": "get_water_bottle" + }, + { + "text": "Get her water bottle.", + "next": "get_water_bottle_fail" + } + ] + }, + "scream_after_her": { + "text": "You sprint down the hall, are able to capture her, setting her back in her laundry basket.", + "choices": [ + { + "text": "grab her water bottle and go to the kitchen", + "next": "get_water_bottle" + } + ] + }, + "hail_willow": { + "text": "Yes. Willow is the diva of the room. There's only one clear option now.", + "choices": [ + { + "text": "Get her water bottle.", + "next": "get_water_bottle" + } + ] + }, + "leave_willow_crazy": { + "text": "Silly silly player - never neglect a cats needs. Especially willow.", + "choices": [ + { + "text": "Try again.", + "next": "start" + } + ] + }, + "get_water_bottle_fail": { + "text": "Silly you, you grabbed the wrong water bottle. She only likes the other one!", + "choices": [ + { + "text": "Get the right water bottle.", + "next": "get_water_bottle" + }, + { + "text": "Ignore her water bottle preference.", + "next": "ignore_preference" + } + ] + }, + "ignore_preference": { + "text": "Silly silly player - Willow bites you and you die.", + "choices": [ + { + "text": "Try again. You are kitty butt.", + "next": "start" + } + ] + }, + "get_water_bottle": { + "text": "You get willow's water bottle, and move to the kitchen sink to put water in.", + "choices": [ + { + "text": "Fill with cold water.", + "next": "cold_water" + }, + { + "text": "Fill with hot water.", + "next": "hot_water" + } + ] + }, + "cold_water": { + "text": "Yay! You pour it into Willow's water dish and she drinks it happily. The end! you win!", + "choices": [ + { + "text": "Play again?", + "next": "start" + } + ] + }, + "hot_water": { + "text": "Silly silly player - why would Willow want hot water?", + "choices": [ + { + "text": "Try again.", + "next": "get_water_bottle" + } + ] + } +} \ No newline at end of file