|
@@ -1,7 +1,10 @@
|
|
|
-from flask import Flask, render_template
|
|
|
|
|
|
|
+from flask import Flask, abort, render_template, request, session
|
|
|
|
|
+
|
|
|
|
|
+from game import Game
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
|
app.secret_key = "somebullshit"
|
|
app.secret_key = "somebullshit"
|
|
|
|
|
+app.games = []
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/")
|
|
@app.route("/")
|
|
@@ -9,5 +12,26 @@ def home():
|
|
|
return render_template("home.html")
|
|
return render_template("home.html")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[email protected]("/newgame")
|
|
|
|
|
+def new_game(name):
|
|
|
|
|
+ try:
|
|
|
|
|
+ name = request.args["playerName"]
|
|
|
|
|
+ hand_size = request.args["handSize"]
|
|
|
|
|
+ match_count = request.args["matchCount"]
|
|
|
|
|
+ turn_count = request.args["turnCount"]
|
|
|
|
|
+ except KeyError as e:
|
|
|
|
|
+ return abort(400)
|
|
|
|
|
+
|
|
|
|
|
+ game = Game(name, hand_size, match_count, turn_count)
|
|
|
|
|
+ app.games.append(game)
|
|
|
|
|
+ session["game_id"] = game.id
|
|
|
|
|
+ session["player_id"] = game.player1.id
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
[email protected]("/game/<game_id>")
|
|
|
|
|
+def game(game_id):
|
|
|
|
|
+ return render_template("game.html", game_id=game_id)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
app.run(debug=True)
|
|
app.run(debug=True)
|