Private
Public Access
1
0

chg: usr: improve the Battle reports to change unnecessary data with interesting data #5

This commit is contained in:
2026-04-18 17:56:50 +02:00
parent c00ed57240
commit 9aef27a0eb
2 changed files with 58 additions and 5 deletions

View File

@@ -111,6 +111,23 @@
<span class="bshare-player__side">Blue</span>
</div>
</div>
{% set durationSec = (game.created and game.updated) ? (game.updated|date('U') - game.created|date('U')) : 0 %}
{% set durationStr = '' %}
{% if durationSec > 0 %}
{% set h = (durationSec / 3600)|round(0, 'floor') %}
{% set m = ((durationSec % 3600) / 60)|round(0, 'floor') %}
{% set s = durationSec % 60 %}
{% if h > 0 %}
{% set durationStr = h ~ 'h ' ~ m ~ 'm ' ~ s ~ 's' %}
{% elseif m > 0 %}
{% set durationStr = m ~ 'm ' ~ s ~ 's' %}
{% else %}
{% set durationStr = s ~ 's' %}
{% endif %}
{% endif %}
{% set pointDiff = (redPts|default(0) - bluePts|default(0))|abs %}
{% set winnerName = redPts|default(0) > bluePts|default(0) ? redName : (bluePts|default(0) > redPts|default(0) ? blueName : null) %}
<div class="bshare-details">
{% if resign %}
<div class="bshare-detail">
@@ -118,16 +135,28 @@
<span>{{ resign|capitalize }} resigned</span>
</div>
{% endif %}
{% if durationStr %}
<div class="bshare-detail">
<i class="fas fa-hourglass-half"></i>
<span>Match duration: {{ durationStr }}</span>
</div>
{% endif %}
{% if pointDiff > 0 and winnerName %}
<div class="bshare-detail">
<i class="fas fa-balance-scale"></i>
<span>{{ winnerName }} won by {{ pointDiff }} mine{{ pointDiff == 1 ? '' : 's' }}</span>
</div>
{% endif %}
{% if game.redExplodedBomb %}
<div class="bshare-detail bshare-detail--bomb">
<i class="fas fa-bomb"></i>
<span>{{ redName }} hit a mine</span>
<span>{{ redName }} used their bomb</span>
</div>
{% endif %}
{% if game.blueExplodedBomb %}
<div class="bshare-detail bshare-detail--bomb">
<i class="fas fa-bomb"></i>
<span>{{ blueName }} hit a mine</span>
<span>{{ blueName }} used their bomb</span>
</div>
{% endif %}
{% if game.updated %}