Commit c8915915 authored by Mahmoud Aglan's avatar Mahmoud Aglan

feat(tournaments): what happens when a player drops mid-game

The tournament form sets how long a game waits for a player who drops
(1 to 60 minutes) and what happens then: they lose, or the game is a draw
(chess; the other games have no draw, so the absent player loses). The
tournament page shows the rule. The player app reads both from
el3ab_tournaments (migration 2026-10-27-disconnect-rules.sql there).
Co-Authored-By: 's avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 6853d8e8
...@@ -756,6 +756,9 @@ class TournamentsController ...@@ -756,6 +756,9 @@ class TournamentsController
'registration_opens_at' => $opensAt, 'registration_opens_at' => $opensAt,
'registration_closes_at' => $closesAt, 'registration_closes_at' => $closesAt,
'auto_start' => !empty($_POST['auto_start']), 'auto_start' => !empty($_POST['auto_start']),
// A player who drops mid-game: how long the table waits, then the rule.
'disconnect_grace_seconds' => 60 * max(1, min(60, (int)($_POST['disconnect_grace_minutes'] ?? 2))),
'disconnect_outcome' => ($_POST['disconnect_outcome'] ?? 'forfeit') === 'draw' ? 'draw' : 'forfeit',
'is_rated' => !empty($_POST['is_rated']), 'is_rated' => !empty($_POST['is_rated']),
'org_id' => $orgId !== '' ? $orgId : null, 'org_id' => $orgId !== '' ? $orgId : null,
'banner_url' => trim((string)($_POST['banner_url'] ?? '')) ?: null, 'banner_url' => trim((string)($_POST['banner_url'] ?? '')) ?: null,
......
...@@ -531,6 +531,30 @@ $builder = [ ...@@ -531,6 +531,30 @@ $builder = [
</div> </div>
</div> </div>
<?php
$graceMin = max(1, min(60, (int)round(((int)($t['disconnect_grace_seconds'] ?? 120)) / 60)));
$dcOutcome = ($t['disconnect_outcome'] ?? 'forfeit') === 'draw' ? 'draw' : 'forfeit';
?>
<div class="grid grid-2 gap-4">
<div class="form-group">
<label class="form-label" for="f-dcgrace">لو لاعب فصل في نص الماتش، نستناه</label>
<select name="disconnect_grace_minutes" id="f-dcgrace" class="form-input">
<?php foreach ([1, 2, 3, 5, 10, 15, 30, 60] as $m): ?>
<option value="<?= $m ?>" <?= $graceMin === $m ? 'selected' : '' ?>><?= $m ?> <?= $m <= 10 && $m > 2 ? 'دقايق' : ($m === 2 ? 'دقيقتين' : 'دقيقة') ?></option>
<?php endforeach; ?>
</select>
<span class="form-hint">ساعة الشطرنج بتفضل شغالة وهو غايب</span>
</div>
<div class="form-group">
<label class="form-label" for="f-dcoutcome">ولو مرجعش</label>
<select name="disconnect_outcome" id="f-dcoutcome" class="form-input">
<option value="forfeit" <?= $dcOutcome === 'forfeit' ? 'selected' : '' ?>>يخسر الماتش، والتاني يكسب</option>
<option value="draw" <?= $dcOutcome === 'draw' ? 'selected' : '' ?>>الماتش تعادل</option>
</select>
<span class="form-hint">التعادل للشطرنج بس؛ باقي الألعاب الغايب بيخسر</span>
</div>
</div>
<div class="grid grid-2 gap-4"> <div class="grid grid-2 gap-4">
<div class="form-group"> <div class="form-group">
<label class="form-label" for="f-ropen">فتح التسجيل</label> <label class="form-label" for="f-ropen">فتح التسجيل</label>
......
...@@ -272,6 +272,11 @@ foreach ([ ...@@ -272,6 +272,11 @@ foreach ([
<span class="info-label">بدء تلقائي</span> <span class="info-label">بدء تلقائي</span>
<span class="info-value"><?= !empty($tournament['auto_start']) ? 'نعم، في الموعد إن اكتمل العدد' : 'لا، يبدأ يدويًا' ?></span> <span class="info-value"><?= !empty($tournament['auto_start']) ? 'نعم، في الموعد إن اكتمل العدد' : 'لا، يبدأ يدويًا' ?></span>
</div> </div>
<div class="info-item">
<span class="info-label">لو لاعب فصل</span>
<?php $dcMin = max(1, (int)round(((int)($tournament['disconnect_grace_seconds'] ?? 120)) / 60)); ?>
<span class="info-value">نستناه <?= $dcMin ?> دقيقة، وبعدها <?= ($tournament['disconnect_outcome'] ?? 'forfeit') === 'draw' ? 'تعادل' : 'يخسر' ?></span>
</div>
<div class="info-item"> <div class="info-item">
<span class="info-label">فتح التسجيل (القاهرة)</span> <span class="info-label">فتح التسجيل (القاهرة)</span>
<span class="info-value tabular-nums"><?= Time::show($tournament['registration_opens_at'] ?? null, 'Y/m/d H:i', 'غير محدد') ?></span> <span class="info-value tabular-nums"><?= Time::show($tournament['registration_opens_at'] ?? null, 'Y/m/d H:i', 'غير محدد') ?></span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment