diff --git a/.env.dist b/.env.dist index b0329a5..e16daf2 100644 --- a/.env.dist +++ b/.env.dist @@ -2,9 +2,9 @@ FLASK_SECRET="" DISCORD_BOT_TOKEN="" ORIGIN="https://example.com" +GAME_LIMIT=100 GAME_TIMEOUT=1800 - # Database DB_HOST="" DB_PORT=3306 diff --git a/truthinquiry/routes/routes_api.py b/truthinquiry/routes/routes_api.py index 5fc3ed2..9b7282f 100644 --- a/truthinquiry/routes/routes_api.py +++ b/truthinquiry/routes/routes_api.py @@ -3,6 +3,7 @@ import io import time import os import flask +import os from sqlalchemy import select from truthinquiry.ext.database.models import * @@ -10,6 +11,7 @@ from truthinquiry.ext.database.fsa import db from truthinquiry.ext.discord_bot import discord_bot from truthinquiry.ext.socketio import socket_io from truthinquiry.logic import game_logic +from dotenv import load_dotenv from flask_apscheduler import APScheduler scheduler = APScheduler() @@ -35,7 +37,8 @@ def create_game(): return {"error": 1, "msg": "username not set"} if not game_logic.check_username(username): return {"error": 1, "msg": "invalid username"} - + if len(game_logic.games_list) >= int(os.getenv("GAME_LIMIT")): + return {"error": 1, "msg": "Game limit reach"} response = {} response["error"] = 0 game = game_logic.create_game(owner=username) @@ -55,7 +58,7 @@ def get_members(): game = game_logic.get_game(game_id) if game is None: return {"error": 1, "msg": "this game doesn't exist"} - response = {"error" : 0} + response = {"error": 0} player_list = [member.username for member in game.members] response["members"] = player_list return response