added points summary
This commit is contained in:
+6
-1
@@ -3,6 +3,7 @@ from bridzik import Bridzik, Card, Card_colors, Card_values, BridzikException
|
|||||||
import json
|
import json
|
||||||
from flask import render_template, url_for, flash, redirect
|
from flask import render_template, url_for, flash, redirect
|
||||||
from api.forms import GuessForm, PlayForm, AdminForm
|
from api.forms import GuessForm, PlayForm, AdminForm
|
||||||
|
from api.utils import get_points_sums
|
||||||
|
|
||||||
b = Bridzik()
|
b = Bridzik()
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ def status(player):
|
|||||||
form = None
|
form = None
|
||||||
player_cards = Card.sort_card_list(b.series[-1].get_last_round().player_cards[player])
|
player_cards = Card.sort_card_list(b.series[-1].get_last_round().player_cards[player])
|
||||||
game_status['player_cards'] = [str(c) for c in player_cards]
|
game_status['player_cards'] = [str(c) for c in player_cards]
|
||||||
|
points_sums = get_points_sums(game_status['standings'])
|
||||||
if b.is_completed() or b.series[-1].get_last_round().get_active_player() != player:
|
if b.is_completed() or b.series[-1].get_last_round().get_active_player() != player:
|
||||||
pass
|
pass
|
||||||
elif not b.series[-1].get_last_round().is_guessing_completed():
|
elif not b.series[-1].get_last_round().is_guessing_completed():
|
||||||
@@ -34,7 +36,10 @@ def status(player):
|
|||||||
form = PlayForm()
|
form = PlayForm()
|
||||||
form.card.choices = [(str(c), str(c)) for c in player_cards]
|
form.card.choices = [(str(c), str(c)) for c in player_cards]
|
||||||
action = 'play'
|
action = 'play'
|
||||||
return render_template('status.html', status=game_status, player=player, action=action, form=form, players=players)
|
return render_template(
|
||||||
|
'status.html', status=game_status, player=player, action=action,
|
||||||
|
form=form, players=players, points_sums=points_sums
|
||||||
|
)
|
||||||
|
|
||||||
@app.route('/bridzik/<player>/guess', methods=['POST'])
|
@app.route('/bridzik/<player>/guess', methods=['POST'])
|
||||||
def guess(player):
|
def guess(player):
|
||||||
|
|||||||
@@ -29,3 +29,11 @@
|
|||||||
width: 82px;
|
width: 82px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#points_summary_row {
|
||||||
|
border-top: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
<p>
|
<p>
|
||||||
{{ form.guess.label }}:
|
{{ form.guess.label }}:
|
||||||
{{ form.guess(size=15) }}
|
{{ form.guess(size=15, autocomplete="off") }}
|
||||||
{% for error in form.guess.errors %}
|
{% for error in form.guess.errors %}
|
||||||
<span style="color: red;">[{{ error }}]</span>
|
<span style="color: red;">[{{ error }}]</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -126,13 +126,13 @@
|
|||||||
<div id="standings">
|
<div id="standings">
|
||||||
<h1>Výsledky</h1>
|
<h1>Výsledky</h1>
|
||||||
<table style="width: auto;">
|
<table style="width: auto;">
|
||||||
{% for series in status['standings'] %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ players[0] }}</th>
|
<th>{{ players[0] }}</th>
|
||||||
<th>{{ players[1] }}</th>
|
<th>{{ players[1] }}</th>
|
||||||
<th>{{ players[2] }}</th>
|
<th>{{ players[2] }}</th>
|
||||||
<th>{{ players[3] }}</th>
|
<th>{{ players[3] }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% for series in status['standings'] %}
|
||||||
{% if series %}
|
{% if series %}
|
||||||
{% for round in series %}
|
{% for round in series %}
|
||||||
{% if round %}
|
{% if round %}
|
||||||
@@ -145,6 +145,11 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<tr id="points_summary_row">
|
||||||
|
{% for player in points_sums %}
|
||||||
|
<td class="points">{{ player }}</td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
def get_points_sums(standings: []):
|
||||||
|
sums = [0] * 4
|
||||||
|
for series in standings:
|
||||||
|
for round in series:
|
||||||
|
for player, points in enumerate(round):
|
||||||
|
sums[player] += points
|
||||||
|
return sums
|
||||||
Reference in New Issue
Block a user