From 58b72ca5b1ff9ef2cfef5de5e0565d9c152f9127 Mon Sep 17 00:00:00 2001 From: Adrian Gunnar Lauterer Date: Thu, 6 Jun 2024 00:20:14 +0200 Subject: [PATCH] trying join with js --- src/ozai_webui/__init__.py | 16 ++---- src/templates/join_game.html | 106 +++++++++++++++-------------------- 2 files changed, 48 insertions(+), 74 deletions(-) diff --git a/src/ozai_webui/__init__.py b/src/ozai_webui/__init__.py index 46c854a..d2481c5 100755 --- a/src/ozai_webui/__init__.py +++ b/src/ozai_webui/__init__.py @@ -141,24 +141,16 @@ def join(): return render_template('join.html', game_id=game_id) return render_template('join.html') -#select player name page -@app.route('/join_game//', methods=['GET','POST']) + + + +@app.route('/join_game//', methods=['GET', 'POST']) def join_game(game_id): - - #get players from servre api and return them to the user response = requests.get(ozai_url + 'game/' + game_id) if response.status_code != 200: - #return error message return 'Game not found', 404 players = response.json().get('players') - if request.method == 'POST': - #get the chosen player name from the form and redirect to the game page - player_name = request.form['player'] - # print('Player Name:', player_name) - local_game = request.form.get('local_game') - return render_template('join_game.html', game_id=game_id, players=players, player_name=player_name, local_game=local_game) - return render_template('join_game.html', game_id=game_id, players=players) diff --git a/src/templates/join_game.html b/src/templates/join_game.html index 63824f3..b26a6dc 100644 --- a/src/templates/join_game.html +++ b/src/templates/join_game.html @@ -1,9 +1,8 @@ - - Ozai webui:Join Game - + Ozai webui: Join Game + -
+ {% if game_id %} +

Selected game to join is: {{ game_id }}

+ {% endif %} - {% if game_id %} -

Selected game to join is: {{ game_id }}

- {% endif %} - - {% if players %} -

Players in game:

-
    - {% for player in players %} -
  • {{ player }}
  • - {% endfor %} -
- -
- -

game type

- - -
- - {% else %} -

No players found in game, please recreate the game.

- {% endif %} - - - {% if player_name %} - - - {% endif %} - + +
+ +

Game type

+ + +
+ {% else %} +

No players found in game, please recreate the game.

+ {% endif %}
+ +