Skip to content

Commit eeca3f4

Browse files
committed
Enh(viewer): Better show of results
1 parent 2d5576d commit eeca3f4

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

codeclash/viewer/templates/index.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,31 @@ <h3>
341341
<!-- Round Results (if available) -->
342342
{% if round_data.results %}
343343
<details class="foldout round-foldout">
344-
<summary>🏆 Round {{ round_num }} Results</summary>
344+
<summary>
345+
🏆 Round {{ round_num }} Results
346+
{% if round_data.results.winner and round_data.results.scores %}
347+
{%- set total_games = round_data.results.scores.values() | sum -%}
348+
{%- set winner = round_data.results.winner -%}
349+
{%- if winner != 'Tie' -%}
350+
{%- set winner_wins = round_data.results.scores.get(winner, 0) -%}
351+
{%- set ties = round_data.results.scores.get('Tie', 0) -%}
352+
{%- set win_percentage = ((winner_wins + 0.5 * ties) / total_games * 100) | round(1) -%}
353+
- Winner: {{ winner }} with {{ win_percentage }}% (
354+
{%- for player, score in round_data.results.scores.items() -%}
355+
{{- score -}}
356+
{%- if not loop.last -%}-{%- endif -%}
357+
{%- endfor -%})
358+
{%- else -%}
359+
- Winner: Tie (
360+
{%- for player, score in round_data.results.scores.items() -%}
361+
{{- score -}}
362+
{%- if not loop.last -%}-{%- endif -%}
363+
{%- endfor -%})
364+
{%- endif -%}
365+
{% elif round_data.results.winner %}
366+
- Winner: {{ round_data.results.winner }}
367+
{% endif %}
368+
</summary>
345369
<div class="log-content">
346370
<div id="round-{{ round_num }}-results-jsoneditor" class="json-viewer"></div>
347371
</div>

0 commit comments

Comments
 (0)