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
|
||||
from flask import render_template, url_for, flash, redirect
|
||||
from api.forms import GuessForm, PlayForm, AdminForm
|
||||
from api.utils import get_points_sums
|
||||
|
||||
b = Bridzik()
|
||||
|
||||
@@ -25,6 +26,7 @@ def status(player):
|
||||
form = None
|
||||
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]
|
||||
points_sums = get_points_sums(game_status['standings'])
|
||||
if b.is_completed() or b.series[-1].get_last_round().get_active_player() != player:
|
||||
pass
|
||||
elif not b.series[-1].get_last_round().is_guessing_completed():
|
||||
@@ -34,7 +36,10 @@ def status(player):
|
||||
form = PlayForm()
|
||||
form.card.choices = [(str(c), str(c)) for c in player_cards]
|
||||
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'])
|
||||
def guess(player):
|
||||
|
||||
@@ -29,3 +29,11 @@
|
||||
width: 82px;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
#points_summary_row {
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{{ form.hidden_tag() }}
|
||||
<p>
|
||||
{{ form.guess.label }}:
|
||||
{{ form.guess(size=15) }}
|
||||
{{ form.guess(size=15, autocomplete="off") }}
|
||||
{% for error in form.guess.errors %}
|
||||
<span style="color: red;">[{{ error }}]</span>
|
||||
{% endfor %}
|
||||
|
||||
@@ -126,13 +126,13 @@
|
||||
<div id="standings">
|
||||
<h1>Výsledky</h1>
|
||||
<table style="width: auto;">
|
||||
{% for series in status['standings'] %}
|
||||
<tr>
|
||||
<th>{{ players[0] }}</th>
|
||||
<th>{{ players[1] }}</th>
|
||||
<th>{{ players[2] }}</th>
|
||||
<th>{{ players[3] }}</th>
|
||||
</tr>
|
||||
{% for series in status['standings'] %}
|
||||
{% if series %}
|
||||
{% for round in series %}
|
||||
{% if round %}
|
||||
@@ -145,6 +145,11 @@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<tr id="points_summary_row">
|
||||
{% for player in points_sums %}
|
||||
<td class="points">{{ player }}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</table>
|
||||
</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