-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathliveblocks.config.ts
More file actions
74 lines (61 loc) · 1.61 KB
/
Copy pathliveblocks.config.ts
File metadata and controls
74 lines (61 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { LiveList, LiveMap, LiveObject } from '@liveblocks/client'
export type GameCard = {
id: string
pairId: number
image: string
isMatched: boolean
}
export type PlayerScore = {
collectedPairIds: Array<number>
pairsCount: number
}
export const ROOM_EVENTS = {
GAME_STARTING: 'GAME_STARTING',
GAME_FINISHED: 'GAME_FINISHED',
MATCH_SOUND: 'MATCH_SOUND',
ERROR_SOUND: 'ERROR_SOUND',
} as const
export type PlayerStates = LiveMap<string, LiveObject<PlayerScore>>
declare global {
interface Liveblocks {
// Each user's Presence
Presence: {
cursor: { x: number; y: number } | null
username: string
}
// Room Storage
Storage: {
state: 'LOBBY' | 'IN_PROGRESS' | 'FINISHED'
cards: LiveList<LiveObject<GameCard>>
playerStates: PlayerStates
// Game configuration
totalPairs: number
totalPairsMatched: number
// Turn & Selection state
currentTurnPlayerId: string | null
firstSelectedId: string | null
secondSelectedId: string | null
// Animation states
animatingMatchIds: Array<string>
animatingErrorIds: Array<string>
canSelect: boolean
// Game outcome
winningPlayerId: string | null
}
// Broadcast events for sounds
RoomEvent:
| { type: typeof ROOM_EVENTS.GAME_STARTING }
| { type: typeof ROOM_EVENTS.GAME_FINISHED }
| { type: typeof ROOM_EVENTS.MATCH_SOUND }
| { type: typeof ROOM_EVENTS.ERROR_SOUND }
// User metadata from auth
UserMeta: {
id: string
info: {
username: string
email: string
}
}
}
}
export {}