Skip to content

Commit f3f5b4a

Browse files
committed
addressed review comments
1 parent 662e714 commit f3f5b4a

4 files changed

Lines changed: 22 additions & 12 deletions

File tree

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# the user has activated it (or has direnv loaded). `make venv` creates it.
33
export PATH := $(CURDIR)/.venv/bin:$(PATH)
44

5-
.PHONY: ci lint format format-check test install-dev run venv init build
5+
.PHONY: ci lint format format-check test install-dev run venv init build frontend-lint frontend-type-check
66

77
# Run all CI checks — called by GitHub Actions.
8-
ci: lint format-check frontend-lint test
8+
ci: lint format-check frontend-lint frontend-type-check test
99

1010
# ── Python ──────────────────────────────────────────────────────────────────
1111

@@ -27,6 +27,9 @@ test:
2727
frontend-lint:
2828
npm --prefix frontend run lint
2929

30+
frontend-type-check:
31+
npm --prefix frontend run type-check
32+
3033
# ── Dev setup ────────────────────────────────────────────────────────────────
3134

3235
venv:

frontend/src/components/HostBoard.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const emit = defineEmits<{
99
const game = useGameStore();
1010
1111
const rowHeight = computed(
12-
() => `${Math.floor(100 / (game.config.QUESTIONS_PER_CATEGORY ?? 5))}%`,
12+
() => `${Math.floor(100 / game.questionsPerCategory)}%`,
1313
);
1414
1515
// Accent colours used in the little answer pills next to each question.
@@ -60,7 +60,7 @@ function onClick(col: number, row: number): void {
6060
<div class="container-questions-host">
6161
<div class="black-box flex-small-pad">
6262
<div
63-
v-for="row in game.config.QUESTIONS_PER_CATEGORY"
63+
v-for="row in game.questionsPerCategory"
6464
:key="row"
6565
class="row-ceopardy flex-vertical-small-pad"
6666
:style="{ height: rowHeight }"
@@ -93,7 +93,7 @@ function onClick(col: number, row: number): void {
9393
</div>
9494
</div>
9595
<div class="box-question-right">
96-
<p>${{ row * (game.config.SCORE_TICK ?? 100) }}</p>
96+
<p>${{ row * game.scoreTick }}</p>
9797
</div>
9898
</div>
9999
</div>

frontend/src/components/ViewerBoard.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TeamRowDailyDouble from "@/components/TeamRowDailyDouble.vue";
99
const game = useGameStore();
1010
1111
const rowHeight = computed(
12-
() => `${Math.floor(100 / (game.config.QUESTIONS_PER_CATEGORY ?? 5))}%`,
12+
() => `${Math.floor(100 / game.questionsPerCategory)}%`,
1313
);
1414
1515
const showCategoriesRow = computed(
@@ -26,7 +26,7 @@ function isAnswered(col: number, row: number): boolean {
2626
}
2727
2828
function questionLabel(row: number): string {
29-
return `$${row * (game.config.SCORE_TICK ?? 100)}`;
29+
return `$${row * game.scoreTick}`;
3030
}
3131
</script>
3232

@@ -71,7 +71,7 @@ function questionLabel(row: number): string {
7171
<div class="container-questions-viewer">
7272
<div class="black-box flex-pad">
7373
<div
74-
v-for="row in game.config.QUESTIONS_PER_CATEGORY"
74+
v-for="row in game.questionsPerCategory"
7575
:key="row"
7676
class="row-ceopardy flex-vertical-pad"
7777
:style="{ height: rowHeight }"

frontend/src/stores/game.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export const useGameStore = defineStore("game", {
6161
initialized: false,
6262
config: {}, // populated from /api/v1/state on connect
6363
game_state: "uninitialized",
64-
teams: [],
65-
categories: [],
66-
questions: {},
64+
teams: [], // [{tid, name, score}]
65+
categories: [], // ['Cat1', ...]
66+
questions: {}, // { c1q1: { answered: bool, team_scores: {team1: 100} } }
6767
ui_state: {
6868
question: "",
6969
team: "",
@@ -78,7 +78,8 @@ export const useGameStore = defineStore("game", {
7878
active_question: {},
7979
messages: [],
8080
dailydouble_range: { min: 0, max: 0 },
81-
// null outside DD or before the operator has nudged the wager slider.
81+
// {team, amount} as the host moves the wager slider during a DD; null
82+
// outside DD or before the operator has set anything.
8283
dailydouble_wager: null,
8384
dailydoubleTrigger: 0,
8485
socket: null,
@@ -88,6 +89,12 @@ export const useGameStore = defineStore("game", {
8889
}),
8990

9091
getters: {
92+
// Config getters with sane defaults so components can use them without
93+
// having to guard against the brief window between mount and the first
94+
// /api/v1/state response.
95+
questionsPerCategory: (s): number => s.config.QUESTIONS_PER_CATEGORY ?? 5,
96+
scoreTick: (s): number => s.config.SCORE_TICK ?? 100,
97+
9198
isInProgress: (s): boolean =>
9299
s.game_state === "in_round" || s.game_state === "in_final",
93100
isFinished: (s): boolean => s.game_state === "finished",

0 commit comments

Comments
 (0)