@drincs/pixi-vn-ink 0.1.4 → 0.2.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.
- package/README.md +63 -4
- package/dist/RootParserItemType-BeypaLqW.d.ts +41 -0
- package/dist/RootParserItemType-DV41SbdA.d.cts +41 -0
- package/dist/constant.cjs +7 -0
- package/dist/constant.d.cts +5 -0
- package/dist/constant.d.ts +3 -1
- package/dist/constant.js +2 -7
- package/dist/functions/ArithmeticUtility.cjs +6 -0
- package/dist/functions/ArithmeticUtility.d.cts +8 -0
- package/dist/functions/ArithmeticUtility.d.ts +8 -0
- package/dist/functions/ArithmeticUtility.js +4 -0
- package/dist/functions/ChoiceInfoConverter.cjs +10 -0
- package/dist/functions/ChoiceInfoConverter.d.cts +20 -0
- package/dist/functions/ChoiceInfoConverter.d.ts +17 -2
- package/dist/functions/ChoiceInfoConverter.js +5 -68
- package/dist/functions/Importer.cjs +51 -0
- package/dist/functions/Importer.js +49 -301
- package/dist/functions/InkToPixivn.cjs +51 -0
- package/dist/functions/{InkToPixivn.d.mts → InkToPixivn.d.cts} +1 -1
- package/dist/functions/InkToPixivn.d.ts +1 -1
- package/dist/functions/InkToPixivn.js +49 -284
- package/dist/functions/StoryInfoConverter.cjs +10 -0
- package/dist/functions/StoryInfoConverter.d.cts +18 -0
- package/dist/functions/StoryInfoConverter.d.ts +15 -3
- package/dist/functions/StoryInfoConverter.js +5 -253
- package/dist/functions/index.cjs +52 -0
- package/dist/functions/index.d.cts +3 -0
- package/dist/functions/index.d.ts +1 -1
- package/dist/functions/index.js +49 -302
- package/dist/index.cjs +52 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -302
- package/dist/parser/AddingElements.cjs +10 -0
- package/dist/parser/AddingElements.d.cts +11 -0
- package/dist/parser/AddingElements.d.ts +11 -0
- package/dist/parser/AddingElements.js +6 -0
- package/dist/parser/ConditionaAritmeticParser.cjs +6 -0
- package/dist/parser/ConditionaAritmeticParser.d.cts +73 -0
- package/dist/parser/ConditionaAritmeticParser.d.ts +73 -0
- package/dist/parser/ConditionaAritmeticParser.js +4 -0
- package/dist/parser/ConditionalStatementsParser.cjs +10 -0
- package/dist/parser/ConditionalStatementsParser.d.cts +19 -0
- package/dist/parser/ConditionalStatementsParser.d.ts +19 -0
- package/dist/parser/ConditionalStatementsParser.js +7 -0
- package/dist/parser/LabelParser.cjs +9 -0
- package/dist/parser/LabelParser.d.cts +25 -0
- package/dist/parser/LabelParser.d.ts +25 -0
- package/dist/parser/LabelParser.js +7 -0
- package/dist/parser/SwitchParser.cjs +9 -0
- package/dist/parser/SwitchParser.d.cts +18 -0
- package/dist/parser/SwitchParser.d.ts +18 -0
- package/dist/parser/SwitchParser.js +7 -0
- package/dist/types/InkRootType.cjs +2 -0
- package/dist/types/InkRootType.d.cts +17 -0
- package/dist/types/InkRootType.d.ts +13 -1
- package/dist/types/InkRootType.js +0 -3
- package/dist/types/InkStoryType.cjs +2 -0
- package/dist/types/InkStoryType.d.cts +20 -0
- package/dist/types/InkStoryType.d.ts +11 -0
- package/dist/types/InkStoryType.js +0 -3
- package/dist/types/LabelChoiceRes.cjs +2 -0
- package/dist/types/LabelChoiceRes.d.cts +16 -0
- package/dist/types/LabelChoiceRes.d.ts +7 -1
- package/dist/types/LabelChoiceRes.js +0 -3
- package/dist/types/parserItems/ChoicePoint.cjs +2 -0
- package/dist/types/parserItems/ChoicePoint.d.cts +11 -0
- package/dist/types/parserItems/ChoicePoint.d.ts +11 -0
- package/dist/types/parserItems/ChoicePoint.js +1 -0
- package/dist/types/parserItems/Cond.cjs +2 -0
- package/dist/types/parserItems/Cond.d.cts +17 -0
- package/dist/types/parserItems/Cond.d.ts +17 -0
- package/dist/types/parserItems/Cond.js +1 -0
- package/dist/types/parserItems/ContainerType.cjs +2 -0
- package/dist/types/parserItems/ContainerType.d.cts +13 -0
- package/dist/types/parserItems/ContainerType.d.ts +13 -0
- package/dist/types/parserItems/ContainerType.js +1 -0
- package/dist/types/parserItems/ControlCommands.cjs +2 -0
- package/dist/types/parserItems/ControlCommands.d.cts +26 -0
- package/dist/types/parserItems/ControlCommands.d.ts +26 -0
- package/dist/types/parserItems/ControlCommands.js +1 -0
- package/dist/types/parserItems/Divert.cjs +2 -0
- package/dist/types/parserItems/Divert.d.cts +38 -0
- package/dist/types/parserItems/Divert.d.ts +38 -0
- package/dist/types/parserItems/Divert.js +1 -0
- package/dist/types/parserItems/NativeFunctions.cjs +8 -0
- package/dist/types/parserItems/NativeFunctions.d.cts +20 -0
- package/dist/types/parserItems/NativeFunctions.d.ts +20 -0
- package/dist/types/parserItems/NativeFunctions.js +3 -0
- package/dist/types/parserItems/ReadCount.cjs +2 -0
- package/dist/types/parserItems/ReadCount.d.cts +14 -0
- package/dist/types/parserItems/ReadCount.d.ts +14 -0
- package/dist/types/parserItems/ReadCount.js +1 -0
- package/dist/types/parserItems/RootParserItemType.cjs +2 -0
- package/dist/types/parserItems/RootParserItemType.d.cts +11 -0
- package/dist/types/parserItems/RootParserItemType.d.ts +11 -5
- package/dist/types/parserItems/RootParserItemType.js +0 -3
- package/dist/types/parserItems/TextType.cjs +2 -0
- package/dist/types/parserItems/TextType.d.cts +6 -0
- package/dist/types/parserItems/TextType.d.ts +6 -0
- package/dist/types/parserItems/TextType.js +1 -0
- package/dist/types/parserItems/VariableAssignment.cjs +2 -0
- package/dist/types/parserItems/VariableAssignment.d.cts +46 -0
- package/dist/types/parserItems/VariableAssignment.d.ts +46 -0
- package/dist/types/parserItems/VariableAssignment.js +1 -0
- package/dist/types/parserItems/VariableReference.cjs +2 -0
- package/dist/types/parserItems/VariableReference.d.cts +14 -0
- package/dist/types/parserItems/VariableReference.d.ts +14 -0
- package/dist/types/parserItems/VariableReference.js +1 -0
- package/dist/utility/ArrayUtility.cjs +5 -0
- package/dist/utility/ArrayUtility.d.cts +3 -0
- package/dist/utility/ArrayUtility.d.ts +3 -0
- package/dist/utility/ArrayUtility.js +3 -0
- package/dist/utility/CommandUtility.cjs +5 -0
- package/dist/utility/CommandUtility.d.cts +5 -0
- package/dist/utility/CommandUtility.d.ts +5 -0
- package/dist/utility/CommandUtility.js +3 -0
- package/dist/utility/DivertUtility.cjs +5 -0
- package/dist/utility/DivertUtility.d.cts +3 -0
- package/dist/utility/DivertUtility.d.ts +3 -0
- package/dist/utility/DivertUtility.js +3 -0
- package/dist/utility/TextUtility.cjs +6 -0
- package/dist/utility/TextUtility.d.cts +3 -0
- package/dist/utility/TextUtility.d.ts +3 -0
- package/dist/utility/TextUtility.js +4 -0
- package/dist/utility/ValueUtility.cjs +6 -0
- package/dist/utility/ValueUtility.d.cts +3 -0
- package/dist/utility/ValueUtility.d.ts +3 -0
- package/dist/utility/ValueUtility.js +4 -0
- package/package.json +12 -11
- package/dist/constant.d.mts +0 -3
- package/dist/constant.js.map +0 -1
- package/dist/constant.mjs +0 -6
- package/dist/constant.mjs.map +0 -1
- package/dist/functions/ChoiceInfoConverter.d.mts +0 -5
- package/dist/functions/ChoiceInfoConverter.js.map +0 -1
- package/dist/functions/ChoiceInfoConverter.mjs +0 -68
- package/dist/functions/ChoiceInfoConverter.mjs.map +0 -1
- package/dist/functions/Importer.js.map +0 -1
- package/dist/functions/Importer.mjs +0 -299
- package/dist/functions/Importer.mjs.map +0 -1
- package/dist/functions/InkToPixivn.js.map +0 -1
- package/dist/functions/InkToPixivn.mjs +0 -282
- package/dist/functions/InkToPixivn.mjs.map +0 -1
- package/dist/functions/StoryInfoConverter.d.mts +0 -6
- package/dist/functions/StoryInfoConverter.js.map +0 -1
- package/dist/functions/StoryInfoConverter.mjs +0 -253
- package/dist/functions/StoryInfoConverter.mjs.map +0 -1
- package/dist/functions/index.d.mts +0 -3
- package/dist/functions/index.js.map +0 -1
- package/dist/functions/index.mjs +0 -299
- package/dist/functions/index.mjs.map +0 -1
- package/dist/functions/utility.d.mts +0 -3
- package/dist/functions/utility.d.ts +0 -3
- package/dist/functions/utility.js +0 -12
- package/dist/functions/utility.js.map +0 -1
- package/dist/functions/utility.mjs +0 -10
- package/dist/functions/utility.mjs.map +0 -1
- package/dist/index.d.mts +0 -3
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -299
- package/dist/index.mjs.map +0 -1
- package/dist/types/InkRootType.d.mts +0 -5
- package/dist/types/InkRootType.js.map +0 -1
- package/dist/types/InkRootType.mjs +0 -3
- package/dist/types/InkRootType.mjs.map +0 -1
- package/dist/types/InkStoryType.d.mts +0 -9
- package/dist/types/InkStoryType.js.map +0 -1
- package/dist/types/InkStoryType.mjs +0 -3
- package/dist/types/InkStoryType.mjs.map +0 -1
- package/dist/types/LabelChoiceRes.d.mts +0 -10
- package/dist/types/LabelChoiceRes.js.map +0 -1
- package/dist/types/LabelChoiceRes.mjs +0 -3
- package/dist/types/LabelChoiceRes.mjs.map +0 -1
- package/dist/types/parserItems/CallParserItemType.d.mts +0 -5
- package/dist/types/parserItems/CallParserItemType.d.ts +0 -5
- package/dist/types/parserItems/CallParserItemType.js +0 -4
- package/dist/types/parserItems/CallParserItemType.js.map +0 -1
- package/dist/types/parserItems/CallParserItemType.mjs +0 -3
- package/dist/types/parserItems/CallParserItemType.mjs.map +0 -1
- package/dist/types/parserItems/ChoiseInfoParserItemType.d.mts +0 -8
- package/dist/types/parserItems/ChoiseInfoParserItemType.d.ts +0 -8
- package/dist/types/parserItems/ChoiseInfoParserItemType.js +0 -4
- package/dist/types/parserItems/ChoiseInfoParserItemType.js.map +0 -1
- package/dist/types/parserItems/ChoiseInfoParserItemType.mjs +0 -3
- package/dist/types/parserItems/ChoiseInfoParserItemType.mjs.map +0 -1
- package/dist/types/parserItems/ChoiseParserItemType.d.mts +0 -6
- package/dist/types/parserItems/ChoiseParserItemType.d.ts +0 -6
- package/dist/types/parserItems/ChoiseParserItemType.js +0 -4
- package/dist/types/parserItems/ChoiseParserItemType.js.map +0 -1
- package/dist/types/parserItems/ChoiseParserItemType.mjs +0 -3
- package/dist/types/parserItems/ChoiseParserItemType.mjs.map +0 -1
- package/dist/types/parserItems/RootParserItemType.d.mts +0 -5
- package/dist/types/parserItems/RootParserItemType.js.map +0 -1
- package/dist/types/parserItems/RootParserItemType.mjs +0 -3
- package/dist/types/parserItems/RootParserItemType.mjs.map +0 -1
- /package/dist/functions/{Importer.d.mts → Importer.d.cts} +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Ink Language Integration
|
|
2
2
|
|
|
3
3
|
Pixi’VN gives you the ability to write your own narrative using Ink.
|
|
4
4
|
|
|
@@ -8,9 +8,19 @@ Ink is a scripting language for writing interactive narrative. It is used in gam
|
|
|
8
8
|
|
|
9
9
|
This language is very simple to learn, you can learn the basics in a few minutes. Go on [ink website](https://www.inklestudios.com/ink/) to learn more about it.
|
|
10
10
|
|
|
11
|
+
## Why use Ink integration?
|
|
12
|
+
|
|
13
|
+
Programming a game narrative in **Javascript/Typescript** has the advantage of having total development freedom, but the disadvantage is that it slows down the writing of a narrative (it makes you write a lot of code).
|
|
14
|
+
|
|
15
|
+
**Ink** is a language that allows you to write a narrative easily, without having to write a lot of code. Plus, it only takes you about ten minutes to learn the basic functions. Ink is basically designed only for writing narratives, so it doesn't require a canvas or other features outside of narrative.
|
|
16
|
+
|
|
17
|
+
Launching narrative labels (or knots) from Javascript/Typescript to Ink sharing the same memory and canvas is a double benefit. You can use Ink to write the narration, while using Javascript/Typescript to handle everything that is not possible with Ink.
|
|
18
|
+
|
|
19
|
+
Furthermore, novice developers can use a template to start writing narratives with Ink. After becoming familiar with Javascript/Typescript they can start to create more laborious features, like minigames or complex animations.
|
|
20
|
+
|
|
11
21
|
## Start using Ink in Pixi’VN
|
|
12
22
|
|
|
13
|
-
If you have not created a project yet then it is recommended to use the [template](/start/getting-started.
|
|
23
|
+
If you have not created a project yet then it is recommended to use the [template](https://pixi-vn.web.app/start/getting-started.html#project-initialization) and select a template that is based on ink.
|
|
14
24
|
|
|
15
25
|
Otherwise to add ink to your Pixi’VN project you need to install the `@drincs/pixi-vn-ink` package.
|
|
16
26
|
|
|
@@ -43,10 +53,10 @@ Hello
|
|
|
43
53
|
importInkText([inkText, ...])
|
|
44
54
|
```
|
|
45
55
|
|
|
46
|
-
Now you can run the `start` knot (or label) with [Pixi’VN functions](/start/labels.
|
|
56
|
+
Now you can run the `start` knot (or label) with [Pixi’VN functions](https://pixi-vn.web.app/start/labels.html#run-a-label).
|
|
47
57
|
|
|
48
58
|
```typescript
|
|
49
|
-
|
|
59
|
+
narration.callLabel(`start`, {})
|
|
50
60
|
```
|
|
51
61
|
|
|
52
62
|
### Import text contained in .ink files
|
|
@@ -83,3 +93,52 @@ import startLabel from './ink_labels/start.ink?raw'
|
|
|
83
93
|
|
|
84
94
|
importInkText([startLabel, ...])
|
|
85
95
|
```
|
|
96
|
+
|
|
97
|
+
## Ink features in development
|
|
98
|
+
|
|
99
|
+
The following features are in development and will be added in the future:
|
|
100
|
+
|
|
101
|
+
( Add a like or comment to the issue to show your interest in the feature )
|
|
102
|
+
|
|
103
|
+
* [Functions and Game Queries](https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#9-game-queries-and-functions) (issue [#11](https://github.com/DRincs-Productions/pixi-vn-ink/issues/11)):
|
|
104
|
+
* [User-created functions](https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#5-functions) (issue [#32](https://github.com/DRincs-Productions/pixi-vn-ink/issues/32))
|
|
105
|
+
* `CHOICE_COUNT()`
|
|
106
|
+
* `TURNS()`
|
|
107
|
+
* `TURNS_SINCE()`
|
|
108
|
+
* `SEED_RANDOM()`
|
|
109
|
+
* [`LIST`](https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#1-basic-lists) (issue [#15](https://github.com/DRincs-Productions/pixi-vn-ink/issues/15))
|
|
110
|
+
* [`Tunnels`](https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#1-tunnels) (issue [#38](https://github.com/DRincs-Productions/pixi-vn-ink/issues/38))
|
|
111
|
+
* [`Threads`](https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#2-threads) (issue [#39](https://github.com/DRincs-Productions/pixi-vn-ink/issues/39))
|
|
112
|
+
|
|
113
|
+
## Ink syntax that will be ignored by Pixi’VN
|
|
114
|
+
|
|
115
|
+
The following syntax will be ignored by Pixi’VN (They will not create errors).
|
|
116
|
+
|
|
117
|
+
### INCLUDE
|
|
118
|
+
|
|
119
|
+
`INCLUDE` is used by Ink to import other ink files.
|
|
120
|
+
|
|
121
|
+
In Pixi’VN you can use the `importInkText()` function to import the ink files. So if you use `INCLUDE` it will not be handled, so it does not import the files.
|
|
122
|
+
|
|
123
|
+
### Narration outside the knots
|
|
124
|
+
|
|
125
|
+
The narration outside the knots (or labels) will be ignored.
|
|
126
|
+
The reason is that as explained by Pixi’VN you can't start a whole ink file, but you have to use this [functions](https://pixi-vn.web.app/start/labels.html#run-a-label) for run a knot (or label).
|
|
127
|
+
|
|
128
|
+
So for example the following cases will be ignored:
|
|
129
|
+
|
|
130
|
+
```ink
|
|
131
|
+
Hello # ❌ This will be ignored
|
|
132
|
+
-> start # ❌ This will be ignored
|
|
133
|
+
=== start === # ✅ This will be handled
|
|
134
|
+
My name is John # ✅ This will be handled
|
|
135
|
+
-> DONE # ✅ This will be handled
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Using Pixi’VN Features from Ink
|
|
139
|
+
|
|
140
|
+
* [Use Character in ink](https://pixi-vn.web.app/ink/ink-character.html)
|
|
141
|
+
* [Style Text on Ink + Pixi’VN](https://pixi-vn.web.app/ink/ink-markdown.html)
|
|
142
|
+
* [Use PixiJS Canvas in Ink](https://pixi-vn.web.app/ink/ink-canvas.html)
|
|
143
|
+
* [Use Sounds and Music in Ink](https://pixi-vn.web.app/ink/ink-sound.html)
|
|
144
|
+
* [Use input in Ink](https://pixi-vn.web.app/ink/ink-input.html)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ContainerTypeN } from './types/parserItems/ContainerType.js';
|
|
2
|
+
import ControlCommands from './types/parserItems/ControlCommands.js';
|
|
3
|
+
import Divert from './types/parserItems/Divert.js';
|
|
4
|
+
import NativeFunctions from './types/parserItems/NativeFunctions.js';
|
|
5
|
+
import ReadCount from './types/parserItems/ReadCount.js';
|
|
6
|
+
import TextType from './types/parserItems/TextType.js';
|
|
7
|
+
import VariableAssignment from './types/parserItems/VariableAssignment.js';
|
|
8
|
+
import VariableReference from './types/parserItems/VariableReference.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generates an instance of a Choice. Its exact behaviour depends on its flags. It doesn't contain any text itself, since choice text is generated at runtime and added to the evaluation stack. When a ChoicePoint is encountered, it pops content off the evaluation stack according to its flags, which indicate which texts are needed.
|
|
12
|
+
*
|
|
13
|
+
* A ChoicePoint object's structure in JSON is:
|
|
14
|
+
* ```json
|
|
15
|
+
* {
|
|
16
|
+
* "*": "path.when.chosen",
|
|
17
|
+
* "flg": 18
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
* The path when chosen is the target path of a Container of content, and is assigned when calling ChooseChoiceIndex.
|
|
21
|
+
*/
|
|
22
|
+
type ChoicePoint = {
|
|
23
|
+
"*": string;
|
|
24
|
+
/**
|
|
25
|
+
* The flg field is a bitfield of flags:
|
|
26
|
+
* - 0x1 - Has condition?: Set if the story should pop a value from the evaluation stack in order to determine whether a choice instance should be created at all.
|
|
27
|
+
* - 0x2 - Has start content? - According to square bracket notation, is there any leading content before any square brackets? If so, this content should be popped from the evaluation stack.
|
|
28
|
+
* - 0x4 - Has choice-only content? - According to square bracket notation, is there any content between the square brackets? If so, this content should be popped from the evaluation stack.
|
|
29
|
+
* - 0x8 - Is invisible default? - When this is enabled, the choice isn't provided to the game (isn't presented to the player), and instead is automatically followed if there are no other choices generated.
|
|
30
|
+
* - 0x10 - Once only? - Defaults to true. This is the difference between the * and + choice bullets in ink. If once only (*), the choice is only displayed if its target container's read count is zero.
|
|
31
|
+
*/
|
|
32
|
+
flg: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type ChoiceInfo = {
|
|
36
|
+
s: RootParserItemType[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type RootParserItemType = null | RootParserItemType[] | ChoiceInfo | ChoicePoint | ControlCommands | Divert | NativeFunctions | TextType | VariableAssignment | VariableReference | ReadCount | ContainerTypeN;
|
|
40
|
+
|
|
41
|
+
export type { ChoicePoint as C, RootParserItemType as R, ChoiceInfo as a };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ContainerTypeN } from './types/parserItems/ContainerType.cjs';
|
|
2
|
+
import ControlCommands from './types/parserItems/ControlCommands.cjs';
|
|
3
|
+
import Divert from './types/parserItems/Divert.cjs';
|
|
4
|
+
import NativeFunctions from './types/parserItems/NativeFunctions.cjs';
|
|
5
|
+
import ReadCount from './types/parserItems/ReadCount.cjs';
|
|
6
|
+
import TextType from './types/parserItems/TextType.cjs';
|
|
7
|
+
import VariableAssignment from './types/parserItems/VariableAssignment.cjs';
|
|
8
|
+
import VariableReference from './types/parserItems/VariableReference.cjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generates an instance of a Choice. Its exact behaviour depends on its flags. It doesn't contain any text itself, since choice text is generated at runtime and added to the evaluation stack. When a ChoicePoint is encountered, it pops content off the evaluation stack according to its flags, which indicate which texts are needed.
|
|
12
|
+
*
|
|
13
|
+
* A ChoicePoint object's structure in JSON is:
|
|
14
|
+
* ```json
|
|
15
|
+
* {
|
|
16
|
+
* "*": "path.when.chosen",
|
|
17
|
+
* "flg": 18
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
* The path when chosen is the target path of a Container of content, and is assigned when calling ChooseChoiceIndex.
|
|
21
|
+
*/
|
|
22
|
+
type ChoicePoint = {
|
|
23
|
+
"*": string;
|
|
24
|
+
/**
|
|
25
|
+
* The flg field is a bitfield of flags:
|
|
26
|
+
* - 0x1 - Has condition?: Set if the story should pop a value from the evaluation stack in order to determine whether a choice instance should be created at all.
|
|
27
|
+
* - 0x2 - Has start content? - According to square bracket notation, is there any leading content before any square brackets? If so, this content should be popped from the evaluation stack.
|
|
28
|
+
* - 0x4 - Has choice-only content? - According to square bracket notation, is there any content between the square brackets? If so, this content should be popped from the evaluation stack.
|
|
29
|
+
* - 0x8 - Is invisible default? - When this is enabled, the choice isn't provided to the game (isn't presented to the player), and instead is automatically followed if there are no other choices generated.
|
|
30
|
+
* - 0x10 - Once only? - Defaults to true. This is the difference between the * and + choice bullets in ink. If once only (*), the choice is only displayed if its target container's read count is zero.
|
|
31
|
+
*/
|
|
32
|
+
flg: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type ChoiceInfo = {
|
|
36
|
+
s: RootParserItemType[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type RootParserItemType = null | RootParserItemType[] | ChoiceInfo | ChoicePoint | ControlCommands | Divert | NativeFunctions | TextType | VariableAssignment | VariableReference | ReadCount | ContainerTypeN;
|
|
40
|
+
|
|
41
|
+
export type { ChoicePoint as C, RootParserItemType as R, ChoiceInfo as a };
|
package/dist/constant.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
declare const CHOISE_LABEL_KEY_SEPARATOR = "_|_";
|
|
2
|
+
declare const GLOBAL_DECL = "global decl";
|
|
3
|
+
declare const MY_LABEL_KER_EXTERNAL_VALUE = "___external_value___";
|
|
2
4
|
|
|
3
|
-
export { CHOISE_LABEL_KEY_SEPARATOR };
|
|
5
|
+
export { CHOISE_LABEL_KEY_SEPARATOR, GLOBAL_DECL, MY_LABEL_KER_EXTERNAL_VALUE };
|
package/dist/constant.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
var _="_|_",E="global decl",L="___external_value___";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var CHOISE_LABEL_KEY_SEPARATOR = "_|_";
|
|
5
|
-
|
|
6
|
-
exports.CHOISE_LABEL_KEY_SEPARATOR = CHOISE_LABEL_KEY_SEPARATOR;
|
|
7
|
-
//# sourceMappingURL=constant.js.map
|
|
8
|
-
//# sourceMappingURL=constant.js.map
|
|
3
|
+
export { _ as CHOISE_LABEL_KEY_SEPARATOR, E as GLOBAL_DECL, L as MY_LABEL_KER_EXTERNAL_VALUE };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var s="_|_";var f=["+","-","/","*","%","POW","RANDOM"],h=["INT","FLOOR","FLOAT"],A=["==",">","<",">=","<=","!=","CONTAINS"];function u(i,o){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(n=>!n.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",s);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let e=i.split("g-");return c(o)+s+"g-"+e[e.length-1]}let r=0;for(;new RegExp(/^\.\^.*$/).test(i);)r++,i=i.substring(2);if(r=r-1,new RegExp(/^\..*$/).test(i)&&o){let e=i.substring(1);return c(o,r)+s+e.replaceAll(".",s)}return i.replaceAll(".",s)||c(o,r).replaceAll(".",s)}function c(i,o=0){let r=i.split(s);for(;r.length>1&&o>0;)r.pop()?.includes("g-")&&o--,o--;return r.join(s)}var y="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function V(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",y),i=i.replaceAll("\\n",`
|
|
4
|
+
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(y,"\\\\"),i}function d(i,o,r){i=i.map(n=>{if(typeof n=="string"){if(n==="rnd")return "RANDOM";if(n==="?")return "CONTAINS"}return n});let e=[];return i.forEach(n=>{if(typeof n=="object"&&"CNT?"in n)if(new RegExp(/.*\.[0-9]\..*/).test(n["CNT?"])){let t=n["CNT?"].split("."),a=t.pop(),g=t.pop();if(g===void 0||a===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let x=parseInt(g),l=t.join(".");if(l.includes("^.")){let p=l.split("."),E=p[p.length-1].replaceAll(".",s);p.pop(),l=p.join(".")+"."+E,a.includes("c-")&&(l=l+s+a);}else l=l.replaceAll(".",s);e.push({type:"compare",leftValue:{type:"value",storageType:"label",storageOperationType:"get",valueType:"biggeststep",label:u(l,o)},operator:">=",rightValue:{type:"value",value:x}});}else e.push({type:"value",storageType:"label",storageOperationType:"get",label:u(n["CNT?"],o)});else if(typeof n=="object"&&"VAR?"in n){let t=r.indexOf(n["VAR?"]);t>=0?e.push({type:"value",storageType:"params",storageOperationType:"get",key:t}):e.push({type:"value",storageType:"storage",storageOperationType:"get",key:n["VAR?"]});}else if(n==="&&"||n==="||")if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"union",unionType:n==="&&"?"and":"or",conditions:[e[e.length-2],e[e.length-1]]};e.pop(),e.pop(),e.push(t);}else if(n==="!")if(e.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"union",unionType:"not",condition:e[e.length-1]};e[e.length-1]=t;}else if(n&&typeof n=="string"&&A.includes(n))if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"compare",operator:n,rightValue:e[e.length-1],leftValue:e[e.length-2]};e.pop(),e.pop(),e.push(t);}else if(n&&typeof n=="string"&&f.includes(n))if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"arithmetic",operator:n,rightValue:e[e.length-1],leftValue:e[e.length-2]};e.pop(),e.pop(),e.push(t);}else if(n&&typeof n=="string"&&h.includes(n)){let t={type:"arithmeticsingle",operator:n,leftValue:e[e.length-1]};e.pop(),e.push(t);}else n&&typeof n=="string"?n.startsWith("^")&&e.push(V(n)):typeof n=="object"&&"^->"in n?n["^->"].includes("$r")||e.push(n["^->"]):e.push(n);}),e}function k(i,o,r){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let e=d(i,o,r);if(e.length===1){let n=e[0];return n&&typeof n=="object"&&"type"in n?{type:"value",storageType:"logic",storageOperationType:"get",operation:n}:n}else console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);}
|
|
5
|
+
|
|
6
|
+
exports.arithmeticParser = k;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StorageElementType } from '@drincs/pixi-vn';
|
|
2
|
+
import { PixiVNJsonValueGet } from '@drincs/pixi-vn-json';
|
|
3
|
+
import { ArithmeticFunctions } from '../types/parserItems/NativeFunctions.cjs';
|
|
4
|
+
import VariableReference from '../types/parserItems/VariableReference.cjs';
|
|
5
|
+
|
|
6
|
+
declare function arithmeticParser(data: (ArithmeticFunctions | VariableReference)[], labelKey: string, paramNames: string[]): PixiVNJsonValueGet | StorageElementType | undefined;
|
|
7
|
+
|
|
8
|
+
export { arithmeticParser };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StorageElementType } from '@drincs/pixi-vn';
|
|
2
|
+
import { PixiVNJsonValueGet } from '@drincs/pixi-vn-json';
|
|
3
|
+
import { ArithmeticFunctions } from '../types/parserItems/NativeFunctions.js';
|
|
4
|
+
import VariableReference from '../types/parserItems/VariableReference.js';
|
|
5
|
+
|
|
6
|
+
declare function arithmeticParser(data: (ArithmeticFunctions | VariableReference)[], labelKey: string, paramNames: string[]): PixiVNJsonValueGet | StorageElementType | undefined;
|
|
7
|
+
|
|
8
|
+
export { arithmeticParser };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var s="_|_";var f=["+","-","/","*","%","POW","RANDOM"],h=["INT","FLOOR","FLOAT"],A=["==",">","<",">=","<=","!=","CONTAINS"];function u(i,o){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(n=>!n.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",s);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let e=i.split("g-");return c(o)+s+"g-"+e[e.length-1]}let r=0;for(;new RegExp(/^\.\^.*$/).test(i);)r++,i=i.substring(2);if(r=r-1,new RegExp(/^\..*$/).test(i)&&o){let e=i.substring(1);return c(o,r)+s+e.replaceAll(".",s)}return i.replaceAll(".",s)||c(o,r).replaceAll(".",s)}function c(i,o=0){let r=i.split(s);for(;r.length>1&&o>0;)r.pop()?.includes("g-")&&o--,o--;return r.join(s)}var y="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function V(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",y),i=i.replaceAll("\\n",`
|
|
2
|
+
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(y,"\\\\"),i}function d(i,o,r){i=i.map(n=>{if(typeof n=="string"){if(n==="rnd")return "RANDOM";if(n==="?")return "CONTAINS"}return n});let e=[];return i.forEach(n=>{if(typeof n=="object"&&"CNT?"in n)if(new RegExp(/.*\.[0-9]\..*/).test(n["CNT?"])){let t=n["CNT?"].split("."),a=t.pop(),g=t.pop();if(g===void 0||a===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let x=parseInt(g),l=t.join(".");if(l.includes("^.")){let p=l.split("."),E=p[p.length-1].replaceAll(".",s);p.pop(),l=p.join(".")+"."+E,a.includes("c-")&&(l=l+s+a);}else l=l.replaceAll(".",s);e.push({type:"compare",leftValue:{type:"value",storageType:"label",storageOperationType:"get",valueType:"biggeststep",label:u(l,o)},operator:">=",rightValue:{type:"value",value:x}});}else e.push({type:"value",storageType:"label",storageOperationType:"get",label:u(n["CNT?"],o)});else if(typeof n=="object"&&"VAR?"in n){let t=r.indexOf(n["VAR?"]);t>=0?e.push({type:"value",storageType:"params",storageOperationType:"get",key:t}):e.push({type:"value",storageType:"storage",storageOperationType:"get",key:n["VAR?"]});}else if(n==="&&"||n==="||")if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"union",unionType:n==="&&"?"and":"or",conditions:[e[e.length-2],e[e.length-1]]};e.pop(),e.pop(),e.push(t);}else if(n==="!")if(e.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"union",unionType:"not",condition:e[e.length-1]};e[e.length-1]=t;}else if(n&&typeof n=="string"&&A.includes(n))if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"compare",operator:n,rightValue:e[e.length-1],leftValue:e[e.length-2]};e.pop(),e.pop(),e.push(t);}else if(n&&typeof n=="string"&&f.includes(n))if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"arithmetic",operator:n,rightValue:e[e.length-1],leftValue:e[e.length-2]};e.pop(),e.pop(),e.push(t);}else if(n&&typeof n=="string"&&h.includes(n)){let t={type:"arithmeticsingle",operator:n,leftValue:e[e.length-1]};e.pop(),e.push(t);}else n&&typeof n=="string"?n.startsWith("^")&&e.push(V(n)):typeof n=="object"&&"^->"in n?n["^->"].includes("$r")||e.push(n["^->"]):e.push(n);}),e}function k(i,o,r){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let e=d(i,o,r);if(e.length===1){let n=e[0];return n&&typeof n=="object"&&"type"in n?{type:"value",storageType:"logic",storageOperationType:"get",operation:n}:n}else console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);}
|
|
3
|
+
|
|
4
|
+
export { k as arithmeticParser };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('@drincs/pixi-vn');
|
|
4
|
+
|
|
5
|
+
var V="_|_";function N(i,e){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",V);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+V+"g-"+n[n.length-1]}let a=0;for(;new RegExp(/^\.\^.*$/).test(i);)a++,i=i.substring(2);if(a=a-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,a)+V+n.replaceAll(".",V)}return i.replaceAll(".",V)||_(e,a).replaceAll(".",V)}function _(i,e=0){let a=i.split(V);for(;a.length>1&&e>0;)a.pop()?.includes("g-")&&e--,e--;return a.join(V)}var w="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function m(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",w),i=i.replaceAll("\\n",`
|
|
6
|
+
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(w,"\\\\"),i}function B(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(m(e)):typeof e=="object"&&"type"in e&&i.push(e));}function D(i,e,a,n=!0,r=!1){return X(i,e,a,n,r)}function X(i,e,a,n,r=!1){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"typeVar"in e&&e.typeOperation==="get"?typeof e=="string"?i.push(m(e)):e.typeVar==="logic"?i.push({type:"value",storageType:e.typeVar,storageOperationType:"get",operation:e.value}):e.typeVar&&i.push({type:"value",storageType:e.typeVar,storageOperationType:"get",key:e.name}):typeof e=="object"&&"type"in e&&i.push(e));}var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],W=["+","-","/","*","%","POW","RANDOM"],$=["INT","FLOOR","FLOAT"],H=["==",">","<",">=","<=","!=","CONTAINS"];function b(i,e,a){i=i.map(r=>{if(typeof r=="string"){if(r==="rnd")return "RANDOM";if(r==="?")return "CONTAINS"}return r});let n=[];return i.forEach(r=>{if(typeof r=="object"&&"CNT?"in r)if(new RegExp(/.*\.[0-9]\..*/).test(r["CNT?"])){let p=r["CNT?"].split("."),c=p.pop(),g=p.pop();if(g===void 0||c===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let u=parseInt(g),o=p.join(".");if(o.includes("^.")){let s=o.split("."),f=s[s.length-1].replaceAll(".",V);s.pop(),o=s.join(".")+"."+f,c.includes("c-")&&(o=o+V+c);}else o=o.replaceAll(".",V);n.push({type:"compare",leftValue:{type:"value",storageType:"label",storageOperationType:"get",valueType:"biggeststep",label:N(o,e)},operator:">=",rightValue:{type:"value",value:u}});}else n.push({type:"value",storageType:"label",storageOperationType:"get",label:N(r["CNT?"],e)});else if(typeof r=="object"&&"VAR?"in r){let p=a.indexOf(r["VAR?"]);p>=0?n.push({type:"value",storageType:"params",storageOperationType:"get",key:p}):n.push({type:"value",storageType:"storage",storageOperationType:"get",key:r["VAR?"]});}else if(r==="&&"||r==="||")if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(p);}else if(r==="!")if(n.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=p;}else if(r&&typeof r=="string"&&H.includes(r))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(r&&typeof r=="string"&&W.includes(r))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(r&&typeof r=="string"&&$.includes(r)){let p={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(p);}else r&&typeof r=="string"?r.startsWith("^")&&n.push(m(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function J(i,e,a){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let n=b(i,e,a);if(n.length===1){let r=n[0];return r&&typeof r=="object"&&"type"in r?{type:"value",storageType:"logic",storageOperationType:"get",operation:r}:r}else console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);}function Y(i,e,a){return b(i,e,a)}function R(i,e,a,n="",r,p,c=void 0){let g=[],u="sequential",o=!1,s=!0;i.forEach(S=>{S==="%"&&(u="loop"),S==="seq"&&(u="random"),S==="MIN"&&(o=!0);});let f=i[i.length-1];return Object.keys(f).forEach(S=>{let h=f[S];if(Array.isArray(h)&&h.length>3){h=h.slice(1,h.length-2);let P=[];v(h,n,r,P,e,e,a,E,c,!0,p),P.length===1?g.push(P[0]):g.push({type:"resulttocombine",combine:"cross",secondConditionalItem:P});}else Array.isArray(h)&&h.length===3&&(s=!1);}),u==="sequential"?{type:"stepswitch",elements:g,choiceType:u,end:s?"lastItem":void 0,nestedId:c}:o&&u==="random"?{type:"stepswitch",elements:g,choiceType:"sequentialrandom",end:s?"lastItem":void 0,nestedId:c}:{type:"stepswitch",elements:g,choiceType:u}}function v(i,e,a,n=[],r,p,c,g,u=void 0,o=!0,s=[]){let f=!1,l=[],S=!1,h=!1,P=[],O=[];if(a.preDialog[e]&&(o=!1,r(n,"^"+a.preDialog[e].text,e,o,h),delete a.preDialog[e]),i.includes("visit")){let t=R(i,p,c,e,a,s,u);t&&(!o&&n.length>0&&r(n,"<>",e,o,h),r(n,t,e,o,h));return}let F=i[0];if(F&&typeof F=="object"&&"temp="in F)for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)s.push(i[0]["temp="]),i.shift();if(i.forEach((t,C)=>{if(h){if(typeof t=="string"&&t=="/#"){let y=[];v(O,e,a,y,D,D,c,g,u,o),r(n,y,e,o,h),h=!1,O=[];}else O.push(t);return}else if(f)if(Array.isArray(t))l.push(t);else if(t&&typeof t=="object")if("CNT?"in t)C>0&&i[C-1]=="ev"?(S=!0,P.push(t)):S?P.push(t):l.push(t),o=!1;else if("VAR="in t||"temp="in t){let y="VAR="in t?"storage":"tempstorage",d="VAR="in t?t["VAR="]:t["temp="],T=s.indexOf(d);T>=0&&(y="params",d=T);let x=i[C-1];if(x&&typeof x=="string"&&x=="/str"&&(x=i[C-2]),x&&typeof x=="object"&&"^->"in x&&(x=x["^->"]),l.length>1){let A=J(l,e,s);l=[],A&&typeof A=="object"&&"type"in A&&A.type=="value"&&"storageType"in A&&A.storageType=="logic"&&(x=A.operation);}(typeof d!="string"||!d.includes("$r"))&&r(n,{typeOperation:"set",typeVar:y,value:x,name:d},e,o,h);}else "VAR?"in t?l.push(t):"^->"in t&&(t["^->"].includes("$r")||l.push(t));else if(typeof t=="string"&&t=="/ev")S&&P.push(t),f=!1,l.push(t);else if(typeof t=="string"&&t=="out"){if(l.length>0){let y=l[l.length-1];if(y&&typeof y=="object"&&"VAR?"in y){l.pop();let d="storage",T=y["VAR?"],x=s.indexOf(T);x>=0&&(d="params",T=x),r(n,{typeOperation:"get",typeVar:d,name:T},e,o,h);}else {let d=[];for(;l.length>0&&l[l.length-1]!="/ev";)d.push(l.pop());d=d.reverse();let T=J(d,e,s);l=[],T&&typeof T=="object"&&"type"in T&&T.type=="value"&&"storageType"in T&&T.storageType=="logic"?r(n,{typeOperation:"get",typeVar:"logic",value:T.operation},e,o,h):(r(n,"<>",e,o,h),T=`^${T}`,r(n,T,e,o,h));}o=!1;}}else l.push(t);else if(typeof t=="string")if(t.startsWith("^"))r(n,t,e,o,h),o=!1;else if(t=="ev")f=!0;else if(t==`
|
|
7
|
+
`)o=!0;else if(t=="done"||t=="end")r(n,t,e,o,h),o=!1;else if(t=="<>")r(n,t,e,o,h),o=!1;else if(t=="nop"&&S){let y=q(P,p,c,e,a,s,u);y&&r(n,y,e,o,h),S=!1,P=[];}else t=="#"&&(h=!0);else if(t instanceof Array)if(S)P.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){l.pop();let y=[],d=[];for(;l.length>0&&l[l.length-1]!="/ev";)y.push(l.pop());P=[...P,...y.reverse()],S=!0,d.push(t.pop()),d.push(t.pop()),P=[...P,...t],P.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let y=t.pop();if(!y){console.error("[Pixi\u2019VN Ink] Error parsing ink file: el is undefined");return}let d=y["#n"];delete y["#n"],t.push(y),r(n,{"->":e?e+V+d:d},e,o,h),c({[d]:t},e,a);}else v(t,e,a,n,r,p,c,g,u,o);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let y=[];l.length>0&&(y=Y(["ev",...l],e,s)),t.params=y,r(n,t,e,o,h),o=!1;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(l.push(t),o=!1);else if("s"in t&&t.s instanceof Array)l.push(t),o=!1;else if("CNT?"in t)l.push(t),o=!1;else if("VAR="in t||"temp="in t){let y=[],d="VAR="in t?"storage":"tempstorage",T="VAR="in t?t["VAR="]:t["temp="],x=s.indexOf(T);if(x>=0&&(d="params",T=x),T!=="$r"){for(l.pop(),l[l.length-1]=="/ev"&&l.pop();l.length>0&&l[l.length-1]!="/ev";)y.push(l.pop());y=y.reverse();let A=J(y,e,s);l=[],(A!==void 0||A!==null)&&r(n,{typeOperation:"set",typeVar:d,value:A,name:T},e,o,h),o=!1;}}else c(t,e,a);}),g(l,n,e,a,s),e.includes(V)&&n.length==2){let t=n[0],C=n[1];t&&C&&typeof t=="object"&&"dialogue"in t&&typeof C=="object"&&"labelToOpen"in C&&t.dialogue==" "&&C.labelToOpen&&(n.shift(),delete C.glueEnabled,n[0]=C);}}function j(i,e,a,n,r){if(e.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",e);return}let p=b(e,n,a);if(p.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",e);else if(p.length===1){let c={type:"ifelse",condition:p[0],then:i,else:r};return c.else||delete c.else,c}else {let c={type:"ifelse",condition:{type:"union",unionType:"and",conditions:p},then:i,else:r};return c.else||delete c.else,c}}function q(i,e,a,n,r,p,c=void 0){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let g=[],u=[];if(i.forEach(f=>{Array.isArray(f)?u.push(f):typeof f=="string"&&f==="du"?r.du?g.push(r.du):r.du=g[g.length-1]:(typeof f!="string"||f!=="/ev")&&g.push(f);}),u.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",u);return}let o=k(u[0],e,a,n+V+"then",r,p,c),s;return u.length===2?s=k(u[1],e,a,n+V+"else",r,p,c):u.length>2&&(u.shift(),u.push("nop"),u=[{b:u}],s=k(u,e,a,n+V+"else",r,p,c)),r.du=void 0,j(o,g,p,n,s)}function k(i,e,a,n,r,p,c=void 0){let g=[];for(let o of i)typeof o=="object"&&"b"in o&&(o.b=o.b.filter(s=>s!==null&&!(typeof s=="object"&&"->"in s&&new RegExp(/.*\.[0-9]/).test(s["->"]))),v(o.b,n,r,g,e,e,a,E,c,!0,p));return g.length===1?g[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:g}}function M(i="",e=""){let a=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...a,...n])]}function E(i,e,a,n,r){if(i.length>0){let p={};U(i,p,r);for(let[c,g]of Object.entries(p)){let u=a+V+c,o={text:g.text.length===1?g.text[0]:g.text,label:u,props:{},type:"jump",oneTime:g.onetime},s=j(o,g.conditions,r,a)||o,f=e[e.length-1];if(typeof f=="object"&&f&&"type"in f&&(f={conditionalStep:f}),e.length>0&&typeof f=="object"&&f&&"choices"in f&&f.choices){let l=f.choices;l&&Array.isArray(l)?l.push(s):console.error("[Pixi\u2019VN Ink] Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",g,l),f.choices=l;}else e.push({choices:[s]});g.preDialog&&(n.preDialog[u]={text:g.preDialog.text});}}}function U(i,e,a,n){let r=[],p="",c="",g=!1,u=[];for(let o=0;o<i.length;o++){let s=i[o];if(typeof s=="string")s.startsWith("^")?r.push(m(s)):G.includes(s)&&u.push(s);else if(Array.isArray(s)&&s.includes("visit")){let f=R(s,B,(l,S,h)=>{},n,{preDialog:{}},a);r.push(f);}else if(s&&typeof s=="object")if("*"in s&&typeof s["*"]&&typeof s["*"]=="string")s["*"].includes("c")&&(p="c"+s["*"].split("c")[1],s.flg&16&&(g=!0));else if("s"in s&&s.s instanceof Array){let f=L(s.s);f&&(n&&e[n]?(e[n].preDialog={text:f},e[n].text=M(f,e[n].text)):(r.push(f),c=f));}else "CNT?"in s&&u.push(s);else u.push(s);if(r.length>0&&p){e[p]?e[p].text=M(r,e[p].text):e[p]={text:r,onetime:g,conditions:u},c&&(e[p].preDialog={text:c});let f=i.slice(o+1);U(f,e,a,p);return}}}function L(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return m(e)}else if(e instanceof Array){let a=L(e);if(a)return a}}
|
|
8
|
+
|
|
9
|
+
exports.addChoiseIntoList = E;
|
|
10
|
+
exports.getLabelChoice = U;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PixiVNJsonConditionalStatements } from '@drincs/pixi-vn-json';
|
|
2
|
+
import { ShareDataParserLabel } from '../parser/LabelParser.cjs';
|
|
3
|
+
import { ConditionalList } from '../parser/SwitchParser.cjs';
|
|
4
|
+
import LabelChoiceRes from '../types/LabelChoiceRes.cjs';
|
|
5
|
+
import { R as RootParserItemType, C as ChoicePoint, a as ChoiceInfo } from '../RootParserItemType-DV41SbdA.cjs';
|
|
6
|
+
import NativeFunctions from '../types/parserItems/NativeFunctions.cjs';
|
|
7
|
+
import ReadCount from '../types/parserItems/ReadCount.cjs';
|
|
8
|
+
import TextType from '../types/parserItems/TextType.cjs';
|
|
9
|
+
import '../types/InkRootType.cjs';
|
|
10
|
+
import '../types/parserItems/Divert.cjs';
|
|
11
|
+
import '../types/parserItems/VariableAssignment.cjs';
|
|
12
|
+
import '@drincs/pixi-vn';
|
|
13
|
+
import '../types/parserItems/ContainerType.cjs';
|
|
14
|
+
import '../types/parserItems/ControlCommands.cjs';
|
|
15
|
+
import '../types/parserItems/VariableReference.cjs';
|
|
16
|
+
|
|
17
|
+
declare function addChoiseIntoList<T>(choiseList: RootParserItemType[], itemList: (T | PixiVNJsonConditionalStatements<T>)[], labelKey: string, shareData: ShareDataParserLabel, paramNames: string[]): void;
|
|
18
|
+
declare function getLabelChoice(items: (TextType | ReadCount | NativeFunctions | ChoicePoint | ChoiceInfo | ConditionalList)[], result: LabelChoiceRes, paramNames: string[], lastLabel?: string): void;
|
|
19
|
+
|
|
20
|
+
export { addChoiseIntoList, getLabelChoice };
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
import { PixiVNJsonConditionalStatements } from '@drincs/pixi-vn-json';
|
|
2
|
+
import { ShareDataParserLabel } from '../parser/LabelParser.js';
|
|
3
|
+
import { ConditionalList } from '../parser/SwitchParser.js';
|
|
1
4
|
import LabelChoiceRes from '../types/LabelChoiceRes.js';
|
|
5
|
+
import { R as RootParserItemType, C as ChoicePoint, a as ChoiceInfo } from '../RootParserItemType-BeypaLqW.js';
|
|
6
|
+
import NativeFunctions from '../types/parserItems/NativeFunctions.js';
|
|
7
|
+
import ReadCount from '../types/parserItems/ReadCount.js';
|
|
8
|
+
import TextType from '../types/parserItems/TextType.js';
|
|
9
|
+
import '../types/InkRootType.js';
|
|
10
|
+
import '../types/parserItems/Divert.js';
|
|
11
|
+
import '../types/parserItems/VariableAssignment.js';
|
|
12
|
+
import '@drincs/pixi-vn';
|
|
13
|
+
import '../types/parserItems/ContainerType.js';
|
|
14
|
+
import '../types/parserItems/ControlCommands.js';
|
|
15
|
+
import '../types/parserItems/VariableReference.js';
|
|
2
16
|
|
|
3
|
-
declare function
|
|
17
|
+
declare function addChoiseIntoList<T>(choiseList: RootParserItemType[], itemList: (T | PixiVNJsonConditionalStatements<T>)[], labelKey: string, shareData: ShareDataParserLabel, paramNames: string[]): void;
|
|
18
|
+
declare function getLabelChoice(items: (TextType | ReadCount | NativeFunctions | ChoicePoint | ChoiceInfo | ConditionalList)[], result: LabelChoiceRes, paramNames: string[], lastLabel?: string): void;
|
|
4
19
|
|
|
5
|
-
export { getLabelChoice };
|
|
20
|
+
export { addChoiseIntoList, getLabelChoice };
|
|
@@ -1,70 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import '@drincs/pixi-vn';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
const endArray = Array.isArray(end) ? end : [end];
|
|
7
|
-
return [.../* @__PURE__ */ new Set([...startArray, ...endArray])];
|
|
8
|
-
}
|
|
3
|
+
var V="_|_";function N(i,e){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",V);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+V+"g-"+n[n.length-1]}let a=0;for(;new RegExp(/^\.\^.*$/).test(i);)a++,i=i.substring(2);if(a=a-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,a)+V+n.replaceAll(".",V)}return i.replaceAll(".",V)||_(e,a).replaceAll(".",V)}function _(i,e=0){let a=i.split(V);for(;a.length>1&&e>0;)a.pop()?.includes("g-")&&e--,e--;return a.join(V)}var w="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function m(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",w),i=i.replaceAll("\\n",`
|
|
4
|
+
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(w,"\\\\"),i}function B(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(m(e)):typeof e=="object"&&"type"in e&&i.push(e));}function D(i,e,a,n=!0,r=!1){return X(i,e,a,n,r)}function X(i,e,a,n,r=!1){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"typeVar"in e&&e.typeOperation==="get"?typeof e=="string"?i.push(m(e)):e.typeVar==="logic"?i.push({type:"value",storageType:e.typeVar,storageOperationType:"get",operation:e.value}):e.typeVar&&i.push({type:"value",storageType:e.typeVar,storageOperationType:"get",key:e.name}):typeof e=="object"&&"type"in e&&i.push(e));}var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],W=["+","-","/","*","%","POW","RANDOM"],$=["INT","FLOOR","FLOAT"],H=["==",">","<",">=","<=","!=","CONTAINS"];function b(i,e,a){i=i.map(r=>{if(typeof r=="string"){if(r==="rnd")return "RANDOM";if(r==="?")return "CONTAINS"}return r});let n=[];return i.forEach(r=>{if(typeof r=="object"&&"CNT?"in r)if(new RegExp(/.*\.[0-9]\..*/).test(r["CNT?"])){let p=r["CNT?"].split("."),c=p.pop(),g=p.pop();if(g===void 0||c===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let u=parseInt(g),o=p.join(".");if(o.includes("^.")){let s=o.split("."),f=s[s.length-1].replaceAll(".",V);s.pop(),o=s.join(".")+"."+f,c.includes("c-")&&(o=o+V+c);}else o=o.replaceAll(".",V);n.push({type:"compare",leftValue:{type:"value",storageType:"label",storageOperationType:"get",valueType:"biggeststep",label:N(o,e)},operator:">=",rightValue:{type:"value",value:u}});}else n.push({type:"value",storageType:"label",storageOperationType:"get",label:N(r["CNT?"],e)});else if(typeof r=="object"&&"VAR?"in r){let p=a.indexOf(r["VAR?"]);p>=0?n.push({type:"value",storageType:"params",storageOperationType:"get",key:p}):n.push({type:"value",storageType:"storage",storageOperationType:"get",key:r["VAR?"]});}else if(r==="&&"||r==="||")if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(p);}else if(r==="!")if(n.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=p;}else if(r&&typeof r=="string"&&H.includes(r))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(r&&typeof r=="string"&&W.includes(r))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(r&&typeof r=="string"&&$.includes(r)){let p={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(p);}else r&&typeof r=="string"?r.startsWith("^")&&n.push(m(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function J(i,e,a){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let n=b(i,e,a);if(n.length===1){let r=n[0];return r&&typeof r=="object"&&"type"in r?{type:"value",storageType:"logic",storageOperationType:"get",operation:r}:r}else console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);}function Y(i,e,a){return b(i,e,a)}function R(i,e,a,n="",r,p,c=void 0){let g=[],u="sequential",o=!1,s=!0;i.forEach(S=>{S==="%"&&(u="loop"),S==="seq"&&(u="random"),S==="MIN"&&(o=!0);});let f=i[i.length-1];return Object.keys(f).forEach(S=>{let h=f[S];if(Array.isArray(h)&&h.length>3){h=h.slice(1,h.length-2);let P=[];v(h,n,r,P,e,e,a,E,c,!0,p),P.length===1?g.push(P[0]):g.push({type:"resulttocombine",combine:"cross",secondConditionalItem:P});}else Array.isArray(h)&&h.length===3&&(s=!1);}),u==="sequential"?{type:"stepswitch",elements:g,choiceType:u,end:s?"lastItem":void 0,nestedId:c}:o&&u==="random"?{type:"stepswitch",elements:g,choiceType:"sequentialrandom",end:s?"lastItem":void 0,nestedId:c}:{type:"stepswitch",elements:g,choiceType:u}}function v(i,e,a,n=[],r,p,c,g,u=void 0,o=!0,s=[]){let f=!1,l=[],S=!1,h=!1,P=[],O=[];if(a.preDialog[e]&&(o=!1,r(n,"^"+a.preDialog[e].text,e,o,h),delete a.preDialog[e]),i.includes("visit")){let t=R(i,p,c,e,a,s,u);t&&(!o&&n.length>0&&r(n,"<>",e,o,h),r(n,t,e,o,h));return}let F=i[0];if(F&&typeof F=="object"&&"temp="in F)for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)s.push(i[0]["temp="]),i.shift();if(i.forEach((t,C)=>{if(h){if(typeof t=="string"&&t=="/#"){let y=[];v(O,e,a,y,D,D,c,g,u,o),r(n,y,e,o,h),h=!1,O=[];}else O.push(t);return}else if(f)if(Array.isArray(t))l.push(t);else if(t&&typeof t=="object")if("CNT?"in t)C>0&&i[C-1]=="ev"?(S=!0,P.push(t)):S?P.push(t):l.push(t),o=!1;else if("VAR="in t||"temp="in t){let y="VAR="in t?"storage":"tempstorage",d="VAR="in t?t["VAR="]:t["temp="],T=s.indexOf(d);T>=0&&(y="params",d=T);let x=i[C-1];if(x&&typeof x=="string"&&x=="/str"&&(x=i[C-2]),x&&typeof x=="object"&&"^->"in x&&(x=x["^->"]),l.length>1){let A=J(l,e,s);l=[],A&&typeof A=="object"&&"type"in A&&A.type=="value"&&"storageType"in A&&A.storageType=="logic"&&(x=A.operation);}(typeof d!="string"||!d.includes("$r"))&&r(n,{typeOperation:"set",typeVar:y,value:x,name:d},e,o,h);}else "VAR?"in t?l.push(t):"^->"in t&&(t["^->"].includes("$r")||l.push(t));else if(typeof t=="string"&&t=="/ev")S&&P.push(t),f=!1,l.push(t);else if(typeof t=="string"&&t=="out"){if(l.length>0){let y=l[l.length-1];if(y&&typeof y=="object"&&"VAR?"in y){l.pop();let d="storage",T=y["VAR?"],x=s.indexOf(T);x>=0&&(d="params",T=x),r(n,{typeOperation:"get",typeVar:d,name:T},e,o,h);}else {let d=[];for(;l.length>0&&l[l.length-1]!="/ev";)d.push(l.pop());d=d.reverse();let T=J(d,e,s);l=[],T&&typeof T=="object"&&"type"in T&&T.type=="value"&&"storageType"in T&&T.storageType=="logic"?r(n,{typeOperation:"get",typeVar:"logic",value:T.operation},e,o,h):(r(n,"<>",e,o,h),T=`^${T}`,r(n,T,e,o,h));}o=!1;}}else l.push(t);else if(typeof t=="string")if(t.startsWith("^"))r(n,t,e,o,h),o=!1;else if(t=="ev")f=!0;else if(t==`
|
|
5
|
+
`)o=!0;else if(t=="done"||t=="end")r(n,t,e,o,h),o=!1;else if(t=="<>")r(n,t,e,o,h),o=!1;else if(t=="nop"&&S){let y=q(P,p,c,e,a,s,u);y&&r(n,y,e,o,h),S=!1,P=[];}else t=="#"&&(h=!0);else if(t instanceof Array)if(S)P.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){l.pop();let y=[],d=[];for(;l.length>0&&l[l.length-1]!="/ev";)y.push(l.pop());P=[...P,...y.reverse()],S=!0,d.push(t.pop()),d.push(t.pop()),P=[...P,...t],P.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let y=t.pop();if(!y){console.error("[Pixi\u2019VN Ink] Error parsing ink file: el is undefined");return}let d=y["#n"];delete y["#n"],t.push(y),r(n,{"->":e?e+V+d:d},e,o,h),c({[d]:t},e,a);}else v(t,e,a,n,r,p,c,g,u,o);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let y=[];l.length>0&&(y=Y(["ev",...l],e,s)),t.params=y,r(n,t,e,o,h),o=!1;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(l.push(t),o=!1);else if("s"in t&&t.s instanceof Array)l.push(t),o=!1;else if("CNT?"in t)l.push(t),o=!1;else if("VAR="in t||"temp="in t){let y=[],d="VAR="in t?"storage":"tempstorage",T="VAR="in t?t["VAR="]:t["temp="],x=s.indexOf(T);if(x>=0&&(d="params",T=x),T!=="$r"){for(l.pop(),l[l.length-1]=="/ev"&&l.pop();l.length>0&&l[l.length-1]!="/ev";)y.push(l.pop());y=y.reverse();let A=J(y,e,s);l=[],(A!==void 0||A!==null)&&r(n,{typeOperation:"set",typeVar:d,value:A,name:T},e,o,h),o=!1;}}else c(t,e,a);}),g(l,n,e,a,s),e.includes(V)&&n.length==2){let t=n[0],C=n[1];t&&C&&typeof t=="object"&&"dialogue"in t&&typeof C=="object"&&"labelToOpen"in C&&t.dialogue==" "&&C.labelToOpen&&(n.shift(),delete C.glueEnabled,n[0]=C);}}function j(i,e,a,n,r){if(e.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",e);return}let p=b(e,n,a);if(p.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",e);else if(p.length===1){let c={type:"ifelse",condition:p[0],then:i,else:r};return c.else||delete c.else,c}else {let c={type:"ifelse",condition:{type:"union",unionType:"and",conditions:p},then:i,else:r};return c.else||delete c.else,c}}function q(i,e,a,n,r,p,c=void 0){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let g=[],u=[];if(i.forEach(f=>{Array.isArray(f)?u.push(f):typeof f=="string"&&f==="du"?r.du?g.push(r.du):r.du=g[g.length-1]:(typeof f!="string"||f!=="/ev")&&g.push(f);}),u.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",u);return}let o=k(u[0],e,a,n+V+"then",r,p,c),s;return u.length===2?s=k(u[1],e,a,n+V+"else",r,p,c):u.length>2&&(u.shift(),u.push("nop"),u=[{b:u}],s=k(u,e,a,n+V+"else",r,p,c)),r.du=void 0,j(o,g,p,n,s)}function k(i,e,a,n,r,p,c=void 0){let g=[];for(let o of i)typeof o=="object"&&"b"in o&&(o.b=o.b.filter(s=>s!==null&&!(typeof s=="object"&&"->"in s&&new RegExp(/.*\.[0-9]/).test(s["->"]))),v(o.b,n,r,g,e,e,a,E,c,!0,p));return g.length===1?g[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:g}}function M(i="",e=""){let a=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...a,...n])]}function E(i,e,a,n,r){if(i.length>0){let p={};U(i,p,r);for(let[c,g]of Object.entries(p)){let u=a+V+c,o={text:g.text.length===1?g.text[0]:g.text,label:u,props:{},type:"jump",oneTime:g.onetime},s=j(o,g.conditions,r,a)||o,f=e[e.length-1];if(typeof f=="object"&&f&&"type"in f&&(f={conditionalStep:f}),e.length>0&&typeof f=="object"&&f&&"choices"in f&&f.choices){let l=f.choices;l&&Array.isArray(l)?l.push(s):console.error("[Pixi\u2019VN Ink] Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",g,l),f.choices=l;}else e.push({choices:[s]});g.preDialog&&(n.preDialog[u]={text:g.preDialog.text});}}}function U(i,e,a,n){let r=[],p="",c="",g=!1,u=[];for(let o=0;o<i.length;o++){let s=i[o];if(typeof s=="string")s.startsWith("^")?r.push(m(s)):G.includes(s)&&u.push(s);else if(Array.isArray(s)&&s.includes("visit")){let f=R(s,B,(l,S,h)=>{},n,{preDialog:{}},a);r.push(f);}else if(s&&typeof s=="object")if("*"in s&&typeof s["*"]&&typeof s["*"]=="string")s["*"].includes("c")&&(p="c"+s["*"].split("c")[1],s.flg&16&&(g=!0));else if("s"in s&&s.s instanceof Array){let f=L(s.s);f&&(n&&e[n]?(e[n].preDialog={text:f},e[n].text=M(f,e[n].text)):(r.push(f),c=f));}else "CNT?"in s&&u.push(s);else u.push(s);if(r.length>0&&p){e[p]?e[p].text=M(r,e[p].text):e[p]={text:r,onetime:g,conditions:u},c&&(e[p].preDialog={text:c});let f=i.slice(o+1);U(f,e,a,p);return}}}function L(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return m(e)}else if(e instanceof Array){let a=L(e);if(a)return a}}
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
function getLabelChoice(items, result, lastLabel) {
|
|
12
|
-
let text = "";
|
|
13
|
-
let label = "";
|
|
14
|
-
let preDialog = "";
|
|
15
|
-
for (let index = 0; index < items.length; index++) {
|
|
16
|
-
let v = items[index];
|
|
17
|
-
if (typeof v === "string") {
|
|
18
|
-
if (v.startsWith("^")) {
|
|
19
|
-
text = v.substring(1);
|
|
20
|
-
}
|
|
21
|
-
} else if (v && typeof v === "object") {
|
|
22
|
-
if ("*" in v && typeof v["*"] && typeof v["*"] === "string" && v["*"].includes("c")) {
|
|
23
|
-
let l = "c" + v["*"].split("c")[1];
|
|
24
|
-
label = l;
|
|
25
|
-
} else if ("s" in v && v["s"] instanceof Array) {
|
|
26
|
-
let t = findChoiceText(v["s"]);
|
|
27
|
-
if (t) {
|
|
28
|
-
if (lastLabel && result[lastLabel]) {
|
|
29
|
-
result[lastLabel].preDialog = { text: t };
|
|
30
|
-
result[lastLabel].text = unionStringOrArray(t, result[lastLabel].text);
|
|
31
|
-
} else {
|
|
32
|
-
text = t;
|
|
33
|
-
preDialog = t;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (text && label) {
|
|
39
|
-
if (result[label]) {
|
|
40
|
-
result[label].text = unionStringOrArray(text, result[label].text);
|
|
41
|
-
} else {
|
|
42
|
-
result[label] = { text };
|
|
43
|
-
}
|
|
44
|
-
if (preDialog) {
|
|
45
|
-
result[label].preDialog = { text: preDialog };
|
|
46
|
-
}
|
|
47
|
-
let newListItem = items.slice(index + 1);
|
|
48
|
-
getLabelChoice(newListItem, result, label);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function findChoiceText(items) {
|
|
54
|
-
for (const item of items) {
|
|
55
|
-
if (typeof item === "string") {
|
|
56
|
-
if (item.startsWith("^")) {
|
|
57
|
-
return item.substring(1);
|
|
58
|
-
}
|
|
59
|
-
} else if (item instanceof Array) {
|
|
60
|
-
let res = findChoiceText(item);
|
|
61
|
-
if (res) {
|
|
62
|
-
return res;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
exports.getLabelChoice = getLabelChoice;
|
|
69
|
-
//# sourceMappingURL=ChoiceInfoConverter.js.map
|
|
70
|
-
//# sourceMappingURL=ChoiceInfoConverter.js.map
|
|
7
|
+
export { E as addChoiseIntoList, U as getLabelChoice };
|