commit 68152c1b677f526966d998886b866034920a73d1 Author: NikolajDanger Date: Tue Aug 1 18:59:55 2023 +0200 :sparkles: diff --git a/main.py b/main.py new file mode 100644 index 0000000..9d5bb22 --- /dev/null +++ b/main.py @@ -0,0 +1,72 @@ +import flask +import string +import json + +BASE64 = string.digits + string.ascii_letters + "-_" + +app = flask.Flask(__name__) + +with open("questions.json", "r", encoding="utf-8") as file_pointer: + QUESTIONS = json.load(file_pointer) + +def encode_state(game_encoding): + characters = [game_encoding[i*6:i*6+6] for i in range(0,6)] + return ''.join( + [BASE64[sum([2**j for j in range(6) if not i[j]])] for i in characters] + ) + + +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('/') +def main_page(): + game_encoding = flask.request.args.get("game_state") + if game_encoding is None: + game_encoding = "000000" + game_state = decode_state(game_encoding) + return flask.render_template("main_board.html", categories=QUESTIONS["categories"], game_state=game_encoding, draw_cells=game_state) + +@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("/") + + game_state = decode_state(game_encoding) + game_state[int(question)] = False + game_encoding = encode_state(game_state) + question_text = QUESTIONS["questions"][int(question)%6][int(question)//6][0] + + if question_text == "": + return flask.redirect("/?game_state="+game_encoding) + elif question_text == "$": + return flask.render_template("question picture.html", question=int(question), game_state=game_encoding) + + + return flask.render_template("question.html", question=int(question), question_text=question_text, game_state=game_encoding) + +@app.route('/answer') +def answer(): + 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("/") + + answer_text = QUESTIONS["questions"][int(question)%6][int(question)//6][1] + + if answer_text == "": + return flask.redirect("/?game_state="+game_encoding) + elif answer_text == "$": + return flask.render_template("answer picture.html", question=int(question), game_state=game_encoding) + + return flask.render_template("answer.html", question=int(question), answer_text=answer_text, game_state=game_encoding) + +@app.route('/static/') +def flag_image(path): + return flask.send_from_directory("static", path) + +if __name__ == "__main__": + app.run(host='0.0.0.0', port=8001) \ No newline at end of file diff --git a/questions.json b/questions.json new file mode 100644 index 0000000..b5735d5 --- /dev/null +++ b/questions.json @@ -0,0 +1,60 @@ +{ + "categories" : [ + "TRUE OR FALSE", + "WHICH GENDERED TERM DOES NIKOLAJ PREFER?", + "KINGDOM HEARTS DEEP CUTS", + "(BAD) RIDDLES", + "CELEBRITY FACEMASH", + "SIMS 4 OR CRUSADER KINGS" + ], + "questions" : [ + [ + ["True or false: The G-spot was named after a dude named Gregory","False. His name was Ernst"], + ["True or false: Bananas grow upside down","False. They grow the way they grow. Humans eat them upside down"], + ["True or false: I just wrote the song of the summer","False. That was terrible"], + ["True or false: An adult gorilla can drink up to 50 liters of water in a single day","IDK, maybe? I didn't look it up"], + ["True or false: Australia is wider than the moon","False. The moon doesn't exist"], + ["True or false: This is a good game and we're having fun","True"] + ], + [ + ["What is Nikolaj's relation to Pepsi?","Mother"], + ["What is Nikolaj's relation to their brother?","Brother"], + ["Which Barbie-world character best encapsulates Nikolaj?","Allan"], + ["What would be Nikolaj's role at their wedding?","The opposite of whatever their partner is"], + ["What should Nikolaj's nieces and nephews call them?","Arch bishop"], + ["What would Nikolaj's title be if they were the head of an empire?","Supreme Overlord/Sexy Genius"] + ], + [ + ["What is the name of the world Sora, Riku and Kairi are from?","Destiny Islands"], + ["What is the name of the legendary Keyblade sought by Xehanort?", "The χ-blade"], + ["Why was King Mickey shirtless at the end of Kingdom Hearts?","A swarm of Heartless ripped his shirt off immediately before"], + ["What is the name of the χ symbol present in the names of Organisation XIII?","The Recusant's Sigil"], + ["How many Xehanorts are in the Real Organisation XIII?","Like, 4.5-ish?"], + ["What's the worst name of a Kingdom Hearts game?","Kingdom Hearts 0.2: Birth by Sleep - A Fragmentary Passage"] + ], + [ + ["What do you break before you use it?","Glowstick"], + ["What has an eye but cannot see?","A blind cyclops"], + ["A cowboy rode into town on the 14th. He stayed for 18 days and rode out on the 14th. How is that possible?","It was in Russia, 14/01/1918-14/02/1918"], + ["What can be clear, green or blue, has a mouth but cannot speak, and can run but has no feet?","Ghosts"], + ["A father and his son get in a car accident. The father dies instantly, but the son is rushed to the hospital. The doctor looks at the son and says \"I can't operate on this man, he's my son\". How's that possible?","Time travel"], + ["Prove the validity of the following statement:\n∀x(P(x) ↔ x = b) ⊢ P(b) ∧ ∀x∀y(P(x)∧P(y) → x=y)","$"] + ], + [ + ["$","Margot Robbie and Ariana Grande"], + ["$","Tom Hiddleston and Jim Parsons"], + ["$","Keira Knightley and Cara Delevigne"], + ["$","Robert Pattinson and Dwayne Johnson"], + ["$","Taylor Swift and Anna Kendrick"], + ["$","Tom Hanks and Daniel Craig"] + ], + [ + ["\"My game glitched and now my in game daughter has a beard 😭\"","$"], + ["\"Is there a mod that would let me seduce my daughter?\"","$"], + ["\"My husband got pregnant and just gave birth\"","$"], + ["\"can i lock infants in prisons?\"","$"], + ["\"Why is my son ugly when both my wife and I are beautiful?\"","$"], + ["\"Is there a way to kill toddlers and children?\"","$"] + ] + ] +} \ No newline at end of file diff --git a/static/images/10.png b/static/images/10.png new file mode 100644 index 0000000..acf5027 Binary files /dev/null and b/static/images/10.png differ diff --git a/static/images/11.png b/static/images/11.png new file mode 100644 index 0000000..6092901 Binary files /dev/null and b/static/images/11.png differ diff --git a/static/images/16.png b/static/images/16.png new file mode 100644 index 0000000..b92cc11 Binary files /dev/null and b/static/images/16.png differ diff --git a/static/images/17.png b/static/images/17.png new file mode 100644 index 0000000..9ff37dc Binary files /dev/null and b/static/images/17.png differ diff --git a/static/images/22.png b/static/images/22.png new file mode 100644 index 0000000..c972f0f Binary files /dev/null and b/static/images/22.png differ diff --git a/static/images/23.png b/static/images/23.png new file mode 100644 index 0000000..c31f46f Binary files /dev/null and b/static/images/23.png differ diff --git a/static/images/28.png b/static/images/28.png new file mode 100644 index 0000000..e389ad7 Binary files /dev/null and b/static/images/28.png differ diff --git a/static/images/29.png b/static/images/29.png new file mode 100644 index 0000000..4b79bf5 Binary files /dev/null and b/static/images/29.png differ diff --git a/static/images/33.png b/static/images/33.png new file mode 100644 index 0000000..3d30ce5 Binary files /dev/null and b/static/images/33.png differ diff --git a/static/images/34.png b/static/images/34.png new file mode 100644 index 0000000..02fd2cd Binary files /dev/null and b/static/images/34.png differ diff --git a/static/images/35.png b/static/images/35.png new file mode 100644 index 0000000..2176b8b Binary files /dev/null and b/static/images/35.png differ diff --git a/static/images/4.png b/static/images/4.png new file mode 100644 index 0000000..8a484c1 Binary files /dev/null and b/static/images/4.png differ diff --git a/static/images/5.png b/static/images/5.png new file mode 100644 index 0000000..007d142 Binary files /dev/null and b/static/images/5.png differ diff --git a/static/korinna.otf b/static/korinna.otf new file mode 100644 index 0000000..c6f8291 Binary files /dev/null and b/static/korinna.otf differ diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..00cc5b4 --- /dev/null +++ b/static/style.css @@ -0,0 +1,80 @@ +@font-face { + font-family: "Swiss 921"; + src: url(/static/swiss\ 921.ttf) format("truetype"); +} + +@font-face { + font-family: "Korinna"; + src: url(/static/korinna.otf) format("truetype"); +} + +body { + background-color: #2903c3; + display: flex; + justify-content: center; + align-items: center; + height: 95%; +} + +table { + margin-top: 2%; + margin-bottom: auto; + margin-left: auto; + margin-right: auto; + height: auto; + border: 18px solid black; + border-collapse: collapse; + font-family: "Swiss 921"; +} + +td { + border: 10px solid black; + border-collapse: collapse; + width: 250px; + height: 135px; + text-align: center; + text-shadow: 6px 6px 0px black; +} + +td a { + color: rgb(255, 204, 0); + text-decoration: none; + font-size: 70px; +} + +.money { + position: absolute; + top: 10px; + left: 10px; + color: rgb(255, 204, 0); + text-decoration: none; + font-size: 70px; + font-family: "Swiss 921"; + text-shadow: 6px 6px 0px black; +} + +th { + border: 15px solid black; + border-collapse: collapse; + width: 250px; + height: 150px; + color: white; + font-size: 25px; + padding: 10px; + text-shadow: 3px 3px 1px black; +} + +.question { + color: white; + font-family: "Korinna"; + text-align: center; + font-size: 100; + bottom: auto; + height: 100%; + width: 80%; + display: flex; + justify-content: center; + align-items: center; + text-decoration: none; + text-shadow: 5px 5px 1px black; +} diff --git a/static/swiss 921.ttf b/static/swiss 921.ttf new file mode 100644 index 0000000..7a57110 Binary files /dev/null and b/static/swiss 921.ttf differ diff --git a/templates/answer picture.html b/templates/answer picture.html new file mode 100644 index 0000000..26c11ea --- /dev/null +++ b/templates/answer picture.html @@ -0,0 +1,14 @@ + + + Jeopardy + + + + + + +
+ ${{ (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 }} +
+ + \ No newline at end of file diff --git a/templates/answer.html b/templates/answer.html new file mode 100644 index 0000000..e32e933 --- /dev/null +++ b/templates/answer.html @@ -0,0 +1,14 @@ + + + Jeopardy + + + + + {{answer_text}} + +
+ ${{ (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 }} +
+ + \ No newline at end of file diff --git a/templates/main_board.html b/templates/main_board.html new file mode 100644 index 0000000..fc60ff1 --- /dev/null +++ b/templates/main_board.html @@ -0,0 +1,26 @@ + + + Jeopardy + + + + + + {% for cat in categories: %} + + {% endfor %} + + {% for i in range(1,7) %} + + {% for j in range(0,6): %} + + {% endfor %} + + {% endfor %} +
{{ cat }}
+ {% if draw_cells[(i-1)*6+j] %} + ${{ i ** 4 + 2*(i ** 3) + 7*(i**2) + i * 33 + ((j+2)%3)**2 + j * 87 - (j+3)**2 - (j+2)**3 + i*((j + 2)%3) + 24 }} + {% endif %} +
+ + \ No newline at end of file diff --git a/templates/question picture.html b/templates/question picture.html new file mode 100644 index 0000000..66d55f2 --- /dev/null +++ b/templates/question picture.html @@ -0,0 +1,14 @@ + + + Jeopardy + + + + + + +
+ ${{ (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 }} +
+ + \ No newline at end of file diff --git a/templates/question.html b/templates/question.html new file mode 100644 index 0000000..9580b1d --- /dev/null +++ b/templates/question.html @@ -0,0 +1,14 @@ + + + Jeopardy + + + + + {{question_text}} + +
+ ${{ (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 }} +
+ + \ No newline at end of file