@datamoc/mw_games 0.11.0 → 0.13.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/CHANGELOG.md +84 -0
- package/dist/audio/Playable.d.ts +2 -0
- package/dist/audio/Playable.d.ts.map +1 -1
- package/dist/audio/Playable.js.map +1 -1
- package/dist/audio/Sound.d.ts +7 -1
- package/dist/audio/Sound.d.ts.map +1 -1
- package/dist/audio/Sound.js +8 -1
- package/dist/audio/Sound.js.map +1 -1
- package/dist/core/DialogueText.d.ts +47 -0
- package/dist/core/DialogueText.d.ts.map +1 -0
- package/dist/core/DialogueText.js +43 -0
- package/dist/core/DialogueText.js.map +1 -0
- package/dist/core/Twee.d.ts +67 -0
- package/dist/core/Twee.d.ts.map +1 -0
- package/dist/core/Twee.js +140 -0
- package/dist/core/Twee.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/mw_games.global.js +116 -115
- package/dist/rpg/EventRunner.d.ts +24 -0
- package/dist/rpg/EventRunner.d.ts.map +1 -1
- package/dist/rpg/EventRunner.js +56 -15
- package/dist/rpg/EventRunner.js.map +1 -1
- package/dist/rpg/GridMover.d.ts +6 -0
- package/dist/rpg/GridMover.d.ts.map +1 -1
- package/dist/rpg/GridMover.js +17 -0
- package/dist/rpg/GridMover.js.map +1 -1
- package/dist/rpg/MoveRoute.d.ts +87 -0
- package/dist/rpg/MoveRoute.d.ts.map +1 -0
- package/dist/rpg/MoveRoute.js +110 -0
- package/dist/rpg/MoveRoute.js.map +1 -0
- package/dist/rpg/dialogue-text.d.ts +81 -0
- package/dist/rpg/dialogue-text.d.ts.map +1 -0
- package/dist/rpg/dialogue-text.js +88 -0
- package/dist/rpg/dialogue-text.js.map +1 -0
- package/dist/rpg/index.d.ts +6 -1
- package/dist/rpg/index.d.ts.map +1 -1
- package/dist/rpg/index.js +3 -0
- package/dist/rpg/index.js.map +1 -1
- package/dist/rpg/twee-events.d.ts +48 -0
- package/dist/rpg/twee-events.d.ts.map +1 -0
- package/dist/rpg/twee-events.js +35 -0
- package/dist/rpg/twee-events.js.map +1 -0
- package/dist/two-d/stage/dialogue-text.d.ts +81 -0
- package/dist/two-d/stage/dialogue-text.d.ts.map +1 -0
- package/dist/two-d/stage/dialogue-text.js +95 -0
- package/dist/two-d/stage/dialogue-text.js.map +1 -0
- package/dist/two-d/stage/index.d.ts +1 -0
- package/dist/two-d/stage/index.d.ts.map +1 -1
- package/dist/two-d/stage/index.js +1 -0
- package/dist/two-d/stage/index.js.map +1 -1
- package/dist/two-d/stage/twee.d.ts +7 -25
- package/dist/two-d/stage/twee.d.ts.map +1 -1
- package/dist/two-d/stage/twee.js +10 -162
- package/dist/two-d/stage/twee.js.map +1 -1
- package/dist/two-d/ui/EventDialogue.d.ts.map +1 -1
- package/dist/two-d/ui/EventDialogue.js +7 -1
- package/dist/two-d/ui/EventDialogue.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { parseDialogueLines } from '../core/DialogueText.js';
|
|
2
|
+
/**
|
|
3
|
+
* A terse, line-based text format for straight (non-branching) dialogue - the format a
|
|
4
|
+
* text-only RPG (`core` plus `rpg`, no renderer at all) can use for its own `EventCommand`
|
|
5
|
+
* scripts without depending on `two-d` for anything. `two-d/stage` has its own wrapper
|
|
6
|
+
* around the same parsing engine (`core.parseDialogueLines`) targeting `StageCommand`
|
|
7
|
+
* instead - declared separately for the same reason `EventChoice` is declared separately
|
|
8
|
+
* from `two-d/ui`'s `Choice`: a Pixi-based visual novel that never touches `rpg`'s map
|
|
9
|
+
* events should not have to pull the whole module in just to parse dialogue text, and a
|
|
10
|
+
* text-only RPG should not have to pull in Pixi either. The actual `@id`/`-` parsing logic
|
|
11
|
+
* lives once in `core.parseDialogueLines`, not copied between the two - only the final
|
|
12
|
+
* command shape (`speaker` here, `as` in `two-d/stage`) differs.
|
|
13
|
+
*
|
|
14
|
+
* Three kinds of line:
|
|
15
|
+
*
|
|
16
|
+
* - `@id text` names who is speaking and says `text`; `@id` alone (no text) just registers
|
|
17
|
+
* the speaker, without saying anything yet.
|
|
18
|
+
* - `- text` continues the two-speaker exchange the first two `@id` lines opened,
|
|
19
|
+
* alternating speaker on every line: the first `-` after the two openers goes to
|
|
20
|
+
* whichever of them did not speak last, and so on.
|
|
21
|
+
* - any other non-blank line narrates, with no speaker.
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* @alice Hello.
|
|
25
|
+
* @bob Hi!
|
|
26
|
+
* - How are you?
|
|
27
|
+
* - Fine, and you?
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The `-` shorthand is deliberately capped at two speakers: it exists for the two-character
|
|
31
|
+
* back-and-forth, not as a guess at which of three or more people talks next. A third
|
|
32
|
+
* distinct `@id` anywhere in the source is a parse error rather than a silent guess; a scene
|
|
33
|
+
* with more than two speakers writes `@id` on every line instead, same as it does today.
|
|
34
|
+
*
|
|
35
|
+
* Lines reach `EventCommand.say` as plain, untranslated text - a game's own translation step
|
|
36
|
+
* decides how that text reaches a player, the same seam MWL's own `_("...")`-marked strings
|
|
37
|
+
* use (the source text doubles as the catalog key). `extractDialogueCatalog` builds that
|
|
38
|
+
* catalog the same way MWL's `extractCatalog` does, for a game that wants a translator-ready
|
|
39
|
+
* file to start from.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { parseDialogueText, EventRunner, GameState } from '@datamoc/mw_games/rpg';
|
|
44
|
+
*
|
|
45
|
+
* declare const game: GameState;
|
|
46
|
+
*
|
|
47
|
+
* const runner = new EventRunner({
|
|
48
|
+
* game,
|
|
49
|
+
* present: async (request) => {
|
|
50
|
+
* console.log(request.speaker ? `${request.speaker}: ${request.text}` : request.text);
|
|
51
|
+
* },
|
|
52
|
+
* });
|
|
53
|
+
* const commands = parseDialogueText(`
|
|
54
|
+
* @alice Hello.
|
|
55
|
+
* @bob Hi!
|
|
56
|
+
* - How are you?
|
|
57
|
+
* - Fine, and you?
|
|
58
|
+
* `);
|
|
59
|
+
* await runner.run(commands);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function parseDialogueText(source) {
|
|
63
|
+
return parseDialogueLines(source).map((line) => line.speaker === undefined ? { say: line.text } : { say: line.text, speaker: line.speaker });
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Collects every `say`/`ask` line's text into an identity catalog - each key mapping to
|
|
67
|
+
* itself, the same shape MWL's own `extractCatalog` builds from `_("...")`-marked strings -
|
|
68
|
+
* so a translator has real entries to work from instead of a wall of untranslated dialogue.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { parseDialogueText, extractDialogueCatalog } from '@datamoc/mw_games/rpg';
|
|
73
|
+
*
|
|
74
|
+
* const commands = parseDialogueText('@alice Hello.\n');
|
|
75
|
+
* console.log(extractDialogueCatalog(commands).messages); // { 'Hello.': 'Hello.' }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export function extractDialogueCatalog(commands, options = {}) {
|
|
79
|
+
const messages = {};
|
|
80
|
+
for (const command of commands) {
|
|
81
|
+
if ('say' in command)
|
|
82
|
+
messages[command.say] = command.say;
|
|
83
|
+
else if ('ask' in command)
|
|
84
|
+
messages[command.ask] = command.ask;
|
|
85
|
+
}
|
|
86
|
+
return { locale: options.locale ?? 'en', direction: options.direction ?? 'ltr', messages };
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=dialogue-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogue-text.js","sourceRoot":"","sources":["../../src/rpg/dialogue-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC/C,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC9C,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAC3F,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sBAAsB,CACrC,QAAiC,EACjC,OAAO,GAA+C,EAAE;IAExD,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,IAAI,KAAK,IAAI,OAAO;YAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;aACrD,IAAI,KAAK,IAAI,OAAO;YAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC5F,CAAC"}
|
package/dist/rpg/index.d.ts
CHANGED
|
@@ -6,9 +6,11 @@ export { GameState } from './GameState.ts';
|
|
|
6
6
|
export { activePage, conditionHolds } from './Event.ts';
|
|
7
7
|
export type { EventTrigger, EventCondition, EventPage, MapEvent } from './Event.ts';
|
|
8
8
|
export { EventRunner } from './EventRunner.ts';
|
|
9
|
-
export type { EventCommand, EventRunnerState, EventRunnerOptions, MoveStep, DialoguePresenter, DialogueRequest, EventChoice, } from './EventRunner.ts';
|
|
9
|
+
export type { EventCommand, EventStoryScript, EventRunnerState, EventRunnerOptions, MoveStep, DialoguePresenter, DialogueRequest, EventChoice, } from './EventRunner.ts';
|
|
10
10
|
export { GridMover } from './GridMover.ts';
|
|
11
11
|
export type { GridMoverOptions, Direction4 } from './GridMover.ts';
|
|
12
|
+
export { MoveRouteRunner } from './MoveRoute.ts';
|
|
13
|
+
export type { MoveRoute, MoveRouteStep, MoveRouteOptions } from './MoveRoute.ts';
|
|
12
14
|
export { FreeMover } from './FreeMover.ts';
|
|
13
15
|
export type { FreeMoverOptions } from './FreeMover.ts';
|
|
14
16
|
export { aabbOverlap, circleOverlap, circleAabbOverlap, resolveAabbAgainstTiles } from './Collision.ts';
|
|
@@ -17,4 +19,7 @@ export { QuestLog, questsFromRows } from './Quest.ts';
|
|
|
17
19
|
export type { QuestStage, QuestDefinition, QuestStatus, QuestMarker, QuestStageRow } from './Quest.ts';
|
|
18
20
|
export { decodeMarshal, encodeMarshal, RubySymbol, hashDefaultOf, withHashDefault } from './Marshal.ts';
|
|
19
21
|
export type { RubyObject, RubyUserDefined } from './Marshal.ts';
|
|
22
|
+
export { parseDialogueText, extractDialogueCatalog } from './dialogue-text.ts';
|
|
23
|
+
export { importTwee } from './twee-events.ts';
|
|
24
|
+
export type { EventTwineStory } from './twee-events.ts';
|
|
20
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/rpg/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,cAAc,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,WAAW,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACxG,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxG,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,cAAc,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EACX,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,WAAW,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACxG,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxG,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/rpg/index.js
CHANGED
|
@@ -4,8 +4,11 @@ export { GameState } from './GameState.js';
|
|
|
4
4
|
export { activePage, conditionHolds } from './Event.js';
|
|
5
5
|
export { EventRunner } from './EventRunner.js';
|
|
6
6
|
export { GridMover } from './GridMover.js';
|
|
7
|
+
export { MoveRouteRunner } from './MoveRoute.js';
|
|
7
8
|
export { FreeMover } from './FreeMover.js';
|
|
8
9
|
export { aabbOverlap, circleOverlap, circleAabbOverlap, resolveAabbAgainstTiles } from './Collision.js';
|
|
9
10
|
export { QuestLog, questsFromRows } from './Quest.js';
|
|
10
11
|
export { decodeMarshal, encodeMarshal, RubySymbol, hashDefaultOf, withHashDefault } from './Marshal.js';
|
|
12
|
+
export { parseDialogueText, extractDialogueCatalog } from './dialogue-text.js';
|
|
13
|
+
export { importTwee } from './twee-events.js';
|
|
11
14
|
//# sourceMappingURL=index.js.map
|
package/dist/rpg/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rpg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rpg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAW/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAExG,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAExG,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { EventStoryScript } from './EventRunner.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A story imported from Twine's Twee notation, ready for `EventRunner.runStory`.
|
|
4
|
+
*
|
|
5
|
+
* The `two-d/stage` counterpart, `importTwee`, targets `StageCommand`/`StoryScript` instead -
|
|
6
|
+
* declared independently here for the same reason `EventChoice` already duplicates
|
|
7
|
+
* `two-d/ui`'s `Choice`: a text-only RPG (`core` plus `rpg`, no renderer at all) should not
|
|
8
|
+
* have to depend on `two-d` just to import a branching Twee story, and a Pixi-based visual
|
|
9
|
+
* novel that never touches map events should not have to depend on `rpg` either.
|
|
10
|
+
*/
|
|
11
|
+
export interface EventTwineStory {
|
|
12
|
+
story: EventStoryScript;
|
|
13
|
+
/** `StoryData`'s start passage when the file names one, else the first passage */
|
|
14
|
+
start: string;
|
|
15
|
+
/** the `StoryTitle` passage, when the file has one */
|
|
16
|
+
title?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads a `.twee` file into an `EventStoryScript`.
|
|
20
|
+
*
|
|
21
|
+
* The actual parsing (passages, `[[links]]`, `StoryData`/`StoryTitle`) lives once in
|
|
22
|
+
* `core.parseTwee` - this is a thin wrapper naming the `rpg`-specific return type, the same
|
|
23
|
+
* way `two-d/stage.importTwee` wraps the same engine for `StageCommand`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { importTwee, EventRunner, GameState, type DialoguePresenter } from '@datamoc/mw_games/rpg';
|
|
28
|
+
*
|
|
29
|
+
* declare const present: DialoguePresenter;
|
|
30
|
+
*
|
|
31
|
+
* const story = importTwee(`:: Start
|
|
32
|
+
* You stand at a crossroads.
|
|
33
|
+
*
|
|
34
|
+
* [[Take the left path->Left]]
|
|
35
|
+
* [[Take the right path->Right]]
|
|
36
|
+
*
|
|
37
|
+
* :: Left
|
|
38
|
+
* The path ends at a wall.
|
|
39
|
+
*
|
|
40
|
+
* :: Right
|
|
41
|
+
* An open road.
|
|
42
|
+
* `);
|
|
43
|
+
* const runner = new EventRunner({ present, game: new GameState() });
|
|
44
|
+
* await runner.runStory(story.story, story.start);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function importTwee(source: string): EventTwineStory;
|
|
48
|
+
//# sourceMappingURL=twee-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twee-events.d.ts","sourceRoot":"","sources":["../../src/rpg/twee-events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,gBAAgB,CAAC;IACxB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAG1D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { parseTwee } from '../core/Twee.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a `.twee` file into an `EventStoryScript`.
|
|
4
|
+
*
|
|
5
|
+
* The actual parsing (passages, `[[links]]`, `StoryData`/`StoryTitle`) lives once in
|
|
6
|
+
* `core.parseTwee` - this is a thin wrapper naming the `rpg`-specific return type, the same
|
|
7
|
+
* way `two-d/stage.importTwee` wraps the same engine for `StageCommand`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { importTwee, EventRunner, GameState, type DialoguePresenter } from '@datamoc/mw_games/rpg';
|
|
12
|
+
*
|
|
13
|
+
* declare const present: DialoguePresenter;
|
|
14
|
+
*
|
|
15
|
+
* const story = importTwee(`:: Start
|
|
16
|
+
* You stand at a crossroads.
|
|
17
|
+
*
|
|
18
|
+
* [[Take the left path->Left]]
|
|
19
|
+
* [[Take the right path->Right]]
|
|
20
|
+
*
|
|
21
|
+
* :: Left
|
|
22
|
+
* The path ends at a wall.
|
|
23
|
+
*
|
|
24
|
+
* :: Right
|
|
25
|
+
* An open road.
|
|
26
|
+
* `);
|
|
27
|
+
* const runner = new EventRunner({ present, game: new GameState() });
|
|
28
|
+
* await runner.runStory(story.story, story.start);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function importTwee(source) {
|
|
32
|
+
const { story, start, title } = parseTwee(source);
|
|
33
|
+
return title === undefined ? { story, start } : { story, start, title };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=twee-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twee-events.js","sourceRoot":"","sources":["../../src/rpg/twee-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAoB5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACxC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Catalog, Direction } from '../../i18n/index.ts';
|
|
2
|
+
import type { StageCommand, StoryScript } from './script.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A terse, line-based text format for straight (non-branching) dialogue - the
|
|
5
|
+
* counterpart to `twee.ts`'s passage graphs, for the common case of a scene
|
|
6
|
+
* that is just a sequence of lines. `rpg` has its own wrapper around the same
|
|
7
|
+
* parsing engine (`core.parseDialogueLines`) for a text-only RPG's map events
|
|
8
|
+
* (`rpg.parseDialogueText`, targeting `EventCommand`) - declared separately
|
|
9
|
+
* here for the same reason `EventChoice` is declared separately from this
|
|
10
|
+
* module's own `Choice`: a text-only RPG built on `core` and `rpg` alone
|
|
11
|
+
* should not have to depend on `two-d` (and its Pixi peer dependency) just to
|
|
12
|
+
* parse dialogue text, and a Pixi-based visual novel that never touches map
|
|
13
|
+
* events should not have to pull in `rpg` either. The actual `@id`/`-`
|
|
14
|
+
* parsing logic lives once in `core.parseDialogueLines`, not copied between
|
|
15
|
+
* the two - only the final command shape (`as` here, `speaker` in `rpg`)
|
|
16
|
+
* differs. Three kinds of line:
|
|
17
|
+
*
|
|
18
|
+
* - `@id text` names who is speaking and says `text`; `@id` alone (no text)
|
|
19
|
+
* just registers the speaker, without saying anything yet.
|
|
20
|
+
* - `- text` continues the two-speaker exchange the first two `@id` lines
|
|
21
|
+
* opened, alternating speaker on every line: the first `-` after the two
|
|
22
|
+
* openers goes to whichever of them did not speak last, and so on.
|
|
23
|
+
* - any other non-blank line narrates, with no speaker.
|
|
24
|
+
*
|
|
25
|
+
* ```
|
|
26
|
+
* @alice Hello.
|
|
27
|
+
* @bob Hi!
|
|
28
|
+
* - How are you?
|
|
29
|
+
* - Fine, and you?
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* The `-` shorthand is deliberately capped at two speakers: it exists for the
|
|
33
|
+
* two-character back-and-forth, not as a guess at which of three or more
|
|
34
|
+
* people talks next. A third distinct `@id` anywhere in the source is a
|
|
35
|
+
* parse error rather than a silent guess; a scene with more than two
|
|
36
|
+
* speakers writes `@id` on every line instead, same as it does today.
|
|
37
|
+
*
|
|
38
|
+
* Like `twee.ts`, lines reach `StageCommand.say` as plain, untranslated
|
|
39
|
+
* text - a game's own translation step decides how that text reaches a
|
|
40
|
+
* player, the same seam MWL's own `_("...")`-marked strings use (the source
|
|
41
|
+
* text doubles as the catalog key). `extractDialogueCatalog` builds that
|
|
42
|
+
* catalog the same way MWL's `extractCatalog` does, for a game that wants a
|
|
43
|
+
* translator-ready file to start from.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { parseDialogueText, StageScript } from '@datamoc/mw_games/two-d';
|
|
48
|
+
*
|
|
49
|
+
* declare const script: StageScript;
|
|
50
|
+
*
|
|
51
|
+
* const commands = parseDialogueText(`
|
|
52
|
+
* @alice Hello.
|
|
53
|
+
* @bob Hi!
|
|
54
|
+
* - How are you?
|
|
55
|
+
* - Fine, and you?
|
|
56
|
+
* `);
|
|
57
|
+
* await script.run(commands);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseDialogueText(source: string): StageCommand[];
|
|
61
|
+
/**
|
|
62
|
+
* Collects every `say`/`ask` line's text into an identity catalog - each key
|
|
63
|
+
* mapping to itself, the same shape MWL's own `extractCatalog` builds from
|
|
64
|
+
* `_("...")`-marked strings - so a translator has real entries to work from
|
|
65
|
+
* instead of a wall of untranslated dialogue. Accepts either a flat command
|
|
66
|
+
* list (`parseDialogueText`'s own output) or a `StoryScript` graph
|
|
67
|
+
* (`importTwee`'s), so the same extraction step covers both dialogue paths.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { parseDialogueText, extractDialogueCatalog } from '@datamoc/mw_games/two-d';
|
|
72
|
+
*
|
|
73
|
+
* const commands = parseDialogueText('@alice Hello.\n');
|
|
74
|
+
* console.log(extractDialogueCatalog(commands).messages); // { 'Hello.': 'Hello.' }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function extractDialogueCatalog(commands: readonly StageCommand[] | StoryScript, options?: {
|
|
78
|
+
locale?: string;
|
|
79
|
+
direction?: Direction;
|
|
80
|
+
}): Catalog;
|
|
81
|
+
//# sourceMappingURL=dialogue-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogue-text.d.ts","sourceRoot":"","sources":["../../../src/two-d/stage/dialogue-text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAIhE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,SAAS,YAAY,EAAE,GAAG,WAAW,EAC/C,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAO,GACtD,OAAO,CAYT"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { parseDialogueLines } from '../../core/DialogueText.js';
|
|
2
|
+
/**
|
|
3
|
+
* A terse, line-based text format for straight (non-branching) dialogue - the
|
|
4
|
+
* counterpart to `twee.ts`'s passage graphs, for the common case of a scene
|
|
5
|
+
* that is just a sequence of lines. `rpg` has its own wrapper around the same
|
|
6
|
+
* parsing engine (`core.parseDialogueLines`) for a text-only RPG's map events
|
|
7
|
+
* (`rpg.parseDialogueText`, targeting `EventCommand`) - declared separately
|
|
8
|
+
* here for the same reason `EventChoice` is declared separately from this
|
|
9
|
+
* module's own `Choice`: a text-only RPG built on `core` and `rpg` alone
|
|
10
|
+
* should not have to depend on `two-d` (and its Pixi peer dependency) just to
|
|
11
|
+
* parse dialogue text, and a Pixi-based visual novel that never touches map
|
|
12
|
+
* events should not have to pull in `rpg` either. The actual `@id`/`-`
|
|
13
|
+
* parsing logic lives once in `core.parseDialogueLines`, not copied between
|
|
14
|
+
* the two - only the final command shape (`as` here, `speaker` in `rpg`)
|
|
15
|
+
* differs. Three kinds of line:
|
|
16
|
+
*
|
|
17
|
+
* - `@id text` names who is speaking and says `text`; `@id` alone (no text)
|
|
18
|
+
* just registers the speaker, without saying anything yet.
|
|
19
|
+
* - `- text` continues the two-speaker exchange the first two `@id` lines
|
|
20
|
+
* opened, alternating speaker on every line: the first `-` after the two
|
|
21
|
+
* openers goes to whichever of them did not speak last, and so on.
|
|
22
|
+
* - any other non-blank line narrates, with no speaker.
|
|
23
|
+
*
|
|
24
|
+
* ```
|
|
25
|
+
* @alice Hello.
|
|
26
|
+
* @bob Hi!
|
|
27
|
+
* - How are you?
|
|
28
|
+
* - Fine, and you?
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* The `-` shorthand is deliberately capped at two speakers: it exists for the
|
|
32
|
+
* two-character back-and-forth, not as a guess at which of three or more
|
|
33
|
+
* people talks next. A third distinct `@id` anywhere in the source is a
|
|
34
|
+
* parse error rather than a silent guess; a scene with more than two
|
|
35
|
+
* speakers writes `@id` on every line instead, same as it does today.
|
|
36
|
+
*
|
|
37
|
+
* Like `twee.ts`, lines reach `StageCommand.say` as plain, untranslated
|
|
38
|
+
* text - a game's own translation step decides how that text reaches a
|
|
39
|
+
* player, the same seam MWL's own `_("...")`-marked strings use (the source
|
|
40
|
+
* text doubles as the catalog key). `extractDialogueCatalog` builds that
|
|
41
|
+
* catalog the same way MWL's `extractCatalog` does, for a game that wants a
|
|
42
|
+
* translator-ready file to start from.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { parseDialogueText, StageScript } from '@datamoc/mw_games/two-d';
|
|
47
|
+
*
|
|
48
|
+
* declare const script: StageScript;
|
|
49
|
+
*
|
|
50
|
+
* const commands = parseDialogueText(`
|
|
51
|
+
* @alice Hello.
|
|
52
|
+
* @bob Hi!
|
|
53
|
+
* - How are you?
|
|
54
|
+
* - Fine, and you?
|
|
55
|
+
* `);
|
|
56
|
+
* await script.run(commands);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function parseDialogueText(source) {
|
|
60
|
+
return parseDialogueLines(source).map((line) => line.speaker === undefined ? { say: line.text } : { say: line.text, as: line.speaker });
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Collects every `say`/`ask` line's text into an identity catalog - each key
|
|
64
|
+
* mapping to itself, the same shape MWL's own `extractCatalog` builds from
|
|
65
|
+
* `_("...")`-marked strings - so a translator has real entries to work from
|
|
66
|
+
* instead of a wall of untranslated dialogue. Accepts either a flat command
|
|
67
|
+
* list (`parseDialogueText`'s own output) or a `StoryScript` graph
|
|
68
|
+
* (`importTwee`'s), so the same extraction step covers both dialogue paths.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { parseDialogueText, extractDialogueCatalog } from '@datamoc/mw_games/two-d';
|
|
73
|
+
*
|
|
74
|
+
* const commands = parseDialogueText('@alice Hello.\n');
|
|
75
|
+
* console.log(extractDialogueCatalog(commands).messages); // { 'Hello.': 'Hello.' }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export function extractDialogueCatalog(commands, options = {}) {
|
|
79
|
+
const messages = {};
|
|
80
|
+
const collect = (list) => {
|
|
81
|
+
for (const command of list) {
|
|
82
|
+
if ('say' in command)
|
|
83
|
+
messages[command.say] = command.say;
|
|
84
|
+
else if ('ask' in command)
|
|
85
|
+
messages[command.ask] = command.ask;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
if (Array.isArray(commands))
|
|
89
|
+
collect(commands);
|
|
90
|
+
else
|
|
91
|
+
for (const list of Object.values(commands))
|
|
92
|
+
collect(list);
|
|
93
|
+
return { locale: options.locale ?? 'en', direction: options.direction ?? 'ltr', messages };
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=dialogue-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogue-text.js","sourceRoot":"","sources":["../../../src/two-d/stage/dialogue-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC/C,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC9C,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CACtF,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CACrC,QAA+C,EAC/C,OAAO,GAA+C,EAAE;IAExD,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAC,IAA6B,EAAQ,EAAE;QACvD,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;YAC5B,IAAI,KAAK,IAAI,OAAO;gBAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;iBACrD,IAAI,KAAK,IAAI,OAAO;gBAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;QAChE,CAAC;IACF,CAAC,CAAC;IACF,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;;QAC1C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/D,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC5F,CAAC"}
|
|
@@ -4,6 +4,7 @@ export { StageScript } from './script.ts';
|
|
|
4
4
|
export type { StageCommand, StageChoice, StoryScript, ScriptOptions, ScriptState, HistoryEntry } from './script.ts';
|
|
5
5
|
export { importTwee } from './twee.ts';
|
|
6
6
|
export type { TwineStory } from './twee.ts';
|
|
7
|
+
export { parseDialogueText, extractDialogueCatalog } from './dialogue-text.ts';
|
|
7
8
|
export { StoryScreen, StorySequence } from './StoryScreen.ts';
|
|
8
9
|
export type { StoryBeat, StoryScreenOptions } from './StoryScreen.ts';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/two-d/stage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/two-d/stage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9D,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DialogueStage } from './DialogueStage.js';
|
|
2
2
|
export { StageScript } from './script.js';
|
|
3
3
|
export { importTwee } from './twee.js';
|
|
4
|
+
export { parseDialogueText, extractDialogueCatalog } from './dialogue-text.js';
|
|
4
5
|
export { StoryScreen, StorySequence } from './StoryScreen.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/two-d/stage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/two-d/stage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -12,31 +12,13 @@ export interface TwineStory {
|
|
|
12
12
|
/**
|
|
13
13
|
* Reads a `.twee` file into a `StoryScript`.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* `[[text->target]]` and `[[target<-text]]`) - the last text line doubles as
|
|
23
|
-
* the question, since a choice box needs a prompt and repeating it works.
|
|
24
|
-
* No story-format macro language
|
|
25
|
-
* (Harlowe, SugarCube, Chapbook) is interpreted - body text reaches the stage
|
|
26
|
-
* untouched, and a link carrying a setter throws instead of silently dropping
|
|
27
|
-
* the behaviour the setter described.
|
|
28
|
-
*
|
|
29
|
-
* ```twee
|
|
30
|
-
* :: Start
|
|
31
|
-
* You stand at a crossroads.
|
|
32
|
-
*
|
|
33
|
-
* [[Take the left path->Left]]
|
|
34
|
-
* [[Take the right path->Right]]
|
|
35
|
-
*
|
|
36
|
-
* :: Left
|
|
37
|
-
* The path ends at a wall.
|
|
38
|
-
* [[Go back->Start]]
|
|
39
|
-
* ```
|
|
15
|
+
* The actual parsing (passages, `[[links]]`, `StoryData`/`StoryTitle`) lives once in
|
|
16
|
+
* `core.parseTwee` - `rpg.importTwee` is the same wrapper around the same engine, targeting
|
|
17
|
+
* `EventStoryScript` instead, declared separately for the same reason `EventChoice` already
|
|
18
|
+
* duplicates `two-d/ui`'s `Choice`: a text-only RPG should not have to depend on `two-d` just
|
|
19
|
+
* to import a branching Twee story, and a Pixi-based visual novel that never touches map
|
|
20
|
+
* events should not have to depend on `rpg` either. `core.parseTwee`'s own doc comment covers
|
|
21
|
+
* the notation itself (passages, links, what a macro-carrying link does).
|
|
40
22
|
*
|
|
41
23
|
* @example
|
|
42
24
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twee.d.ts","sourceRoot":"","sources":["../../../src/two-d/stage/twee.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"twee.d.ts","sourceRoot":"","sources":["../../../src/two-d/stage/twee.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAGrD"}
|