@seriousgaming/sdk-tools 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/cli.js +4055 -2646
  2. package/dist/client.js +807 -172
  3. package/dist/core/session-host.d.ts +4 -2
  4. package/dist/core/settings-locks.d.ts +27 -2
  5. package/dist/dev/console/assets/{index-DEV8N0na.js → index-BVF8exas.js} +22 -22
  6. package/dist/dev/console/index.html +1 -1
  7. package/dist/dev/public-origins.d.ts +61 -0
  8. package/dist/dev/routes.d.ts +4 -0
  9. package/dist/dev/shell.d.ts +32 -4
  10. package/dist/dev/view/batch.d.ts +7 -1
  11. package/dist/docs/ai-agents.md +5 -0
  12. package/dist/docs/api/index.md +1 -1
  13. package/dist/docs/api/sdk-tools-client.md +1 -0
  14. package/dist/docs/api/sdk.md +79 -2
  15. package/dist/docs/changelog-0.x.md +2 -2
  16. package/dist/docs/changelog.md +62 -4
  17. package/dist/docs/cli-and-dev-server.md +58 -0
  18. package/dist/docs/cli-error-codes.md +39 -36
  19. package/dist/docs/cli-reference.md +68 -21
  20. package/dist/docs/concepts/terminology.md +1 -1
  21. package/dist/docs/environment-variables.md +10 -5
  22. package/dist/docs/guides/ai-facilitation.md +2 -0
  23. package/dist/docs/guides/capabilities.md +4 -0
  24. package/dist/docs/guides/designing-a-game.md +2 -0
  25. package/dist/docs/guides/designing-screens.md +133 -0
  26. package/dist/docs/guides/endpoints.md +4 -2
  27. package/dist/docs/guides/engine-testing.md +6 -2
  28. package/dist/docs/guides/engine.md +2 -0
  29. package/dist/docs/guides/file-handling.md +116 -22
  30. package/dist/docs/guides/games.md +3 -1
  31. package/dist/docs/guides/global-settings.md +2 -0
  32. package/dist/docs/guides/guide.md +2 -0
  33. package/dist/docs/guides/hooks.md +2 -0
  34. package/dist/docs/guides/index.md +9 -0
  35. package/dist/docs/guides/internationalization.md +2 -0
  36. package/dist/docs/guides/llm-integration.md +5 -3
  37. package/dist/docs/guides/multi-team-games.md +3 -1
  38. package/dist/docs/guides/patterns.md +2 -0
  39. package/dist/docs/guides/presentation.md +1 -1
  40. package/dist/docs/guides/production-constraints.md +2 -0
  41. package/dist/docs/guides/scenario-editor.md +3 -1
  42. package/dist/docs/guides/scenarios.md +15 -3
  43. package/dist/docs/guides/session-game-flow.md +365 -0
  44. package/dist/docs/guides/session-hooks.md +205 -0
  45. package/dist/docs/guides/session.md +27 -565
  46. package/dist/docs/guides/settings.md +64 -2
  47. package/dist/docs/guides/setup.md +3 -1
  48. package/dist/docs/guides/speech-generation.md +2 -0
  49. package/dist/docs/guides/starter-game.md +61 -21
  50. package/dist/docs/guides/testing.md +2 -0
  51. package/dist/docs/guides/tick-controller.md +3 -1
  52. package/dist/docs/guides/type-safety.md +2 -0
  53. package/dist/docs/guides/ui-files-and-llms.md +328 -0
  54. package/dist/docs/guides/ui-participants.md +281 -0
  55. package/dist/docs/guides/ui-styling.md +263 -0
  56. package/dist/docs/guides/ui-ticks.md +247 -0
  57. package/dist/docs/guides/ui.md +11 -1092
  58. package/dist/docs/guides/upgrading.md +2 -0
  59. package/dist/docs/guides/validators.md +64 -4
  60. package/dist/docs/guides/waiting-room.md +1 -1
  61. package/dist/docs/index.md +2 -1
  62. package/dist/docs/page-index.md +145 -0
  63. package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +1 -1
  64. package/dist/docs/recipes/adapt-ui-for-observers.md +1 -1
  65. package/dist/docs/recipes/create-presentation.md +11 -0
  66. package/dist/docs/recipes/create-scenario-editor.md +1 -0
  67. package/dist/docs/recipes/create-session-ui.md +2 -1
  68. package/dist/docs/recipes/create-setup.md +1 -0
  69. package/dist/docs/recipes/create-user-interface.md +1 -0
  70. package/dist/docs/recipes/create-waiting-room-ui.md +1 -0
  71. package/dist/docs/recipes/design-state-for-concurrent-writes.md +1 -1
  72. package/dist/docs/recipes/fix-duplicate-packages.md +2 -2
  73. package/dist/docs/recipes/index.md +3 -0
  74. package/dist/docs/recipes/screenshot-a-surface.md +80 -0
  75. package/dist/docs/recipes/test-a-multi-role-game.md +1 -1
  76. package/dist/docs/recipes/upload-and-display-files.md +7 -7
  77. package/dist/docs/recipes/use-request-tick.md +2 -2
  78. package/dist/docs/recipes/validate-scenarios.md +4 -1
  79. package/dist/execution/config-resolver.d.ts +4 -1
  80. package/dist/execution/endpoint-runner.d.ts +6 -0
  81. package/dist/execution/logic-calls.d.ts +7 -2
  82. package/dist/execution/scenario-gates.d.ts +21 -1
  83. package/dist/guide/settings.d.ts +1 -1
  84. package/dist/host.js +64 -2
  85. package/dist/runtime/manifest-version.d.ts +1 -1
  86. package/dist/runtime.js +7 -2
  87. package/dist/storage/asset-resolver.d.ts +24 -1
  88. package/dist/storage/blob-store.d.ts +7 -0
  89. package/dist/templates/package/CLAUDE.md.template +14 -5
  90. package/dist/templates/package/DESIGN.md.liquid +39 -7
  91. package/dist/templates/package/README.md.liquid +1 -1
  92. package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
  93. package/dist/templates/package/pnpm-workspace.yaml.template +13 -0
  94. package/dist/templates/starter-game/capabilities/pacing/capability.sdk.json +18 -0
  95. package/dist/templates/starter-game/package.json +2 -0
  96. package/dist/templates/starter-game/presentation/defaults.ts +52 -0
  97. package/dist/templates/starter-game/presentation/index.html +20 -0
  98. package/dist/templates/starter-game/presentation/presentation.sdk.json +10 -0
  99. package/dist/templates/starter-game/presentation/src/App.tsx +55 -0
  100. package/dist/templates/starter-game/presentation/src/Band.tsx +40 -0
  101. package/dist/templates/starter-game/presentation/src/Slides.tsx +415 -0
  102. package/dist/templates/starter-game/presentation/src/WeatherIcon.tsx +21 -0
  103. package/dist/templates/starter-game/presentation/src/i18n.ts +88 -0
  104. package/dist/templates/starter-game/presentation/src/main.tsx +15 -0
  105. package/dist/templates/starter-game/presentation/src/stalls.test.ts +196 -0
  106. package/dist/templates/starter-game/presentation/src/stalls.ts +199 -0
  107. package/dist/templates/starter-game/presentation/types.ts +94 -0
  108. package/dist/templates/starter-game/seriousgaming.sdk.json +2 -1
  109. package/dist/templates/starter-game/session/defaults.ts +6 -0
  110. package/dist/templates/starter-game/session/index.html +1 -1
  111. package/dist/templates/starter-game/session/session.sdk.json +2 -2
  112. package/dist/templates/starter-game/session/src/App.test.tsx +436 -115
  113. package/dist/templates/starter-game/session/src/App.tsx +372 -222
  114. package/dist/templates/starter-game/session/src/JoinCodes.tsx +184 -0
  115. package/dist/templates/starter-game/session/src/ManagePanel.tsx +188 -0
  116. package/dist/templates/starter-game/session/src/Results.tsx +340 -0
  117. package/dist/templates/starter-game/session/src/SessionBar.tsx +179 -0
  118. package/dist/templates/starter-game/session/src/SessionPanels.tsx +105 -0
  119. package/dist/templates/starter-game/session/src/SidePanel.tsx +89 -0
  120. package/dist/templates/starter-game/session/src/StallCard.tsx +253 -0
  121. package/dist/templates/starter-game/session/src/TopBar.tsx +36 -0
  122. package/dist/templates/starter-game/session/src/i18n.ts +91 -24
  123. package/dist/templates/starter-game/session/src/status.ts +28 -0
  124. package/dist/templates/starter-game/session/types.ts +8 -2
  125. package/dist/templates/starter-game/shared/Awning.tsx +31 -0
  126. package/dist/templates/starter-game/shared/HostLogo.test.tsx +38 -0
  127. package/dist/templates/starter-game/shared/HostLogo.tsx +48 -0
  128. package/dist/templates/starter-game/shared/StallIcons.tsx +83 -0
  129. package/dist/templates/starter-game/shared/days.ts +11 -0
  130. package/dist/templates/starter-game/shared/format.test.ts +13 -0
  131. package/dist/templates/starter-game/{ui/src → shared}/format.ts +1 -1
  132. package/dist/templates/starter-game/testing/e2e/game.spec.ts +42 -8
  133. package/dist/templates/starter-game/ui/defaults.ts +3 -0
  134. package/dist/templates/starter-game/ui/src/App.test.tsx +197 -29
  135. package/dist/templates/starter-game/ui/src/App.tsx +176 -99
  136. package/dist/templates/starter-game/ui/src/DayBar.test.tsx +50 -7
  137. package/dist/templates/starter-game/ui/src/DayBar.tsx +96 -38
  138. package/dist/templates/starter-game/ui/src/DaysTable.tsx +69 -0
  139. package/dist/templates/starter-game/ui/src/FirstDay.tsx +37 -0
  140. package/dist/templates/starter-game/ui/src/Header.tsx +257 -0
  141. package/dist/templates/starter-game/ui/src/Lesson.tsx +63 -0
  142. package/dist/templates/starter-game/ui/src/MakeRow.tsx +98 -71
  143. package/dist/templates/starter-game/ui/src/Notices.tsx +59 -0
  144. package/dist/templates/starter-game/ui/src/PastDay.tsx +88 -0
  145. package/dist/templates/starter-game/ui/src/Section.tsx +26 -26
  146. package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +25 -11
  147. package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +37 -33
  148. package/dist/templates/starter-game/ui/src/TodayPanel.tsx +66 -52
  149. package/dist/templates/starter-game/ui/src/WeatherCard.tsx +47 -0
  150. package/dist/templates/starter-game/ui/src/WeekOver.tsx +145 -0
  151. package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +65 -114
  152. package/dist/templates/starter-game/ui/src/days.ts +58 -0
  153. package/dist/templates/starter-game/ui/src/i18n.ts +86 -32
  154. package/dist/templates/starter-game/ui/src/test-helpers.ts +1 -0
  155. package/dist/templates/starter-game/ui/src/theme.ts +8 -8
  156. package/dist/templates/starter-game/ui/types.ts +6 -0
  157. package/dist/templates/starter-game/ui/ui.sdk.json +1 -1
  158. package/dist/templates/starter-game/validators/daylimit/defaults.ts +13 -0
  159. package/dist/templates/starter-game/validators/daylimit/logic/logic.test.ts +20 -0
  160. package/dist/templates/starter-game/validators/daylimit/logic/logic.ts +23 -0
  161. package/dist/templates/starter-game/validators/daylimit/types.ts +23 -0
  162. package/dist/templates/starter-game/validators/daylimit/validator.sdk.json +10 -0
  163. package/dist/templates/starter-game/waiting_room/src/App.test.tsx +83 -5
  164. package/dist/templates/starter-game/waiting_room/src/App.tsx +262 -119
  165. package/dist/templates/starter-game/waiting_room/src/i18n.ts +8 -4
  166. package/dist/utils/error-codes.d.ts +12 -0
  167. package/dist/utils/local-refs.d.ts +40 -0
  168. package/dist/utils/schema-members.d.ts +19 -0
  169. package/package.json +11 -4
  170. package/dist/templates/starter-game/session/src/Section.tsx +0 -37
  171. package/dist/templates/starter-game/session/src/TeamDoor.tsx +0 -96
  172. package/dist/templates/starter-game/session/src/format.ts +0 -8
  173. package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +0 -74
  174. package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +0 -120
  175. package/dist/templates/starter-game/ui/src/HostLogo.test.tsx +0 -25
  176. package/dist/templates/starter-game/ui/src/HostLogo.tsx +0 -38
@@ -0,0 +1,89 @@
1
+ import CloseIcon from '@mui/icons-material/Close';
2
+ import { Box, IconButton, Typography } from '@mui/material';
3
+ import { useId, type ReactNode } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+
6
+ type Props = {
7
+ title: string;
8
+ onClose: () => void;
9
+ children: ReactNode;
10
+ };
11
+
12
+ /**
13
+ * A column of its own beside the stalls, rather than a dialog over them.
14
+ *
15
+ * On the platform this surface sits in a frame under the host's bar, and a
16
+ * backdrop would dim only the frame, which reads as broken rather than as
17
+ * paused. A column also leaves the cards where they were, which matters to a
18
+ * facilitator who is pointing at one of them while they talk.
19
+ */
20
+ export default function SidePanel({ title, onClose, children }: Props) {
21
+ const { t } = useTranslation();
22
+ const headingId = useId();
23
+
24
+ return (
25
+ <Box
26
+ component="aside"
27
+ aria-labelledby={headingId}
28
+ sx={(theme) => ({
29
+ width: { xs: '100%', md: 360 },
30
+ flex: 'none',
31
+ boxSizing: 'border-box',
32
+ bgcolor: 'background.paper',
33
+ borderInlineStart: { xs: 0, md: `1px solid ${theme.palette.divider}` },
34
+ boxShadow: { md: '-12px 0 32px rgba(0, 0, 0, 0.06)' },
35
+ px: 3,
36
+ py: 2.5,
37
+ display: 'flex',
38
+ flexDirection: 'column',
39
+ gap: 2.5,
40
+ overflowY: 'auto',
41
+ minHeight: 0,
42
+ })}
43
+ >
44
+ <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
45
+ <Typography
46
+ id={headingId}
47
+ component="h2"
48
+ noWrap
49
+ sx={{ flex: 1, minWidth: 0, fontSize: '1.15rem', fontWeight: 600 }}
50
+ >
51
+ {title}
52
+ </Typography>
53
+ <IconButton aria-label={t('panel.close')} onClick={onClose} edge="end">
54
+ <CloseIcon />
55
+ </IconButton>
56
+ </Box>
57
+ {children}
58
+ </Box>
59
+ );
60
+ }
61
+
62
+ /** A labelled group inside a panel. */
63
+ export function PanelGroup({
64
+ label,
65
+ divided = false,
66
+ children,
67
+ }: {
68
+ label: string;
69
+ divided?: boolean;
70
+ children: ReactNode;
71
+ }) {
72
+ return (
73
+ <Box
74
+ component="section"
75
+ aria-label={label}
76
+ sx={{
77
+ display: 'flex',
78
+ flexDirection: 'column',
79
+ gap: 1,
80
+ ...(divided && { borderTop: 1, borderColor: 'divider', pt: 2 }),
81
+ }}
82
+ >
83
+ <Typography component="h3" sx={{ fontWeight: 600, fontSize: '0.875rem' }}>
84
+ {label}
85
+ </Typography>
86
+ {children}
87
+ </Box>
88
+ );
89
+ }
@@ -0,0 +1,253 @@
1
+ import { Avatar, AvatarGroup, Box, Button, Card, Chip, Popover, Typography } from '@mui/material';
2
+ import { alpha, type Theme } from '@mui/material/styles';
3
+ import type { Participant, TeamLinks } from '@seriousgaming/sdk/ui';
4
+ import { useRef, useState } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+
7
+ import { initials, type StallStatus } from './status';
8
+
9
+ type Props = {
10
+ teamId: string;
11
+ name: string;
12
+ status: StallStatus;
13
+ people: Participant[];
14
+ jar: string;
15
+ links: TeamLinks | undefined;
16
+ showLinks: boolean;
17
+ selected: boolean;
18
+ onManage: () => void;
19
+ };
20
+
21
+ // The host's roles, in turn, so two people at one stall rarely share a colour
22
+ // and a rebrand recolours them with everything else.
23
+ const AVATAR_ROLES = ['primary', 'secondary', 'success', 'info'] as const;
24
+
25
+ const chipColours = (theme: Theme, status: StallStatus) => {
26
+ const role =
27
+ status.kind === 'waiting'
28
+ ? theme.palette.warning
29
+ : status.kind === 'finished'
30
+ ? theme.palette.success
31
+ : theme.palette.primary;
32
+ return {
33
+ bgcolor: alpha(role.main, 0.14),
34
+ color: theme.palette.mode === 'dark' ? role.light : role.dark,
35
+ };
36
+ };
37
+
38
+ /**
39
+ * One stall, always in three rows: who it is and where it has got to, who is
40
+ * there and what it has made, and the ways in.
41
+ *
42
+ * Three rows whatever the stall is doing is what keeps a grid of eight calm:
43
+ * a card that grew a fourth line when something happened would push its row
44
+ * out of line with its neighbours, and the eye goes to the misalignment rather
45
+ * than to the stall.
46
+ */
47
+ export default function StallCard({
48
+ teamId,
49
+ name,
50
+ status,
51
+ people,
52
+ jar,
53
+ links,
54
+ showLinks,
55
+ selected,
56
+ onManage,
57
+ }: Props) {
58
+ const { t } = useTranslation();
59
+ const copyButton = useRef<HTMLButtonElement>(null);
60
+ const [copied, setCopied] = useState(false);
61
+ const [byHand, setByHand] = useState(false);
62
+
63
+ const label =
64
+ status.kind === 'playing'
65
+ ? t('stall.playing', { day: status.day })
66
+ : status.kind === 'waiting'
67
+ ? t('stall.waiting', { day: status.day })
68
+ : t('stall.finished');
69
+
70
+ const copyJoinLink = () => {
71
+ if (!links) return;
72
+ // Called straight from the click, never after an await: Safari and
73
+ // Firefox only allow the write inside the gesture. Where it is refused
74
+ // anyway, the link is shown to copy by hand, which is worse than
75
+ // copying and better than a button that does nothing.
76
+ try {
77
+ navigator.clipboard.writeText(links.joinUrl).then(
78
+ () => {
79
+ setCopied(true);
80
+ window.setTimeout(() => setCopied(false), 2000);
81
+ },
82
+ () => setByHand(true)
83
+ );
84
+ } catch {
85
+ setByHand(true);
86
+ }
87
+ };
88
+
89
+ return (
90
+ <Card
91
+ component="article"
92
+ variant="outlined"
93
+ data-testid={`team-${teamId}`}
94
+ aria-label={name}
95
+ sx={(theme) => ({
96
+ borderRadius: 4,
97
+ p: 2,
98
+ display: 'grid',
99
+ gridTemplateRows: 'auto auto auto',
100
+ rowGap: 1.75,
101
+ ...(selected && {
102
+ borderColor: theme.palette.primary.main,
103
+ boxShadow: `0 0 0 1px ${theme.palette.primary.main}`,
104
+ }),
105
+ })}
106
+ >
107
+ <Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, minWidth: 0 }}>
108
+ <Typography
109
+ component="h3"
110
+ noWrap
111
+ sx={{ flex: 1, minWidth: 0, fontWeight: 600, fontSize: '1.05rem' }}
112
+ >
113
+ {name}
114
+ </Typography>
115
+ <Chip
116
+ size="small"
117
+ label={label}
118
+ sx={(theme) => ({
119
+ fontWeight: 600,
120
+ flexShrink: 0,
121
+ ...chipColours(theme, status),
122
+ })}
123
+ />
124
+ </Box>
125
+
126
+ <Box
127
+ sx={{
128
+ display: 'flex',
129
+ alignItems: 'center',
130
+ justifyContent: 'space-between',
131
+ gap: 1.5,
132
+ height: 32,
133
+ }}
134
+ >
135
+ {people.length === 0 ? (
136
+ <Typography variant="body2" color="text.secondary" noWrap>
137
+ {t('stall.nobody')}
138
+ </Typography>
139
+ ) : (
140
+ <AvatarGroup
141
+ max={6}
142
+ sx={{
143
+ '& .MuiAvatar-root': {
144
+ width: 28,
145
+ height: 28,
146
+ fontSize: '0.7rem',
147
+ fontWeight: 600,
148
+ },
149
+ }}
150
+ >
151
+ {people.map((person, index) => {
152
+ const name = person.connected
153
+ ? person.name
154
+ : t('stall.away', { name: person.name });
155
+ const role = AVATAR_ROLES[index % AVATAR_ROLES.length] ?? 'primary';
156
+ return (
157
+ <Avatar
158
+ key={person.id}
159
+ alt={name}
160
+ title={name}
161
+ aria-label={name}
162
+ role="img"
163
+ sx={(theme) => ({
164
+ bgcolor: person.connected
165
+ ? theme.palette[role].main
166
+ : theme.palette.action.disabledBackground,
167
+ color: person.connected
168
+ ? theme.palette[role].contrastText
169
+ : theme.palette.text.secondary,
170
+ })}
171
+ >
172
+ {initials(person.name)}
173
+ </Avatar>
174
+ );
175
+ })}
176
+ </AvatarGroup>
177
+ )}
178
+ <Typography
179
+ variant="body2"
180
+ color="text.secondary"
181
+ noWrap
182
+ sx={{ fontVariantNumeric: 'tabular-nums' }}
183
+ >
184
+ {t('stall.jar')}{' '}
185
+ <Box component="strong" sx={{ color: 'text.primary' }}>
186
+ {jar}
187
+ </Box>
188
+ </Typography>
189
+ </Box>
190
+
191
+ <Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, mx: -1, mb: -0.75 }}>
192
+ {/* `target="_blank"` rather than navigating this frame: a
193
+ session surface owns the canvas, and replacing it with a
194
+ stall's screen would leave the facilitator no way back.
195
+ Observing admits nobody, so the stall never sees a fourth
196
+ person appear. */}
197
+ {showLinks && links && (
198
+ <>
199
+ <Button
200
+ component="a"
201
+ href={links.observeUrl}
202
+ target="_blank"
203
+ rel="noopener"
204
+ sx={{ whiteSpace: 'nowrap' }}
205
+ >
206
+ {t('stall.observe')}
207
+ </Button>
208
+ <Button
209
+ ref={copyButton}
210
+ aria-label={t('stall.copyLabel', { team: name })}
211
+ onClick={copyJoinLink}
212
+ sx={{ whiteSpace: 'nowrap' }}
213
+ >
214
+ {copied ? t('stall.copied') : t('stall.copy')}
215
+ </Button>
216
+ <Popover
217
+ open={byHand}
218
+ anchorEl={copyButton.current}
219
+ onClose={() => setByHand(false)}
220
+ anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
221
+ >
222
+ <Box sx={{ p: 2, maxWidth: 360 }}>
223
+ <Typography variant="body2" sx={{ mb: 1 }}>
224
+ {t('stall.copyByHand')}
225
+ </Typography>
226
+ <Typography
227
+ variant="body2"
228
+ sx={{
229
+ fontFamily: 'monospace',
230
+ userSelect: 'all',
231
+ wordBreak: 'break-all',
232
+ }}
233
+ >
234
+ {links.joinUrl}
235
+ </Typography>
236
+ </Box>
237
+ </Popover>
238
+ </>
239
+ )}
240
+ <Box sx={{ flex: 1 }} />
241
+ <Button
242
+ color="inherit"
243
+ aria-label={t('stall.manageLabel', { team: name })}
244
+ aria-expanded={selected}
245
+ onClick={onManage}
246
+ sx={{ whiteSpace: 'nowrap' }}
247
+ >
248
+ {t('stall.manage')}
249
+ </Button>
250
+ </Box>
251
+ </Card>
252
+ );
253
+ }
@@ -0,0 +1,36 @@
1
+ import { Box, Typography } from '@mui/material';
2
+ import { useTranslation } from 'react-i18next';
3
+
4
+ import { Awning } from '../../shared/Awning';
5
+ import HostLogo from '../../shared/HostLogo';
6
+
7
+ /**
8
+ * The host's colour, its logo where it sent one, and the game's name, with the
9
+ * awning underneath. The session's own controls sit on the band below, so this
10
+ * stays the same on every screen of the game.
11
+ */
12
+ export default function TopBar() {
13
+ const { t } = useTranslation();
14
+
15
+ return (
16
+ <Box component="header">
17
+ <Box
18
+ sx={{
19
+ bgcolor: 'primary.main',
20
+ color: 'primary.contrastText',
21
+ height: 56,
22
+ px: { xs: 2, md: 4 },
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ gap: 2.5,
26
+ }}
27
+ >
28
+ <HostLogo height={28} />
29
+ <Typography variant="h6" component="h1" noWrap sx={{ fontWeight: 700 }}>
30
+ {t('game')}
31
+ </Typography>
32
+ </Box>
33
+ <Awning />
34
+ </Box>
35
+ );
36
+ }
@@ -4,38 +4,105 @@ import { initReactI18next } from 'react-i18next';
4
4
  const resources = {
5
5
  en: {
6
6
  translation: {
7
- session: {
8
- waitingRoom: 'Waiting room',
9
- waitingRoomHint:
7
+ game: 'Lemonade Stand',
8
+ bar: {
9
+ label: 'Session',
10
+ limitLead: 'Stalls can play up to',
11
+ limitGroup: 'Day limit',
12
+ limitDay: 'Day {{day}}',
13
+ limitOf: 'of {{last}}',
14
+ hold: 'Hold at day {{day}}',
15
+ open: 'Open day {{day}}',
16
+ waitingOpen: 'Waiting room open',
17
+ waitingClosed: 'Waiting room closed',
18
+ waitingHint:
10
19
  'Holds every player on the holding screen. Nothing about the session changes, so you can park it for a discussion and pick up where the stalls were.',
11
20
  guide: 'Facilitator guide',
12
- readOnly: 'This session is read only, so the controls below will be refused.',
13
- stalls: 'Stalls',
14
- movedOn: '{{movedOn}} of {{total}} have changed their numbers today',
15
- team: 'Stall',
21
+ slides: 'Slides',
22
+ },
23
+ tabs: {
24
+ label: 'Facilitator views',
25
+ teams: 'Teams',
26
+ results: 'Results',
27
+ },
28
+ tools: {
29
+ joinCodes: 'Show join codes',
30
+ more: 'More',
31
+ notice: 'Notice to the room',
32
+ print: 'Print join sheets',
33
+ addStall: 'Add a stall',
34
+ startAgain: 'Start the session again',
35
+ },
36
+ readOnly: 'This session is read only, so the controls here will be refused.',
37
+ noStalls: 'No stalls yet. They appear here as soon as the session has one.',
38
+ stall: {
39
+ playing: 'Playing day {{day}}',
40
+ waiting: 'Waiting for day {{day}}',
41
+ finished: 'Finished',
42
+ jar: 'In the jar',
43
+ nobody: 'Nobody yet',
44
+ away: '{{name}} (away)',
45
+ observe: 'Observe',
46
+ copy: 'Copy join link',
47
+ copyLabel: 'Copy the join link for {{team}}',
48
+ copied: 'Copied',
49
+ copyByHand: 'Copy this link by hand',
50
+ manage: 'Manage',
51
+ manageLabel: 'Manage {{team}}',
52
+ },
53
+ panel: {
54
+ close: 'Close',
55
+ name: 'Stall name',
16
56
  people: 'People',
17
- day: 'Day',
18
- making: 'Making',
19
- ofCapacity: '{{planned}} of {{capacity}}',
20
- status: 'Today',
21
- purse: 'In the jar',
22
- wayIn: 'Way in',
23
- controls: '',
24
- unchanged: 'Same as yesterday',
25
- changed: 'Changed',
57
+ nobody: 'Nobody has joined this stall yet.',
58
+ move: 'Move',
59
+ moveLabel: 'Move {{name}} to another stall',
60
+ moveTo: 'Move to {{team}}',
26
61
  undo: 'Undo',
27
- notice: 'Notice to the room',
62
+ undoNothing: 'Nothing to undo until this stall has played a day.',
63
+ undoDay: 'Undo day {{day}}',
64
+ undoAsk: 'Take {{team}} back to the start of day {{day}}?',
65
+ keep: 'Keep it',
28
66
  noticeHint: 'One note, shown on every stall’s screen and in the waiting room.',
29
67
  noticeLabel: 'Message',
30
68
  send: 'Send',
69
+ startAgainAsk:
70
+ 'Take every stall back to the start of day 1? Everything they have made so far is lost.',
71
+ startAgain: 'Start again',
31
72
  },
32
- door: {
33
- observe: 'Observe',
34
- join: 'Join',
35
- copy: 'Copy the join link for {{team}}',
36
- copyShort: 'Copy link',
37
- copyHint: 'Copy {{team}}’s join link, to hand out or put on a slide',
38
- copied: 'Copied',
73
+ results: {
74
+ after: 'After day {{day}}',
75
+ show: 'Show day {{day}}',
76
+ fullScreen: 'Full screen',
77
+ exitFullScreen: 'Leave full screen',
78
+ empty: 'Results appear here once a stall has played its first day.',
79
+ jarAverage: 'In the jar, average stall',
80
+ profitAverage: 'Profit on day {{day}}, average stall',
81
+ turnedAway: 'Turned away on day {{day}}',
82
+ people_one: '{{count}} person',
83
+ people_other: '{{count}} people',
84
+ range: '{{low}} to {{high}}',
85
+ played: '{{played}} of {{total}} stalls have played day {{day}}',
86
+ caption: 'Every stall after day {{day}}',
87
+ stall: 'Stall',
88
+ jar: 'In the jar',
89
+ profit: 'Profit, day {{day}}',
90
+ sold: 'Sold',
91
+ turned: 'Turned away',
92
+ poured: 'Poured away',
93
+ notYet: 'Not played yet',
94
+ none: '–',
95
+ },
96
+ codes: {
97
+ position: 'Stall {{position}} of {{total}}',
98
+ goTo: 'Go to',
99
+ pin: 'Session PIN',
100
+ fallback: 'Link not working?',
101
+ fallbackLead: 'Try',
102
+ previous: 'Previous stall',
103
+ next: 'Next stall',
104
+ done: 'Done',
105
+ missing: 'The join links have not arrived yet.',
39
106
  },
40
107
  },
41
108
  },
@@ -0,0 +1,28 @@
1
+ import { LAST_DAY } from '../../shared/days';
2
+
3
+ export type StallStatus =
4
+ | { kind: 'playing'; day: number }
5
+ | { kind: 'waiting'; day: number }
6
+ | { kind: 'finished' };
7
+
8
+ /**
9
+ * Where a stall is in its week, from the two numbers that decide it.
10
+ *
11
+ * There is no 'ready' here, and nothing on a player's screen to say so: the
12
+ * stalls open their own days, so the only things a facilitator needs to know
13
+ * are which day each one is on and whether the day limit is holding it.
14
+ */
15
+ export function stallStatus(completedTicks: number, lastOpenDay: number): StallStatus {
16
+ if (completedTicks >= LAST_DAY) return { kind: 'finished' };
17
+ if (completedTicks >= lastOpenDay) return { kind: 'waiting', day: completedTicks + 1 };
18
+ return { kind: 'playing', day: completedTicks + 1 };
19
+ }
20
+
21
+ /** Initials for an avatar: the first letter of the first and last words. */
22
+ export function initials(name: string) {
23
+ const words = name.trim().split(/\s+/).filter(Boolean);
24
+ if (words.length === 0) return '?';
25
+ const first = words.at(0)?.charAt(0) ?? '';
26
+ const last = words.length > 1 ? (words.at(-1)?.charAt(0) ?? '') : '';
27
+ return (first + last).toUpperCase();
28
+ }
@@ -56,6 +56,12 @@ export interface Context {
56
56
  */
57
57
  Message: string;
58
58
  };
59
+ pacing: {
60
+ /**
61
+ * The last day a stall may open. The facilitator lowers it to hold the room at a day, and raises it to let them on; the default opens all ten
62
+ */
63
+ LastOpenDay: number;
64
+ };
59
65
  }
60
66
  export interface DayLine {
61
67
  Made: number;
@@ -76,9 +82,9 @@ export interface DayLine {
76
82
 
77
83
  export type TeamContext = Pick<Context, 'plan' | 'results' | 'roles'>;
78
84
 
79
- export type SharedContext = Pick<Context, 'briefing'>;
85
+ export type SharedContext = Pick<Context, 'briefing' | 'pacing'>;
80
86
 
81
- export type SharedWrites = Pick<Context, 'briefing'>;
87
+ export type SharedWrites = Pick<Context, 'briefing' | 'pacing'>;
82
88
 
83
89
  export type TeamWrites = Record<string, never>;
84
90
 
@@ -0,0 +1,31 @@
1
+ import { Box, useTheme } from '@mui/material';
2
+ import { useId } from 'react';
3
+
4
+ /**
5
+ * The scalloped edge of a stall's awning, under the top bar of every screen.
6
+ *
7
+ * This is the game's one drawn motif: the host's theme supplies the colour, so
8
+ * it changes with the brand, and everything else on screen comes from the icon
9
+ * set. One shape used everywhere is what makes the screens recognisably this
10
+ * game's without competing with the host's identity.
11
+ */
12
+ export function Awning({ depth = 12, scallop = 20 }: { depth?: number; scallop?: number }) {
13
+ const theme = useTheme();
14
+ const id = useId();
15
+
16
+ return (
17
+ <Box aria-hidden sx={{ height: depth, mt: '-1px', lineHeight: 0 }}>
18
+ <svg width="100%" height={depth} preserveAspectRatio="none">
19
+ <defs>
20
+ <pattern id={id} width={scallop} height={depth} patternUnits="userSpaceOnUse">
21
+ <path
22
+ d={`M0 0 H${scallop} V2 Q${scallop / 2} ${depth} 0 2 Z`}
23
+ fill={theme.palette.primary.main}
24
+ />
25
+ </pattern>
26
+ </defs>
27
+ <rect width="100%" height={depth} fill={`url(#${id})`} />
28
+ </svg>
29
+ </Box>
30
+ );
31
+ }
@@ -0,0 +1,38 @@
1
+ import {
2
+ createMockBrand,
3
+ createMockUserInterfaceTheme,
4
+ renderUserInterface,
5
+ } from '@seriousgaming/sdk/ui/testing';
6
+ import { screen } from '@testing-library/react';
7
+ import { describe, expect, it } from 'vitest';
8
+
9
+ import HostLogo from './HostLogo';
10
+
11
+ describe('the host logo', () => {
12
+ // The logo sits on the top bar, which is the host's primary colour with
13
+ // light text on it, so the artwork drawn for a dark background is the one
14
+ // that reads.
15
+ it("shows the host's logo drawn for the bar, named for the host", () => {
16
+ const brand = createMockBrand({ name: 'Northwind' });
17
+ renderUserInterface(<HostLogo />, { theme: createMockUserInterfaceTheme({ brand }) });
18
+
19
+ const logo = screen.getByRole('img', { name: 'Northwind' });
20
+ expect(logo).toHaveAttribute('src', brand.logo?.onDark);
21
+ });
22
+
23
+ it('falls back to the only variant the host sent', () => {
24
+ const brand = createMockBrand({ name: 'Northwind' });
25
+ const onLight = brand.logo?.onLight;
26
+ renderUserInterface(<HostLogo />, {
27
+ theme: createMockUserInterfaceTheme({ brand: { ...brand, logo: { onLight } } }),
28
+ });
29
+
30
+ expect(screen.getByRole('img', { name: 'Northwind' })).toHaveAttribute('src', onLight);
31
+ });
32
+
33
+ it('shows nothing when the host sends no logo', () => {
34
+ renderUserInterface(<HostLogo />);
35
+
36
+ expect(screen.queryByTestId('host-logo')).not.toBeInTheDocument();
37
+ });
38
+ });