diff --git a/assets/js/components/BattleDialog.jsx b/assets/js/components/BattleDialog.jsx
index 0991af1..ee303f9 100644
--- a/assets/js/components/BattleDialog.jsx
+++ b/assets/js/components/BattleDialog.jsx
@@ -198,6 +198,24 @@ export default function BattleDialog({ games }) {
: 'Points';
const shareUrl = `${window.location.origin}/battle/${game.uuid}`;
+ const formatDuration = (from, to) => {
+ if (!from || !to) return null;
+ const diffMs = new Date(to.replace(' ', 'T')) - new Date(from.replace(' ', 'T'));
+ if (isNaN(diffMs) || 0 >= diffMs) return null;
+ const totalSec = Math.floor(diffMs / 1000);
+ const h = Math.floor(totalSec / 3600);
+ const m = Math.floor((totalSec % 3600) / 60);
+ const s = totalSec % 60;
+ if (0 < h) return `${h}h ${m}m ${s}s`;
+ if (0 < m) return `${m}m ${s}s`;
+ return `${s}s`;
+ };
+ const duration = formatDuration(game.created, game.date);
+ const pointDiff = Math.abs((game.redPoints ?? 0) - (game.bluePoints ?? 0));
+ const winnerColor = (game.redPoints ?? 0) > (game.bluePoints ?? 0) ? '#f67d52'
+ : (game.bluePoints ?? 0) > (game.redPoints ?? 0) ? '#95cff5'
+ : 'rgba(255,255,255,0.45)';
+
const handleShare = () => {
navigator.clipboard.writeText(shareUrl).then(() => {
setCopied(true);
@@ -261,15 +279,21 @@ export default function BattleDialog({ games }) {
+ {duration && (
+
+ )}
+ {0 < pointDiff && (
+
+ )}
{game.created && game.date && game.created !== game.date && (
diff --git a/templates/Game/battle_share.html.twig b/templates/Game/battle_share.html.twig
index 878d137..32008b8 100644
--- a/templates/Game/battle_share.html.twig
+++ b/templates/Game/battle_share.html.twig
@@ -111,6 +111,23 @@
Blue
+ {% 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) %}
+
{% if resign %}
@@ -118,16 +135,28 @@
{{ resign|capitalize }} resigned
{% endif %}
+ {% if durationStr %}
+
+
+ Match duration: {{ durationStr }}
+
+ {% endif %}
+ {% if pointDiff > 0 and winnerName %}
+
+
+ {{ winnerName }} won by {{ pointDiff }} mine{{ pointDiff == 1 ? '' : 's' }}
+
+ {% endif %}
{% if game.redExplodedBomb %}
- {{ redName }} hit a mine
+ {{ redName }} used their bomb
{% endif %}
{% if game.blueExplodedBomb %}
- {{ blueName }} hit a mine
+ {{ blueName }} used their bomb
{% endif %}
{% if game.updated %}