narrat 0.7.1 → 0.8.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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Narrat changelog
2
2
 
3
+ ## 0.7.2
4
+
5
+ - Changed the `set` method to access things without caps (`data`, `skills`, `buttons` instead of `DATA`, `SKILLS`, `BUTTONS`) for consistency.
6
+ - Changed string interpolation to have more accessible objects, now values in `data` need to be access with `%{data.something}` instead of just `%{something}`
7
+ - Now possible to access skill levels in string interpolation with `%{skills.someSkill.level}`
8
+ - Improvements to how skill checks are printed to be less awkward
9
+
3
10
  ## 0.7.1
4
11
 
5
12
  - Added `stop` and `pause` functions which work similarly to play for stopping or pausing audio.
package/lib/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version: 0.7.1 - April 26, 2022 12:31:17
1
+ // Version: 0.8.0 - April 26, 2022 13:18:38
2
2
  import 'es6-promise/auto';
3
3
  import { ref, reactive, readonly, defineComponent, openBlock, createElementBlock, normalizeStyle, createElementVNode, createCommentVNode, Fragment, renderList, createBlock, Transition, withCtx, renderSlot, createTextVNode, resolveComponent, toDisplayString, createVNode, TransitionGroup, createApp } from 'vue';
4
4
  import { createLogger, createStore } from 'vuex';
@@ -4079,16 +4079,20 @@ function addDataHelper(sourceObj, path, value) {
4079
4079
  }
4080
4080
  function getModifiableData(state) {
4081
4081
  return {
4082
- DATA: state.machine.data,
4083
- SKILLS: state.skills,
4084
- BUTTONS: state.buttons,
4082
+ data: state.machine.data,
4083
+ skills: state.skills,
4084
+ buttons: state.buttons,
4085
4085
  };
4086
4086
  }
4087
4087
 
4088
4088
  function processText(store, text) {
4089
4089
  return text.replace(/%{[^}]*}/g, (match) => {
4090
4090
  const key = match.substr(2, match.length - 3);
4091
- const [obj, newKey] = findDataHelper(store.state.machine.data, key);
4091
+ const searchableState = {
4092
+ data: store.state.machine.data,
4093
+ skills: store.state.skills,
4094
+ };
4095
+ const [obj, newKey] = findDataHelper(searchableState, key);
4092
4096
  return obj[newKey];
4093
4097
  });
4094
4098
  }
@@ -4716,6 +4720,8 @@ function processSkillCheck(ctx, skillcheck) {
4716
4720
  skill: skillcheck.skill,
4717
4721
  value: skillcheck.value,
4718
4722
  id: skillcheck.id,
4723
+ success: skillcheck.success.text,
4724
+ failure: skillcheck.failure.text,
4719
4725
  });
4720
4726
  }
4721
4727
  function runSkillCheck(ctx, params) {
@@ -4734,11 +4740,11 @@ function runSkillCheck(ctx, params) {
4734
4740
  }
4735
4741
  if (success) {
4736
4742
  ctx.commit('passSkillCheck', params.id);
4737
- writeText(ctx, `[${skill.name} - Success]`);
4743
+ writeText(ctx, `[${skill.name} - Success] ${params.success || ''}`);
4738
4744
  return true;
4739
4745
  }
4740
4746
  ctx.commit('failSkillCheck', params.id);
4741
- writeText(ctx, `[${skill.name} - Failure]`);
4747
+ writeText(ctx, `[${skill.name} - Failure] ${params.failure || ''}`);
4742
4748
  return false;
4743
4749
  }
4744
4750
  function runConditionCommand(ctx, command) {
@@ -4979,18 +4985,21 @@ async function playerAnswered(context, choiceIndex) {
4979
4985
  const result = processSkillCheck(context, skillcheck);
4980
4986
  const winner = result ? skillcheck.success : skillcheck.failure;
4981
4987
  newBranch = winner.branch;
4982
- playerText = `[${result ? 'SUCCESS' : 'FAILURE'}] – ${winner.text}`;
4988
+ playerText = undefined;
4983
4989
  }
4984
4990
  }
4985
4991
  else {
4986
4992
  newBranch = choice.branch;
4987
4993
  }
4988
- const dialog = {
4989
- speaker: 'player',
4990
- text: playerText,
4991
- interactive: false,
4992
- };
4993
- commit('addDialog', { dialog });
4994
+ if (playerText) {
4995
+ // If the choice involves printing a player dialog, show it
4996
+ const dialog = {
4997
+ speaker: 'player',
4998
+ text: playerText,
4999
+ interactive: false,
5000
+ };
5001
+ commit('addDialog', { dialog });
5002
+ }
4994
5003
  if (newBranch) {
4995
5004
  const newStack = {
4996
5005
  currentIndex: 0,
@@ -5802,7 +5811,7 @@ async function startApp(config, options) {
5802
5811
  mousePos.x = e.clientX;
5803
5812
  mousePos.y = e.clientY;
5804
5813
  });
5805
- console.log('%c Narrat game engine – 0.7.1 - April 26, 2022 12:31:17', 'background: #222; color: #bada55');
5814
+ console.log('%c Narrat game engine – 0.8.0 - April 26, 2022 13:18:38', 'background: #222; color: #bada55');
5806
5815
  const storeSetup = setupStore(options);
5807
5816
  store$1 = storeSetup.store;
5808
5817
  app = createApp(script$8, {
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version: 0.7.1 - April 26, 2022 12:31:17
1
+ // Version: 0.8.0 - April 26, 2022 13:18:38
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -4083,16 +4083,20 @@ function addDataHelper(sourceObj, path, value) {
4083
4083
  }
4084
4084
  function getModifiableData(state) {
4085
4085
  return {
4086
- DATA: state.machine.data,
4087
- SKILLS: state.skills,
4088
- BUTTONS: state.buttons,
4086
+ data: state.machine.data,
4087
+ skills: state.skills,
4088
+ buttons: state.buttons,
4089
4089
  };
4090
4090
  }
4091
4091
 
4092
4092
  function processText(store, text) {
4093
4093
  return text.replace(/%{[^}]*}/g, (match) => {
4094
4094
  const key = match.substr(2, match.length - 3);
4095
- const [obj, newKey] = findDataHelper(store.state.machine.data, key);
4095
+ const searchableState = {
4096
+ data: store.state.machine.data,
4097
+ skills: store.state.skills,
4098
+ };
4099
+ const [obj, newKey] = findDataHelper(searchableState, key);
4096
4100
  return obj[newKey];
4097
4101
  });
4098
4102
  }
@@ -4720,6 +4724,8 @@ function processSkillCheck(ctx, skillcheck) {
4720
4724
  skill: skillcheck.skill,
4721
4725
  value: skillcheck.value,
4722
4726
  id: skillcheck.id,
4727
+ success: skillcheck.success.text,
4728
+ failure: skillcheck.failure.text,
4723
4729
  });
4724
4730
  }
4725
4731
  function runSkillCheck(ctx, params) {
@@ -4738,11 +4744,11 @@ function runSkillCheck(ctx, params) {
4738
4744
  }
4739
4745
  if (success) {
4740
4746
  ctx.commit('passSkillCheck', params.id);
4741
- writeText(ctx, `[${skill.name} - Success]`);
4747
+ writeText(ctx, `[${skill.name} - Success] ${params.success || ''}`);
4742
4748
  return true;
4743
4749
  }
4744
4750
  ctx.commit('failSkillCheck', params.id);
4745
- writeText(ctx, `[${skill.name} - Failure]`);
4751
+ writeText(ctx, `[${skill.name} - Failure] ${params.failure || ''}`);
4746
4752
  return false;
4747
4753
  }
4748
4754
  function runConditionCommand(ctx, command) {
@@ -4983,18 +4989,21 @@ async function playerAnswered(context, choiceIndex) {
4983
4989
  const result = processSkillCheck(context, skillcheck);
4984
4990
  const winner = result ? skillcheck.success : skillcheck.failure;
4985
4991
  newBranch = winner.branch;
4986
- playerText = `[${result ? 'SUCCESS' : 'FAILURE'}] – ${winner.text}`;
4992
+ playerText = undefined;
4987
4993
  }
4988
4994
  }
4989
4995
  else {
4990
4996
  newBranch = choice.branch;
4991
4997
  }
4992
- const dialog = {
4993
- speaker: 'player',
4994
- text: playerText,
4995
- interactive: false,
4996
- };
4997
- commit('addDialog', { dialog });
4998
+ if (playerText) {
4999
+ // If the choice involves printing a player dialog, show it
5000
+ const dialog = {
5001
+ speaker: 'player',
5002
+ text: playerText,
5003
+ interactive: false,
5004
+ };
5005
+ commit('addDialog', { dialog });
5006
+ }
4998
5007
  if (newBranch) {
4999
5008
  const newStack = {
5000
5009
  currentIndex: 0,
@@ -5806,7 +5815,7 @@ async function startApp(config, options) {
5806
5815
  mousePos.x = e.clientX;
5807
5816
  mousePos.y = e.clientY;
5808
5817
  });
5809
- console.log('%c Narrat game engine – 0.7.1 - April 26, 2022 12:31:17', 'background: #222; color: #bada55');
5818
+ console.log('%c Narrat game engine – 0.8.0 - April 26, 2022 13:18:38', 'background: #222; color: #bada55');
5810
5819
  const storeSetup = setupStore(options);
5811
5820
  store$1 = storeSetup.store;
5812
5821
  app = vue.createApp(script$8, {
@@ -5,6 +5,8 @@ export interface SkillCheckParams {
5
5
  skill: string;
6
6
  value: number;
7
7
  id: string;
8
+ success?: string;
9
+ failure?: string;
8
10
  }
9
11
  export declare function runSkillCheck(ctx: ActionContext<State, State>, params: SkillCheckParams): boolean;
10
12
  export declare function runConditionCommand(ctx: ActionContext<State, State>, command: Parser.Command): Parser.Branch | undefined;
@@ -3,7 +3,7 @@ export declare function findDataHelper<T>(sourceObj: any, path: string): [T, str
3
3
  export declare function setDataHelper<T>(sourceObj: any, path: string, value: T): void;
4
4
  export declare function addDataHelper<T>(sourceObj: any, path: string, value: T): void;
5
5
  export declare function getModifiableData(state: State): {
6
- DATA: import("../types/vuex").DataState;
7
- SKILLS: import("../types/vuex").SkillsState;
8
- BUTTONS: import("vue").ButtonsState;
6
+ data: import("../types/vuex").DataState;
7
+ skills: import("../types/vuex").SkillsState;
8
+ buttons: import("vue").ButtonsState;
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "narrat",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "narrat narrative engine",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",