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)