mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-14 14:22:16 +00:00
Give config more options
Display pretty name for versions and difficulties Add controls image into about
This commit is contained in:
parent
fd6384ef90
commit
7503f7e5cb
7 changed files with 50 additions and 48 deletions
|
@ -1,5 +1,4 @@
|
||||||
import uuid
|
import uuid
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
@ -29,9 +28,6 @@ def settings():
|
||||||
username = request.form.get("username", "").strip()
|
username = request.form.get("username", "").strip()
|
||||||
email = request.form.get("email", "").strip()
|
email = request.form.get("email", "").strip()
|
||||||
password = request.form.get("password", "").strip()
|
password = request.form.get("password", "").strip()
|
||||||
|
|
||||||
user_regex = re.compile(USER_REGEX)
|
|
||||||
email_regex = re.compile(USER_EMAIL_REGEX)
|
|
||||||
error = []
|
error = []
|
||||||
|
|
||||||
user = Users.query.filter_by(username=current_user.username).first()
|
user = Users.query.filter_by(username=current_user.username).first()
|
||||||
|
@ -78,12 +74,12 @@ def settings():
|
||||||
image.close()
|
image.close()
|
||||||
|
|
||||||
if username:
|
if username:
|
||||||
if user_regex.match(username):
|
if USER_REGEX.match(username):
|
||||||
user.username = username
|
user.username = username
|
||||||
else:
|
else:
|
||||||
error.append("Username is invalid!")
|
error.append("Username is invalid!")
|
||||||
if email:
|
if email:
|
||||||
if email_regex.match(email):
|
if USER_EMAIL_REGEX.match(email):
|
||||||
user.email = email
|
user.email = email
|
||||||
else:
|
else:
|
||||||
error.append("Email is invalid!")
|
error.append("Email is invalid!")
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import re
|
|
||||||
import shortuuid
|
import shortuuid
|
||||||
|
|
||||||
from flask import Blueprint, request, jsonify, send_from_directory
|
from flask import Blueprint, request, jsonify, send_from_directory
|
||||||
|
@ -9,6 +8,9 @@ from werkzeug.utils import secure_filename
|
||||||
from .models import Scores, Sessions, Users
|
from .models import Scores, Sessions, Users
|
||||||
from .extensions import db
|
from .extensions import db
|
||||||
from .config import (
|
from .config import (
|
||||||
|
GAME_VERSION,
|
||||||
|
GAME_VERSIONS,
|
||||||
|
GAME_DIFFICULTY,
|
||||||
GAME_DIFFICULTIES,
|
GAME_DIFFICULTIES,
|
||||||
MAX_SEARCH_RESULTS,
|
MAX_SEARCH_RESULTS,
|
||||||
USER_REGEX,
|
USER_REGEX,
|
||||||
|
@ -49,8 +51,8 @@ def tokens():
|
||||||
@blueprint.route("/post", methods=["POST"])
|
@blueprint.route("/post", methods=["POST"])
|
||||||
def post():
|
def post():
|
||||||
session_key = request.form.get("session", "").strip()
|
session_key = request.form.get("session", "").strip()
|
||||||
version = request.form.get("version", "alpha").strip()
|
version = request.form.get("version", GAME_VERSION).strip()
|
||||||
difficulty = request.form.get("difficulty", 0)
|
difficulty = request.form.get("difficulty", GAME_DIFFICULTY)
|
||||||
score = request.form.get("score", 0)
|
score = request.form.get("score", 0)
|
||||||
|
|
||||||
if not session_key:
|
if not session_key:
|
||||||
|
@ -66,6 +68,8 @@ def post():
|
||||||
|
|
||||||
if int(difficulty) not in GAME_DIFFICULTIES:
|
if int(difficulty) not in GAME_DIFFICULTIES:
|
||||||
return "Invalid difficulty!"
|
return "Invalid difficulty!"
|
||||||
|
if version not in GAME_VERSIONS:
|
||||||
|
return "Invalid version!"
|
||||||
# This is a fix for a bug in the game that we dunno how to actually fix
|
# This is a fix for a bug in the game that we dunno how to actually fix
|
||||||
# if score < 10:
|
# if score < 10:
|
||||||
# return "Score is impossible!"
|
# return "Score is impossible!"
|
||||||
|
@ -110,9 +114,8 @@ def login():
|
||||||
username = request.form.get("username", "").strip()
|
username = request.form.get("username", "").strip()
|
||||||
password = request.form.get("password", "").strip()
|
password = request.form.get("password", "").strip()
|
||||||
device = request.form.get("device", "Unknown").strip()
|
device = request.form.get("device", "Unknown").strip()
|
||||||
username_regex = re.compile(USER_REGEX)
|
|
||||||
|
|
||||||
if not username or not username_regex.match(username) or not password:
|
if not username or not USER_REGEX.match(username) or not password:
|
||||||
return "Username or Password is incorrect!", 400
|
return "Username or Password is incorrect!", 400
|
||||||
|
|
||||||
user = Users.query.filter_by(username=username).first()
|
user = Users.query.filter_by(username=username).first()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import re
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from flask import Blueprint, render_template, request, flash, redirect, url_for
|
from flask import Blueprint, render_template, request, flash, redirect, url_for
|
||||||
|
@ -24,12 +23,10 @@ def register():
|
||||||
username = request.form.get("username", None).strip()
|
username = request.form.get("username", None).strip()
|
||||||
password = request.form.get("password", None).strip()
|
password = request.form.get("password", None).strip()
|
||||||
confirm = request.form.get("confirm", None).strip()
|
confirm = request.form.get("confirm", None).strip()
|
||||||
|
|
||||||
username_regex = re.compile(USER_REGEX)
|
|
||||||
error = []
|
error = []
|
||||||
|
|
||||||
# Validate the form
|
# Validate the form
|
||||||
if not username or not username_regex.match(username):
|
if not username or not USER_REGEX.match(username):
|
||||||
error.append("Username is invalid! Must be alphanumeric, and can contain ._-")
|
error.append("Username is invalid! Must be alphanumeric, and can contain ._-")
|
||||||
if not password or len(password) < 8:
|
if not password or len(password) < 8:
|
||||||
error.append("Password is too short! Must be at least 8 characters long.")
|
error.append("Password is too short! Must be at least 8 characters long.")
|
||||||
|
@ -61,11 +58,10 @@ def login():
|
||||||
# Get the form data
|
# Get the form data
|
||||||
username = request.form.get("username", None).strip()
|
username = request.form.get("username", None).strip()
|
||||||
password = request.form.get("password", None).strip()
|
password = request.form.get("password", None).strip()
|
||||||
username_regex = re.compile(USER_REGEX)
|
|
||||||
error = []
|
error = []
|
||||||
|
|
||||||
# Validate the form
|
# Validate the form
|
||||||
if not username or not username_regex.match(username) or not password:
|
if not username or not USER_REGEX.match(username) or not password:
|
||||||
error.append("Username or Password is incorrect!")
|
error.append("Username or Password is incorrect!")
|
||||||
|
|
||||||
user = Users.query.filter_by(username=username).first()
|
user = Users.query.filter_by(username=username).first()
|
||||||
|
|
|
@ -1,35 +1,41 @@
|
||||||
from os import getenv
|
from os import getenv
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
SECRET_KEY = getenv("FLASK_KEY")
|
||||||
|
|
||||||
UPLOAD_DIR = "/data/uploads"
|
UPLOAD_DIR = "/data/uploads"
|
||||||
UPLOAD_EXTENSIONS = ["png", "jpg", "jpeg", "gif"]
|
UPLOAD_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp"]
|
||||||
UPLOAD_RESOLUTION = 512
|
UPLOAD_RESOLUTION = 512
|
||||||
UPLOAD_MAX_SIZE = 3 * 1024 * 1024 # 3MB
|
UPLOAD_MAX_SIZE = 3 * 1024 * 1024 # 3MB
|
||||||
|
|
||||||
GAME_VERSION = "alpha"
|
GAME_VERSION = "alpha"
|
||||||
GAME_VERSIONS = ["alpha"]
|
GAME_DIFFICULTY = 0
|
||||||
GAME_DIFFICULTIES = [0, 1, 2, 3, 4]
|
|
||||||
|
|
||||||
USER_REGEX = r"\b[A-Za-z0-9._-]+\b"
|
GAME_VERSIONS = {
|
||||||
USER_EMAIL_REGEX = r"[^@]+@[^@]+\.[^@]+"
|
"alpha": "Alpha",
|
||||||
|
"alpha-expo": "Alpha (Expo Build)",
|
||||||
|
}
|
||||||
|
GAME_DIFFICULTIES = {
|
||||||
|
0: "Easy - Level 1",
|
||||||
|
1: "Easy - Level 2",
|
||||||
|
2: "Easy - Level 3",
|
||||||
|
3: "Medium",
|
||||||
|
4: "Hard",
|
||||||
|
}
|
||||||
|
|
||||||
|
USER_REGEX = re.compile(r"\b[A-Za-z0-9._-]+\b")
|
||||||
|
USER_EMAIL_REGEX = re.compile(r"[^@]+@[^@]+\.[^@]+")
|
||||||
|
|
||||||
MAX_TOP_SCORES = 15
|
MAX_TOP_SCORES = 15
|
||||||
MAX_SEARCH_RESULTS = 5
|
MAX_SEARCH_RESULTS = 5
|
||||||
|
|
||||||
# Postgres
|
|
||||||
SECRET_KEY = getenv("FLASK_KEY")
|
|
||||||
|
|
||||||
user = getenv("DB_USER")
|
user = getenv("DB_USER")
|
||||||
password = getenv("DB_PASSWORD")
|
password = getenv("DB_PASSWORD")
|
||||||
host = getenv("DB_HOST")
|
host = getenv("DB_HOST")
|
||||||
db = getenv("DB_NAME")
|
db = getenv("DB_NAME")
|
||||||
|
port = 5432
|
||||||
|
|
||||||
SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{user}:{password}@{host}:5432/{db}"
|
SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{db}"
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
SQLALCHEMY_POOL_RECYCLE = 621
|
SQLALCHEMY_POOL_RECYCLE = 621
|
||||||
|
|
||||||
"""
|
|
||||||
# SQLite
|
|
||||||
SECRET_KEY = "dev"
|
|
||||||
SQLALCHEMY_DATABASE_URI = "sqlite:///tfr.db"
|
|
||||||
"""
|
|
||||||
|
|
BIN
TFR/server/static/images/controls.png
Normal file
BIN
TFR/server/static/images/controls.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 360 KiB |
|
@ -3,6 +3,8 @@
|
||||||
<h2>What is The Front Rooms?</h2>
|
<h2>What is The Front Rooms?</h2>
|
||||||
<p>The Front Rooms is a game based on The Backrooms Genre of games.</p>
|
<p>The Front Rooms is a game based on The Backrooms Genre of games.</p>
|
||||||
|
|
||||||
|
<img src="{{ url_for('static', filename='images/controls.png') }}" alt="Drawing of keyboard displaying controls" width="500" height="500">
|
||||||
|
|
||||||
<h2>Is my data secured?</h2>
|
<h2>Is my data secured?</h2>
|
||||||
<p>Yes, all passwords and emails are hashed and salted, and at no point stored in plain text.</p>
|
<p>Yes, all passwords and emails are hashed and salted, and at no point stored in plain text.</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -4,19 +4,18 @@
|
||||||
<nav>
|
<nav>
|
||||||
<form method="GET" action="{{ url_for('views.index') }}" class="compact">
|
<form method="GET" action="{{ url_for('views.index') }}" class="compact">
|
||||||
<select name="diff" class="button">
|
<select name="diff" class="button">
|
||||||
<option value="0" {% if diff==0 %}selected{% endif %}>Level 1</option>
|
{% for difficulty in config["GAME_DIFFICULTIES"] %}
|
||||||
<option value="1" {% if diff==1 %}selected{% endif %}>Level 2</option>
|
<option value="{{ difficulty }}" {% if diff==difficulty %}selected{% endif %}>
|
||||||
<option value="2" {% if diff==2 %}selected{% endif %}>Level 3</option>
|
{{ config["GAME_DIFFICULTIES"][difficulty] }}
|
||||||
<option value="3" {% if diff==3 %}selected{% endif %}>Normal</option>
|
</option>
|
||||||
<option value="4" {% if diff==4 %}selected{% endif %}>Hard</option>
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select name="ver" class="button">
|
<select name="ver" class="button">
|
||||||
{% for game_version in config["GAME_VERSIONS"] %}
|
{% for version in config["GAME_VERSIONS"] %}
|
||||||
<option
|
<option value="{{ version }}" {% if ver==version %}selected{% endif %}>
|
||||||
value="{{ game_version }}"
|
{{ config["GAME_VERSIONS"][version] }}
|
||||||
{% if ver==game_version %}selected{% endif %}
|
</option>
|
||||||
>{{ game_version }}</option>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@
|
||||||
<div class="table">
|
<div class="table">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th>Pos</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Time Set</th>
|
<th>Time Set</th>
|
||||||
<th>Submitted</th>
|
<th>Submitted</th>
|
||||||
|
@ -72,10 +71,10 @@
|
||||||
<td>{{ loop.index }}</td>
|
<td>{{ loop.index }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
<a
|
<a href="{{ url_for('views.index', user=score.users.username) }}"
|
||||||
href="{{ url_for('views.index', user=score.users.username) }}"
|
{% if score.users.id == current_user.id %}id="you"{% endif %}>
|
||||||
{% if score.users.id == current_user.id %}id="you"{% endif %}
|
{{ score.users.username }}
|
||||||
>{{ score.users.username }}</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ score.score|format_result }}</td>
|
<td>{{ score.score|format_result }}</td>
|
||||||
<td>{{ score.scored_at.strftime('%Y-%m-%d') }}</td>
|
<td>{{ score.scored_at.strftime('%Y-%m-%d') }}</td>
|
||||||
|
@ -86,7 +85,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="center-text">
|
<div class="center-text">
|
||||||
<h2>No scores</h2>
|
<h2>No scores</h2>
|
||||||
<p>Go set some!</p>
|
<p>We searched far and wide, but nothing was found</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Add table
Reference in a new issue