working demo

This commit is contained in:
LockeShor
2026-09-19 19:36:30 -04:00
parent 3fcf542a7a
commit 5ffdc0bbb2
5 changed files with 304 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Choose Your Own Adventure</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="2685.7">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
</style>
<script id="discord:component-embed" type="application/json">
{
"component": {
"type": 17,
"accent_color": 16711680,
"components": [
{
"type": 10,
"content": "{{CurrText}}\n{{Choices}}"
}
]
}
}
</script>
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary_large_image">
<meta name="theme-color" content="#5865f2">
</head>
<body>
<p class="p1">test</p>
</body></html>
+41
View File
@@ -0,0 +1,41 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Choose Your Own Adventure</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="2685.7">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
</style>
<script id="discord:component-embed" type="application/json">
{
"component": {
"type": 17,
"accent_color": 16711680,
"components": [
{
"type": 10,
"content": "{{CurrText}}\n{{Choices}}"
},
{
"type": 14,
"spacing": 1,
"divider": true
},
{
"type": 10,
"content": "type s/0/[choice] where [choice] is your selected option to choose your path!"
}
]
}
}
</script>
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary_large_image">
<meta name="theme-color" content="#5865f2">
</head>
<body>
<p class="p1">test</p>
</body></html>
+37
View File
@@ -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)
+46
View File
@@ -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"
}
]
}
}
+148
View File
@@ -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"
}
]
}
}