This commit is contained in:
2024-09-10 11:08:36 +02:00
parent 8ee14b3984
commit d91c5137c7
9 changed files with 100 additions and 8 deletions

42
main.py
View File

@@ -20,21 +20,53 @@ def decode_state(game_state):
bit_string = ''.join([format(BASE64.index(s), '06b')[::-1] for s in game_state])
return [x != "1" for x in bit_string]
@app.route('/')
@app.route('/board')
def main_page():
game_encoding = flask.request.args.get("game_state")
if game_encoding == ".":
return flask.redirect("/")
if game_encoding is None:
game_encoding = "000000"
game_state = decode_state(game_encoding)
empty = 36-sum(game_state)
return flask.render_template("main_board.html", categories=QUESTIONS["categories"], game_state=game_encoding, draw_cells=game_state, empty=empty)
@app.route('/final')
def final_jeopardy():
question_text = QUESTIONS['final'][0]
if question_text == "":
return flask.redirect("/")
elif question_text == "$":
return flask.render_template("question picture.html", game_state=".")
return flask.render_template("question.html", question_text=question_text, game_state=".")
@app.route('/final_answer')
def final_answer():
answer_text = QUESTIONS["final"][1]
if answer_text == "":
return flask.redirect("/")
elif answer_text == "$":
return flask.render_template("answer picture.html", game_state=".")
return flask.render_template("answer.html", answer_text=answer_text, game_state=".")
@app.route('/')
def empty_page():
return flask.render_template("empty.html")
@app.route('/question')
def question():
game_encoding = flask.request.args.get("game_state")
question = flask.request.args.get("question")
if game_encoding is None or question is None:
return flask.redirect("/")
return flask.redirect("/board")
game_state = decode_state(game_encoding)
empty = 36-sum(game_state)
@@ -43,7 +75,7 @@ def question():
question_text = QUESTIONS["questions"][int(question)%6][int(question)//6][0]
if question_text == "":
return flask.redirect("/?game_state="+game_encoding)
return flask.redirect("/board?game_state="+game_encoding)
elif question_text == "$":
return flask.render_template("question picture.html", question=int(question), game_state=game_encoding, empty=empty)
@@ -57,12 +89,12 @@ def answer():
empty = 35-sum(game_state)
question = flask.request.args.get("question")
if game_encoding is None or question is None:
return flask.redirect("/")
return flask.redirect("/board")
answer_text = QUESTIONS["questions"][int(question)%6][int(question)//6][1]
if answer_text == "":
return flask.redirect("/?game_state="+game_encoding)
return flask.redirect("/board?game_state="+game_encoding)
elif answer_text == "$":
return flask.render_template("answer picture.html", question=int(question), game_state=game_encoding, empty=empty)

View File

@@ -21,7 +21,7 @@
["Elphaba's signature song in Wicked + The main source of thrust for Nomai spaceships","Defying Gravity cannon"],
["",""],
["NSYNC's lead single + What the Nomai constructed the ATP to find","Bye Bye Beye of the Universe"],
["",""],
["Bonnie Tyler's biggest hit + The citizens of the starting planet","Total Eclipse of the Hearthians"],
["The lead single of Sabrina Carpenter's 2024 album + The Nomai you meet at the quantum moon","Espressolanum"]
],
[
@@ -56,5 +56,9 @@
["",""],
["",""]
]
],
"final": [
"test",
"answer"
]
}

View File

@@ -79,6 +79,21 @@ th {
text-shadow: 5px 5px 1px black;
}
.title {
color: rgb(255, 204, 0);
font-family: "Korinna";
text-align: center;
font-size: 150;
bottom: auto;
height: 100%;
width: 80%;
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
text-shadow: 5px 5px 1px black;
}
.question img {
height: 70%;
}

View File

@@ -4,12 +4,18 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<a class="question" href="/?game_state={{ game_state }}">
{% if game_state != "." %}
<a class="question" href="/board?game_state={{ game_state }}">
<img src="/static/images/{{question}}.png">
</a>
<div class="money">
${{(question//6+1)*((1+empty)*7-2)}}
<!--${{ (question//6+1) ** 4 + 2*((question//6+1) ** 3) + 7*((question//6+1)**2) + (question//6+1) * 33 + (((question%6)+2)%3)**2 + (question%6) * 87 - ((question%6)+3)**2 - ((question%6)+2)**3 + (question//6+1)*(((question%6) + 2)%3) + 24 }}-->
</div>
{% else %}
<a class="question" href="/">
<img src="/static/images/final.png">
</a>
{% endif %}
</body>
</html>

View File

@@ -4,12 +4,18 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<a class="question" href="/?game_state={{ game_state }}">
{% if game_state != "." %}
<a class="question" href="/board?game_state={{ game_state }}">
{{answer_text}}
</a>
<div class="money">
${{(question//6+1)*((1+empty)*7-2)}}
<!--${{ (question//6+1) ** 4 + 2*((question//6+1) ** 3) + 7*((question//6+1)**2) + (question//6+1) * 33 + (((question%6)+2)%3)**2 + (question%6) * 87 - ((question%6)+3)**2 - ((question%6)+2)**3 + (question//6+1)*(((question%6) + 2)%3) + 24 }}-->
</div>
{% else %}
<a class="question" href="/">
{{answer_text}}
</a>
{% endif %}
</body>
</html>

11
templates/empty.html Normal file
View File

@@ -0,0 +1,11 @@
<html>
<head>
<title>Jeopardy</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<a class="title" href="/board">
Jeopardy
</a>
</body>
</html>

View File

@@ -4,6 +4,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
{% if empty < 36 %}
<table>
<tr>
{% for cat in categories: %}
@@ -22,5 +23,10 @@
</tr>
{% endfor %}
</table>
{% else %}
<a class="title" href="/final">
Final Jeopardy
</a>
{% endif %}
</body>
</html>

View File

@@ -4,6 +4,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
{% if game_state != "." %}
<a class="question" href="/answer?question={{ question }}&game_state={{ game_state }}">
<img src="/static/images/{{question}}.png">
</a>
@@ -11,5 +12,10 @@
${{(question//6+1)*((1+empty)*7-2)}}
<!--${{ (question//6+1) ** 4 + 2*((question//6+1) ** 3) + 7*((question//6+1)**2) + (question//6+1) * 33 + (((question%6)+2)%3)**2 + (question%6) * 87 - ((question%6)+3)**2 - ((question%6)+2)**3 + (question//6+1)*(((question%6) + 2)%3) + 24 }}-->
</div>
{% else %}
<a class="question" href="/final_answer">
<img src="/static/images/final.png">
</a>
{% endif %}
</body>
</html>

View File

@@ -4,6 +4,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
{% if game_state != "." %}
<a class="question" href="/answer?question={{ question }}&game_state={{ game_state }}">
{{question_text}}
</a>
@@ -11,5 +12,10 @@
${{(question//6+1)*((1+empty)*7-2)}}
<!--${{ (question//6+1) ** 4 + 2*((question//6+1) ** 3) + 7*((question//6+1)**2) + (question//6+1) * 33 + (((question%6)+2)%3)**2 + (question%6) * 87 - ((question%6)+3)**2 - ((question%6)+2)**3 + (question//6+1)*(((question%6) + 2)%3) + 24 }}-->
</div>
{% else %}
<a class="question" href="/final_answer">
{{question_text}}
</a>
{% endif %}
</body>
</html>