|
@@ -8,12 +8,17 @@ from flask import (
|
|
|
url_for,
|
|
url_for,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+import logging
|
|
|
from game import Game, randomword
|
|
from game import Game, randomword
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
|
app.secret_key = "somebullshit"
|
|
app.secret_key = "somebullshit"
|
|
|
app.games = []
|
|
app.games = []
|
|
|
|
|
|
|
|
|
|
+logging.basicConfig(
|
|
|
|
|
+ level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@app.route("/")
|
|
@app.route("/")
|
|
|
def home():
|
|
def home():
|
|
@@ -23,11 +28,14 @@ def home():
|
|
|
@app.route("/newgame")
|
|
@app.route("/newgame")
|
|
|
def new_game():
|
|
def new_game():
|
|
|
try:
|
|
try:
|
|
|
|
|
+ app.logger.info("Creating game...")
|
|
|
name = request.args["playerName"]
|
|
name = request.args["playerName"]
|
|
|
hand_size = request.args["handSize"]
|
|
hand_size = request.args["handSize"]
|
|
|
match_count = request.args["matchCount"]
|
|
match_count = request.args["matchCount"]
|
|
|
turn_count = request.args["turnCount"]
|
|
turn_count = request.args["turnCount"]
|
|
|
except (KeyError, TypeError) as e:
|
|
except (KeyError, TypeError) as e:
|
|
|
|
|
+ app.logger.error(e)
|
|
|
|
|
+ app.logger.error("Failed, bad args")
|
|
|
return abort(400)
|
|
return abort(400)
|
|
|
|
|
|
|
|
game_id = None
|
|
game_id = None
|
|
@@ -35,6 +43,9 @@ def new_game():
|
|
|
if game_id not in [game.id for game in app.games]:
|
|
if game_id not in [game.id for game in app.games]:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
|
|
+ app.logger.info(
|
|
|
|
|
+ f"Game created: {game_id} {name} {hand_size} {match_count} {turn_count}"
|
|
|
|
|
+ )
|
|
|
game = Game(name, hand_size, match_count, turn_count, game_id)
|
|
game = Game(name, hand_size, match_count, turn_count, game_id)
|
|
|
app.games.append(game)
|
|
app.games.append(game)
|
|
|
session["game_id"] = game.id
|
|
session["game_id"] = game.id
|