@tastic/shell 0.22.0 → 0.23.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/README.md +44 -9
- package/dist/index.d.mts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +421 -400
- package/dist/index.mjs +341 -321
- package/package.json +1 -1
- package/src/components/GuideCards.tsx +63 -0
- package/src/components/GuideHost.tsx +36 -97
- package/src/components/StartGuide.tsx +46 -0
- package/src/index.ts +1 -0
- package/src/screens/GameRoute.tsx +10 -2
- package/src/screens/HomeScreen.tsx +4 -9
- package/src/types.ts +20 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tastic/shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "The app around a pack of React Native games, two-seat or for one player: Home, the loadout, the stats screen, Profiles and Settings, the pack's Redux store and its root providers, driven by one PackDefinition",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useIsTouchPrimaryDevice } from '@tastic/core'
|
|
2
|
+
import { HowToPlayDialog } from '@tastic/hud/guide'
|
|
3
|
+
import { useCallback, useMemo } from 'react'
|
|
4
|
+
import { shallowEqual, useDispatch, useSelector } from 'react-redux'
|
|
5
|
+
|
|
6
|
+
import { usePack } from '../PackContext'
|
|
7
|
+
import type { ShellState } from '../redux/shellState'
|
|
8
|
+
import { type GameGuide, type PackDefinition, type PackGameDefinition, type PackGuide, roundModeFor, seatTwoFor } from '../types'
|
|
9
|
+
|
|
10
|
+
// Which How to Play cards: a game's, by its id, or the pack's own.
|
|
11
|
+
export const PACK_GUIDE = '__pack__'
|
|
12
|
+
|
|
13
|
+
// The cards a game opens over its board the first time it's started, or null where it opens none there:
|
|
14
|
+
// its own, where they open at the start (GameGuide.atStart), or, with none of its own, the pack's.
|
|
15
|
+
export function startSubject(pack: PackDefinition, game: PackGameDefinition): string | null {
|
|
16
|
+
if (game.guide) return game.guide.atStart ? game.id : null
|
|
17
|
+
return pack.guide ? PACK_GUIDE : null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function guideFor(pack: PackDefinition, subject: string | null): PackGuide | GameGuide | undefined {
|
|
21
|
+
return subject === PACK_GUIDE ? pack.guide : pack.games.find((g) => g.id === subject)?.guide
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const NO_INPUT = {}
|
|
25
|
+
|
|
26
|
+
interface Props {
|
|
27
|
+
// PACK_GUIDE or a game's id: cards the pack has.
|
|
28
|
+
subject: string
|
|
29
|
+
visible: boolean
|
|
30
|
+
// After the player finished or skipped them, which counts as having seen them.
|
|
31
|
+
onClose?: () => void
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// One set of How to Play cards, in hud's dialog (or the pack's own, PackDefinition.HowToPlay): the pack's,
|
|
35
|
+
// or a game's, built from the live settings and seat 2 so a replay after any loadout change describes the
|
|
36
|
+
// next match.
|
|
37
|
+
export function GuideCards({ subject, visible, onClose }: Props) {
|
|
38
|
+
const pack = usePack()
|
|
39
|
+
const packGuide = subject === PACK_GUIDE ? pack.guide : undefined
|
|
40
|
+
const game = subject === PACK_GUIDE ? undefined : pack.games.find((g) => g.id === subject)
|
|
41
|
+
const gameGuide = game?.guide
|
|
42
|
+
const guide = packGuide ?? gameGuide
|
|
43
|
+
|
|
44
|
+
const touch = useIsTouchPrimaryDevice()
|
|
45
|
+
const seatTwo = useSelector((state: ShellState) => state.opponent.seatTwo)
|
|
46
|
+
const input = useSelector((state: ShellState) => (gameGuide ? gameGuide.selectInput(state) : NO_INPUT), shallowEqual)
|
|
47
|
+
const seen = useSelector((state: ShellState) => !guide || guide.selectVersionSeen(state) >= guide.version)
|
|
48
|
+
const dispatch = useDispatch()
|
|
49
|
+
|
|
50
|
+
// The seat-2 choice the cards describe: the one the player last picked, or where the game doesn't
|
|
51
|
+
// offer it the CPU (a saved 'nobody' in a game without a solo mode) or, in a game with no CPU, its
|
|
52
|
+
// first choice; nobody in a game for one.
|
|
53
|
+
const mode = roundModeFor(seatTwoFor(seatTwo, game?.seatTwo))
|
|
54
|
+
const steps = useMemo(() => (packGuide ? packGuide.getSteps({ touch }) : gameGuide ? gameGuide.getSteps(input, { touch, mode }) : []), [packGuide, gameGuide, input, touch, mode])
|
|
55
|
+
|
|
56
|
+
const close = useCallback(() => {
|
|
57
|
+
if (guide && !seen) dispatch(guide.markSeen(guide.version))
|
|
58
|
+
onClose?.()
|
|
59
|
+
}, [guide, seen, dispatch, onClose])
|
|
60
|
+
|
|
61
|
+
const Dialog = pack.HowToPlay ?? HowToPlayDialog
|
|
62
|
+
return <Dialog visible={visible} steps={steps} onFinish={close} onSkip={close} />
|
|
63
|
+
}
|
|
@@ -1,138 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { createContext, ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'
|
|
4
|
-
import { shallowEqual, useDispatch, useSelector, useStore } from 'react-redux'
|
|
1
|
+
import { createContext, ReactNode, useCallback, useContext, useMemo, useState } from 'react'
|
|
2
|
+
import { useStore } from 'react-redux'
|
|
5
3
|
|
|
6
4
|
import { usePack } from '../PackContext'
|
|
7
5
|
import type { ShellState } from '../redux/shellState'
|
|
8
|
-
import {
|
|
6
|
+
import { GuideCards, guideFor, PACK_GUIDE } from './GuideCards'
|
|
9
7
|
|
|
10
8
|
interface GameGuideContextValue {
|
|
11
|
-
//
|
|
12
|
-
// then runs `next` once they close
|
|
13
|
-
//
|
|
14
|
-
// its loadout opens.
|
|
9
|
+
// Home's tile tap: shows a game's cards if this player hasn't finished or skipped this version yet,
|
|
10
|
+
// then runs `next` (into its loadout) once they close. Runs `next` at once otherwise, for a game with
|
|
11
|
+
// no cards of its own, and for one whose cards open over its board instead (GameGuide.atStart).
|
|
15
12
|
openFirstTime: (gameId: string, next: () => void) => void
|
|
16
13
|
// Shows a game's cards now, seen or not (a tile's rules button, a loadout's How to Play row). Does
|
|
17
14
|
// nothing for a game with no cards of its own.
|
|
18
15
|
openFor: (gameId: string) => void
|
|
19
16
|
// Shows the pack's own cards now (PackDefinition.guide: Home's Settings).
|
|
20
17
|
openPack: () => void
|
|
21
|
-
// Shows the pack's own cards once per session, while this player hasn't seen this version (Home's
|
|
22
|
-
// first launch).
|
|
23
|
-
autoShowPack: () => void
|
|
24
18
|
}
|
|
25
19
|
|
|
26
|
-
// What the one GuideProvider is showing: the pack's own cards, or a game's (by id).
|
|
27
|
-
const PACK_GUIDE = '__pack__'
|
|
28
|
-
|
|
29
|
-
const NO_INPUT = {}
|
|
30
|
-
|
|
31
20
|
const GameGuideContext = createContext<GameGuideContextValue | null>(null)
|
|
32
21
|
|
|
33
22
|
interface Props {
|
|
34
23
|
children: ReactNode
|
|
35
24
|
}
|
|
36
25
|
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// in RootLayout, inside the toast provider because the card renders through a Portal, and inside the
|
|
42
|
-
// profiles gate so it mounts together with Home.
|
|
43
|
-
export function GuideHost({ children }: Props) {
|
|
44
|
-
const pack = usePack()
|
|
45
|
-
const [subject, setSubject] = useState(() => (pack.guide ? PACK_GUIDE : (pack.games.find((g) => g.guide)?.id ?? null)))
|
|
46
|
-
const packGuide = subject === PACK_GUIDE ? pack.guide : undefined
|
|
47
|
-
const game = subject === PACK_GUIDE ? undefined : pack.games.find((g) => g.id === subject)
|
|
48
|
-
const gameGuide = game?.guide
|
|
49
|
-
|
|
50
|
-
const touch = useIsTouchPrimaryDevice()
|
|
51
|
-
const seatTwo = useSelector((state: ShellState) => state.opponent.seatTwo)
|
|
52
|
-
const input = useSelector((state: ShellState) => (gameGuide ? gameGuide.selectInput(state) : NO_INPUT), shallowEqual)
|
|
53
|
-
const seenVersion = useSelector((state: ShellState) => (packGuide ?? gameGuide)?.selectVersionSeen(state) ?? 0)
|
|
54
|
-
const dispatch = useDispatch()
|
|
55
|
-
|
|
56
|
-
// The seat-2 choice the cards describe: the one the player last picked, or where the game doesn't
|
|
57
|
-
// offer it the CPU (a saved 'nobody' in a game without a solo mode) or, in a game with no CPU, its
|
|
58
|
-
// first choice; nobody in a game for one.
|
|
59
|
-
const mode = roundModeFor(seatTwoFor(seatTwo, game?.seatTwo))
|
|
60
|
-
const steps = useMemo(() => (packGuide ? packGuide.getSteps({ touch }) : gameGuide ? gameGuide.getSteps(input, { touch, mode }) : []), [packGuide, gameGuide, input, touch, mode])
|
|
61
|
-
const onSeen = useCallback(
|
|
62
|
-
(version: number) => {
|
|
63
|
-
const guide = packGuide ?? gameGuide
|
|
64
|
-
if (guide) dispatch(guide.markSeen(version))
|
|
65
|
-
},
|
|
66
|
-
[dispatch, packGuide, gameGuide]
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<GuideProvider steps={steps} currentVersion={(packGuide ?? gameGuide)?.version ?? 0} seenVersion={seenVersion} onSeen={onSeen}>
|
|
71
|
-
<GameGuideBridge onPick={setSubject}>{children}</GameGuideBridge>
|
|
72
|
-
</GuideProvider>
|
|
73
|
-
)
|
|
26
|
+
// What's open: whose cards, and where the tap that opened them was going.
|
|
27
|
+
interface Shown {
|
|
28
|
+
subject: string
|
|
29
|
+
next?: () => void
|
|
74
30
|
}
|
|
75
31
|
|
|
76
|
-
//
|
|
77
|
-
|
|
32
|
+
// The How to Play cards opened from Home and the loadouts, for the whole pack: one set at a time, the
|
|
33
|
+
// pack's own (PackDefinition.guide) or a game's (GameDefinition.guide). The ones a game opens over its
|
|
34
|
+
// board are its play route's (StartGuide). Mounted around the stack in RootLayout, inside the toast
|
|
35
|
+
// provider because the card renders through a Portal, and inside the profiles gate so it mounts together
|
|
36
|
+
// with Home.
|
|
37
|
+
export function GuideHost({ children }: Props) {
|
|
78
38
|
const pack = usePack()
|
|
79
39
|
const store = useStore<ShellState>()
|
|
80
|
-
const
|
|
81
|
-
const pendingNext = useRef<(() => void) | null>(null)
|
|
82
|
-
const wasOpen = useRef(false)
|
|
83
|
-
// The pack's cards show by themselves once per session at most: Home mounts again whenever the
|
|
84
|
-
// player comes back to it, and skipping shouldn't have to happen twice before the seen version is
|
|
85
|
-
// written back.
|
|
86
|
-
const packAutoShown = useRef(false)
|
|
87
|
-
|
|
88
|
-
// When cards opened by openFirstTime close (finished, skipped or dismissed), carry on to where the
|
|
89
|
-
// tap was going.
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (wasOpen.current && !isOpen && pendingNext.current) {
|
|
92
|
-
const next = pendingNext.current
|
|
93
|
-
pendingNext.current = null
|
|
94
|
-
next()
|
|
95
|
-
}
|
|
96
|
-
wasOpen.current = isOpen
|
|
97
|
-
}, [isOpen])
|
|
40
|
+
const [shown, setShown] = useState<Shown | null>(null)
|
|
98
41
|
|
|
99
42
|
const openFor = useCallback(
|
|
100
43
|
(gameId: string) => {
|
|
101
|
-
if (
|
|
102
|
-
onPick(gameId)
|
|
103
|
-
open()
|
|
44
|
+
if (guideFor(pack, gameId)) setShown({ subject: gameId })
|
|
104
45
|
},
|
|
105
|
-
[pack
|
|
46
|
+
[pack]
|
|
106
47
|
)
|
|
107
48
|
|
|
108
49
|
const openFirstTime = useCallback(
|
|
109
50
|
(gameId: string, next: () => void) => {
|
|
110
51
|
const guide = pack.games.find((g) => g.id === gameId)?.guide
|
|
111
|
-
if (!guide || guide.selectVersionSeen(store.getState()) >= guide.version)
|
|
112
|
-
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
pendingNext.current = next
|
|
116
|
-
openFor(gameId)
|
|
52
|
+
if (!guide || guide.atStart || guide.selectVersionSeen(store.getState()) >= guide.version) next()
|
|
53
|
+
else setShown({ subject: gameId, next })
|
|
117
54
|
},
|
|
118
|
-
[pack, store
|
|
55
|
+
[pack, store]
|
|
119
56
|
)
|
|
120
57
|
|
|
121
58
|
const openPack = useCallback(() => {
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
open()
|
|
125
|
-
}, [pack, onPick, open])
|
|
59
|
+
if (pack.guide) setShown({ subject: PACK_GUIDE })
|
|
60
|
+
}, [pack])
|
|
126
61
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}, [pack, store, openPack])
|
|
62
|
+
// Finished or skipped: on to where the tap was going.
|
|
63
|
+
const handleClose = useCallback(() => {
|
|
64
|
+
setShown(null)
|
|
65
|
+
shown?.next?.()
|
|
66
|
+
}, [shown])
|
|
133
67
|
|
|
134
|
-
const value = useMemo(() => ({ openFirstTime, openFor, openPack
|
|
135
|
-
return
|
|
68
|
+
const value = useMemo(() => ({ openFirstTime, openFor, openPack }), [openFirstTime, openFor, openPack])
|
|
69
|
+
return (
|
|
70
|
+
<GameGuideContext.Provider value={value}>
|
|
71
|
+
{children}
|
|
72
|
+
{shown && <GuideCards subject={shown.subject} visible onClose={handleClose} />}
|
|
73
|
+
</GameGuideContext.Provider>
|
|
74
|
+
)
|
|
136
75
|
}
|
|
137
76
|
|
|
138
77
|
export function useGameGuide(): GameGuideContextValue {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useIsFocused } from 'expo-router'
|
|
2
|
+
import { createContext, type ReactNode, useContext, useEffect, useState } from 'react'
|
|
3
|
+
import { useSelector } from 'react-redux'
|
|
4
|
+
|
|
5
|
+
import { usePack } from '../PackContext'
|
|
6
|
+
import type { ShellState } from '../redux/shellState'
|
|
7
|
+
import type { PackGameDefinition } from '../types'
|
|
8
|
+
import { GuideCards, guideFor, startSubject } from './GuideCards'
|
|
9
|
+
|
|
10
|
+
// Long enough for the play screen to have come in and its board to show (HexFleet's delay).
|
|
11
|
+
export const GUIDE_DELAY_MS = 700
|
|
12
|
+
|
|
13
|
+
const GuideCoveringContext = createContext(false)
|
|
14
|
+
|
|
15
|
+
// Whether How to Play cards are over this game's board, or about to be: true from the play screen's first
|
|
16
|
+
// frame until the player closes them, the first time the game is started. A game that opens its cards
|
|
17
|
+
// there (GameGuide.atStart, or a game the pack's own cards teach) holds everything while it's true, as
|
|
18
|
+
// under its Settings: its clock, its simulation, its input and any card of its own (a hand-off). False
|
|
19
|
+
// everywhere else, a test that renders the play screen on its own included.
|
|
20
|
+
export function useGuideCovering(): boolean {
|
|
21
|
+
return useContext(GuideCoveringContext)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// A play screen, with its How to Play cards over the board the first time the game is started, however the
|
|
25
|
+
// player got there (Ready, a link, a relaunch into the board). Leaving before they're closed counts as
|
|
26
|
+
// nothing seen, so they come up again next time.
|
|
27
|
+
export function StartGuide({ game, enabled, children }: { game: PackGameDefinition; enabled: boolean; children: ReactNode }) {
|
|
28
|
+
const pack = usePack()
|
|
29
|
+
const focused = useIsFocused()
|
|
30
|
+
const subject = enabled ? startSubject(pack, game) : null
|
|
31
|
+
const guide = guideFor(pack, subject)
|
|
32
|
+
const covering = useSelector((state: ShellState) => !!guide && guide.selectVersionSeen(state) < guide.version)
|
|
33
|
+
const [due, setDue] = useState(false)
|
|
34
|
+
const waiting = covering && focused && !due
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!waiting) return
|
|
37
|
+
const timeout = setTimeout(() => setDue(true), GUIDE_DELAY_MS)
|
|
38
|
+
return () => clearTimeout(timeout)
|
|
39
|
+
}, [waiting])
|
|
40
|
+
return (
|
|
41
|
+
<GuideCoveringContext.Provider value={covering}>
|
|
42
|
+
{children}
|
|
43
|
+
{subject !== null && covering && <GuideCards subject={subject} visible={due && focused} />}
|
|
44
|
+
</GuideCoveringContext.Provider>
|
|
45
|
+
)
|
|
46
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { imageGameIcon } from './components/imageGameIcon'
|
|
|
19
19
|
export { MATCH_CHIPS_FADE_MS, MatchChips, type MatchChipsProps } from './components/MatchChips'
|
|
20
20
|
export { SettingsDialog, type SettingsDialogProps } from './components/SettingsDialog'
|
|
21
21
|
export { Staged } from './components/Staged'
|
|
22
|
+
export { useGuideCovering } from './components/StartGuide'
|
|
22
23
|
export { useActiveRound } from './hooks/useActiveRound'
|
|
23
24
|
export { useAppSettings } from './hooks/useAppSettings'
|
|
24
25
|
export { useAtComputer } from './hooks/useAtComputer'
|
|
@@ -2,6 +2,7 @@ import { Redirect, useLocalSearchParams } from 'expo-router'
|
|
|
2
2
|
import { useEffect } from 'react'
|
|
3
3
|
import { AppState } from 'react-native'
|
|
4
4
|
|
|
5
|
+
import { StartGuide } from '../components/StartGuide'
|
|
5
6
|
import { useLastActiveGame } from '../hooks/useLastActiveGame'
|
|
6
7
|
import { usePackGame } from '../PackContext'
|
|
7
8
|
import { playHref } from '../routes'
|
|
@@ -27,14 +28,21 @@ function hasLoadout(game: PackGameDefinition): game is LoadoutGame {
|
|
|
27
28
|
return !!game.useLoadout
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
// `guide` false opens no How to Play over this play of the game, and holds nothing for it: a game whose
|
|
32
|
+
// clock can't be held (CardTastic's Daily Deals, timed by the server from the tap that starts one). The
|
|
33
|
+
// cards stay unseen, for the next play without it.
|
|
34
|
+
export function PlayRoute({ guide = true }: { guide?: boolean } = {}) {
|
|
31
35
|
const { game: id } = useLocalSearchParams<{ game: string }>()
|
|
32
36
|
const game = usePackGame(id)
|
|
33
37
|
useResumePoint(game?.resumable ? game.id : null)
|
|
34
38
|
useResumeUp()
|
|
35
39
|
if (!game) return <Redirect href='/' />
|
|
36
40
|
const { PlayScreen } = game
|
|
37
|
-
return
|
|
41
|
+
return (
|
|
42
|
+
<StartGuide key={game.id} game={game} enabled={guide}>
|
|
43
|
+
<PlayScreen />
|
|
44
|
+
</StartGuide>
|
|
45
|
+
)
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
// Tells a launch going back into a game that its play screen is mounted (by the second frame after this one
|
|
@@ -24,18 +24,16 @@ import { HOME_GRID_GAP, HOME_LEFT_PANE_PICKER_GAP, HOME_TILE_PADDING, HOME_TOP_B
|
|
|
24
24
|
// pack as a row in a fixed order, Solitaire's list: each game on its own well, its small app icon
|
|
25
25
|
// (or its preview, GameDefinition.Preview) beside its name and blurb. A tap opens that game's
|
|
26
26
|
// loadout, or its play screen in a game without one, after its How to Play cards the first time it's
|
|
27
|
-
// picked
|
|
28
|
-
//
|
|
27
|
+
// picked (a game whose cards open over its board goes straight in, GameGuide.atStart). Seat 2 is chosen in
|
|
28
|
+
// the loadout, from player 1's opponent button. A pack with tabs (PackDefinition.homeTabs) shows one tab's
|
|
29
|
+
// games at a time, from a switch over the rows.
|
|
29
30
|
//
|
|
30
31
|
// A cold launch that finds the player left the app inside a resumable game's play screen
|
|
31
32
|
// (GameDefinition.resumable) goes straight back there instead, before the menu ever paints, with the
|
|
32
|
-
// game's setup screen and this Home beneath it (useResume).
|
|
33
|
-
// pack's own How to Play (PackDefinition.guide) shows by itself on a first launch, held back while
|
|
34
|
-
// that launch is about to drop into a game: it must never open over a game in progress.
|
|
33
|
+
// game's setup screen and this Home beneath it (useResume).
|
|
35
34
|
export function HomeScreen() {
|
|
36
35
|
const pack = usePack()
|
|
37
36
|
const { consumeResumeGame } = useLastActiveGame()
|
|
38
|
-
const { autoShowPack } = useGameGuide()
|
|
39
37
|
// A one-shot cold-launch decision, read exactly once at this instance's mount (see
|
|
40
38
|
// hooks/useLastActiveGame.tsx), never a live value this screen re-renders from. Reading it live made
|
|
41
39
|
// every Home in the stack swap its whole menu for a Redirect while a game was on top and rebuild it
|
|
@@ -45,9 +43,6 @@ export function HomeScreen() {
|
|
|
45
43
|
const id = consumeResumeGame()
|
|
46
44
|
return pack.games.find((g) => g.id === id && g.resumable) ?? null
|
|
47
45
|
})
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (!resumeGame) autoShowPack()
|
|
50
|
-
}, [resumeGame, autoShowPack])
|
|
51
46
|
useResume(resumeGame)
|
|
52
47
|
return useMenuShown(!!resumeGame) ? <HomeMenu /> : null
|
|
53
48
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ThemeAppearance, ThemeSettings } from '@rific/auto-paper'
|
|
2
2
|
import type { AlignResult, PopoverHost } from '@tastic/hud/chrome'
|
|
3
|
-
import type { GuideStep } from '@tastic/hud/guide'
|
|
3
|
+
import type { GuideStep, HowToPlayDialogProps } from '@tastic/hud/guide'
|
|
4
4
|
import type { MenuOption } from '@tastic/hud/lobby'
|
|
5
5
|
import type { Profile } from '@tastic/profile'
|
|
6
6
|
import type { FontSource } from 'expo-font'
|
|
@@ -117,6 +117,10 @@ export interface GameGuide {
|
|
|
117
117
|
// Returns a value compared with shallowEqual, so keep it a flat object of the settings read.
|
|
118
118
|
selectInput: (state: ShellState) => object
|
|
119
119
|
getSteps: (input: object, context: { touch: boolean; mode: RoundMode }) => GuideStep[]
|
|
120
|
+
// The cards open over the board the first time the game is started, however the player got there, in
|
|
121
|
+
// place of its tile's first tap on Home. Only for a game whose play screen holds while useGuideCovering()
|
|
122
|
+
// is true: the cards come up over a board that's already there, its clock and its CPU with it.
|
|
123
|
+
atStart?: boolean
|
|
120
124
|
}
|
|
121
125
|
|
|
122
126
|
// A game's icon on Home, drawn in the seats' colors (seat 1's from Home's button, seat 2's from
|
|
@@ -141,8 +145,9 @@ export interface GamePreviewProps {
|
|
|
141
145
|
dark: boolean
|
|
142
146
|
}
|
|
143
147
|
|
|
144
|
-
// The pack's own How to Play (PackDefinition.guide): cards that teach every game
|
|
145
|
-
// shown
|
|
148
|
+
// The pack's own How to Play (PackDefinition.guide): cards that teach every game with none of its own at
|
|
149
|
+
// once, shown over the board the first time any of them is started and replayed from Home's Settings. Each
|
|
150
|
+
// of those games' play screens holds while useGuideCovering() is true. Its seen version is a key of the
|
|
146
151
|
// pack's own (hud's createGuideSlice), so a pack keeps whatever it already saved.
|
|
147
152
|
export interface PackGuide {
|
|
148
153
|
version: number
|
|
@@ -191,8 +196,8 @@ export interface GameDefinition {
|
|
|
191
196
|
// a game whose stats live in the pack's own (PackDefinition.Provider).
|
|
192
197
|
Provider?: ComponentType<{ children: ReactNode }>
|
|
193
198
|
// Left out by a game with nothing to set up before it starts: Home opens its play screen
|
|
194
|
-
// straight away (after its How to Play the first time
|
|
195
|
-
// play screen's own Settings (SettingsDialog's children).
|
|
199
|
+
// straight away (after its How to Play the first time, where that isn't over its board), and its rule
|
|
200
|
+
// variants are rows in its play screen's own Settings (SettingsDialog's children).
|
|
196
201
|
useLoadout?: (mode: RoundMode) => GameLoadout
|
|
197
202
|
PlayScreen: ComponentType
|
|
198
203
|
// A cold launch drops the player back into this game's play screen if that's where they left the
|
|
@@ -211,15 +216,16 @@ export interface GameDefinition {
|
|
|
211
216
|
// Clears the game's stats and achievements (the stats screen's Reset). Left out by a game whose stats
|
|
212
217
|
// the pack resets itself (PackDefinition.resetStats).
|
|
213
218
|
resetStats?: () => Action
|
|
214
|
-
// The game's own How to Play cards: shown the first time its tile is picked,
|
|
215
|
-
// button and its loadout's Settings.
|
|
219
|
+
// The game's own How to Play cards: shown the first time its tile is picked, or over its board the first
|
|
220
|
+
// time it's started (GameGuide.atStart), and from its rules button and its loadout's Settings.
|
|
216
221
|
guide: GameGuide
|
|
217
222
|
// The rules sheet its tile's rules button opens, in place of its How to Play cards.
|
|
218
223
|
Rules?: ComponentType<GameRulesProps>
|
|
219
224
|
}
|
|
220
225
|
|
|
221
|
-
// A game with no How to Play cards of its own, taught by the pack's own (PackDefinition.guide):
|
|
222
|
-
//
|
|
226
|
+
// A game with no How to Play cards of its own, taught by the pack's own (PackDefinition.guide): those open
|
|
227
|
+
// over its board the first time any such game is started, its tile opens without cards, and its rules
|
|
228
|
+
// button shows its Rules or nothing. Its own type
|
|
223
229
|
// rather than an optional `guide` on GameDefinition, so a pack's code that reads its own games' cards
|
|
224
230
|
// (DuelTastic's packGuides test) keeps compiling.
|
|
225
231
|
export type GuidelessGameDefinition = Omit<GameDefinition, 'guide'> & { guide?: undefined }
|
|
@@ -376,9 +382,12 @@ export interface PackDefinition {
|
|
|
376
382
|
// swatches, a loadout's Ready button, each ProfileChip): mounted as @tastic/profile's
|
|
377
383
|
// ProfileColorProvider. The saved colors stay as picked.
|
|
378
384
|
previewColor?: (hex: string, dark: boolean) => string
|
|
379
|
-
// The pack's own How to Play: shown
|
|
380
|
-
//
|
|
385
|
+
// The pack's own How to Play: shown over the board the first time a game with no cards of its own is
|
|
386
|
+
// started, and from Home's Settings.
|
|
381
387
|
guide?: PackGuide
|
|
388
|
+
// The dialog every set of How to Play cards is drawn in, in place of hud's HowToPlayDialog: a pack's own
|
|
389
|
+
// around it (a theme that keeps its titles readable).
|
|
390
|
+
HowToPlay?: ComponentType<HowToPlayDialogProps>
|
|
382
391
|
// Seat 1's button, on Home and in every loadout: the chip's label for a guest (default 'P1') and the
|
|
383
392
|
// guest row's in its menu (default @tastic/profile's). A 2 Player loadout's seat 2 button takes the
|
|
384
393
|
// same two, its guest label defaulting to 'P2'.
|