@doodle-engine/core 0.0.1

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.
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Snapshot type definitions for the Doodle Engine.
3
+ * A snapshot is a point-in-time view of the game state formatted for rendering.
4
+ * The renderer displays snapshots but never sees raw game state.
5
+ */
6
+ import type { Time } from './state';
7
+ /**
8
+ * Location information in a snapshot (localized).
9
+ */
10
+ export interface SnapshotLocation {
11
+ /** Location ID */
12
+ id: string;
13
+ /** Localized display name */
14
+ name: string;
15
+ /** Localized description text */
16
+ description: string;
17
+ /** Banner image filename */
18
+ banner: string;
19
+ }
20
+ /**
21
+ * Character information in a snapshot (localized).
22
+ */
23
+ export interface SnapshotCharacter {
24
+ /** Character ID */
25
+ id: string;
26
+ /** Localized display name */
27
+ name: string;
28
+ /** Localized biography text */
29
+ biography: string;
30
+ /** Portrait image filename */
31
+ portrait: string;
32
+ /** Current location ID */
33
+ location: string;
34
+ /** Whether this character is in the party */
35
+ inParty: boolean;
36
+ /** Relationship value with the player */
37
+ relationship: number;
38
+ /** Character stats */
39
+ stats: Record<string, unknown>;
40
+ }
41
+ /**
42
+ * Item information in a snapshot (localized).
43
+ */
44
+ export interface SnapshotItem {
45
+ /** Item ID */
46
+ id: string;
47
+ /** Localized display name */
48
+ name: string;
49
+ /** Localized description text */
50
+ description: string;
51
+ /** Icon image filename */
52
+ icon: string;
53
+ /** Large image filename */
54
+ image: string;
55
+ /** Item stats */
56
+ stats: Record<string, unknown>;
57
+ }
58
+ /**
59
+ * A player choice in a dialogue (localized).
60
+ */
61
+ export interface SnapshotChoice {
62
+ /** Choice ID */
63
+ id: string;
64
+ /** Localized choice text */
65
+ text: string;
66
+ }
67
+ /**
68
+ * Current dialogue node information (localized).
69
+ */
70
+ export interface SnapshotDialogue {
71
+ /** Character ID speaking, or null for narration */
72
+ speaker: string | null;
73
+ /** Localized speaker name (or "Narrator") */
74
+ speakerName: string;
75
+ /** Localized dialogue text */
76
+ text: string;
77
+ /** Portrait image filename (if speaker is a character) */
78
+ portrait?: string;
79
+ /** Voice audio filename (optional) */
80
+ voice?: string;
81
+ }
82
+ /**
83
+ * Quest information in a snapshot (localized).
84
+ */
85
+ export interface SnapshotQuest {
86
+ /** Quest ID */
87
+ id: string;
88
+ /** Localized quest name */
89
+ name: string;
90
+ /** Localized quest description */
91
+ description: string;
92
+ /** Current stage ID */
93
+ currentStage: string;
94
+ /** Localized current stage description */
95
+ currentStageDescription: string;
96
+ }
97
+ /**
98
+ * Journal entry information in a snapshot (localized).
99
+ */
100
+ export interface SnapshotJournalEntry {
101
+ /** Entry ID */
102
+ id: string;
103
+ /** Localized entry title */
104
+ title: string;
105
+ /** Localized entry text */
106
+ text: string;
107
+ /** Entry category */
108
+ category: string;
109
+ }
110
+ /**
111
+ * Map location marker in a snapshot (localized).
112
+ */
113
+ export interface SnapshotMapLocation {
114
+ /** Location ID */
115
+ id: string;
116
+ /** Localized location name */
117
+ name: string;
118
+ /** X coordinate on map */
119
+ x: number;
120
+ /** Y coordinate on map */
121
+ y: number;
122
+ /** Whether this is the player's current location */
123
+ isCurrent: boolean;
124
+ }
125
+ /**
126
+ * Map information in a snapshot (localized).
127
+ */
128
+ export interface SnapshotMap {
129
+ /** Map ID */
130
+ id: string;
131
+ /** Localized map name */
132
+ name: string;
133
+ /** Map image filename */
134
+ image: string;
135
+ /** Map scale for travel time calculation */
136
+ scale: number;
137
+ /** Locations on this map */
138
+ locations: SnapshotMapLocation[];
139
+ }
140
+ /**
141
+ * A snapshot represents everything the renderer needs to display the current moment.
142
+ * All localization has been resolved, all conditions have been evaluated.
143
+ * The renderer never sees raw game state, content registry, or localization keys.
144
+ */
145
+ export interface Snapshot {
146
+ /** Current location information */
147
+ location: SnapshotLocation;
148
+ /** Characters at the current location */
149
+ charactersHere: SnapshotCharacter[];
150
+ /** Items at the current location (not in inventory) */
151
+ itemsHere: SnapshotItem[];
152
+ /** Available dialogue choices (only if in dialogue) */
153
+ choices: SnapshotChoice[];
154
+ /** Current dialogue node (null if not in dialogue) */
155
+ dialogue: SnapshotDialogue | null;
156
+ /** Characters in the player's party */
157
+ party: SnapshotCharacter[];
158
+ /** Items in the player's inventory */
159
+ inventory: SnapshotItem[];
160
+ /** Active quests with current stages */
161
+ quests: SnapshotQuest[];
162
+ /** Unlocked journal entries */
163
+ journal: SnapshotJournalEntry[];
164
+ /** Game variables (gold, counters, etc.) */
165
+ variables: Record<string, number | string>;
166
+ /** Current in-game time */
167
+ time: Time;
168
+ /** Map data (null if map is disabled) */
169
+ map: SnapshotMap | null;
170
+ /** Current music track filename */
171
+ music: string;
172
+ /** Current ambient sound filename */
173
+ ambient: string;
174
+ /** Notifications to display (cleared after shown) */
175
+ notifications: string[];
176
+ /** Sound effects to play (from recent playSound effects) */
177
+ pendingSounds: string[];
178
+ /** Video to play fullscreen (from playVideo effect) */
179
+ pendingVideo: string | null;
180
+ }
181
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/types/snapshot.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEnC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mBAAmB;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAA;I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EvB,+BAA+B;IAC/B,OAAO,EAAE,oBAAoB,EAAE,CAAA;IAE/B,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;IAE1C,2BAA2B;IAC3B,IAAI,EAAE,IAAI,CAAA;IAEV,yCAAyC;IACzC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAA;IAEvB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IAEb,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAA;IAEf,qDAAqD;IACrD,aAAa,EAAE,MAAM,EAAE,CAAA;IAEvB,4DAA4D;IAC5D,aAAa,EAAE,MAAM,EAAE,CAAA;IAEvB,uDAAuD;IACvD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Game state type definitions for the Doodle Engine.
3
+ * These represent all mutable data that changes during gameplay.
4
+ */
5
+ /**
6
+ * In-game time representation.
7
+ */
8
+ export interface Time {
9
+ /** Current day number (1-based) */
10
+ day: number;
11
+ /** Current hour (0-23) */
12
+ hour: number;
13
+ }
14
+ /**
15
+ * Mutable state for a single character.
16
+ */
17
+ export interface CharacterState {
18
+ /** Current location ID where this character is */
19
+ location: string;
20
+ /** Whether this character is traveling with the player */
21
+ inParty: boolean;
22
+ /** Disposition value toward the player */
23
+ relationship: number;
24
+ /** Extensible stats object - engine stores but doesn't interpret */
25
+ stats: Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Current dialogue state.
29
+ */
30
+ export interface DialogueState {
31
+ /** ID of the active dialogue */
32
+ dialogueId: string;
33
+ /** ID of the current node in that dialogue */
34
+ nodeId: string;
35
+ }
36
+ /**
37
+ * A note written by the player.
38
+ */
39
+ export interface PlayerNote {
40
+ /** Unique ID for this note */
41
+ id: string;
42
+ /** Note title */
43
+ title: string;
44
+ /** Note content */
45
+ text: string;
46
+ }
47
+ /**
48
+ * Complete game state - everything that changes during play.
49
+ * This is what gets saved and loaded.
50
+ */
51
+ export interface GameState {
52
+ /** Location ID where the player currently is */
53
+ currentLocation: string;
54
+ /** Current in-game time */
55
+ currentTime: Time;
56
+ /** True/false values for story tracking */
57
+ flags: Record<string, boolean>;
58
+ /** Numbers or strings for quantities, names, etc. */
59
+ variables: Record<string, number | string>;
60
+ /** Item IDs the player is carrying */
61
+ inventory: string[];
62
+ /** Current stage for each started quest (questId -> stageId) */
63
+ questProgress: Record<string, string>;
64
+ /** Journal entry IDs that have been unlocked */
65
+ unlockedJournalEntries: string[];
66
+ /** Notes the player has written */
67
+ playerNotes: PlayerNote[];
68
+ /** Current conversation state, or null if not in dialogue */
69
+ dialogueState: DialogueState | null;
70
+ /** All mutable character data (characterId -> CharacterState) */
71
+ characterState: Record<string, CharacterState>;
72
+ /** Current location of each item (itemId -> locationId or "inventory") */
73
+ itemLocations: Record<string, string>;
74
+ /** Whether the player can open the map */
75
+ mapEnabled: boolean;
76
+ /** Recent events to show the player (cleared after shown) */
77
+ notifications: string[];
78
+ /** Sound effects to play (cleared after snapshot is built) */
79
+ pendingSounds: string[];
80
+ /** Video to play (cleared after snapshot is built) */
81
+ pendingVideo: string | null;
82
+ /** Active language code (e.g., "en", "es") */
83
+ currentLocale: string;
84
+ }
85
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/types/state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAA;IAChB,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAA;IAChB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAA;IACpB,oEAAoE;I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,EAAE,MAAM,EAAE,CAAA;IAEvB,sDAAsD;IACtD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3B,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAA;CACtB"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@doodle-engine/core",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/core.cjs",
6
+ "module": "./dist/core.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/core.js",
12
+ "require": "./dist/core.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "dev": "vite build --watch",
20
+ "build": "vite build && tsc -p tsconfig.json",
21
+ "test": "vitest run"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^24.0.0",
25
+ "typescript": "^5.7.0",
26
+ "vite": "^6.0.0",
27
+ "vitest": "^2.0.0"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/katbella/doodle-engine.git",
35
+ "directory": "packages/core"
36
+ },
37
+ "engines": {
38
+ "node": ">=24.0.0"
39
+ }
40
+ }