global
This commit is contained in:
parent
ccbdd92300
commit
b407bee0c9
26
main.py
26
main.py
|
@ -36,7 +36,7 @@ def create():
|
|||
#replace spaces with underscores
|
||||
player_name = player_name.replace(' ', '_')
|
||||
# replace illegal characters with nothing
|
||||
illegal_chars = ['<', '>', '(', ')', '[', ']', ',', '.', ':', ';', '-', '/', '|', '\\', 'exec', 'spectator']
|
||||
illegal_chars = ['<', '>', '(', ')', '[', ']', ',', '.', ':', ';', '-', '/', '|', '\\','=', 'exec', 'spectator']
|
||||
for char in illegal_chars:
|
||||
player_name = player_name.replace(char, '')
|
||||
if player_name:
|
||||
|
@ -90,6 +90,7 @@ def game(game_id, player_name):
|
|||
gamestate = requests.get(ozai_url + 'game/' + game_id).json()
|
||||
move_status = False
|
||||
|
||||
#if a move was made.
|
||||
if request.method == 'POST':
|
||||
|
||||
source = request.form['source']
|
||||
|
@ -116,16 +117,17 @@ def game(game_id, player_name):
|
|||
else:
|
||||
move_status = response.text
|
||||
|
||||
|
||||
if player_name == 'spectator':
|
||||
gamestate = requests.get(ozai_url + 'game/' + game_id).json()
|
||||
return render_template('game.html', game_id=game_id, gamestate=gamestate)
|
||||
elif player_name in gamestate['players']:
|
||||
gamestate = requests.get(ozai_url + 'game/' + game_id + '?player=' + player_name).json()
|
||||
return render_template('game.html', game_id=game_id, gamestate=gamestate, player_name=player_name, move_status=move_status)
|
||||
else:
|
||||
return 'Player not found', 404
|
||||
|
||||
#dont send player parameter if the player is a spectator
|
||||
while True:
|
||||
if player_name == 'spectator':
|
||||
gamestate = requests.get(ozai_url + 'game/' + game_id).json()
|
||||
return render_template('game.html', game_id=game_id, gamestate=gamestate)
|
||||
elif player_name in gamestate['players']:
|
||||
gamestate = requests.get(ozai_url + 'game/' + game_id + '?player=' + player_name).json()
|
||||
return render_template('game.html', game_id=game_id, gamestate=gamestate, player_name=player_name, move_status=move_status)
|
||||
else:
|
||||
return 'Player not found', 404
|
||||
return 'Player not found', 404
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
app.run(debug=True, host='0.0.0.0', port=5000)
|
|
@ -133,6 +133,22 @@
|
|||
height: 1.5em;
|
||||
}
|
||||
|
||||
.blue_bg {
|
||||
background-color: rgb(49, 157, 245, 0.5);
|
||||
}
|
||||
.yellow_bg {
|
||||
background-color: rgb(245, 245, 10, 0.5);
|
||||
}
|
||||
.red_bg {
|
||||
background-color: rgb(255, 0, 0, 0.5);
|
||||
}
|
||||
.black_bg {
|
||||
background-color: rgb(93, 93, 93, 0.5);
|
||||
}
|
||||
.white_bg {
|
||||
background-color:rgb(208, 202, 195, 0.5);
|
||||
}
|
||||
|
||||
.blue {
|
||||
background-color: rgb(49, 157, 245);
|
||||
}
|
||||
|
@ -231,11 +247,14 @@
|
|||
</div>
|
||||
<div class="flex-col">
|
||||
<!-- <h3>Wall</h3> -->
|
||||
<div class="wall">
|
||||
<div class="wall">
|
||||
{% set colors_base = ['blue', 'yellow', 'red', 'black', 'white'] %}
|
||||
{% for row in player_data.wall %}
|
||||
{% for cell in row %}
|
||||
<div class="{{ cell }}">{% if cell %}{{ cell[:1] }}{% else %}{{ '_' }}{% endif %}</div>
|
||||
{% endfor %}
|
||||
{% set colors = colors_base[-loop.index0:] + colors_base[:-loop.index0] %}
|
||||
{% for cell in row %}
|
||||
{% set color = colors[loop.index0] + "_bg" %}
|
||||
<div class="{{ color }}">{% if cell %}{{ color[:1] }}{% else %}{{ '_' }}{% endif %}</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue