From d91c5137c74e5e57496660d0f767fa3180e6aa50 Mon Sep 17 00:00:00 2001 From: Nikolaj Gade Date: Tue, 10 Sep 2024 11:08:36 +0200 Subject: [PATCH] :sparkles: --- main.py | 42 +++++++++++++++++++++++++++++---- questions.json | 6 ++++- static/style.css | 15 ++++++++++++ templates/answer picture.html | 8 ++++++- templates/answer.html | 8 ++++++- templates/empty.html | 11 +++++++++ templates/main_board.html | 6 +++++ templates/question picture.html | 6 +++++ templates/question.html | 6 +++++ 9 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 templates/empty.html diff --git a/main.py b/main.py index ef18a58..e8216a4 100644 --- a/main.py +++ b/main.py @@ -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) diff --git a/questions.json b/questions.json index 79c2a97..f40f56d 100644 --- a/questions.json +++ b/questions.json @@ -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" ] } \ No newline at end of file diff --git a/static/style.css b/static/style.css index 83f590a..5180979 100644 --- a/static/style.css +++ b/static/style.css @@ -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%; } diff --git a/templates/answer picture.html b/templates/answer picture.html index d33380e..916a960 100644 --- a/templates/answer picture.html +++ b/templates/answer picture.html @@ -4,12 +4,18 @@ - + {% if game_state != "." %} +
${{(question//6+1)*((1+empty)*7-2)}}
+ {% else %} + + + + {% endif %} \ No newline at end of file diff --git a/templates/answer.html b/templates/answer.html index 0c24e60..cf48b0e 100644 --- a/templates/answer.html +++ b/templates/answer.html @@ -4,12 +4,18 @@ - + {% if game_state != "." %} + {{answer_text}}
${{(question//6+1)*((1+empty)*7-2)}}
+ {% else %} + + {{answer_text}} + + {% endif %} \ No newline at end of file diff --git a/templates/empty.html b/templates/empty.html new file mode 100644 index 0000000..56e9b92 --- /dev/null +++ b/templates/empty.html @@ -0,0 +1,11 @@ + + + Jeopardy + + + + + Jeopardy + + + \ No newline at end of file diff --git a/templates/main_board.html b/templates/main_board.html index 31b9fa0..8d17ec9 100644 --- a/templates/main_board.html +++ b/templates/main_board.html @@ -4,6 +4,7 @@ + {% if empty < 36 %} {% for cat in categories: %} @@ -22,5 +23,10 @@ {% endfor %}
+ {% else %} + + Final Jeopardy + + {% endif %} \ No newline at end of file diff --git a/templates/question picture.html b/templates/question picture.html index 21b90d9..dc42d7d 100644 --- a/templates/question picture.html +++ b/templates/question picture.html @@ -4,6 +4,7 @@ + {% if game_state != "." %} @@ -11,5 +12,10 @@ ${{(question//6+1)*((1+empty)*7-2)}} + {% else %} + + + + {% endif %} \ No newline at end of file diff --git a/templates/question.html b/templates/question.html index e3f4f90..34917e2 100644 --- a/templates/question.html +++ b/templates/question.html @@ -4,6 +4,7 @@ + {% if game_state != "." %} {{question_text}} @@ -11,5 +12,10 @@ ${{(question//6+1)*((1+empty)*7-2)}} + {% else %} + + {{question_text}} + + {% endif %} \ No newline at end of file