global
This commit is contained in:
parent
ccbdd92300
commit
b407bee0c9
10
main.py
10
main.py
|
@ -36,7 +36,7 @@ def create():
|
||||||
#replace spaces with underscores
|
#replace spaces with underscores
|
||||||
player_name = player_name.replace(' ', '_')
|
player_name = player_name.replace(' ', '_')
|
||||||
# replace illegal characters with nothing
|
# replace illegal characters with nothing
|
||||||
illegal_chars = ['<', '>', '(', ')', '[', ']', ',', '.', ':', ';', '-', '/', '|', '\\', 'exec', 'spectator']
|
illegal_chars = ['<', '>', '(', ')', '[', ']', ',', '.', ':', ';', '-', '/', '|', '\\','=', 'exec', 'spectator']
|
||||||
for char in illegal_chars:
|
for char in illegal_chars:
|
||||||
player_name = player_name.replace(char, '')
|
player_name = player_name.replace(char, '')
|
||||||
if player_name:
|
if player_name:
|
||||||
|
@ -90,6 +90,7 @@ def game(game_id, player_name):
|
||||||
gamestate = requests.get(ozai_url + 'game/' + game_id).json()
|
gamestate = requests.get(ozai_url + 'game/' + game_id).json()
|
||||||
move_status = False
|
move_status = False
|
||||||
|
|
||||||
|
#if a move was made.
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
||||||
source = request.form['source']
|
source = request.form['source']
|
||||||
|
@ -116,7 +117,8 @@ def game(game_id, player_name):
|
||||||
else:
|
else:
|
||||||
move_status = response.text
|
move_status = response.text
|
||||||
|
|
||||||
|
#dont send player parameter if the player is a spectator
|
||||||
|
while True:
|
||||||
if player_name == 'spectator':
|
if player_name == 'spectator':
|
||||||
gamestate = requests.get(ozai_url + 'game/' + game_id).json()
|
gamestate = requests.get(ozai_url + 'game/' + game_id).json()
|
||||||
return render_template('game.html', game_id=game_id, gamestate=gamestate)
|
return render_template('game.html', game_id=game_id, gamestate=gamestate)
|
||||||
|
@ -125,7 +127,7 @@ def game(game_id, player_name):
|
||||||
return render_template('game.html', game_id=game_id, gamestate=gamestate, player_name=player_name, move_status=move_status)
|
return render_template('game.html', game_id=game_id, gamestate=gamestate, player_name=player_name, move_status=move_status)
|
||||||
else:
|
else:
|
||||||
return 'Player not found', 404
|
return 'Player not found', 404
|
||||||
|
return 'Player not found', 404
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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;
|
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 {
|
.blue {
|
||||||
background-color: rgb(49, 157, 245);
|
background-color: rgb(49, 157, 245);
|
||||||
}
|
}
|
||||||
|
@ -232,9 +248,12 @@
|
||||||
<div class="flex-col">
|
<div class="flex-col">
|
||||||
<!-- <h3>Wall</h3> -->
|
<!-- <h3>Wall</h3> -->
|
||||||
<div class="wall">
|
<div class="wall">
|
||||||
|
{% set colors_base = ['blue', 'yellow', 'red', 'black', 'white'] %}
|
||||||
{% for row in player_data.wall %}
|
{% for row in player_data.wall %}
|
||||||
|
{% set colors = colors_base[-loop.index0:] + colors_base[:-loop.index0] %}
|
||||||
{% for cell in row %}
|
{% for cell in row %}
|
||||||
<div class="{{ cell }}">{% if cell %}{{ cell[:1] }}{% else %}{{ '_' }}{% endif %}</div>
|
{% set color = colors[loop.index0] + "_bg" %}
|
||||||
|
<div class="{{ color }}">{% if cell %}{{ color[:1] }}{% else %}{{ '_' }}{% endif %}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue