|
|
@@ -1,6 +1,6 @@
|
|
|
from flask import Flask, abort, render_template, request, session
|
|
|
|
|
|
-from game import Game
|
|
|
+from game import Game, randomword
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
app.secret_key = "somebullshit"
|
|
|
@@ -22,7 +22,13 @@ def new_game(name):
|
|
|
except KeyError as e:
|
|
|
return abort(400)
|
|
|
|
|
|
- game = Game(name, hand_size, match_count, turn_count)
|
|
|
+ game_id = None
|
|
|
+ while game_id := randomword(4):
|
|
|
+ for game in app.games:
|
|
|
+ if game_id != game.id:
|
|
|
+ break
|
|
|
+
|
|
|
+ game = Game(name, hand_size, match_count, turn_count, game_id)
|
|
|
app.games.append(game)
|
|
|
session["game_id"] = game.id
|
|
|
session["player_id"] = game.player1.id
|