@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.
- package/dist/cli.js +4055 -2646
- package/dist/client.js +807 -172
- package/dist/core/session-host.d.ts +4 -2
- package/dist/core/settings-locks.d.ts +27 -2
- package/dist/dev/console/assets/{index-DEV8N0na.js → index-BVF8exas.js} +22 -22
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/public-origins.d.ts +61 -0
- package/dist/dev/routes.d.ts +4 -0
- package/dist/dev/shell.d.ts +32 -4
- package/dist/dev/view/batch.d.ts +7 -1
- package/dist/docs/ai-agents.md +5 -0
- package/dist/docs/api/index.md +1 -1
- package/dist/docs/api/sdk-tools-client.md +1 -0
- package/dist/docs/api/sdk.md +79 -2
- package/dist/docs/changelog-0.x.md +2 -2
- package/dist/docs/changelog.md +62 -4
- package/dist/docs/cli-and-dev-server.md +58 -0
- package/dist/docs/cli-error-codes.md +39 -36
- package/dist/docs/cli-reference.md +68 -21
- package/dist/docs/concepts/terminology.md +1 -1
- package/dist/docs/environment-variables.md +10 -5
- package/dist/docs/guides/ai-facilitation.md +2 -0
- package/dist/docs/guides/capabilities.md +4 -0
- package/dist/docs/guides/designing-a-game.md +2 -0
- package/dist/docs/guides/designing-screens.md +133 -0
- package/dist/docs/guides/endpoints.md +4 -2
- package/dist/docs/guides/engine-testing.md +6 -2
- package/dist/docs/guides/engine.md +2 -0
- package/dist/docs/guides/file-handling.md +116 -22
- package/dist/docs/guides/games.md +3 -1
- package/dist/docs/guides/global-settings.md +2 -0
- package/dist/docs/guides/guide.md +2 -0
- package/dist/docs/guides/hooks.md +2 -0
- package/dist/docs/guides/index.md +9 -0
- package/dist/docs/guides/internationalization.md +2 -0
- package/dist/docs/guides/llm-integration.md +5 -3
- package/dist/docs/guides/multi-team-games.md +3 -1
- package/dist/docs/guides/patterns.md +2 -0
- package/dist/docs/guides/presentation.md +1 -1
- package/dist/docs/guides/production-constraints.md +2 -0
- package/dist/docs/guides/scenario-editor.md +3 -1
- package/dist/docs/guides/scenarios.md +15 -3
- package/dist/docs/guides/session-game-flow.md +365 -0
- package/dist/docs/guides/session-hooks.md +205 -0
- package/dist/docs/guides/session.md +27 -565
- package/dist/docs/guides/settings.md +64 -2
- package/dist/docs/guides/setup.md +3 -1
- package/dist/docs/guides/speech-generation.md +2 -0
- package/dist/docs/guides/starter-game.md +61 -21
- package/dist/docs/guides/testing.md +2 -0
- package/dist/docs/guides/tick-controller.md +3 -1
- package/dist/docs/guides/type-safety.md +2 -0
- package/dist/docs/guides/ui-files-and-llms.md +328 -0
- package/dist/docs/guides/ui-participants.md +281 -0
- package/dist/docs/guides/ui-styling.md +263 -0
- package/dist/docs/guides/ui-ticks.md +247 -0
- package/dist/docs/guides/ui.md +11 -1092
- package/dist/docs/guides/upgrading.md +2 -0
- package/dist/docs/guides/validators.md +64 -4
- package/dist/docs/guides/waiting-room.md +1 -1
- package/dist/docs/index.md +2 -1
- package/dist/docs/page-index.md +145 -0
- package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +1 -1
- package/dist/docs/recipes/adapt-ui-for-observers.md +1 -1
- package/dist/docs/recipes/create-presentation.md +11 -0
- package/dist/docs/recipes/create-scenario-editor.md +1 -0
- package/dist/docs/recipes/create-session-ui.md +2 -1
- package/dist/docs/recipes/create-setup.md +1 -0
- package/dist/docs/recipes/create-user-interface.md +1 -0
- package/dist/docs/recipes/create-waiting-room-ui.md +1 -0
- package/dist/docs/recipes/design-state-for-concurrent-writes.md +1 -1
- package/dist/docs/recipes/fix-duplicate-packages.md +2 -2
- package/dist/docs/recipes/index.md +3 -0
- package/dist/docs/recipes/screenshot-a-surface.md +80 -0
- package/dist/docs/recipes/test-a-multi-role-game.md +1 -1
- package/dist/docs/recipes/upload-and-display-files.md +7 -7
- package/dist/docs/recipes/use-request-tick.md +2 -2
- package/dist/docs/recipes/validate-scenarios.md +4 -1
- package/dist/execution/config-resolver.d.ts +4 -1
- package/dist/execution/endpoint-runner.d.ts +6 -0
- package/dist/execution/logic-calls.d.ts +7 -2
- package/dist/execution/scenario-gates.d.ts +21 -1
- package/dist/guide/settings.d.ts +1 -1
- package/dist/host.js +64 -2
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +7 -2
- package/dist/storage/asset-resolver.d.ts +24 -1
- package/dist/storage/blob-store.d.ts +7 -0
- package/dist/templates/package/CLAUDE.md.template +14 -5
- package/dist/templates/package/DESIGN.md.liquid +39 -7
- package/dist/templates/package/README.md.liquid +1 -1
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/pnpm-workspace.yaml.template +13 -0
- package/dist/templates/starter-game/capabilities/pacing/capability.sdk.json +18 -0
- package/dist/templates/starter-game/package.json +2 -0
- package/dist/templates/starter-game/presentation/defaults.ts +52 -0
- package/dist/templates/starter-game/presentation/index.html +20 -0
- package/dist/templates/starter-game/presentation/presentation.sdk.json +10 -0
- package/dist/templates/starter-game/presentation/src/App.tsx +55 -0
- package/dist/templates/starter-game/presentation/src/Band.tsx +40 -0
- package/dist/templates/starter-game/presentation/src/Slides.tsx +415 -0
- package/dist/templates/starter-game/presentation/src/WeatherIcon.tsx +21 -0
- package/dist/templates/starter-game/presentation/src/i18n.ts +88 -0
- package/dist/templates/starter-game/presentation/src/main.tsx +15 -0
- package/dist/templates/starter-game/presentation/src/stalls.test.ts +196 -0
- package/dist/templates/starter-game/presentation/src/stalls.ts +199 -0
- package/dist/templates/starter-game/presentation/types.ts +94 -0
- package/dist/templates/starter-game/seriousgaming.sdk.json +2 -1
- package/dist/templates/starter-game/session/defaults.ts +6 -0
- package/dist/templates/starter-game/session/index.html +1 -1
- package/dist/templates/starter-game/session/session.sdk.json +2 -2
- package/dist/templates/starter-game/session/src/App.test.tsx +436 -115
- package/dist/templates/starter-game/session/src/App.tsx +372 -222
- package/dist/templates/starter-game/session/src/JoinCodes.tsx +184 -0
- package/dist/templates/starter-game/session/src/ManagePanel.tsx +188 -0
- package/dist/templates/starter-game/session/src/Results.tsx +340 -0
- package/dist/templates/starter-game/session/src/SessionBar.tsx +179 -0
- package/dist/templates/starter-game/session/src/SessionPanels.tsx +105 -0
- package/dist/templates/starter-game/session/src/SidePanel.tsx +89 -0
- package/dist/templates/starter-game/session/src/StallCard.tsx +253 -0
- package/dist/templates/starter-game/session/src/TopBar.tsx +36 -0
- package/dist/templates/starter-game/session/src/i18n.ts +91 -24
- package/dist/templates/starter-game/session/src/status.ts +28 -0
- package/dist/templates/starter-game/session/types.ts +8 -2
- package/dist/templates/starter-game/shared/Awning.tsx +31 -0
- package/dist/templates/starter-game/shared/HostLogo.test.tsx +38 -0
- package/dist/templates/starter-game/shared/HostLogo.tsx +48 -0
- package/dist/templates/starter-game/shared/StallIcons.tsx +83 -0
- package/dist/templates/starter-game/shared/days.ts +11 -0
- package/dist/templates/starter-game/shared/format.test.ts +13 -0
- package/dist/templates/starter-game/{ui/src → shared}/format.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +42 -8
- package/dist/templates/starter-game/ui/defaults.ts +3 -0
- package/dist/templates/starter-game/ui/src/App.test.tsx +197 -29
- package/dist/templates/starter-game/ui/src/App.tsx +176 -99
- package/dist/templates/starter-game/ui/src/DayBar.test.tsx +50 -7
- package/dist/templates/starter-game/ui/src/DayBar.tsx +96 -38
- package/dist/templates/starter-game/ui/src/DaysTable.tsx +69 -0
- package/dist/templates/starter-game/ui/src/FirstDay.tsx +37 -0
- package/dist/templates/starter-game/ui/src/Header.tsx +257 -0
- package/dist/templates/starter-game/ui/src/Lesson.tsx +63 -0
- package/dist/templates/starter-game/ui/src/MakeRow.tsx +98 -71
- package/dist/templates/starter-game/ui/src/Notices.tsx +59 -0
- package/dist/templates/starter-game/ui/src/PastDay.tsx +88 -0
- package/dist/templates/starter-game/ui/src/Section.tsx +26 -26
- package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +25 -11
- package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +37 -33
- package/dist/templates/starter-game/ui/src/TodayPanel.tsx +66 -52
- package/dist/templates/starter-game/ui/src/WeatherCard.tsx +47 -0
- package/dist/templates/starter-game/ui/src/WeekOver.tsx +145 -0
- package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +65 -114
- package/dist/templates/starter-game/ui/src/days.ts +58 -0
- package/dist/templates/starter-game/ui/src/i18n.ts +86 -32
- package/dist/templates/starter-game/ui/src/test-helpers.ts +1 -0
- package/dist/templates/starter-game/ui/src/theme.ts +8 -8
- package/dist/templates/starter-game/ui/types.ts +6 -0
- package/dist/templates/starter-game/ui/ui.sdk.json +1 -1
- package/dist/templates/starter-game/validators/daylimit/defaults.ts +13 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.test.ts +20 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/types.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/validator.sdk.json +10 -0
- package/dist/templates/starter-game/waiting_room/src/App.test.tsx +83 -5
- package/dist/templates/starter-game/waiting_room/src/App.tsx +262 -119
- package/dist/templates/starter-game/waiting_room/src/i18n.ts +8 -4
- package/dist/utils/error-codes.d.ts +12 -0
- package/dist/utils/local-refs.d.ts +40 -0
- package/dist/utils/schema-members.d.ts +19 -0
- package/package.json +11 -4
- package/dist/templates/starter-game/session/src/Section.tsx +0 -37
- package/dist/templates/starter-game/session/src/TeamDoor.tsx +0 -96
- package/dist/templates/starter-game/session/src/format.ts +0 -8
- package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +0 -74
- package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +0 -120
- package/dist/templates/starter-game/ui/src/HostLogo.test.tsx +0 -25
- package/dist/templates/starter-game/ui/src/HostLogo.tsx +0 -38
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useId } from 'react';
|
|
2
|
+
|
|
3
|
+
const BAND = 60;
|
|
4
|
+
const DEPTH = 30;
|
|
5
|
+
const SCALLOP = 96;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The awning across the top of every slide: a band of the host's primary
|
|
9
|
+
* colour with the game's scalloped edge under it, the same motif as
|
|
10
|
+
* `shared/Awning.tsx` on the player screens.
|
|
11
|
+
*
|
|
12
|
+
* It is drawn again here rather than imported because a deck has no MUI
|
|
13
|
+
* theme to read the colour from: the deck's own brand reaches every slide as
|
|
14
|
+
* `--deck-primary`, so the shape fills with that.
|
|
15
|
+
*/
|
|
16
|
+
export function Band() {
|
|
17
|
+
const id = useId();
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div aria-hidden style={{ lineHeight: 0 }}>
|
|
21
|
+
<div style={{ height: BAND, background: 'var(--deck-primary)' }} />
|
|
22
|
+
<svg
|
|
23
|
+
width="100%"
|
|
24
|
+
height={DEPTH}
|
|
25
|
+
preserveAspectRatio="none"
|
|
26
|
+
style={{ display: 'block', marginTop: -1 }}
|
|
27
|
+
>
|
|
28
|
+
<defs>
|
|
29
|
+
<pattern id={id} width={SCALLOP} height={DEPTH} patternUnits="userSpaceOnUse">
|
|
30
|
+
<path
|
|
31
|
+
d={`M0 0 H${SCALLOP} V2 Q${SCALLOP / 2} ${DEPTH} 0 2 Z`}
|
|
32
|
+
style={{ fill: 'var(--deck-primary)' }}
|
|
33
|
+
/>
|
|
34
|
+
</pattern>
|
|
35
|
+
</defs>
|
|
36
|
+
<rect width="100%" height={DEPTH} fill={`url(#${id})`} />
|
|
37
|
+
</svg>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import StorefrontRounded from '@mui/icons-material/StorefrontRounded';
|
|
2
|
+
import { Heading, Slide, Text } from '@seriousgaming/deck';
|
|
3
|
+
import { usePastState, usePresentation } from '@seriousgaming/sdk/ui';
|
|
4
|
+
import { useEffect, useRef, type CSSProperties, type ReactNode } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import { count, money } from '../../shared/format';
|
|
8
|
+
import type { Settings, SharedContext, TeamContext } from '../types';
|
|
9
|
+
import { Band } from './Band';
|
|
10
|
+
import {
|
|
11
|
+
collectBoards,
|
|
12
|
+
forecastFor,
|
|
13
|
+
forecastsByStall,
|
|
14
|
+
roomOnDay,
|
|
15
|
+
roomSoFar,
|
|
16
|
+
stallsOnDay,
|
|
17
|
+
standings,
|
|
18
|
+
type Board,
|
|
19
|
+
type BoardContext,
|
|
20
|
+
type Spread,
|
|
21
|
+
type Weather,
|
|
22
|
+
} from './stalls';
|
|
23
|
+
import { WeatherIcon } from './WeatherIcon';
|
|
24
|
+
|
|
25
|
+
const WEATHERS: Weather[] = ['sunny', 'cloudy', 'rainy'];
|
|
26
|
+
|
|
27
|
+
const figure: CSSProperties = {
|
|
28
|
+
fontFamily: 'var(--deck-font-heading)',
|
|
29
|
+
fontWeight: 700,
|
|
30
|
+
lineHeight: 1,
|
|
31
|
+
fontVariantNumeric: 'tabular-nums',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
Every element in the returned array is one slide, so add a slide by adding an
|
|
36
|
+
element. Keep them in an array rather than wrapping them in a component of your
|
|
37
|
+
own: the deck counts its direct children, and a wrapper would be one slide.
|
|
38
|
+
|
|
39
|
+
Every slide makes sense with no session, because a facilitator rehearses and
|
|
40
|
+
exports the deck before the day.
|
|
41
|
+
|
|
42
|
+
The projector shows the room, never a stall by name: a stall that did badly
|
|
43
|
+
should not find out from a wall. What each stall did goes in the speaker notes,
|
|
44
|
+
which only the facilitator sees and which export to PowerPoint's notes pane.
|
|
45
|
+
*/
|
|
46
|
+
export function useSlides(): React.ReactElement[] {
|
|
47
|
+
const { t } = useTranslation();
|
|
48
|
+
const { game, session, settings } = usePresentation<Settings, TeamContext, SharedContext>();
|
|
49
|
+
const symbol = settings.session.CurrencySymbol;
|
|
50
|
+
const totalDays = game.maxTicks ?? 10;
|
|
51
|
+
const days = Array.from({ length: totalDays }, (_, i) => i + 1);
|
|
52
|
+
const boards = collectBoards(session, useHistory());
|
|
53
|
+
|
|
54
|
+
const room = roomSoFar(boards, totalDays);
|
|
55
|
+
const table = standings(boards);
|
|
56
|
+
|
|
57
|
+
return [
|
|
58
|
+
<Slide key="title" notes={t('notes.title')}>
|
|
59
|
+
<Frame>
|
|
60
|
+
<div
|
|
61
|
+
style={{
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexDirection: 'column',
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
gap: 36,
|
|
66
|
+
height: '100%',
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<StorefrontRounded
|
|
70
|
+
aria-hidden
|
|
71
|
+
style={{ fontSize: 144, color: 'var(--deck-primary)' }}
|
|
72
|
+
/>
|
|
73
|
+
<Heading level={1} style={{ margin: 0 }}>
|
|
74
|
+
{game.name}
|
|
75
|
+
</Heading>
|
|
76
|
+
<Text variant="lead" style={{ margin: 0 }}>
|
|
77
|
+
{t('subtitle')}
|
|
78
|
+
</Text>
|
|
79
|
+
{game.scenarioName && (
|
|
80
|
+
<Text variant="caption" style={{ margin: 0 }}>
|
|
81
|
+
{t('scenario', { name: game.scenarioName })}
|
|
82
|
+
</Text>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
</Frame>
|
|
86
|
+
</Slide>,
|
|
87
|
+
|
|
88
|
+
// One slide a day. The stalls run their own days, so the forecast and
|
|
89
|
+
// the room's figures each count only the stalls that have got that far.
|
|
90
|
+
...days.map((day) => (
|
|
91
|
+
<Slide
|
|
92
|
+
key={`day-${day}`}
|
|
93
|
+
transition="slide"
|
|
94
|
+
notes={dayNotes(boards, day, (key, values) => t(key, values), symbol)}
|
|
95
|
+
>
|
|
96
|
+
<Frame>
|
|
97
|
+
<div
|
|
98
|
+
style={{
|
|
99
|
+
display: 'grid',
|
|
100
|
+
gridTemplateColumns: 'minmax(0, 5fr) minmax(0, 6fr)',
|
|
101
|
+
gap: 96,
|
|
102
|
+
alignItems: 'center',
|
|
103
|
+
height: '100%',
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
<Outlook day={day} totalDays={totalDays} boards={boards} live={!!session} />
|
|
107
|
+
{day === 1 ? (
|
|
108
|
+
<HowADayWorks />
|
|
109
|
+
) : (
|
|
110
|
+
<RoomOnDay day={day - 1} boards={boards} symbol={symbol} />
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
</Frame>
|
|
114
|
+
</Slide>
|
|
115
|
+
)),
|
|
116
|
+
|
|
117
|
+
<Slide
|
|
118
|
+
key="results"
|
|
119
|
+
transition="rise"
|
|
120
|
+
notes={[
|
|
121
|
+
t('notes.results'),
|
|
122
|
+
...table.map((stall, place) =>
|
|
123
|
+
t('notes.standing', {
|
|
124
|
+
place: place + 1,
|
|
125
|
+
name: stall.name,
|
|
126
|
+
purse: money(symbol, stall.purse),
|
|
127
|
+
count: stall.days,
|
|
128
|
+
})
|
|
129
|
+
),
|
|
130
|
+
].join('\n')}
|
|
131
|
+
>
|
|
132
|
+
<Frame>
|
|
133
|
+
<Heading style={{ margin: 0 }}>{t('resultsHeading')}</Heading>
|
|
134
|
+
{room ? (
|
|
135
|
+
<div style={{ display: 'grid', gap: 48, marginTop: 64 }}>
|
|
136
|
+
<div>
|
|
137
|
+
<div style={{ ...figure, fontSize: 168 }}>
|
|
138
|
+
{money(symbol, room.purse.average)}
|
|
139
|
+
</div>
|
|
140
|
+
<Text style={{ margin: '12px 0 0' }}>{t('resultsAverage')}</Text>
|
|
141
|
+
</div>
|
|
142
|
+
<Cards
|
|
143
|
+
items={[
|
|
144
|
+
[t('range'), range(symbol, room.purse)],
|
|
145
|
+
[t('resultsTurnedAway'), count(room.turnedAway)],
|
|
146
|
+
]}
|
|
147
|
+
/>
|
|
148
|
+
<Text variant="caption" style={{ margin: 0 }}>
|
|
149
|
+
{room.unfinished
|
|
150
|
+
? t('resultsUnfinished', { count: room.purse.stalls })
|
|
151
|
+
: t('fromStalls', { count: room.purse.stalls })}
|
|
152
|
+
</Text>
|
|
153
|
+
</div>
|
|
154
|
+
) : (
|
|
155
|
+
<Text variant="caption" style={{ marginTop: 48 }}>
|
|
156
|
+
{t('resultsPending')}
|
|
157
|
+
</Text>
|
|
158
|
+
)}
|
|
159
|
+
</Frame>
|
|
160
|
+
</Slide>,
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Every past day of every stall, for the slides that count a day the stalls
|
|
166
|
+
* have already moved past. A stall's live state holds only its latest day.
|
|
167
|
+
*
|
|
168
|
+
* The query reads up to the furthest stall, which a slower stall finishing a
|
|
169
|
+
* day does not move, so the read is repeated whenever any stall moves on.
|
|
170
|
+
*/
|
|
171
|
+
function useHistory() {
|
|
172
|
+
const { session } = usePresentation<Settings, TeamContext, SharedContext>();
|
|
173
|
+
const { entries, refetch } = usePastState<BoardContext>(
|
|
174
|
+
session
|
|
175
|
+
? {
|
|
176
|
+
fromTick: 0,
|
|
177
|
+
toTick: session.completedTicks,
|
|
178
|
+
teams: 'all',
|
|
179
|
+
capabilityIds: ['weather', 'results'],
|
|
180
|
+
}
|
|
181
|
+
: null
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const progress = session
|
|
185
|
+
? session.teams
|
|
186
|
+
.map((team) => session.data.teams[team.teamId]?.completedTicks ?? 0)
|
|
187
|
+
.join(',')
|
|
188
|
+
: '';
|
|
189
|
+
const seen = useRef(progress);
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (seen.current === progress) return;
|
|
192
|
+
seen.current = progress;
|
|
193
|
+
refetch();
|
|
194
|
+
}, [progress, refetch]);
|
|
195
|
+
|
|
196
|
+
return entries;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function Frame({ children }: { children: ReactNode }) {
|
|
200
|
+
return (
|
|
201
|
+
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
|
|
202
|
+
<Band />
|
|
203
|
+
<div style={{ flex: 1, minHeight: 0, padding: '72px 120px 84px' }}>{children}</div>
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** The left of a day's slide: which day, and the weather the room faces. */
|
|
209
|
+
function Outlook({
|
|
210
|
+
day,
|
|
211
|
+
totalDays,
|
|
212
|
+
boards,
|
|
213
|
+
live,
|
|
214
|
+
}: {
|
|
215
|
+
day: number;
|
|
216
|
+
totalDays: number;
|
|
217
|
+
boards: Board[];
|
|
218
|
+
live: boolean;
|
|
219
|
+
}) {
|
|
220
|
+
const { t } = useTranslation();
|
|
221
|
+
const forecast = forecastFor(boards, day);
|
|
222
|
+
const kinds = WEATHERS.filter((weather) => forecast[weather]);
|
|
223
|
+
const only = kinds.length === 1 ? kinds[0] : undefined;
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<section style={{ display: 'flex', flexDirection: 'column', gap: 30 }}>
|
|
227
|
+
<Text style={{ margin: 0, fontSize: 36, fontWeight: 600, color: 'var(--deck-muted)' }}>
|
|
228
|
+
{t('dayOf', { n: day, total: totalDays })}
|
|
229
|
+
</Text>
|
|
230
|
+
<Heading level={1} style={{ margin: 0, fontSize: 108, lineHeight: 1.02 }}>
|
|
231
|
+
{only
|
|
232
|
+
? t(`headline.${only}`)
|
|
233
|
+
: kinds.length > 1
|
|
234
|
+
? t('headline.mixed')
|
|
235
|
+
: t('question')}
|
|
236
|
+
</Heading>
|
|
237
|
+
{only && (
|
|
238
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 30 }}>
|
|
239
|
+
<WeatherIcon weather={only} size={144} />
|
|
240
|
+
<Text style={{ margin: 0, fontSize: 42, lineHeight: 1.3 }}>
|
|
241
|
+
{t(`outlook.${only}`)}
|
|
242
|
+
</Text>
|
|
243
|
+
</div>
|
|
244
|
+
)}
|
|
245
|
+
{kinds.length > 1 && (
|
|
246
|
+
<div style={{ display: 'grid', gap: 18 }}>
|
|
247
|
+
{kinds.map((weather) => (
|
|
248
|
+
<div
|
|
249
|
+
key={weather}
|
|
250
|
+
style={{ display: 'flex', alignItems: 'center', gap: 24 }}
|
|
251
|
+
>
|
|
252
|
+
<WeatherIcon weather={weather} size={84} />
|
|
253
|
+
<Text style={{ margin: 0, fontSize: 42 }}>
|
|
254
|
+
{t(`stallsFacing.${weather}`, { count: forecast[weather] })}
|
|
255
|
+
</Text>
|
|
256
|
+
</div>
|
|
257
|
+
))}
|
|
258
|
+
<Text style={{ margin: '12px 0 0', fontSize: 42 }}>{t('question')}</Text>
|
|
259
|
+
</div>
|
|
260
|
+
)}
|
|
261
|
+
{kinds.length === 0 && (
|
|
262
|
+
<Text variant="caption" style={{ margin: 0 }}>
|
|
263
|
+
{live ? t('forecastNotYet') : t('forecastPending')}
|
|
264
|
+
</Text>
|
|
265
|
+
)}
|
|
266
|
+
</section>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The right of a day's slide: what the day before did, across the room. */
|
|
271
|
+
function RoomOnDay({ day, boards, symbol }: { day: number; boards: Board[]; symbol: string }) {
|
|
272
|
+
const { t } = useTranslation();
|
|
273
|
+
const room = roomOnDay(boards, day);
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<section style={{ display: 'flex', flexDirection: 'column', gap: 36 }}>
|
|
277
|
+
<Heading level={3} style={{ margin: 0, fontSize: 45, fontWeight: 600 }}>
|
|
278
|
+
{t('acrossTheRoom', { n: day })}
|
|
279
|
+
</Heading>
|
|
280
|
+
{room ? (
|
|
281
|
+
<>
|
|
282
|
+
<div>
|
|
283
|
+
<div style={{ ...figure, fontSize: 132 }}>{count(room.turnedAway)}</div>
|
|
284
|
+
<Text style={{ margin: '9px 0 0', fontSize: 42 }}>
|
|
285
|
+
{t('turnedAway', { count: room.turnedAway })}
|
|
286
|
+
</Text>
|
|
287
|
+
</div>
|
|
288
|
+
<Cards
|
|
289
|
+
items={[
|
|
290
|
+
[t('averageProfit'), money(symbol, room.profit.average)],
|
|
291
|
+
[t('range'), range(symbol, room.profit)],
|
|
292
|
+
]}
|
|
293
|
+
/>
|
|
294
|
+
<Text variant="caption" style={{ margin: 0 }}>
|
|
295
|
+
{t('fromStalls', { count: room.profit.stalls })}
|
|
296
|
+
</Text>
|
|
297
|
+
</>
|
|
298
|
+
) : (
|
|
299
|
+
<Text variant="caption" style={{ margin: 0 }}>
|
|
300
|
+
{t('roomPending', { n: day })}
|
|
301
|
+
</Text>
|
|
302
|
+
)}
|
|
303
|
+
</section>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** Day 1 has no day before it, so its slide says how a day works instead. */
|
|
308
|
+
function HowADayWorks() {
|
|
309
|
+
const { t } = useTranslation();
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
<section style={{ display: 'flex', flexDirection: 'column', gap: 36 }}>
|
|
313
|
+
<Heading level={3} style={{ margin: 0, fontSize: 45, fontWeight: 600 }}>
|
|
314
|
+
{t('howHeading')}
|
|
315
|
+
</Heading>
|
|
316
|
+
<Cards
|
|
317
|
+
columns={1}
|
|
318
|
+
items={[
|
|
319
|
+
[t('howMake'), t('howMakeDetail')],
|
|
320
|
+
[t('howPour'), t('howPourDetail')],
|
|
321
|
+
[t('howTurn'), t('howTurnDetail')],
|
|
322
|
+
]}
|
|
323
|
+
quiet
|
|
324
|
+
/>
|
|
325
|
+
</section>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function Cards({
|
|
330
|
+
items,
|
|
331
|
+
columns = 2,
|
|
332
|
+
quiet = false,
|
|
333
|
+
}: {
|
|
334
|
+
items: [string, string][];
|
|
335
|
+
columns?: number;
|
|
336
|
+
quiet?: boolean;
|
|
337
|
+
}) {
|
|
338
|
+
return (
|
|
339
|
+
<div
|
|
340
|
+
style={{
|
|
341
|
+
display: 'grid',
|
|
342
|
+
gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
|
|
343
|
+
gap: 30,
|
|
344
|
+
}}
|
|
345
|
+
>
|
|
346
|
+
{items.map(([label, value]) => (
|
|
347
|
+
<div
|
|
348
|
+
key={label}
|
|
349
|
+
style={{
|
|
350
|
+
background: 'var(--deck-surface)',
|
|
351
|
+
borderRadius: 24,
|
|
352
|
+
padding: '27px 33px',
|
|
353
|
+
}}
|
|
354
|
+
>
|
|
355
|
+
<Text
|
|
356
|
+
style={{
|
|
357
|
+
margin: 0,
|
|
358
|
+
fontSize: quiet ? 36 : 30,
|
|
359
|
+
fontWeight: quiet ? 700 : 400,
|
|
360
|
+
color: quiet ? undefined : 'var(--deck-muted)',
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
{label}
|
|
364
|
+
</Text>
|
|
365
|
+
<Text
|
|
366
|
+
style={{
|
|
367
|
+
margin: '6px 0 0',
|
|
368
|
+
fontSize: quiet ? 32 : 54,
|
|
369
|
+
fontWeight: quiet ? 400 : 700,
|
|
370
|
+
fontVariantNumeric: 'tabular-nums',
|
|
371
|
+
}}
|
|
372
|
+
>
|
|
373
|
+
{value}
|
|
374
|
+
</Text>
|
|
375
|
+
</div>
|
|
376
|
+
))}
|
|
377
|
+
</div>
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const range = (symbol: string, spread: Spread) =>
|
|
382
|
+
spread.lowest === spread.highest
|
|
383
|
+
? money(symbol, spread.lowest)
|
|
384
|
+
: `${money(symbol, spread.lowest)} – ${money(symbol, spread.highest)}`;
|
|
385
|
+
|
|
386
|
+
/** What the facilitator sees beside a day's slide: each stall by name. */
|
|
387
|
+
function dayNotes(
|
|
388
|
+
boards: Board[],
|
|
389
|
+
day: number,
|
|
390
|
+
t: (key: string, values?: Record<string, unknown>) => string,
|
|
391
|
+
symbol: string
|
|
392
|
+
): string {
|
|
393
|
+
const lines = [t('notes.day')];
|
|
394
|
+
const forecasts = forecastsByStall(boards, day);
|
|
395
|
+
if (forecasts.length > 0) {
|
|
396
|
+
lines.push(
|
|
397
|
+
t('notes.forecasts', {
|
|
398
|
+
list: forecasts
|
|
399
|
+
.map((stall) => `${stall.name} (${t(`weather.${stall.weather}`)})`)
|
|
400
|
+
.join(', '),
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
for (const stall of stallsOnDay(boards, day - 1)) {
|
|
405
|
+
lines.push(
|
|
406
|
+
t('notes.stallDay', {
|
|
407
|
+
name: stall.name,
|
|
408
|
+
day: day - 1,
|
|
409
|
+
profit: money(symbol, stall.profit),
|
|
410
|
+
count: stall.turnedAway,
|
|
411
|
+
})
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
return lines.join('\n');
|
|
415
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import CloudRounded from '@mui/icons-material/CloudRounded';
|
|
2
|
+
import UmbrellaRounded from '@mui/icons-material/UmbrellaRounded';
|
|
3
|
+
import WbSunnyRounded from '@mui/icons-material/WbSunnyRounded';
|
|
4
|
+
|
|
5
|
+
import type { Weather } from './stalls';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Weather is the one thing on a day's slide the room reads before the words,
|
|
9
|
+
* so it is an icon from the same set as every other screen, in a colour that
|
|
10
|
+
* survives a washed-out projector. Decorative: the words beside it say the same.
|
|
11
|
+
*/
|
|
12
|
+
const ICONS = {
|
|
13
|
+
sunny: { Icon: WbSunnyRounded, color: '#B07F00' },
|
|
14
|
+
cloudy: { Icon: CloudRounded, color: 'var(--deck-muted)' },
|
|
15
|
+
rainy: { Icon: UmbrellaRounded, color: '#2F6DB5' },
|
|
16
|
+
} as const satisfies Record<Weather, unknown>;
|
|
17
|
+
|
|
18
|
+
export function WeatherIcon({ weather, size }: { weather: Weather; size: number }) {
|
|
19
|
+
const { Icon, color } = ICONS[weather];
|
|
20
|
+
return <Icon aria-hidden style={{ fontSize: size, color, flex: 'none' }} />;
|
|
21
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import i18n from 'i18next';
|
|
2
|
+
import { initReactI18next } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
// Every word on a slide comes from here, so the deck follows the session's
|
|
5
|
+
// language and exports in it.
|
|
6
|
+
const resources = {
|
|
7
|
+
en: {
|
|
8
|
+
translation: {
|
|
9
|
+
subtitle: 'Read the forecast, decide what to make, open up',
|
|
10
|
+
scenario: 'Scenario: {{name}}',
|
|
11
|
+
dayOf: 'Day {{n}} of {{total}}',
|
|
12
|
+
question: 'What will you make?',
|
|
13
|
+
headline: {
|
|
14
|
+
sunny: 'Sunny and busy',
|
|
15
|
+
cloudy: 'Cloudy and steady',
|
|
16
|
+
rainy: 'Rain on the way',
|
|
17
|
+
mixed: 'Mixed weather',
|
|
18
|
+
},
|
|
19
|
+
outlook: {
|
|
20
|
+
sunny: 'More people about than on a cloudy day. What will you make?',
|
|
21
|
+
cloudy: 'An ordinary day for trade. What will you make?',
|
|
22
|
+
rainy: 'Fewer people about than on a cloudy day. What will you make?',
|
|
23
|
+
},
|
|
24
|
+
stallsFacing: {
|
|
25
|
+
sunny_one: 'Sunny at {{count}} stall',
|
|
26
|
+
sunny_other: 'Sunny at {{count}} stalls',
|
|
27
|
+
cloudy_one: 'Cloudy at {{count}} stall',
|
|
28
|
+
cloudy_other: 'Cloudy at {{count}} stalls',
|
|
29
|
+
rainy_one: 'Rain at {{count}} stall',
|
|
30
|
+
rainy_other: 'Rain at {{count}} stalls',
|
|
31
|
+
},
|
|
32
|
+
weather: {
|
|
33
|
+
sunny: 'sunny',
|
|
34
|
+
cloudy: 'cloudy',
|
|
35
|
+
rainy: 'rainy',
|
|
36
|
+
},
|
|
37
|
+
forecastNotYet: 'No stall has reached this day yet',
|
|
38
|
+
forecastPending: 'The forecast appears here when the stalls reach this day',
|
|
39
|
+
acrossTheRoom: 'Day {{n}}, across the room',
|
|
40
|
+
turnedAway_one: 'person wanted something and went away without it',
|
|
41
|
+
turnedAway_other: 'people wanted something and went away without it',
|
|
42
|
+
averageProfit: 'Profit, average stall',
|
|
43
|
+
range: 'Lowest to highest',
|
|
44
|
+
fromStalls_one: 'From the {{count}} stall that has played it',
|
|
45
|
+
fromStalls_other: 'From the {{count}} stalls that have played it',
|
|
46
|
+
roomPending: 'The room’s figures for day {{n}} appear here once a stall has played it',
|
|
47
|
+
howHeading: 'How a day works',
|
|
48
|
+
howMake: 'Make what you think will sell',
|
|
49
|
+
howMakeDetail: 'Read the forecast, then choose how many of each item to make',
|
|
50
|
+
howPour: 'Too many, and it is poured away',
|
|
51
|
+
howPourDetail: 'Everything you make costs money, sold or not',
|
|
52
|
+
howTurn: 'Too few, and customers go elsewhere',
|
|
53
|
+
howTurnDetail: 'Every person turned away is a sale you did not make',
|
|
54
|
+
resultsHeading: 'How the room did',
|
|
55
|
+
resultsAverage: 'in the purse of the average stall',
|
|
56
|
+
resultsTurnedAway: 'Turned away, every day together',
|
|
57
|
+
resultsUnfinished_one:
|
|
58
|
+
'From the {{count}} stall that has opened. Some days are still to play',
|
|
59
|
+
resultsUnfinished_other:
|
|
60
|
+
'From the {{count}} stalls that have opened. Some days are still to play',
|
|
61
|
+
resultsPending: 'The room’s results appear here once the stalls have opened up',
|
|
62
|
+
notes: {
|
|
63
|
+
title: 'Welcome the room, then explain the stall in one sentence.',
|
|
64
|
+
day: 'Ask a stall that turned people away what it would make differently.',
|
|
65
|
+
forecasts: 'Forecasts: {{list}}.',
|
|
66
|
+
stallDay_one:
|
|
67
|
+
'{{name}}, day {{day}}: {{profit}} profit, {{count}} person turned away.',
|
|
68
|
+
stallDay_other:
|
|
69
|
+
'{{name}}, day {{day}}: {{profit}} profit, {{count}} people turned away.',
|
|
70
|
+
results:
|
|
71
|
+
'Ask the richest stall which mistake it preferred: pouring away, or turning away.',
|
|
72
|
+
standing_one: '{{place}}. {{name}}: {{purse}} after {{count}} day.',
|
|
73
|
+
standing_other: '{{place}}. {{name}}: {{purse}} after {{count}} days.',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
void i18n.use(initReactI18next).init({
|
|
80
|
+
resources,
|
|
81
|
+
lng: 'en',
|
|
82
|
+
fallbackLng: 'en',
|
|
83
|
+
interpolation: {
|
|
84
|
+
escapeValue: false, // React already escapes
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export default i18n;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '@fontsource-variable/work-sans';
|
|
2
|
+
import { PresentationWrapper } from '@seriousgaming/sdk/ui';
|
|
3
|
+
import { StrictMode } from 'react';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
|
|
6
|
+
import App from './App';
|
|
7
|
+
import './i18n';
|
|
8
|
+
|
|
9
|
+
createRoot(document.getElementById('root')!).render(
|
|
10
|
+
<StrictMode>
|
|
11
|
+
<PresentationWrapper>
|
|
12
|
+
<App />
|
|
13
|
+
</PresentationWrapper>
|
|
14
|
+
</StrictMode>
|
|
15
|
+
);
|