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 re
|
||||
import os
|
||||
from PIL import Image
|
||||
|
||||
|
@ -29,9 +28,6 @@ def settings():
|
|||
username = request.form.get("username", "").strip()
|
||||
email = request.form.get("email", "").strip()
|
||||
password = request.form.get("password", "").strip()
|
||||
|
||||
user_regex = re.compile(USER_REGEX)
|
||||
email_regex = re.compile(USER_EMAIL_REGEX)
|
||||
error = []
|
||||
|
||||
user = Users.query.filter_by(username=current_user.username).first()
|
||||
|
@ -78,12 +74,12 @@ def settings():
|
|||
image.close()
|
||||
|
||||
if username:
|
||||
if user_regex.match(username):
|
||||
if USER_REGEX.match(username):
|
||||
user.username = username
|
||||
else:
|
||||
error.append("Username is invalid!")
|
||||
if email:
|
||||
if email_regex.match(email):
|
||||
if USER_EMAIL_REGEX.match(email):
|
||||
user.email = email
|
||||
else:
|
||||
error.append("Email is invalid!")
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import re
|
||||
import shortuuid
|
||||
|
||||
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 .extensions import db
|
||||
from .config import (
|
||||
GAME_VERSION,
|
||||
GAME_VERSIONS,
|
||||
GAME_DIFFICULTY,
|
||||
GAME_DIFFICULTIES,
|
||||
MAX_SEARCH_RESULTS,
|
||||
USER_REGEX,
|
||||
|
@ -49,8 +51,8 @@ def tokens():
|
|||
@blueprint.route("/post", methods=["POST"])
|
||||
def post():
|
||||
session_key = request.form.get("session", "").strip()
|
||||
version = request.form.get("version", "alpha").strip()
|
||||
difficulty = request.form.get("difficulty", 0)
|
||||
version = request.form.get("version", GAME_VERSION).strip()
|
||||
difficulty = request.form.get("difficulty", GAME_DIFFICULTY)
|
||||
score = request.form.get("score", 0)
|
||||
|
||||
if not session_key:
|
||||
|
@ -66,6 +68,8 @@ def post():
|
|||
|
||||
if int(difficulty) not in GAME_DIFFICULTIES:
|
||||
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
|
||||
# if score < 10:
|
||||
# return "Score is impossible!"
|
||||
|
@ -110,9 +114,8 @@ def login():
|
|||
username = request.form.get("username", "").strip()
|
||||
password = request.form.get("password", "").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
|
||||
|
||||
user = Users.query.filter_by(username=username).first()
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import re
|
||||
import uuid
|
||||
|
||||
from flask import Blueprint, render_template, request, flash, redirect, url_for
|
||||
|
@ -24,12 +23,10 @@ def register():
|
|||
username = request.form.get("username", None).strip()
|
||||
password = request.form.get("password", None).strip()
|
||||
confirm = request.form.get("confirm", None).strip()
|
||||
|
||||
username_regex = re.compile(USER_REGEX)
|
||||
error = []
|
||||
|
||||
# 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 ._-")
|
||||
if not password or len(password) < 8:
|
||||
error.append("Password is too short! Must be at least 8 characters long.")
|
||||
|
@ -61,11 +58,10 @@ def login():
|
|||
# Get the form data
|
||||
username = request.form.get("username", None).strip()
|
||||
password = request.form.get("password", None).strip()
|
||||
username_regex = re.compile(USER_REGEX)
|
||||
error = []
|
||||
|
||||
# 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!")
|
||||
|
||||
user = Users.query.filter_by(username=username).first()
|
||||
|
|
|
@ -1,35 +1,41 @@
|
|||
from os import getenv
|
||||
import re
|
||||
|
||||
|
||||
SECRET_KEY = getenv("FLASK_KEY")
|
||||
|
||||
UPLOAD_DIR = "/data/uploads"
|
||||
UPLOAD_EXTENSIONS = ["png", "jpg", "jpeg", "gif"]
|
||||
UPLOAD_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp"]
|
||||
UPLOAD_RESOLUTION = 512
|
||||
UPLOAD_MAX_SIZE = 3 * 1024 * 1024 # 3MB
|
||||
|
||||
GAME_VERSION = "alpha"
|
||||
GAME_VERSIONS = ["alpha"]
|
||||
GAME_DIFFICULTIES = [0, 1, 2, 3, 4]
|
||||
GAME_DIFFICULTY = 0
|
||||
|
||||
USER_REGEX = r"\b[A-Za-z0-9._-]+\b"
|
||||
USER_EMAIL_REGEX = r"[^@]+@[^@]+\.[^@]+"
|
||||
GAME_VERSIONS = {
|
||||
"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_SEARCH_RESULTS = 5
|
||||
|
||||
# Postgres
|
||||
SECRET_KEY = getenv("FLASK_KEY")
|
||||
|
||||
user = getenv("DB_USER")
|
||||
password = getenv("DB_PASSWORD")
|
||||
host = getenv("DB_HOST")
|
||||
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_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>
|
||||
<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>
|
||||
<p>Yes, all passwords and emails are hashed and salted, and at no point stored in plain text.</p>
|
||||
{% endblock %}
|
|
@ -4,19 +4,18 @@
|
|||
<nav>
|
||||
<form method="GET" action="{{ url_for('views.index') }}" class="compact">
|
||||
<select name="diff" class="button">
|
||||
<option value="0" {% if diff==0 %}selected{% endif %}>Level 1</option>
|
||||
<option value="1" {% if diff==1 %}selected{% endif %}>Level 2</option>
|
||||
<option value="2" {% if diff==2 %}selected{% endif %}>Level 3</option>
|
||||
<option value="3" {% if diff==3 %}selected{% endif %}>Normal</option>
|
||||
<option value="4" {% if diff==4 %}selected{% endif %}>Hard</option>
|
||||
{% for difficulty in config["GAME_DIFFICULTIES"] %}
|
||||
<option value="{{ difficulty }}" {% if diff==difficulty %}selected{% endif %}>
|
||||
{{ config["GAME_DIFFICULTIES"][difficulty] }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<select name="ver" class="button">
|
||||
{% for game_version in config["GAME_VERSIONS"] %}
|
||||
<option
|
||||
value="{{ game_version }}"
|
||||
{% if ver==game_version %}selected{% endif %}
|
||||
>{{ game_version }}</option>
|
||||
{% for version in config["GAME_VERSIONS"] %}
|
||||
<option value="{{ version }}" {% if ver==version %}selected{% endif %}>
|
||||
{{ config["GAME_VERSIONS"][version] }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
|
@ -55,7 +54,7 @@
|
|||
<div class="table">
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Pos</th>
|
||||
<th>Name</th>
|
||||
<th>Time Set</th>
|
||||
<th>Submitted</th>
|
||||
|
@ -72,10 +71,10 @@
|
|||
<td>{{ loop.index }}</td>
|
||||
{% endif %}
|
||||
<td>
|
||||
<a
|
||||
href="{{ url_for('views.index', user=score.users.username) }}"
|
||||
{% if score.users.id == current_user.id %}id="you"{% endif %}
|
||||
>{{ score.users.username }}</a>
|
||||
<a href="{{ url_for('views.index', user=score.users.username) }}"
|
||||
{% if score.users.id == current_user.id %}id="you"{% endif %}>
|
||||
{{ score.users.username }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ score.score|format_result }}</td>
|
||||
<td>{{ score.scored_at.strftime('%Y-%m-%d') }}</td>
|
||||
|
@ -86,7 +85,7 @@
|
|||
{% else %}
|
||||
<div class="center-text">
|
||||
<h2>No scores</h2>
|
||||
<p>Go set some!</p>
|
||||
<p>We searched far and wide, but nothing was found</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
Loading…
Add table
Reference in a new issue