Exemplo n.º 1
0
def game():
	if "player" not in session:#player never logged in
		return redirect(url_for("index"))
	elif db.getplayer(session["player"]) == False:#player never logged back in after the last game ended
		return redirect(url_for("index"))
	elif db.inprogress():
		if int(db.getplayer(session["player"])[2]) < 4:#checks if the player was one of the first 4 to log in
			return render_template("gamepage.html", playing = True, game = (db.getgame())[0], _map = (db.getgame())[1], player=session["player"])
		else:
			return render_template("gamepage.html", playing = False, game = (db.getgame())[0], _map = (db.getgame())[1], player=session["player"])
	else:
		return redirect(url_for("playlist"))#redirects to playlist if the game's not set up yet.
Exemplo n.º 2
0
def playlist():#where the map and gametype are chosen (by 1st player to log in)
	if "player" not in session:#player never logged in
		return redirect(url_for("index"))
	elif db.getplayer(session["player"]) == False:#player never logged back in after the last game ended
		return redirect(url_for("index"))
	elif db.inprogress():#game already set up
		return redirect(url_for("game"))
	elif request.method == "GET":
		 return render_template("mapselectionpage.html", user = session["player"])
	else: 
		db.setupgame("game", int(request.form["map"]), -1)
		return redirect(url_for("game"))
Exemplo n.º 3
0
def index():#choose player name
	if request.method=="GET":
		if "player" not in session:
			return render_template("loginpage.html")
		elif db.getplayer(session["player"]) == False:
			return render_template("loginpage.html", pname = session["player"])#for when the player gets redirected here after the game's done
		else:
			return render_template("loginpage.html", pname = session["player"], loggedin= True)#for when the player opens the page when they're already logged in
	else:
		if db.addplayer(str(request.form["name"])):#addplayer returns false if there's already a player with name "name"
			if "player" in session:#logs the user out if they're trying to log in while already being logged in
				session.pop("player", None)
			session["player"] = str(request.form["name"])
			if db.inprogress():#if a game has already been set up(map and gametype chosen), redirects to game page.
				return redirect(url_for("game"))
			else:
				return redirect(url_for("playlist"))
		else: 
			return render_template("loginpage.html", failed = True)#log in has failed