tpmkms 7.12.4-beta.2 → 7.12.4-beta.3

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.
@@ -30,6 +30,8 @@ const fastfood_instance = require('./fastfood.instance.json')
30
30
  double hamburger
31
31
  number 1 and 2
32
32
  number 1 2 and 3
33
+ combo 1 through 5
34
+
33
35
  */
34
36
 
35
37
  const template = {
@@ -348,6 +350,18 @@ const template = {
348
350
  {
349
351
  where: where(),
350
352
  oneShot: false,
353
+ onNevermind: ({verbatim, ...args}) => {
354
+ // this is cross km boundaries from the dialogues km to this one so the api if for dialogs.
355
+ // i need to get the one for fastfood here.
356
+ const api = args.kms.fastfood.api
357
+ const needsDrink = askAbout({ args, api })
358
+ if (needsDrink.length > 1) {
359
+ verbatim("The drinks must be specified")
360
+ } else {
361
+ verbatim("The drink must be specified")
362
+ }
363
+ return false
364
+ },
351
365
  matchq: (args) => askAbout(args).length > 0 && args.context.marker == 'controlEnd',
352
366
  applyq: (args) => {
353
367
  args.context.cascade = true
@@ -693,6 +707,27 @@ class API {
693
707
  }
694
708
  return map[number]
695
709
  }
710
+
711
+ canBeCombo(id) {
712
+ return this.getComboNumber(id) > 0
713
+ }
714
+
715
+ getComboNumber(id) {
716
+ const combos = [
717
+ 'single',
718
+ 'double',
719
+ 'triple',
720
+ 'baconator',
721
+ 'bacon_deluxe',
722
+ 'spicy',
723
+ 'homestyle',
724
+ 'asiago_range_chicken_club',
725
+ 'ultimate_chicken_grill',
726
+ 'chicken_nugget',
727
+ 'premium_cod',
728
+ ]
729
+ return combos.findIndex((e) => e == id) + 1
730
+ }
696
731
  }
697
732
 
698
733
  const api = new API()
@@ -813,7 +848,66 @@ class State {
813
848
  for (let i = 0; i < quantity; ++i) {
814
849
  const item = addSize(food, { id, combo, modifications, pieces, food })
815
850
  if (!this.api.isAvailable(item)) {
816
- this.api.addAskedForButNotAvailable(food)
851
+ const available = []
852
+ for (const descendant of this.api.args.hierarchy.descendants(food.marker)) {
853
+ if (this.api.isAvailable({ id: descendant })) {
854
+ available.push(descendant)
855
+ }
856
+ }
857
+
858
+ // this sentence runs but it doesnt setup the hierarchy: 'combo 1, 2, 3, 4, 5, 6, 7, 9, 10, and 11 are combos'
859
+ // i made a wrong design choice when i setup the phrase 'combo 1 etc'. I should have mapped that to the 'single_combo'
860
+ // but instead had it be a combo with a comboNumber property. That means the language layer doesnt know about the mapping
861
+ // so that phrase doesnt work. if I set it up the other way that phrase would work. This is just a demo and I have other
862
+ // demoes to write so i am not fixin that and instead will do || is a combo
863
+
864
+ if (available.length > 0 || food.marker == 'combo') {
865
+ this.api.args.ask([
866
+ {
867
+ where: where(),
868
+ oneShot: true,
869
+ matchq: ({context}) => context.marker == 'controlEnd',
870
+ applyq: () => {
871
+ // args.context.cascade = true
872
+ const word = food.word
873
+ return `What kind of ${word}?`
874
+ },
875
+ semanticsr: [
876
+ // stuipid hack one because i didnt put combo fully into the NLI layer
877
+ {
878
+ where: where(),
879
+ match: ({context, callId, isA, api}) => {
880
+ return api.canBeCombo(context.marker)
881
+ },
882
+ apply: ({context}) => {
883
+ const comboNumber = {
884
+ value: api.getComboNumber(context.marker)
885
+ }
886
+ food.comboNumber = comboNumber
887
+ this.add(food)
888
+ }
889
+ },
890
+ {
891
+ where: where(),
892
+ match: ({context, isA}) => isA(context.marker, food.marker),
893
+ apply: ({context}) => {
894
+ this.add(Object.assign(food, context))
895
+ }
896
+ },
897
+ {
898
+ where: where(),
899
+ match: ({context, isA}) => isA(context.marker, `${food.marker}_modifier`),
900
+ apply: ({context}) => {
901
+ const value = `${context.value}_${food.value}`
902
+ this.add(Object.assign(food, { value }))
903
+ }
904
+ },
905
+ ]
906
+ },
907
+ ])
908
+ } else {
909
+ this.api.addAskedForButNotAvailable(food)
910
+ }
817
911
  return
818
912
  }
819
913