This commit is contained in:
2023-08-01 18:59:55 +02:00
commit 68152c1b67
23 changed files with 294 additions and 0 deletions

72
main.py Normal file
View File

@@ -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/<path:path>')
def flag_image(path):
return flask.send_from_directory("static", path)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8001)

60
questions.json Normal file
View File

@@ -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?\"","$"]
]
]
}

BIN
static/images/10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

BIN
static/images/11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

BIN
static/images/16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 KiB

BIN
static/images/17.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 KiB

BIN
static/images/22.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 KiB

BIN
static/images/23.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

BIN
static/images/28.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 KiB

BIN
static/images/29.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

BIN
static/images/33.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

BIN
static/images/34.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 KiB

BIN
static/images/35.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

BIN
static/images/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

BIN
static/images/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 KiB

BIN
static/korinna.otf Normal file

Binary file not shown.

80
static/style.css Normal file
View File

@@ -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;
}

BIN
static/swiss 921.ttf Normal file

Binary file not shown.

View File

@@ -0,0 +1,14 @@
<html>
<head>
<title>Jeopardy</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<a class="question" href="/?game_state={{ game_state }}">
<img src="/static/images/{{question}}.png">
</a>
<div class="money">
${{ (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>
</body>
</html>

14
templates/answer.html Normal file
View File

@@ -0,0 +1,14 @@
<html>
<head>
<title>Jeopardy</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<a class="question" href="/?game_state={{ game_state }}">
{{answer_text}}
</a>
<div class="money">
${{ (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>
</body>
</html>

26
templates/main_board.html Normal file
View File

@@ -0,0 +1,26 @@
<html>
<head>
<title>Jeopardy</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<table>
<tr>
{% for cat in categories: %}
<th>{{ cat }}</th>
{% endfor %}
</tr>
{% for i in range(1,7) %}
<tr>
{% for j in range(0,6): %}
<td>
{% if draw_cells[(i-1)*6+j] %}
<a href="/question?question={{ (i-1) * 6 + j }}&game_state={{ game_state }}">${{ 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 }}</a>
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<html>
<head>
<title>Jeopardy</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<a class="question" href="/answer?question={{ question }}&game_state={{ game_state }}">
<img src="/static/images/{{question}}.png">
</a>
<div class="money">
${{ (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>
</body>
</html>

14
templates/question.html Normal file
View File

@@ -0,0 +1,14 @@
<html>
<head>
<title>Jeopardy</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<a class="question" href="/answer?question={{ question }}&game_state={{ game_state }}">
{{question_text}}
</a>
<div class="money">
${{ (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>
</body>
</html>