narrat 2.0.3 → 2.0.6

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 (101) hide show
  1. package/CHANGELOG.md +776 -0
  2. package/LICENSE +21 -21
  3. package/README.md +38 -38
  4. package/dist/.DS_Store +0 -0
  5. package/dist/app.vue.d.ts +106 -106
  6. package/dist/components/MainMenu.vue.d.ts +12 -12
  7. package/dist/components/Skills.vue.d.ts +22 -22
  8. package/dist/components/debug/debug-menu.vue.d.ts +48 -48
  9. package/dist/components/dialog-picture.vue.d.ts +9 -9
  10. package/dist/components/game-dialog.vue.d.ts +65 -65
  11. package/dist/components/hud.vue.d.ts +12 -12
  12. package/dist/components/inventory-ui.vue.d.ts +30 -30
  13. package/dist/components/loading-bar.vue.d.ts +10 -10
  14. package/dist/components/menu-buttons.vue.d.ts +26 -26
  15. package/dist/components/notification-toast.vue.d.ts +6 -6
  16. package/dist/components/quests-ui.vue.d.ts +20 -20
  17. package/dist/components/utils/modal.vue.d.ts +6 -6
  18. package/dist/components/volume-controls.vue.d.ts +7 -7
  19. package/dist/config.d.ts +151 -151
  20. package/dist/constants.d.ts +1 -1
  21. package/dist/data/characters.json +62 -62
  22. package/dist/data/config.json +182 -182
  23. package/dist/data/example.rpy +360 -360
  24. package/dist/data/refactor.rpy +30 -30
  25. package/dist/defaultConfig.d.ts +2 -2
  26. package/dist/demo/demo.d.ts +1 -1
  27. package/dist/dialog-box.vue.d.ts +37 -37
  28. package/dist/exports/config.d.ts +1 -1
  29. package/dist/exports/display.d.ts +2 -2
  30. package/dist/exports/plugins.d.ts +20 -20
  31. package/dist/fonts/OpenDyslexic.ttf.svg +2326 -2326
  32. package/dist/gameloop.d.ts +3 -3
  33. package/dist/img/.DS_Store +0 -0
  34. package/dist/lib/lib.d.ts +15 -15
  35. package/dist/main.d.ts +5 -5
  36. package/dist/music/.DS_Store +0 -0
  37. package/dist/narrat.es.js +40 -14
  38. package/dist/narrat.es.js.map +1 -1
  39. package/dist/narrat.umd.js +70 -70
  40. package/dist/narrat.umd.js.map +1 -1
  41. package/dist/plugins/NarratPlugin.d.ts +11 -11
  42. package/dist/sounds/.DS_Store +0 -0
  43. package/dist/stores/audio-store.d.ts +12 -12
  44. package/dist/stores/dialog-store.d.ts +31 -31
  45. package/dist/stores/hud-stats-store.d.ts +22 -22
  46. package/dist/stores/inventory-store.d.ts +37 -37
  47. package/dist/stores/main-store.d.ts +276 -276
  48. package/dist/stores/notification-store.d.ts +12 -12
  49. package/dist/stores/quest-log.d.ts +39 -39
  50. package/dist/stores/rendering-store.d.ts +13 -13
  51. package/dist/stores/screens-store.d.ts +23 -23
  52. package/dist/stores/skills.d.ts +36 -36
  53. package/dist/stores/vm-store.d.ts +148 -148
  54. package/dist/types/app-types.d.ts +4 -4
  55. package/dist/types/character-types.d.ts +27 -27
  56. package/dist/types/dialog-box-types.d.ts +10 -10
  57. package/dist/types/game-save.d.ts +21 -21
  58. package/dist/types/parser.d.ts +92 -92
  59. package/dist/types/state.d.ts +3 -3
  60. package/dist/utils/ajax.d.ts +1 -1
  61. package/dist/utils/audio-loader.d.ts +13 -13
  62. package/dist/utils/characters.d.ts +5 -5
  63. package/dist/utils/data-helpers.d.ts +19 -19
  64. package/dist/utils/debounce.d.ts +14 -14
  65. package/dist/utils/error-handling.d.ts +3 -3
  66. package/dist/utils/helpers.d.ts +6 -6
  67. package/dist/utils/images-loader.d.ts +6 -6
  68. package/dist/utils/logger.d.ts +11 -11
  69. package/dist/utils/object-iterators.d.ts +8 -8
  70. package/dist/utils/promises.d.ts +1 -1
  71. package/dist/utils/randomId.d.ts +1 -1
  72. package/dist/utils/save-helpers.d.ts +3 -0
  73. package/dist/utils/skillchecks.d.ts +17 -17
  74. package/dist/utils/string-helpers.d.ts +3 -3
  75. package/dist/utils/time-helpers.d.ts +2 -2
  76. package/dist/vm/commands/arithmetic-commands.d.ts +17 -17
  77. package/dist/vm/commands/audio-commands.d.ts +8 -8
  78. package/dist/vm/commands/choice.d.ts +37 -37
  79. package/dist/vm/commands/clear_dialog.d.ts +2 -2
  80. package/dist/vm/commands/command-helpers.d.ts +2 -2
  81. package/dist/vm/commands/command-plugin.d.ts +30 -30
  82. package/dist/vm/commands/flow-commands.d.ts +14 -14
  83. package/dist/vm/commands/if.d.ts +10 -10
  84. package/dist/vm/commands/index.d.ts +2 -2
  85. package/dist/vm/commands/inventory-commands.d.ts +15 -15
  86. package/dist/vm/commands/logic-command.d.ts +42 -42
  87. package/dist/vm/commands/notify.d.ts +4 -4
  88. package/dist/vm/commands/quest-commands.d.ts +30 -30
  89. package/dist/vm/commands/screen-commands.d.ts +8 -8
  90. package/dist/vm/commands/set.d.ts +6 -6
  91. package/dist/vm/commands/skill-commands.d.ts +33 -33
  92. package/dist/vm/commands/stats-commands.d.ts +12 -12
  93. package/dist/vm/commands/string-commands.d.ts +9 -9
  94. package/dist/vm/commands/text-field.d.ts +7 -7
  95. package/dist/vm/commands/text.d.ts +13 -13
  96. package/dist/vm/commands/wait.d.ts +4 -4
  97. package/dist/vm/vm-helpers.d.ts +16 -16
  98. package/dist/vm/vm-parser.d.ts +19 -19
  99. package/dist/vm/vm-parser.test.d.ts +1 -1
  100. package/dist/vm/vm.d.ts +19 -19
  101. package/package.json +79 -79
@@ -1,3 +1,3 @@
1
- export declare function startGameLoop(): void;
2
- export declare function gameLoop(): void;
3
- export declare function mouseclick(e: MouseEvent): void;
1
+ export declare function startGameLoop(): void;
2
+ export declare function gameLoop(): void;
3
+ export declare function mouseclick(e: MouseEvent): void;
Binary file
package/dist/lib/lib.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { App } from 'vue';
2
- import 'es6-promise/auto';
3
- import './/../sass/main.css';
4
- export * from '../main';
5
- export declare type Narrat = {
6
- app: App;
7
- };
8
- declare global {
9
- export interface Window {
10
- narrat: Narrat;
11
- }
12
- }
13
- export * from '../exports/plugins';
14
- export * from '../exports/display';
15
- export * from '../exports/config';
1
+ import { App } from 'vue';
2
+ import 'es6-promise/auto';
3
+ import './/../sass/main.css';
4
+ export * from '../main';
5
+ export declare type Narrat = {
6
+ app: App;
7
+ };
8
+ declare global {
9
+ export interface Window {
10
+ narrat: Narrat;
11
+ }
12
+ }
13
+ export * from '../exports/plugins';
14
+ export * from '../exports/display';
15
+ export * from '../exports/config';
package/dist/main.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import "es6-promise/auto";
2
- import ".//sass/main.css";
3
- import { GameConfig } from "./types/app-types";
4
- import { AppOptions } from "./config";
5
- export declare function startApp(config: GameConfig, options: AppOptions): Promise<void>;
1
+ import "es6-promise/auto";
2
+ import ".//sass/main.css";
3
+ import { GameConfig } from "./types/app-types";
4
+ import { AppOptions } from "./config";
5
+ export declare function startApp(config: GameConfig, options: AppOptions): Promise<void>;
Binary file
package/dist/narrat.es.js CHANGED
@@ -34291,7 +34291,6 @@ ws.exports.parseJSONPointer;
34291
34291
  ws.exports.revertJSONPatch;
34292
34292
  ws.exports.setIn;
34293
34293
  ws.exports.updateIn;
34294
- const SAVE_FILE = "gameSave";
34295
34294
  const defaultConfig = {
34296
34295
  gameTitle: "Narrat Game Example",
34297
34296
  images: {
@@ -36696,8 +36695,9 @@ const useAudio = defineStore("audio", {
36696
36695
  actions: {
36697
36696
  stopMusic() {
36698
36697
  if (this.currentMusic) {
36699
- stopAudio(this.currentMusic);
36698
+ const music = this.currentMusic;
36700
36699
  this.currentMusic = void 0;
36700
+ stopAudio(music);
36701
36701
  }
36702
36702
  },
36703
36703
  setMusic(music, soundId) {
@@ -36780,16 +36780,24 @@ async function changeMusic(newMusic) {
36780
36780
  }, audioOptions.musicFadeOutTime * 1e3);
36781
36781
  }
36782
36782
  }
36783
+ let sound;
36784
+ let newId;
36785
+ if (newMusic) {
36786
+ sound = getAudio(newMusic);
36787
+ if (!sound) {
36788
+ throw new Error(`Could not find music ${newMusic}`);
36789
+ }
36790
+ sound.volume(0);
36791
+ newId = sound.play();
36792
+ sound.pause();
36793
+ audio2.setMusic(newMusic, newId);
36794
+ }
36783
36795
  if (audio2.currentMusic) {
36784
36796
  await timeout(audioOptions.musicFadeInDelay * 1e3);
36785
36797
  }
36786
- if (newMusic) {
36787
- const sound = getAudio(newMusic);
36788
- if (sound) {
36789
- const newId = sound.play();
36790
- sound.fade(0, 1, audioOptions.musicFadeInTime * 1e3, newId);
36791
- audio2.setMusic(newMusic, newId);
36792
- }
36798
+ if (sound && useAudio().musicHowlId === newId) {
36799
+ sound.play();
36800
+ sound.fade(0, 1, audioOptions.musicFadeInTime * 1e3, newId);
36793
36801
  }
36794
36802
  }
36795
36803
  function playAudio(key) {
@@ -36805,9 +36813,13 @@ function getAudio(key) {
36805
36813
  return audio[key];
36806
36814
  }
36807
36815
  function stopAudio(key) {
36808
- const sound = getAudio(key);
36809
- if (sound) {
36810
- sound.stop();
36816
+ if (key === useAudio().currentMusic) {
36817
+ useAudio().stopMusic();
36818
+ } else {
36819
+ const sound = getAudio(key);
36820
+ if (sound) {
36821
+ sound.stop();
36822
+ }
36811
36823
  }
36812
36824
  }
36813
36825
  function pauseAudio(key) {
@@ -36816,6 +36828,10 @@ function pauseAudio(key) {
36816
36828
  sound.pause();
36817
36829
  }
36818
36830
  }
36831
+ const SAVE_FILE = "gameSave";
36832
+ function saveGame(object) {
36833
+ localStorage.setItem(SAVE_FILE, JSON.stringify(object));
36834
+ }
36819
36835
  function randomId() {
36820
36836
  return `${Date.now() - Math.floor(Math.random() * 99999999)}`;
36821
36837
  }
@@ -38327,7 +38343,7 @@ const useMain = defineStore("main", {
38327
38343
  inventory: inventoryStore.generateSaveData(),
38328
38344
  quests: useQuests().generateSaveData()
38329
38345
  };
38330
- localStorage.setItem(SAVE_FILE, JSON.stringify(save));
38346
+ saveGame(save);
38331
38347
  },
38332
38348
  setLoadedData(save) {
38333
38349
  const screensStore = useScreens();
@@ -40790,7 +40806,7 @@ const stopCommand = new CommandPlugin("stop", playCommandArgs, async (cmd) => {
40790
40806
  if (stopOptions.mode === "music") {
40791
40807
  const audioStore = useAudio();
40792
40808
  if (audioStore.currentMusic) {
40793
- stopAudio(audioStore.currentMusic);
40809
+ useAudio().stopMusic();
40794
40810
  }
40795
40811
  } else if (stopOptions.mode === "sound" && stopOptions.audio) {
40796
40812
  stopAudio(stopOptions.audio);
@@ -41237,8 +41253,10 @@ choicePlugin.onPlayerAnswered = async (command, playerChoice) => {
41237
41253
  const { choices } = command.staticOptions;
41238
41254
  const choice = choices[choiceIndex];
41239
41255
  const choicePromptResult = command.options.choiceResults[choiceIndex];
41256
+ let playerText = choicePromptResult.text;
41240
41257
  let newBranch;
41241
41258
  if (choicePromptResult.skillCheck) {
41259
+ playerText = null;
41242
41260
  const result = runSkillCheck({
41243
41261
  skill: choicePromptResult.skillCheck.skillId,
41244
41262
  value: choicePromptResult.skillCheck.difficulty,
@@ -41253,6 +41271,14 @@ choicePlugin.onPlayerAnswered = async (command, playerChoice) => {
41253
41271
  } else {
41254
41272
  newBranch = choice.branch;
41255
41273
  }
41274
+ if (playerText) {
41275
+ const dialog = {
41276
+ speaker: "player",
41277
+ text: playerText,
41278
+ interactive: false
41279
+ };
41280
+ useDialogStore().addDialog(dialog);
41281
+ }
41256
41282
  if (newBranch) {
41257
41283
  const newStack = {
41258
41284
  currentIndex: 0,