feat(mm): wait longer for a real opponent; add "start with bots now"
CI/CD / CI - API (dotnet build + engine sim) (push) Successful in 34s
CI/CD / CI - Web (tsc + next build) (push) Successful in 1m9s
CI/CD / Deploy - local stack (db + server + web) (push) Successful in 1m8s

- server: a lone player in the online-league queue now keeps waiting (re-checking
  every 15s) up to 75s so an online opponent has a real chance to join; the moment
  a 2nd human queues they're matched together, and a full 4 still forms instantly.
  Add PlayNow hub method to force-start with bots on demand.
- client: matchmaking screen shows a "شروع با ربات / Start with bots" button after
  a few seconds so the player can skip the wait; waiting copy updated; raise the
  "connection stuck" hint threshold to 90s so it no longer fires during normal waits.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-16 22:12:48 +03:30
parent 9901c5e6d4
commit c0e3fdb046
7 changed files with 100 additions and 13 deletions
+23 -2
View File
@@ -60,6 +60,15 @@ export function MatchmakingScreen() {
go("online");
};
// Stop waiting for an online opponent — start immediately with bots.
const startNow = async () => {
try {
await getService().playNow();
} catch {
/* ignore — server will still fall back to bots after the wait window */
}
};
const enter = () => {
const players = getService().getMatchPlayers();
if (!players) return;
@@ -131,7 +140,7 @@ export function MatchmakingScreen() {
{searching && (
<>
<div className="mt-2 text-3xl font-black gold-text tabular-nums">{elapsed}s</div>
{elapsed >= 28 ? (
{elapsed >= 90 ? (
<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>
@@ -185,10 +194,22 @@ export function MatchmakingScreen() {
})}
</div>
<div className="mt-10 flex gap-3">
<div className="mt-10 flex flex-wrap items-center justify-center gap-3">
<button onClick={cancel} className="press-3d glass rounded-2xl px-6 py-3 text-cream/70">
{t("mm.cancel")}
</button>
{/* After a few seconds of waiting, let the player skip the wait and
start against bots instead of waiting for a real opponent. */}
{searching && elapsed >= 5 && (
<motion.button
initial={{ scale: 0.8, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
onClick={startNow}
className="press-3d btn-gold rounded-2xl px-6 py-3"
>
{t("mm.playNow")}
</motion.button>
)}
{ready && (
<motion.button
initial={{ scale: 0.8, opacity: 0 }}