commit 0007f25cf6c21cf48679392e961413774c552b96
Author: Yannik Enss
Date: Wed Jan 2 04:30:59 2019 +0100
init
diff --git a/templates/main.html b/templates/main.html
new file mode 100644
index 0000000..a365ddb
--- /dev/null
+++ b/templates/main.html
@@ -0,0 +1,9 @@
+
+
+ {% block title %}Wer bin ich{% endblock %}
+
+
+
+ {% block content %}{% endblock %}
+
+
diff --git a/templates/name_edit.html b/templates/name_edit.html
new file mode 100644
index 0000000..8621f4b
--- /dev/null
+++ b/templates/name_edit.html
@@ -0,0 +1,19 @@
+{% extends "main.html" %}
+{% block title %}Choose name{% endblock %}
+{% block content %}
+
+Choose a name
+You are: {{ current_player }}
+
+
+Please name your player:
+
+
+
+
+{% endblock %}
diff --git a/templates/name_show.html b/templates/name_show.html
new file mode 100644
index 0000000..2ed4725
--- /dev/null
+++ b/templates/name_show.html
@@ -0,0 +1,16 @@
+{% extends "main.html" %}
+{% block title %}Play!{% endblock %}
+{% block content %}
+
+Play!
+You are: {{ current_player }}
+
+
+
+{% for player,name in other_players.items() %}
+| {{ player }} | {{ name }} |
+{% endfor %}
+
+
+
+{% endblock %}
diff --git a/templates/new_game.html b/templates/new_game.html
new file mode 100644
index 0000000..89ae1ca
--- /dev/null
+++ b/templates/new_game.html
@@ -0,0 +1,15 @@
+{% extends "main.html" %}
+{% block title %}New Game{% endblock %}
+{% block content %}
+
+New Game
+
+Please enter player names:
+
+
+{% endblock %}
diff --git a/templates/player_select.html b/templates/player_select.html
new file mode 100644
index 0000000..79fd64d
--- /dev/null
+++ b/templates/player_select.html
@@ -0,0 +1,19 @@
+{% extends "main.html" %}
+{% block title %}Player select{% endblock %}
+{% block content %}
+
+Player select
+
+
+Please select your player:
+
+{% for player in players %}
+{{ player }}
+{% endfor %}
+
+
+
+You can share this link
+
+
+{% endblock %}
diff --git a/werbinich.py b/werbinich.py
new file mode 100644
index 0000000..9caa788
--- /dev/null
+++ b/werbinich.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python3
+from flask import Flask,render_template,request,url_for,redirect
+from pprint import pprint
+from uuid import uuid4
+app = Flask(__name__)
+
+games = {}
+
+@app.route("/")
+def new_game():
+ return render_template("new_game.html")
+
+@app.route("/", methods=["post"])
+def create_game():
+ global games
+ pnames = [ x for x in request.form.getlist("pname") if x != "" ]
+ gameid = str(uuid4())
+ mapping = {}
+ for player in pnames:
+ mapping[player] = None
+ games[gameid] = mapping
+
+ return redirect(url_for("player_select", gameid=gameid),303)
+
+@app.route("/game//")
+def player_select(gameid):
+ return render_template("player_select.html", players=games[str(gameid)].keys(), gameurl=url_for("player_select", gameid=gameid))
+
+@app.route("/game//edit/")
+def name_edit(gameid, player):
+ all_players = games[str(gameid)].keys()
+ other_players = [ x for x in all_players if x != player ]
+ return render_template("name_edit.html", current_player=player, other_players=other_players)
+
+@app.route("/game//edit/", methods=["post"])
+def store_name(gameid, player):
+ all_players = games[str(gameid)].keys()
+ for p in all_players:
+ if p not in request.form:
+ continue
+ if request.form[p]:
+ games[str(gameid)][p] = request.form[p]
+ return redirect(url_for("name_show", gameid=gameid, player=player), 303)
+
+@app.route("/game//show/")
+def name_show(gameid, player):
+ other_players = dict(games[str(gameid)])
+ other_players.pop(player,None)
+ pprint(other_players)
+ return render_template("name_show.html", current_player=player, other_players=other_players)