Skip to content

Commit 13dfb5f

Browse files
committed
убрал таблица пожертвований с 1 и 2ой доски квиза и убрал таблицу подертвований после начисления очков, "С глаз долой из сердца вон!"(С).
1 parent 840dbb5 commit 13dfb5f

7 files changed

Lines changed: 47 additions & 2 deletions

File tree

artifacts/api-server/src/adepts.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
applyPickCell,
1313
applyPlayerDonation,
1414
applyHostMounts400DedDonationDoubleReward,
15+
clearHideDonationsTableOnBoard3,
1516
cloneQuizRelay,
1617
getQuizRelayOrDefault,
1718
} from "./lib/adepts-quiz-room-store";
@@ -312,6 +313,11 @@ export function setupAdepts(io: Server): void {
312313
run();
313314
return;
314315
}
316+
case "showDonationsTableOnBoard3": {
317+
clearHideDonationsTableOnBoard3(sessionId);
318+
run();
319+
return;
320+
}
315321
case "hostClearActiveCard": {
316322
if (!host) return;
317323
applyHostClearActiveCard(sessionId);

artifacts/api-server/src/lib/adepts-quiz-relay-types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export type AdeptsQuizRelayPayload = {
3737
dataVersion?: number;
3838
/** Журнал пожертвований. */
3939
donationLog?: AdeptsDonationLogEntry[];
40+
/** После бонуса ×2 с «деда» на 400 — скрыть таблицу на квиз-доске 3; сброс при входе на похороны. */
41+
hideDonationsTableOnBoard3?: boolean;
4042
};
4143

4244
const THEME_COUNT = 8;
@@ -60,6 +62,7 @@ export function defaultQuizRelayPayload(sessionId: string): AdeptsQuizRelayPaylo
6062
questionUsedGrid,
6163
dataVersion: 59,
6264
donationLog: [],
65+
hideDonationsTableOnBoard3: false,
6366
};
6467
}
6568

artifacts/api-server/src/lib/adepts-quiz-room-store.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export function getQuizRelayOrDefault(sessionId: string): AdeptsQuizRelayPayload
4747
if (!Array.isArray(s.donationLog)) {
4848
s.donationLog = [];
4949
}
50+
if (s.hideDonationsTableOnBoard3 === undefined) {
51+
s.hideDonationsTableOnBoard3 = false;
52+
}
5053
return s;
5154
}
5255

@@ -109,10 +112,18 @@ export function setQuizRelayFull(sessionId: string, payload: AdeptsQuizRelayPayl
109112
if (Array.isArray(payload.themes) && payload.themes.length > 0) {
110113
base.themes = payload.themes.map((x) => String(x ?? "").trim().slice(0, 64));
111114
}
115+
if (typeof payload.hideDonationsTableOnBoard3 === "boolean") {
116+
base.hideDonationsTableOnBoard3 = payload.hideDonationsTableOnBoard3;
117+
}
112118
// (lean relay, same board) → keep existing catalog intact so clients that connect later
113119
// still receive the most recently edited catalog for this board.
114120
}
115121

122+
/** Снова показать таблицу пожертвований на 3-й доске (вход на страницу похорон). */
123+
export function clearHideDonationsTableOnBoard3(sessionId: string): void {
124+
getQuizRelayOrDefault(sessionId).hideDonationsTableOnBoard3 = false;
125+
}
126+
116127
export function applyHostQuizRelay(sessionId: string, payload: unknown): { ok: true } | { ok: false; error: string } {
117128
if (!payload || typeof payload !== "object") return { ok: false, error: "payload required" };
118129
const p = payload as AdeptsQuizRelayPayload;
@@ -354,6 +365,7 @@ export function applyHostMounts400DedDonationDoubleReward(
354365
const p = s.players[seat];
355366
if (p) p.score += add;
356367
}
368+
s.hideDonationsTableOnBoard3 = true;
357369
return { ok: true };
358370
}
359371

artifacts/game-client/src/apps/adepts-game/hooks/useGameState.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export type GameState = {
4949
boardRoom?: string;
5050
/** Журнал пожертвований (строки); общий для всех раундов квиза. */
5151
donationLog: DonationLogEntry[];
52+
/** После ×2 с деда на 400 — скрыть таблицу на 3-й доске; сброс при входе на похороны (сервер). */
53+
hideDonationsTableOnBoard3?: boolean;
5254
};
5355

5456
const DEFAULT_PLAYERS: Player[] = Array.from({ length: 5 }, (_, i) => ({
@@ -83,6 +85,7 @@ const DEFAULT_CORE: Omit<GameState, "themes" | "questions"> = {
8385
dataVersion: undefined,
8486
boardRoom: undefined,
8587
donationLog: [...DEFAULT_DONATION_LOG],
88+
hideDonationsTableOnBoard3: false,
8689
};
8790

8891
const PLAYERS_KEY = "adepts-shared-players";
@@ -377,6 +380,10 @@ function loadInitialState(boardId: AdeptsBoardId): GameState {
377380
typeof parsed.quizBoardHoverCell.questionIndex === "number"
378381
? parsed.quizBoardHoverCell
379382
: null,
383+
hideDonationsTableOnBoard3:
384+
typeof parsed.hideDonationsTableOnBoard3 === "boolean"
385+
? parsed.hideDonationsTableOnBoard3
386+
: false,
380387
});
381388
}
382389
} catch (err) {
@@ -482,6 +489,7 @@ export function useGameState(boardId: AdeptsBoardId) {
482489
players: rec["players"],
483490
currentTurnSeat: rec["currentTurnSeat"],
484491
donationLog: rec["donationLog"],
492+
hideDonationsTableOnBoard3: rec["hideDonationsTableOnBoard3"],
485493
// Reset all board-specific fields to safe defaults
486494
activeQuizCard: null,
487495
quizBoardHoverCell: null,
@@ -529,6 +537,10 @@ export function useGameState(boardId: AdeptsBoardId) {
529537
const incomingLog = normalizeDonationLog(recToUse["donationLog"]);
530538
const nextDonationLog = incomingLog ?? prev.donationLog;
531539

540+
const rawHide = recToUse["hideDonationsTableOnBoard3"];
541+
const nextHideDonationsTableOnBoard3 =
542+
typeof rawHide === "boolean" ? rawHide : (prev.hideDonationsTableOnBoard3 ?? false);
543+
532544
let nextState = withClosedActiveQuizIfCellUsed(
533545
migrateCatalog(boardId, {
534546
...prev,
@@ -544,6 +556,7 @@ export function useGameState(boardId: AdeptsBoardId) {
544556
quizBoardHoverCell: hoverFromRelay,
545557
dataVersion:
546558
typeof recToUse["dataVersion"] === "number" ? recToUse["dataVersion"] : prev.dataVersion,
559+
hideDonationsTableOnBoard3: nextHideDonationsTableOnBoard3,
547560
})
548561
);
549562

artifacts/game-client/src/apps/adepts-game/pages/FuneralRoundPage.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ChatPanel } from "@/components/ChatPanel";
88
import { QuizBoardPandoraLottoOverlay } from "@/components/QuizBoardPandoraLottoOverlay";
99
import { DonationsTable } from "@/components/DonationsTable";
1010
import { FuneralDonationHat } from "@/components/FuneralDonationHat";
11-
import { readAdeptsPlayerSeatIndexForSocket } from "@/lib/adeptsCommandSocket";
11+
import { getAdeptsCommandSocket, readAdeptsPlayerSeatIndexForSocket } from "@/lib/adeptsCommandSocket";
1212
import { getQuizNavSocket } from "@/hooks/quizNavSocket";
1313

1414
const BOARD_BG = "/funeral-board-bg.png";
@@ -41,6 +41,11 @@ export default function FuneralRoundPage() {
4141
fetch(`/api/track/${trackKey}`, { method: "POST" }).catch(() => {});
4242
}, [trackKey]);
4343

44+
/** Снова показывать таблицу пожертвований на 3-й квиз-доске после визита на похороны. */
45+
useEffect(() => {
46+
getAdeptsCommandSocket().emit("command", { type: "showDonationsTableOnBoard3" });
47+
}, []);
48+
4449
const bgStyle = useMemo(
4550
() => ({
4651
backgroundImage: `url(${resolveUrl(BOARD_BG)})`,

artifacts/game-client/src/apps/adepts-game/pages/Home.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ export default function Home({ boardId }: { boardId: AdeptsBoardId }) {
190190
</div>
191191
</main>
192192
<aside className="flex min-h-0 min-w-0 flex-col items-end p-2 pt-3">
193-
<DonationsTable donationLog={state.donationLog} />
193+
{boardId === 3 && !state.hideDonationsTableOnBoard3 ? (
194+
<DonationsTable donationLog={state.donationLog} />
195+
) : null}
194196
</aside>
195197
</div>
196198

artifacts/game-client/src/lib/adeptsQuizSocketRelay.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export type AdeptsQuizRelayPayload = {
3636
dataVersion?: number;
3737
/** Журнал пожертвований (строки «ник — сумма»). */
3838
donationLog?: DonationLogEntry[];
39+
/** Скрыть таблицу пожертвований на 3-й доске (после ×2 с деда); сброс на странице похорон. */
40+
hideDonationsTableOnBoard3?: boolean;
3941
};
4042

4143
export function buildAdeptsQuizRelayPayload(
@@ -48,6 +50,7 @@ export function buildAdeptsQuizRelayPayload(
4850
quizBoardHoverCell?: QuizBoardHoverCell | null;
4951
dataVersion?: number;
5052
donationLog: DonationLogEntry[];
53+
hideDonationsTableOnBoard3?: boolean;
5154
},
5255
boardRoom: string,
5356
includeCatalog: boolean,
@@ -61,6 +64,7 @@ export function buildAdeptsQuizRelayPayload(
6164
quizBoardHoverCell: slice.quizBoardHoverCell ?? null,
6265
questionUsedGrid: slice.questions.map((row) => row.map((q) => Boolean(q.used))),
6366
donationLog: normalizeDonationLog(slice.donationLog) ?? [],
67+
hideDonationsTableOnBoard3: slice.hideDonationsTableOnBoard3 === true,
6468
};
6569
if (boardId !== undefined) out.boardId = boardId;
6670
if (slice.dataVersion !== undefined) out.dataVersion = slice.dataVersion;

0 commit comments

Comments
 (0)