tune(mm): cap the solo wait at 25s (was 75s)
- full table of 4 humans still starts instantly at any time - at the 15s checkpoint, 2+ humans start together (bots fill empty seats) - a lone player now waits until a precise 25s deadline, then AI fills and starts - lower the client "connection stuck" hint to 40s to match the shorter wait Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,14 +17,15 @@ public sealed class Player
|
|||||||
/// <summary>In-memory matchmaking + room registry. (EF/Postgres persistence is a TODO.)</summary>
|
/// <summary>In-memory matchmaking + room registry. (EF/Postgres persistence is a TODO.)</summary>
|
||||||
public sealed partial class GameManager
|
public sealed partial class GameManager
|
||||||
{
|
{
|
||||||
// Real players get priority. We re-check the queue every QueueWaitMs; the
|
// Real players get priority:
|
||||||
// moment a second human is waiting they're matched together (+ bots for any
|
// • a full table of 4 humans forms instantly, at any time;
|
||||||
// empty seats), and a full group of 4 forms instantly. A player left ALONE
|
// • at the 15s checkpoint, if ≥2 humans are waiting they start together
|
||||||
// keeps waiting up to MaxAloneWaitMs so an online opponent has a genuine
|
// (bots fill any empty seats);
|
||||||
// chance to join before we fall back to a bot table. (QueueWaitMs mirrors
|
// • a player left ALONE keeps waiting until the 25s hard deadline, then we
|
||||||
// MATCH_QUEUE_WAIT_MS on the client — keep both in sync.)
|
// fill the seats with AI and start.
|
||||||
|
// (QueueWaitMs mirrors MATCH_QUEUE_WAIT_MS on the client — keep both in sync.)
|
||||||
private const int QueueWaitMs = 15000;
|
private const int QueueWaitMs = 15000;
|
||||||
private const int MaxAloneWaitMs = 75000;
|
private const int MaxAloneWaitMs = 25000;
|
||||||
|
|
||||||
private static readonly string[] BotNames =
|
private static readonly string[] BotNames =
|
||||||
{ "آرش", "کیان", "نیلوفر", "سارا", "رضا", "مهسا", "امیر", "پارسا", "الناز", "بابک" };
|
{ "آرش", "کیان", "نیلوفر", "سارا", "رضا", "مهسا", "امیر", "پارسا", "الناز", "بابک" };
|
||||||
@@ -102,12 +103,14 @@ public sealed partial class GameManager
|
|||||||
// bots fill any empty chairs (real players matched immediately).
|
// bots fill any empty chairs (real players matched immediately).
|
||||||
if (_waiting.Count >= 2) { FormGroupLocked(_waiting.Count); return; }
|
if (_waiting.Count >= 2) { FormGroupLocked(_waiting.Count); return; }
|
||||||
|
|
||||||
// Alone: keep the table open for an online opponent until the max wait
|
// Alone: keep the table open for an online opponent until the 25s
|
||||||
// elapses, then fall back to a bot table. Re-arm the re-check timer.
|
// deadline, then fill the seats with AI. Re-arm the timer to land
|
||||||
|
// exactly on the deadline rather than overshooting by a full window.
|
||||||
var waited = (DateTime.UtcNow - _waiting[idx].since).TotalMilliseconds;
|
var waited = (DateTime.UtcNow - _waiting[idx].since).TotalMilliseconds;
|
||||||
if (waited < MaxAloneWaitMs)
|
var remaining = MaxAloneWaitMs - waited;
|
||||||
|
if (remaining > 250)
|
||||||
{
|
{
|
||||||
_waiting[idx].timer.Change(QueueWaitMs, Timeout.Infinite);
|
_waiting[idx].timer.Change((int)remaining, Timeout.Infinite);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FormGroupLocked(1);
|
FormGroupLocked(1);
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ export function MatchmakingScreen() {
|
|||||||
{searching && (
|
{searching && (
|
||||||
<>
|
<>
|
||||||
<div className="mt-2 text-3xl font-black gold-text tabular-nums">{elapsed}s</div>
|
<div className="mt-2 text-3xl font-black gold-text tabular-nums">{elapsed}s</div>
|
||||||
{elapsed >= 90 ? (
|
{elapsed >= 40 ? (
|
||||||
<p className="text-rose-300 text-xs mt-2 max-w-[18rem]">{t("mm.stuck")}</p>
|
<p className="text-rose-300 text-xs mt-2 max-w-[18rem]">{t("mm.stuck")}</p>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-cream/50 text-xs mt-1 max-w-[16rem]">{t("mm.fillHint")}</p>
|
<p className="text-cream/50 text-xs mt-1 max-w-[16rem]">{t("mm.fillHint")}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user