fix tiebreaker handling
This commit is contained in:
@@ -167,9 +167,19 @@ export const actions: Actions = {
|
||||
const sorted = [...updated.participants].sort(
|
||||
(a: any, b: any) => (a.pickOrder ?? 99) - (b.pickOrder ?? 99)
|
||||
);
|
||||
lobby.chat(
|
||||
`Rolls complete! ${sorted[0]?.team.name} picks first. Use !pick <slot> (e.g. !pick NM1) or pick in web UI.`
|
||||
).catch(() => {});
|
||||
const rollConfig = updated.config as MatchConfig;
|
||||
const rollWinsNeeded = Math.ceil(rollConfig.bestOf / 2);
|
||||
const isTBRoll = updated.participants.every((p: any) => p.score === rollWinsNeeded - 1);
|
||||
|
||||
if (isTBRoll) {
|
||||
lobby.chat(
|
||||
`Rolls complete! ${sorted[0]?.team.name} picks the tiebreaker. Use !pick TB<n> or pick in web UI.`
|
||||
).catch(() => {});
|
||||
} else {
|
||||
lobby.chat(
|
||||
`Rolls complete! ${sorted[0]?.team.name} picks first. Use !pick <slot> (e.g. !pick NM1) or pick in web UI.`
|
||||
).catch(() => {});
|
||||
}
|
||||
} else if (isLastRoll && updated.participants.every((p: any) => p.rollValue === null)) {
|
||||
lobby.chat(`Tie! All players rolled ${value}. Please !roll again.`).catch(() => {});
|
||||
}
|
||||
@@ -205,16 +215,17 @@ export const actions: Actions = {
|
||||
return { error: "It's not your turn to pick" };
|
||||
}
|
||||
|
||||
// ── Tiebreaker restriction ──
|
||||
// TB maps can only be picked when both teams are at match point (e.g. 2-2 in BO5)
|
||||
// ── Tiebreaker restrictions ──
|
||||
const config = m.config as MatchConfig;
|
||||
const winsNeeded = Math.ceil(config.bestOf / 2);
|
||||
const allAtMatchPoint = m.participants.every((p) => p.score === winsNeeded - 1);
|
||||
const slot = m.mappool?.slots?.find((s) => s.id === slotId);
|
||||
if (slot?.category === 'TB') {
|
||||
const allAtMatchPoint = m.participants.every((p) => p.score === winsNeeded - 1);
|
||||
if (!allAtMatchPoint) {
|
||||
return { error: 'Tiebreaker can only be picked when both teams are at match point' };
|
||||
}
|
||||
|
||||
if (slot?.category === 'TB' && !allAtMatchPoint) {
|
||||
return { error: 'Tiebreaker can only be picked when both teams are at match point' };
|
||||
}
|
||||
if (allAtMatchPoint && slot?.category !== 'TB') {
|
||||
return { error: 'Only tiebreaker maps can be picked at match point' };
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -253,8 +253,8 @@
|
||||
{#if m.state === 'ROLLING'}
|
||||
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm">
|
||||
<div class="w-full max-w-md rounded-xl border border-yellow-500/30 bg-surface-800 p-8 text-center shadow-2xl">
|
||||
<h2 class="text-lg font-700">🎲 Roll Phase</h2>
|
||||
<p class="mt-2 text-sm text-text-secondary">Highest roll picks first</p>
|
||||
<h2 class="text-lg font-700">{isTiebreakerAllowed ? '🔥 Tiebreaker Roll' : '🎲 Roll Phase'}</h2>
|
||||
<p class="mt-2 text-sm text-text-secondary">{isTiebreakerAllowed ? 'Highest roll picks the tiebreaker' : 'Highest roll picks first'}</p>
|
||||
|
||||
<div class="mt-6 flex justify-center gap-6">
|
||||
{#each m.participants as p}
|
||||
@@ -425,11 +425,13 @@
|
||||
{@const isPlayed = playedSlotIds.has(slot.id)}
|
||||
{@const isTB = slot.category === 'TB'}
|
||||
{@const tbLocked = isTB && !isTiebreakerAllowed}
|
||||
{@const matchPointLocked = !isTB && isTiebreakerAllowed}
|
||||
{@const slotLocked = tbLocked || matchPointLocked}
|
||||
{@const cantPick = !isMyTurnToPick || !pickingPhase}
|
||||
|
||||
<div class="flex items-center gap-2 rounded-lg border p-2 transition-all {isPlayed
|
||||
? 'border-border/50 bg-surface-900 opacity-30'
|
||||
: tbLocked
|
||||
: slotLocked
|
||||
? 'border-border/50 bg-surface-900 opacity-30'
|
||||
: 'border-border bg-surface-800'}">
|
||||
<a
|
||||
@@ -454,8 +456,8 @@
|
||||
<span class="text-xs font-600 text-text-secondary">{category}{slot.orderInCategory}</span>
|
||||
{#if isPlayed}
|
||||
<span class="text-xs text-text-secondary">✓</span>
|
||||
{:else if tbLocked}
|
||||
<span class="text-[10px] text-pink-400/60" title="Match point only">🔒</span>
|
||||
{:else if slotLocked}
|
||||
<span class="text-[10px] text-pink-400/60" title={tbLocked ? 'Match point only' : 'Tiebreaker only'}>🔒</span>
|
||||
{:else if pickingPhase}
|
||||
<form method="post" action="?/pick" use:enhance={() => {
|
||||
picking = true;
|
||||
|
||||
Reference in New Issue
Block a user