BUILD201 (2026.11.05.2) — исправить снятие одиночного удаления и убрать ШБ

This commit is contained in:
2026-11-05 12:28:13 +03:00
parent 2a243e3441
commit 357a631207
18 changed files with 1546 additions and 93 deletions

View File

@@ -4295,34 +4295,6 @@ function startCustomTooltips() {
return "unknown";
}
function hockeyScorePenaltyShotArmed() {
const pending = state.hockeyScorePenaltyShotPending;
if (pending?.context === hockeyGoalPenaltyContext()) return pending.desired;
return hockeyMatchFlags().score_penalty_shot === true;
}
async function hockeySetScorePenaltyShotArmed(enabled) {
if (!hockeyCanControl() || !hockeyTimerSelectedGameId()) return false;
const ticket = { context: hockeyGoalPenaltyContext(), desired: enabled === true };
state.hockeyScorePenaltyShotPending = ticket;
const current = () => hockeyCanControl() && ticket.context === hockeyGoalPenaltyContext()
&& state.hockeyScorePenaltyShotPending === ticket;
const job = (async () => {
try {
const saved = await hockeySetMatchFlags({ score_penalty_shot: ticket.desired });
if (!current()) return false;
if (!saved) throw new Error("Не сохранён режим штрафного броска");
return true;
} finally {
if (state.hockeyScorePenaltyShotPending === ticket) state.hockeyScorePenaltyShotPending = null;
renderHockeyQuickCommandDock({ force: true });
}
})();
ticket.promise = job;
renderHockeyQuickCommandDock({ force: true });
return job;
}
function hockeyGoalPenaltyRemaining(event, now = performance.now()) {
const elapsed = event?.running ? Math.max(0, now - Number(event.lastTimestamp || now)) : 0;
return Math.max(0, Number(event?.remainingMs || 0) - elapsed);
@@ -4351,7 +4323,9 @@ function startCustomTooltips() {
const allowed = new Set(goal.penaltyKeys || []);
const now = performance.now();
const serving = entries.filter(({ component, event }) => (!goal.penaltyKeys || allowed.has(penaltyMirrorKey(component, event)))
&& hockeyPenaltyHasStarted(event) && !event.finished && hockeyGoalPenaltyRemaining(event, now) > 0
// Ready penalties already affect scoreboard strength and may have a
// visible stopped plate before the operator starts their Countdown.
&& hockeyEventReady(event) && !event.finished && hockeyGoalPenaltyRemaining(event, now) > 0
&& !event.queued && !event.awaitingStart && !event.coincidental && !event.offsetting
&& !event.infraction?.coincidental && !event.infraction?.offsetting
&& !["misconduct", "game_misconduct"].includes(String(event.penaltyKind || event.penalty_kind || event.infraction?.penalty_kind || "").toLowerCase())
@@ -4733,14 +4707,7 @@ function startCustomTooltips() {
if (plan.reason === "equal_minor_choice_required") toast("Равные остатки малых штрафов: выберите нужное удаление и завершите его по решению судьи", true);
if (plan.reason === "unresolved_penalty_queue" || plan.reason === "previous_goal_unresolved") toast("Сначала проверьте неподтверждённое удаление или очередь штрафов; автоматическое снятие не выполнено", true);
}
const consumption = (async () => {
if (!goal.consumePenaltyShotFlag) return true;
const pending = state.hockeyScorePenaltyShotPending;
if (pending?.context === goal.context && pending.promise) { try { await pending.promise; } catch (_) {} }
if (!workspaceCurrent()) return false;
return Boolean(await hockeySetMatchFlags({ score_penalty_shot: false }));
})();
const [saved, consumed] = await Promise.allSettled([hockeyPersistGameTimers(goal.gameId, { force: true }), consumption]);
const [saved] = await Promise.allSettled([hockeyPersistGameTimers(goal.gameId, { force: true })]);
if (!workspaceCurrent()) return { skipped: true };
if (committed) {
hockeySyncPenaltySideMappingContext({ force: true }).catch(() => {});
@@ -4748,7 +4715,6 @@ function startCustomTooltips() {
else emitHockeyEventUpdated(committed.component, committed.event, "goal-next-minor");
}
if (saved.status !== "fulfilled" || !saved.value) toast("vMix подтверждён, но сохранение удаления не подтверждено; проверьте журнал", true);
if (goal.consumePenaltyShotFlag && (consumed.status !== "fulfilled" || !consumed.value)) toast("Гол с ШБ учтён. Не подтверждён сброс исключения ШБ: снимите его вручную", true);
return { ok: saved.status === "fulfilled" && Boolean(saved.value), result: plan.reason, transport: marker.goal.transport || "not_needed" };
}
@@ -4897,14 +4863,12 @@ function startCustomTooltips() {
// later activation. Both observation and dispatch must share this gate epoch.
if (!hockeyScoreboardAuxiliariesEnabled()) return null;
const after = { home: current.home, away: current.away };
const pendingShot = state.hockeyScorePenaltyShotPending;
const armedShot = pendingShot?.context === context ? pendingShot.desired : control.flags?.score_penalty_shot === true;
const sourceKind = String(goalType || score.goal_type || score.last_goal_type || control.last_goal_type || "").toLowerCase().replace(/[\s-]+/g, "_");
const penaltyShot = armedShot || ["penalty_shot", "penaltyshot", "ps"].includes(sourceKind);
const penaltyShot = ["penalty_shot", "penaltyshot", "ps"].includes(sourceKind);
const goal = { gameId: String(gameId), context, side, before, after, phase: current.phase,
auxiliariesEnabled: true, auxiliaryVersion: state.hockeyAuxiliaryGateVersion || 0,
kind: penaltyShot ? "penalty_shot" : "normal", consumePenaltyShotFlag: !undo && armedShot && !["so", "shootout", "finished"].includes(current.phase),
strength: clone(control.strength || {}), penaltyKeys: activeHockeyPenaltyEntries().map(({ component, event }) => penaltyMirrorKey(component, event)),
kind: penaltyShot ? "penalty_shot" : "normal",
strength: clone(control.strength || {}), penaltyKeys: currentHockeyPenaltyEntries().map(({ component, event }) => penaltyMirrorKey(component, event)),
key: JSON.stringify([String(gameId), current.phase, before.home, before.away, after.home, after.away]) };
const task = (state.hockeyGoalPenaltyQueue || Promise.resolve()).catch(() => {}).then(() => undo ? hockeyUndoGoalPenalty(goal) : hockeyApplyGoalPenalty(goal));
state.hockeyGoalPenaltyQueue = task.catch((error) => { console.error("Goal penalty resolution failed", error); toast("Не удалось обработать удаление после гола: проверьте журнал", true); });
@@ -11510,8 +11474,6 @@ async function hockeyScoreCommand(command, { refreshMapping = true, announce = t
if (!allowed.has(command)) throw new Error("Неизвестная команда счёта");
const language = hockeyGameControlLanguage();
const ticket = hockeyControlReadContext(gameId);
const pendingShot = state.hockeyScorePenaltyShotPending;
if (/_plus$/.test(command) && pendingShot?.context === hockeyGoalPenaltyContext() && pendingShot.promise) await pendingShot.promise;
const before = hockeyScoreControl();
// Before entering manual mode (and before an explicit resync), resolve only the
// configured score SQL source so the operation starts from the freshest baseline.
@@ -11538,8 +11500,6 @@ function hockeyScoreDockMarkup() {
const game = getByPath(state.data, "hockey.selected_game") || {};
if (!String(game?.external_id || game?.id || "").trim()) return "";
const score = hockeyScoreControl();
const penaltyShot = hockeyScorePenaltyShotArmed();
const penaltyShotPending = state.hockeyScorePenaltyShotPending?.context === hockeyGoalPenaltyContext();
const homeName = String(game?.home?.name || "HOME");
const awayName = String(game?.away?.name || "AWAY");
const tooltip = score.manual
@@ -11555,7 +11515,6 @@ function hockeyScoreDockMarkup() {
<strong>${score.away}</strong>
<button type="button" data-hockey-score-command="away_plus" aria-label="AWAY плюс гол">+</button>
<span class="quick-score-team side-away" title="${escapeHtml(awayName)}">${escapeHtml(awayName)}</span>
<button type="button" class="quick-score-sync quick-score-penalty-shot" data-hockey-score-penalty-shot aria-pressed="${penaltyShot ? "true" : "false"}" ${!hockeyCanControl() || penaltyShotPending ? "disabled" : ""} title="Следующий гол — со штрафного броска: малые штрафы не снимаются. После промаха снимите ШБ вручную.">ШБ</button>
<button type="button" class="quick-score-sync" data-hockey-score-command="sync" aria-label="Синхронизировать счёт с SQL/API">↻</button>
<small>${score.manual ? "РУЧН" : "SQL"}</small>
</div>`;
@@ -11700,14 +11659,6 @@ function renderHockeyQuickCommandDock({ force = false } = {}) {
}
});
});
el.runtimeButtonDock.querySelectorAll("[data-hockey-score-penalty-shot]").forEach((control) => control.addEventListener("click", async (event) => {
event.preventDefault(); event.stopPropagation();
if (!hockeyCanControl() || control.dataset.busy === "1") return;
control.dataset.busy = "1";
try { await hockeySetScorePenaltyShotArmed(!hockeyScorePenaltyShotArmed()); }
catch (error) { toast(`Штрафной бросок: ${String(error?.message || error)}`, true); }
finally { delete control.dataset.busy; }
}));
el.runtimeButtonDock.querySelectorAll("[data-hockey-score-command]").forEach((control) => control.addEventListener("click", async (event) => {
event.preventDefault();
event.stopPropagation();

View File

@@ -7891,9 +7891,6 @@ body.hockey-navigation-open .runtime-viewport.has-hockey-pbp { gap: 14px !import
}
.quick-score-control i{color:#647d99;font-style:normal;font-size:13px;font-weight:950}
.quick-score-control .quick-score-sync{width:27px;color:#87a0bc;font-size:13px}
.quick-score-control .quick-score-penalty-shot{width:29px;font-size:10px;letter-spacing:.02em}
.quick-score-control .quick-score-penalty-shot[aria-pressed="true"]{color:#fff2be;border-color:#c49b41;background:#624b20}
.quick-score-control .quick-score-penalty-shot:disabled{opacity:.55;cursor:default}
.quick-score-control small{
min-width:29px;
padding:3px 4px;