narrat 2.0.12 → 2.0.13-test

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.
Files changed (53) hide show
  1. package/README.md +15 -0
  2. package/dist/{lib.css → assets/lib.d7c0f4e9.css} +1 -1
  3. package/dist/components/hud.vue.d.ts +3 -1
  4. package/dist/config.d.ts +7 -0
  5. package/dist/img/backgrounds/rpg.png +0 -0
  6. package/dist/img/enemies/goblin.png +0 -0
  7. package/dist/img/enemies/skeleton.png +0 -0
  8. package/dist/img/enemies/slime.png +0 -0
  9. package/dist/img/levels/cave.png +0 -0
  10. package/dist/img/levels/dungeon.png +0 -0
  11. package/dist/img/levels/dungeon_F.png +0 -0
  12. package/dist/img/levels/dungeon_FL.png +0 -0
  13. package/dist/img/levels/dungeon_FR.png +0 -0
  14. package/dist/img/levels/dungeon_FRL.png +0 -0
  15. package/dist/img/levels/dungeon_LR.png +0 -0
  16. package/dist/img/levels/grass.png +0 -0
  17. package/dist/img/players/wizard.png +0 -0
  18. package/dist/img/ui/front.png +0 -0
  19. package/dist/img/ui/left.png +0 -0
  20. package/dist/img/ui/right.png +0 -0
  21. package/dist/img/ui/start.png +0 -0
  22. package/dist/narrat.es.js +30719 -33126
  23. package/dist/narrat.es.js.map +1 -1
  24. package/dist/narrat.umd.js +87 -98
  25. package/dist/narrat.umd.js.map +1 -1
  26. package/dist/stores/main-store.d.ts +8 -0
  27. package/dist/stores/screens-store.d.ts +1 -1
  28. package/dist/stores/skills.d.ts +4 -0
  29. package/dist/types/app-types.d.ts +1 -0
  30. package/dist/types/parser.d.ts +1 -1
  31. package/dist/vm/commands/arithmetic-commands.d.ts +6 -0
  32. package/dist/vm/commands/command-helpers.d.ts +1 -0
  33. package/dist/vm/commands/flow-commands.d.ts +3 -0
  34. package/dist/vm/commands/math-commands.d.ts +14 -0
  35. package/dist/vm/commands/random-commands.d.ts +10 -0
  36. package/dist/vm/commands/skill-commands.d.ts +12 -0
  37. package/dist/vm/vm-helpers.d.ts +2 -0
  38. package/dist/vm/vm.d.ts +0 -1
  39. package/package.json +5 -2
  40. package/dist/audio/click.ogg +0 -0
  41. package/dist/audio/failure.ogg +0 -0
  42. package/dist/audio/game_start.ogg +0 -0
  43. package/dist/audio/success.wav +0 -0
  44. package/dist/audio.7z +0 -0
  45. package/dist/data/characters.json +0 -62
  46. package/dist/data/config.json +0 -187
  47. package/dist/data/example.rpy +0 -369
  48. package/dist/data/refactor.rpy +0 -31
  49. package/dist/fonts/OpenDyslexic.ttf.eot +0 -0
  50. package/dist/fonts/OpenDyslexic.ttf.svg +0 -2326
  51. package/dist/fonts/OpenDyslexic.ttf.woff +0 -0
  52. package/dist/img/characters/music_cat.jpeg +0 -0
  53. package/dist/music/calm.mp3 +0 -0
@@ -31,6 +31,7 @@ export declare const useMain: import("pinia").StoreDefinition<"main", MainState,
31
31
  previousPlaytime: number;
32
32
  };
33
33
  options: {
34
+ baseAssetsPath?: string | undefined;
34
35
  logging: boolean;
35
36
  debug: boolean;
36
37
  };
@@ -72,6 +73,7 @@ export declare const useMain: import("pinia").StoreDefinition<"main", MainState,
72
73
  previousPlaytime: number;
73
74
  };
74
75
  options: {
76
+ baseAssetsPath?: string | undefined;
75
77
  logging: boolean;
76
78
  debug: boolean;
77
79
  };
@@ -90,6 +92,7 @@ export declare const useMain: import("pinia").StoreDefinition<"main", MainState,
90
92
  previousPlaytime: number;
91
93
  };
92
94
  options: {
95
+ baseAssetsPath?: string | undefined;
93
96
  logging: boolean;
94
97
  debug: boolean;
95
98
  };
@@ -109,6 +112,7 @@ export declare const useMain: import("pinia").StoreDefinition<"main", MainState,
109
112
  previousPlaytime: number;
110
113
  };
111
114
  options: {
115
+ baseAssetsPath?: string | undefined;
112
116
  logging: boolean;
113
117
  debug: boolean;
114
118
  };
@@ -139,7 +143,11 @@ export declare const useMain: import("pinia").StoreDefinition<"main", MainState,
139
143
  setupSkills(skills: {
140
144
  [key: string]: import("../config").SkillData;
141
145
  }): void;
146
+ getSkill(skill: string): import("./skills").SkillState;
147
+ getSkillLevel(skill: string): number;
148
+ getSkillXp(skill: string): number;
142
149
  addXp(skill: string, xp: number): void;
150
+ setSkillLevel(skill: string, level: number): void;
143
151
  incrementSkill(skill: string, amount: number): void;
144
152
  levelledUp(skill: string): void;
145
153
  }>;
@@ -1,5 +1,5 @@
1
1
  import { Config } from '../config';
2
- export declare type ButtonStateValue = boolean | 'hidden';
2
+ export declare type ButtonStateValue = boolean | 'hidden' | 'greyed';
3
3
  export interface ButtonsState {
4
4
  [key: string]: {
5
5
  state: ButtonStateValue;
@@ -30,7 +30,11 @@ export declare const useSkills: import("pinia").StoreDefinition<"skills", Skills
30
30
  setupSkills(skills: {
31
31
  [key: string]: SkillData;
32
32
  }): void;
33
+ getSkill(skill: string): SkillState;
34
+ getSkillLevel(skill: string): number;
35
+ getSkillXp(skill: string): number;
33
36
  addXp(skill: string, xp: number): void;
37
+ setSkillLevel(skill: string, level: number): void;
34
38
  incrementSkill(skill: string, amount: number): void;
35
39
  levelledUp(skill: string): void;
36
40
  }>;
@@ -1,4 +1,5 @@
1
1
  export interface GameConfig {
2
+ baseAssetsPath?: string;
2
3
  charactersPath: string;
3
4
  configPath: string;
4
5
  }
@@ -1,5 +1,5 @@
1
1
  export declare namespace Parser {
2
- type Primitive = string | number | boolean;
2
+ type Primitive = string | number | boolean | undefined | null;
3
3
  type Expression = Array<Primitive | Expression>;
4
4
  interface IfOptions {
5
5
  condition: string;
@@ -7,6 +7,12 @@ export declare const substractionPlugin: CommandPlugin<{
7
7
  a: number;
8
8
  b: number;
9
9
  }, {}>;
10
+ export declare const negPlugin: CommandPlugin<{
11
+ a: number;
12
+ }, {}>;
13
+ export declare const absPlugin: CommandPlugin<{
14
+ a: number;
15
+ }, {}>;
10
16
  export declare const multiplicationPlugin: CommandPlugin<{
11
17
  a: number;
12
18
  b: number;
@@ -1,2 +1,3 @@
1
1
  import { Parser } from '../../types/parser';
2
2
  export declare function commandRuntimeError(cmd: Parser.Command<any, any>, errorText: string): void;
3
+ export declare function commandLog(cmd: Parser.Command<any, any>, ...log: any[]): void;
@@ -12,3 +12,6 @@ export declare const defineVariablePlugin: CommandPlugin<{
12
12
  export declare const returnPlugin: CommandPlugin<{
13
13
  value: any;
14
14
  }, {}>;
15
+ export declare const logPlugin: CommandPlugin<{
16
+ value: any;
17
+ }, {}>;
@@ -0,0 +1,14 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const minPlugin: CommandPlugin<{
3
+ min: number;
4
+ value: number;
5
+ }, {}>;
6
+ export declare const maxPlugin: CommandPlugin<{
7
+ max: number;
8
+ value: number;
9
+ }, {}>;
10
+ export declare const clampPlugin: CommandPlugin<{
11
+ min: number;
12
+ max: number;
13
+ value: number;
14
+ }, {}>;
@@ -0,0 +1,10 @@
1
+ import { CommandPlugin } from './command-plugin';
2
+ export declare const randomIntPlugin: CommandPlugin<{
3
+ a: number;
4
+ b: number;
5
+ }, {}>;
6
+ export declare const randomFloatPlugin: CommandPlugin<{
7
+ a: number;
8
+ b: number;
9
+ }, {}>;
10
+ export declare const randomFromArgsPlugin: CommandPlugin<{}, {}>;
@@ -5,11 +5,23 @@ export interface AddLevelArgs {
5
5
  amount: number;
6
6
  }
7
7
  export declare const addLevelPlugin: CommandPlugin<AddLevelArgs, {}>;
8
+ export declare const setLevelPlugin: CommandPlugin<{
9
+ skill: string;
10
+ level: number;
11
+ }, {}>;
8
12
  export interface AddXpArgs {
9
13
  xpKey: string;
10
14
  xpToAdd: number;
11
15
  }
12
16
  export declare const addXpPlugin: CommandPlugin<AddXpArgs, {}>;
17
+ export interface GetLevelArgs {
18
+ skillKey: string;
19
+ }
20
+ export declare const getLevelPlugin: CommandPlugin<GetLevelArgs, {}>;
21
+ export interface GetXpArgs {
22
+ xpKey: string;
23
+ }
24
+ export declare const getXpPlugin: CommandPlugin<GetXpArgs, {}>;
13
25
  export interface SkillCheckOptions {
14
26
  id: string;
15
27
  skill: string;
@@ -11,6 +11,8 @@ export interface SkillCheckParams {
11
11
  export declare function runSkillCheck(params: SkillCheckParams): SkillCheckState;
12
12
  export declare function runConditionCommand(command: Parser.Command<IfOptions, IfStaticOptions>): Parser.Branch | undefined;
13
13
  export declare function isExpression(arg: Parser.Arg): arg is Parser.ParsedExpression;
14
+ export declare type Variable = string | number | boolean | undefined | null;
15
+ export declare function isVariable(arg: Parser.Arg): arg is Variable;
14
16
  export declare function writeText(text: string): void;
15
17
  export declare function textCommand(dialog: AddDialogParams): Promise<void>;
16
18
  export declare function getLine(lines: Parser.Line[], index: number): Parser.Line | undefined;
package/dist/vm/vm.d.ts CHANGED
@@ -16,4 +16,3 @@ export declare function runCommand(expression: Parser.ParsedExpression, choices?
16
16
  export declare function generateCommand(expr: Parser.ParsedExpression, choices?: DialogChoice[]): Promise<Parser.Command>;
17
17
  export declare function runExpression<ReturnType = any>(expr: Parser.ParsedExpression, choices?: DialogChoice[]): Promise<ReturnType>;
18
18
  export declare function playerAnswered(choice: string | number): Promise<any>;
19
- export declare function finishGame(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "narrat",
3
- "version": "2.0.12",
3
+ "version": "2.0.13-test",
4
4
  "description": "narrat narrative engine",
5
5
  "main": "dist/narrat.umd.js",
6
6
  "module": "dist/narrat.es.js",
@@ -16,6 +16,8 @@
16
16
  "scripts": {
17
17
  "test": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest",
18
18
  "start": "npm run dev",
19
+ "rpg": "cross-env VITE_EXAMPLE=examples/rpg npx vite dev",
20
+ "build-rpg": "cross-env VITE_DEMO_BUILD=rpg npx vite build && shx cp -r examples/rpg/* built-example/rpg",
19
21
  "dev": "vite",
20
22
  "generate-types": "vue-tsc --emitDeclarationOnly --outDir dist && npm run fix-type-aliases",
21
23
  "fix-type-aliases": "tsc-alias -p tsconfig.json",
@@ -66,12 +68,13 @@
66
68
  "postcss": "^8.4.14",
67
69
  "prettier": "^2.7.1",
68
70
  "rollup-plugin-typescript2": "^0.32.1",
71
+ "shx": "^0.3.4",
69
72
  "tailwindcss": "^3.1.4",
70
73
  "ts-jest": "^28.0.5",
71
74
  "tsc-alias": "^1.6.11",
72
75
  "tslib": "^2.4.0",
73
76
  "typescript": "^4.7.4",
74
- "vite": "^2.9.9",
77
+ "vite": "^3.0.0",
75
78
  "vite-plugin-eslint": "^1.6.1",
76
79
  "vue": "^3.2.37",
77
80
  "vue-tsc": "^0.38.2"
Binary file
Binary file
Binary file
Binary file
package/dist/audio.7z DELETED
Binary file
@@ -1,62 +0,0 @@
1
- {
2
- "config": {
3
- "imagesPath": "./img/characters/"
4
- },
5
- "characters": {
6
- "game": {
7
- "name": "",
8
- "color": "white"
9
- },
10
- "player": {
11
- "style": {
12
- "color": "orange"
13
- },
14
- "name": "You"
15
- },
16
- "cat": {
17
- "sprites": {
18
- "idle": "cat_idle.jpg"
19
- },
20
- "style": {
21
- "color": "white"
22
- },
23
- "name": "Generic Cat"
24
- },
25
- "shopkeeper": {
26
- "sprites": {
27
- "idle": "music_cat.jpeg"
28
- },
29
- "style": {
30
- "color": "white"
31
- },
32
- "name": "Shopkeeper"
33
- },
34
- "helper": {
35
- "sprites": {
36
- "idle": "helper_cat.png"
37
- },
38
- "style": {
39
- "color": "green"
40
- },
41
- "name": "Helper Cat"
42
- },
43
- "music_cat": {
44
- "sprites": {
45
- "idle": "music_cat.jpeg"
46
- },
47
- "style": {
48
- "color": "green"
49
- },
50
- "name": "Music Cat"
51
- },
52
- "inner": {
53
- "sprites": {
54
- "idle": "inner_voice.png"
55
- },
56
- "style": {
57
- "color": "red"
58
- },
59
- "name": "Inner Voice"
60
- }
61
- }
62
- }
@@ -1,187 +0,0 @@
1
- {
2
- "gameTitle": "Narrat Game Example",
3
- "images": {
4
- "narrat": "img/backgrounds/narrat.png",
5
- "map": "img/backgrounds/map.png",
6
- "shopButton": "img/ui/shop-button.png",
7
- "parkButton": "img/ui/park-button.png"
8
- },
9
- "layout": {
10
- "backgrounds": {
11
- "width": 880,
12
- "height": 720
13
- },
14
- "dialogBottomPadding": 70,
15
- "minTextWidth": 475,
16
- "mobileDialogHeightPercentage": 60,
17
- "verticalLayoutThreshold": 1000,
18
- "portraits": {
19
- "width": 100,
20
- "height": 100
21
- }
22
- },
23
- "screens": {
24
- "default": {
25
- "background": "narrat"
26
- },
27
- "layers-test": {
28
- "background": "img/backgrounds/test-layers.gif"
29
- },
30
- "map": {
31
- "background": "img/backgrounds/map.png",
32
- "buttons": [
33
- {
34
- "id": "shopButton",
35
- "enabled": false,
36
- "background": "img/ui/shop-button.png",
37
- "position": {
38
- "left": 38,
39
- "top": 6,
40
- "width": 255,
41
- "height": 226
42
- },
43
- "action": "shopButton"
44
- },
45
- {
46
- "id": "parkButton",
47
- "enabled": false,
48
- "background": "img/ui/park-button.png",
49
- "position": {
50
- "left": 632,
51
- "top": 86,
52
- "width": 255,
53
- "height": 226
54
- },
55
- "action": "parkButton"
56
- }
57
- ]
58
- }
59
- },
60
- "buttons": {},
61
- "skills": {
62
- "agility": {
63
- "name": "Agility",
64
- "description": "How good you are at moving around.",
65
- "startingLevel": 0,
66
- "icon": "img/skills/agility.jpg",
67
- "hidden": true
68
- },
69
- "haggling": {
70
- "name": "Haggling",
71
- "description": "Get good prices on items",
72
- "icon": "img/skills/logic.jpg",
73
- "startingLevel": 1
74
- }
75
- },
76
- "skillChecks": {
77
- "rollRange": 100,
78
- "skillMultiplier": 10,
79
- "failureChance": 1,
80
- "difficultyText": [
81
- [0, "Very Easy"],
82
- [10, "Easy"],
83
- [30, "Medium"],
84
- [50, "Hard"],
85
- [70, "Very Hard"],
86
- [80, "Extremely Hard"],
87
- [90, "Near Impossible"]
88
- ]
89
- },
90
- "scripts": ["data/example.rpy"],
91
- "audio": {
92
- "calm": {
93
- "loop": true,
94
- "src": "music/calm.mp3"
95
- },
96
- "click": {
97
- "src": "audio/click.ogg"
98
- },
99
- "game_start": {
100
- "src": "audio/game_start.ogg"
101
- },
102
- "failure": {
103
- "src": "audio/failure.ogg"
104
- },
105
- "success": {
106
- "src": "audio/success.wav"
107
- }
108
- },
109
- "audioOptions": {
110
- "volume": 0.5,
111
- "musicFadeInTime": 0.5,
112
- "musicFadeInDelay": 0.5,
113
- "musicFadeOutTime": 0.5
114
- },
115
- "notifications": {
116
- "timeOnScreen": 2.5,
117
- "alsoPrintInDialogue": true
118
- },
119
- "hudStats": {
120
- "money": {
121
- "icon": "img/ui/money.png",
122
- "name": "Money",
123
- "startingValue": 10,
124
- "minValue": 0
125
- },
126
- "energy": {
127
- "icon": "img/ui/energy.png",
128
- "name": "Energy",
129
- "startingValue": 10,
130
- "minValue": 0,
131
- "maxValue": 10
132
- }
133
- },
134
- "items": {
135
- "bread": {
136
- "name": "Bread",
137
- "description": "A bread in the game.",
138
- "icon": "img/items/bread.png",
139
- "onUse": {
140
- "action": "jump",
141
- "label": "eat_bread"
142
- }
143
- },
144
- "book": {
145
- "name": "Ominous Book",
146
- "description": "An ominous book. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sed ullamcorper turpis. Aliquam tincidunt dolor sed mollis aliquet. Duis in odio eros. Maecenas sapien arcu, fermentum id tincidunt non, accumsan vel metus. Nullam pretium molestie accumsan. In ut rutrum tellus. Integer vitae nisl eleifend lorem tristique auctor quis sed nulla. Cras gravida viverra tristique. Mauris imperdiet tortor purus, fringilla vehicula metus ullamcorper eget. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla porta imperdiet justo, sed blandit orci. Aenean accumsan hendrerit arcu, laoreet vestibulum turpis vulputate eu. Etiam dignissim nibh dictum pharetra congue. Nulla ultrices, augue a blandit laoreet, metus enim sodales arcu, eget pellentesque lorem justo et ipsum. ",
147
- "icon": "img/items/book.png",
148
- "onUse": {
149
- "action": "run",
150
- "label": "read_book"
151
- },
152
- "tag": "always_interactable"
153
- }
154
- },
155
- "interactionTags": {
156
- "default": {
157
- "onlyInteractOutsideOfScripts": true
158
- }
159
- },
160
- "quests": {
161
- "breadShopping": {
162
- "title": "Bread Shopping",
163
- "description": "The helper cat asked you to buy bread for him.",
164
- "objectives": {
165
- "bread": {
166
- "description": "Buy bread for the helper cat."
167
- },
168
- "delivery": {
169
- "hidden": true,
170
- "description": "Deliver the bread to the helper cat."
171
- }
172
- }
173
- }
174
- },
175
- "audioTriggers": {
176
- "onPlayerAnswered": "click",
177
- "onPressStart": "game_start",
178
- "onSkillCheckFailure": "failure",
179
- "onSkillCheckSuccess": "success"
180
- },
181
- "menuButtons": {
182
- "menu": {
183
- "text": "Menu",
184
- "cssId": "my-custom-id"
185
- }
186
- }
187
- }