libram 0.11.8 → 0.11.10

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.
@@ -70,10 +70,76 @@ describe(Macro, () => {
70
70
  const mock = $item `mock item`;
71
71
  expect(Macro.item(mock).toString()).toEqual(`use ${mock.name};`);
72
72
  });
73
+ it("item pair", () => {
74
+ const mock = $item `mock item`;
75
+ expect(Macro.item([mock, mock]).toString()).toEqual(`use ${mock.name}, ${mock.name};`);
76
+ });
77
+ it("item pair + single", () => {
78
+ const mock = $item `mock item`;
79
+ expect(Macro.item([mock, mock], mock).toString()).toEqual(`${Macro.item([mock, mock]).toString()}${Macro.item(mock).toString()}`);
80
+ });
81
+ it("item pair + pair", () => {
82
+ const mock = $item `mock item`;
83
+ expect(Macro.item([mock, mock], [mock, mock]).toString()).toEqual(`use ${mock.name}, ${mock.name};use ${mock.name}, ${mock.name};`);
84
+ });
73
85
  it("tryItem", () => {
74
86
  const mock = $item `mock item`;
75
87
  expect(Macro.tryItem(mock).toString()).toEqual(`if hascombatitem mock item;use ${mock.name};endif;`);
76
88
  });
89
+ it("tryItem same pair", () => {
90
+ const mock = $item `mock item`;
91
+ expect(Macro.tryItem([mock, mock]).toString()).toEqual(`if hastwocombatitems mock item;use mock item, mock item;endif;`);
92
+ });
93
+ it("tryItem different pair", () => {
94
+ const mock1 = $item `mock item`;
95
+ const mock2 = $item `mock item two`;
96
+ expect(Macro.tryItem([mock1, mock2]).toString()).toEqual(`if hascombatitem mock item && hascombatitem mock item two;use mock item, mock item two;endif;`);
97
+ });
98
+ it("tryItem same pair + single", () => {
99
+ const mock = $item `mock item`;
100
+ expect(Macro.tryItem([mock, mock], mock).toString()).toEqual(`${Macro.tryItem([mock, mock]).toString()}${Macro.tryItem(mock).toString()}`);
101
+ });
102
+ it("tryItem different pair + single", () => {
103
+ const mock1 = $item `mock item`;
104
+ const mock2 = $item `mock item two`;
105
+ expect(Macro.tryItem([mock1, mock2], mock1).toString()).toEqual(`${Macro.tryItem([mock1, mock2]).toString()}${Macro.tryItem(mock1).toString()}`);
106
+ });
107
+ it("funkslingItem same items", () => {
108
+ const mock = $item `mock item`;
109
+ expect(Macro.funkslingItem(mock, mock).toString()).toEqual(Macro.item([mock, mock]).toString());
110
+ });
111
+ it("funkslingItem different items", () => {
112
+ const mock1 = $item `mock item`;
113
+ const mock2 = $item `mock item two`;
114
+ expect(Macro.funkslingItem(mock1, mock2).toString()).toEqual(Macro.item([mock1, mock2]).toString());
115
+ });
116
+ it("funklingItem same pair + single", () => {
117
+ const mock = $item `mock item`;
118
+ expect(Macro.funkslingItem(mock, mock, mock).toString()).toEqual(Macro.item([mock, mock], mock).toString());
119
+ });
120
+ it("funklingItem different pair + single", () => {
121
+ const mock1 = $item `mock item`;
122
+ const mock2 = $item `mock item two`;
123
+ expect(Macro.funkslingItem(mock1, mock2, mock1).toString()).toEqual(Macro.item([mock1, mock2], mock1).toString());
124
+ });
125
+ it("tryFunklingItem same", () => {
126
+ const mock = $item `mock item`;
127
+ expect(Macro.tryFunkslingItem(mock, mock).toString()).toEqual(Macro.tryItem([mock, mock]).toString());
128
+ });
129
+ it("tryFunklingItem different", () => {
130
+ const mock1 = $item `mock item`;
131
+ const mock2 = $item `mock item two`;
132
+ expect(Macro.tryFunkslingItem(mock1, mock2).toString()).toEqual(Macro.tryItem([mock1, mock2]).toString());
133
+ });
134
+ it("tryFunklingItem same pair + single", () => {
135
+ const mock = $item `mock item`;
136
+ expect(Macro.tryFunkslingItem(mock, mock, mock).toString()).toEqual(Macro.tryItem([mock, mock], mock).toString());
137
+ });
138
+ it("tryFunklingItem different pair + single", () => {
139
+ const mock1 = $item `mock item`;
140
+ const mock2 = $item `mock item two`;
141
+ expect(Macro.tryFunkslingItem(mock1, mock2, mock1).toString()).toEqual(Macro.tryItem([mock1, mock2], mock1).toString());
142
+ });
77
143
  it("attack", () => {
78
144
  expect(Macro.attack().toString()).toEqual(`attack;`);
79
145
  });
@@ -105,6 +171,15 @@ describe(Macro.makeBALLSPredicate, () => {
105
171
  const mock = $item `mock combat item`;
106
172
  expect(Macro.makeBALLSPredicate(mock)).toEqual(`hascombatitem ${mock.name}`);
107
173
  });
174
+ it("Item Pair Same", () => {
175
+ const mock = $item `mock combat item`;
176
+ expect(Macro.makeBALLSPredicate([mock, mock])).toEqual(`hastwocombatitems ${mock.name}`);
177
+ });
178
+ it("Item Pair Different", () => {
179
+ const mock1 = $item `mock combat item`;
180
+ const mock2 = $item `mock combat item two`;
181
+ expect(Macro.makeBALLSPredicate([mock1, mock2])).toEqual(`hascombatitem ${mock1.name} && hascombatitem ${mock2.name}`);
182
+ });
108
183
  it("Item Overlapping", () => {
109
184
  const mock = $item `spider web`;
110
185
  expect(Macro.makeBALLSPredicate(mock)).toEqual(`hascombatitem ${mock.id}`);
package/dist/combat.d.ts CHANGED
@@ -283,6 +283,40 @@ export declare class Macro {
283
283
  * @returns {Macro} This object itself.
284
284
  */
285
285
  static tryItem<T extends Macro>(this: Constructor<T>, ...items: (ItemOrName | [ItemOrName, ItemOrName])[]): T;
286
+ /**
287
+ * Add one or more item steps to the macro, and automatically attempting to funksling as many of the items as possible.
288
+ * This function does not check if you can funksling or not.
289
+ *
290
+ * @param items Items to use.
291
+ * @returns {Macro} This object itself.
292
+ */
293
+ funkslingItem(...items: ItemOrName[]): this;
294
+ /**
295
+ * Create a new macro with one or more item steps, and automatically attempting to funksling as many of the items as possible.
296
+ * This function does not check if you can funksling or not.
297
+ *
298
+ * @param items Items to use.
299
+ * @returns {Macro} This object itself.
300
+ */
301
+ static funkslingItem<T extends Macro>(this: Constructor<T>, ...items: ItemOrName[]): T;
302
+ /**
303
+ * Add one or more item steps to the macro, where each step checks to see if you have the item first,
304
+ * and automatically attempting to funksling as many of the items as possible.
305
+ * This function does not check if you can funksling or not.
306
+ *
307
+ * @param items Items to use.
308
+ * @returns {Macro} This object itself.
309
+ */
310
+ tryFunkslingItem(...items: ItemOrName[]): this;
311
+ /**
312
+ * Create a new macro with one or more item steps, where each step checks to see if you have the item first,
313
+ * and automatically attempting to funksling as many of the items as possible.
314
+ * This function does not check if you can funksling or not.
315
+ *
316
+ * @param items Items to use.
317
+ * @returns {Macro} This object itself.
318
+ */
319
+ static tryFunkslingItem<T extends Macro>(this: Constructor<T>, ...items: ItemOrName[]): T;
286
320
  /**
287
321
  * Add an attack step to the macro.
288
322
  *
@@ -402,6 +436,40 @@ export declare class StrictMacro extends Macro {
402
436
  * @returns {StrictMacro} This object itself.
403
437
  */
404
438
  static tryItem<T extends StrictMacro>(this: Constructor<T>, ...items: (Item | [Item, Item])[]): T;
439
+ /**
440
+ * Add one or more item steps to the macro, and automatically attempting to funksling as many of the items as possible.
441
+ * This function does not check if you can funksling or not.
442
+ *
443
+ * @param items Items to use.
444
+ * @returns {StrictMacro} This object itself.
445
+ */
446
+ funkslingItem(...items: Item[]): this;
447
+ /**
448
+ * Create a new macro with one or more item steps, and automatically attempting to funksling as many of the items as possible.
449
+ * This function does not check if you can funksling or not.
450
+ *
451
+ * @param items Items to use.
452
+ * @returns {StrictMacro} This object itself.
453
+ */
454
+ static funkslingItem<T extends StrictMacro>(this: Constructor<T>, ...items: Item[]): T;
455
+ /**
456
+ * Add one or more item steps to the macro, where each step checks to see if you have the item first,
457
+ * and automatically attempting to funksling as many of the items as possible.
458
+ * This function does not check if you can funksling or not.
459
+ *
460
+ * @param items Items to use.
461
+ * @returns {StrictMacro} This object itself.
462
+ */
463
+ tryFunkslingItem(...items: Item[]): this;
464
+ /**
465
+ * Create a new macro with one or more item steps, where each step checks to see if you have the item first,
466
+ * and automatically attempting to funksling as many of the items as possible.
467
+ * This function does not check if you can funksling or not.
468
+ *
469
+ * @param items Items to use.
470
+ * @returns {StrictMacro} This object itself.
471
+ */
472
+ static tryFunkslingItem<T extends StrictMacro>(this: Constructor<T>, ...items: Item[]): T;
405
473
  /**
406
474
  * Add one or more skill-cast-and-repeat steps to the macro, where each step checks if you have the skill first.
407
475
  *
package/dist/combat.js CHANGED
@@ -98,6 +98,19 @@ function skillBallsMacroName(skillOrName) {
98
98
  ? skill.name
99
99
  : skill.id;
100
100
  }
101
+ /**
102
+ * Reduces a list of items into pairs to funksling.
103
+ *
104
+ * @param items - The items to be reduced.
105
+ * @returns The reduced list of items or item pairs.
106
+ */
107
+ function funkslingReduce(...items) {
108
+ return items.reduce((acc, item, i, arr) => i % 2 === 0
109
+ ? acc.concat(i + 1 < arr.length
110
+ ? [[item, arr[i + 1]]]
111
+ : [item])
112
+ : acc, []);
113
+ }
101
114
  export class InvalidMacroError extends Error {
102
115
  }
103
116
  /**
@@ -537,6 +550,48 @@ export class Macro {
537
550
  static tryItem(...items) {
538
551
  return new this().tryItem(...items);
539
552
  }
553
+ /**
554
+ * Add one or more item steps to the macro, and automatically attempting to funksling as many of the items as possible.
555
+ * This function does not check if you can funksling or not.
556
+ *
557
+ * @param items Items to use.
558
+ * @returns {Macro} This object itself.
559
+ */
560
+ funkslingItem(...items) {
561
+ return this.item(...funkslingReduce(...items));
562
+ }
563
+ /**
564
+ * Create a new macro with one or more item steps, and automatically attempting to funksling as many of the items as possible.
565
+ * This function does not check if you can funksling or not.
566
+ *
567
+ * @param items Items to use.
568
+ * @returns {Macro} This object itself.
569
+ */
570
+ static funkslingItem(...items) {
571
+ return new this().funkslingItem(...items);
572
+ }
573
+ /**
574
+ * Add one or more item steps to the macro, where each step checks to see if you have the item first,
575
+ * and automatically attempting to funksling as many of the items as possible.
576
+ * This function does not check if you can funksling or not.
577
+ *
578
+ * @param items Items to use.
579
+ * @returns {Macro} This object itself.
580
+ */
581
+ tryFunkslingItem(...items) {
582
+ return this.tryItem(...funkslingReduce(...items));
583
+ }
584
+ /**
585
+ * Create a new macro with one or more item steps, where each step checks to see if you have the item first,
586
+ * and automatically attempting to funksling as many of the items as possible.
587
+ * This function does not check if you can funksling or not.
588
+ *
589
+ * @param items Items to use.
590
+ * @returns {Macro} This object itself.
591
+ */
592
+ static tryFunkslingItem(...items) {
593
+ return new this().tryFunkslingItem(...items);
594
+ }
540
595
  /**
541
596
  * Add an attack step to the macro.
542
597
  *
@@ -717,6 +772,48 @@ export class StrictMacro extends Macro {
717
772
  static tryItem(...items) {
718
773
  return new this().tryItem(...items);
719
774
  }
775
+ /**
776
+ * Add one or more item steps to the macro, and automatically attempting to funksling as many of the items as possible.
777
+ * This function does not check if you can funksling or not.
778
+ *
779
+ * @param items Items to use.
780
+ * @returns {StrictMacro} This object itself.
781
+ */
782
+ funkslingItem(...items) {
783
+ return super.funkslingItem(...items);
784
+ }
785
+ /**
786
+ * Create a new macro with one or more item steps, and automatically attempting to funksling as many of the items as possible.
787
+ * This function does not check if you can funksling or not.
788
+ *
789
+ * @param items Items to use.
790
+ * @returns {StrictMacro} This object itself.
791
+ */
792
+ static funkslingItem(...items) {
793
+ return new this().funkslingItem(...items);
794
+ }
795
+ /**
796
+ * Add one or more item steps to the macro, where each step checks to see if you have the item first,
797
+ * and automatically attempting to funksling as many of the items as possible.
798
+ * This function does not check if you can funksling or not.
799
+ *
800
+ * @param items Items to use.
801
+ * @returns {StrictMacro} This object itself.
802
+ */
803
+ tryFunkslingItem(...items) {
804
+ return super.tryFunkslingItem(...items);
805
+ }
806
+ /**
807
+ * Create a new macro with one or more item steps, where each step checks to see if you have the item first,
808
+ * and automatically attempting to funksling as many of the items as possible.
809
+ * This function does not check if you can funksling or not.
810
+ *
811
+ * @param items Items to use.
812
+ * @returns {StrictMacro} This object itself.
813
+ */
814
+ static tryFunkslingItem(...items) {
815
+ return new this().tryFunkslingItem(...items);
816
+ }
720
817
  /**
721
818
  * Add one or more skill-cast-and-repeat steps to the macro, where each step checks if you have the skill first.
722
819
  *
@@ -22,6 +22,7 @@ export const overlappingItemNames = [
22
22
  "spoon",
23
23
  ];
24
24
  export const overlappingSkillNames = [
25
+ "Lightning Bolt",
25
26
  "Shoot",
26
27
  "Thrust-Smack",
27
28
  "Headbutt",
@@ -41,4 +42,5 @@ export const overlappingSkillNames = [
41
42
  "Boil",
42
43
  "Slice",
43
44
  "Rainbow",
45
+ "Lightning Bolt",
44
46
  ];