libram 0.3.2 → 0.4.2

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 (99) hide show
  1. package/dist/Clan.js +268 -485
  2. package/dist/Copier.js +11 -48
  3. package/dist/Dungeon.js +77 -157
  4. package/dist/Kmail.d.ts +13 -7
  5. package/dist/Kmail.js +92 -233
  6. package/dist/Path.js +68 -120
  7. package/dist/ascend.js +153 -172
  8. package/dist/combat.d.ts +86 -1
  9. package/dist/combat.js +295 -387
  10. package/dist/console.js +13 -36
  11. package/dist/diet/index.d.ts +31 -0
  12. package/dist/diet/index.js +333 -0
  13. package/dist/diet/knapsack.d.ts +7 -0
  14. package/dist/diet/knapsack.js +106 -0
  15. package/dist/dungeons/Dreadsylvania.d.ts +4 -0
  16. package/dist/dungeons/Dreadsylvania.js +14 -0
  17. package/dist/dungeons/Dungeon.d.ts +28 -0
  18. package/dist/dungeons/Dungeon.js +99 -0
  19. package/dist/dungeons/Hobopolis.d.ts +4 -0
  20. package/dist/dungeons/Hobopolis.js +14 -0
  21. package/dist/dungeons/SlimeTube.d.ts +4 -0
  22. package/dist/dungeons/SlimeTube.js +14 -0
  23. package/dist/freerun.d.ts +23 -0
  24. package/dist/freerun.js +92 -0
  25. package/dist/index.d.ts +6 -1
  26. package/dist/index.js +21 -263
  27. package/dist/lib.d.ts +43 -0
  28. package/dist/lib.js +296 -405
  29. package/dist/logger.js +23 -63
  30. package/dist/maximize.d.ts +29 -12
  31. package/dist/maximize.js +318 -421
  32. package/dist/modifier.d.ts +13 -0
  33. package/dist/modifier.js +35 -0
  34. package/dist/modifierTypes.d.ts +16 -0
  35. package/dist/modifierTypes.js +9 -0
  36. package/dist/mood.js +220 -531
  37. package/dist/property.d.ts +2 -0
  38. package/dist/property.js +96 -242
  39. package/dist/propertyTypes.d.ts +9 -0
  40. package/dist/propertyTypes.js +1 -0
  41. package/dist/propertyTyping.d.ts +2 -9
  42. package/dist/propertyTyping.js +42 -53
  43. package/dist/resources/2007/CandyHearts.d.ts +9 -0
  44. package/dist/resources/2007/CandyHearts.js +24 -0
  45. package/dist/resources/2008/DivineFavors.d.ts +9 -0
  46. package/dist/resources/2008/DivineFavors.js +27 -0
  47. package/dist/resources/2009/Bandersnatch.js +37 -112
  48. package/dist/resources/2009/LoveSongs.d.ts +9 -0
  49. package/dist/resources/2009/LoveSongs.js +24 -0
  50. package/dist/resources/2009/SpookyPutty.js +20 -46
  51. package/dist/resources/2010/Brickos.d.ts +9 -0
  52. package/dist/resources/2010/Brickos.js +21 -0
  53. package/dist/resources/2010/CrownOfThrones.d.ts +18 -0
  54. package/dist/resources/2010/CrownOfThrones.js +550 -0
  55. package/dist/resources/2011/Gygaxian.d.ts +9 -0
  56. package/dist/resources/2011/Gygaxian.js +24 -0
  57. package/dist/resources/2011/ObtuseAngel.js +21 -63
  58. package/dist/resources/2012/RainDoh.js +14 -40
  59. package/dist/resources/2012/Resolutions.d.ts +9 -0
  60. package/dist/resources/2012/Resolutions.js +28 -0
  61. package/dist/resources/2013/Florist.d.ts +61 -0
  62. package/dist/resources/2013/Florist.js +149 -0
  63. package/dist/resources/2013/PulledTaffy.d.ts +9 -0
  64. package/dist/resources/2013/PulledTaffy.js +33 -0
  65. package/dist/resources/2014/WinterGarden.js +15 -43
  66. package/dist/resources/2015/ChateauMantegna.js +52 -86
  67. package/dist/resources/2015/MayoClinic.d.ts +13 -0
  68. package/dist/resources/2015/MayoClinic.js +36 -0
  69. package/dist/resources/2016/SourceTerminal.d.ts +1 -0
  70. package/dist/resources/2016/SourceTerminal.js +114 -237
  71. package/dist/resources/2016/Witchess.js +33 -59
  72. package/dist/resources/2017/TunnelOfLove.js +62 -111
  73. package/dist/resources/2018/SongBoom.js +32 -68
  74. package/dist/resources/2019/BeachComb.d.ts +2 -0
  75. package/dist/resources/2019/BeachComb.js +26 -0
  76. package/dist/resources/2019/Snapper.d.ts +28 -0
  77. package/dist/resources/2019/Snapper.js +70 -0
  78. package/dist/resources/2020/Guzzlr.js +79 -163
  79. package/dist/resources/LibramSummon.d.ts +12 -0
  80. package/dist/resources/LibramSummon.js +66 -0
  81. package/dist/resources/index.d.ts +18 -11
  82. package/dist/resources/index.js +19 -85
  83. package/dist/resources/putty-likes.js +15 -30
  84. package/dist/ring-buffer.d.ts +24 -0
  85. package/dist/ring-buffer.js +135 -0
  86. package/dist/since.d.ts +1 -0
  87. package/dist/since.js +56 -112
  88. package/dist/template-string.js +40 -132
  89. package/dist/utils.d.ts +14 -0
  90. package/dist/utils.js +50 -114
  91. package/package.json +5 -3
  92. package/dist/libram-example-briefcase.js +0 -16073
  93. package/dist/libram-example-clan.js +0 -8898
  94. package/dist/libram-example-consult.js +0 -6179
  95. package/dist/libram-example-item.js +0 -3248
  96. package/dist/libram-example-kmail.js +0 -2065
  97. package/dist/libram-example-lib.js +0 -7608
  98. package/dist/libram-example-props.js +0 -4770
  99. package/dist/libram-example-resources.js +0 -12226
package/dist/logger.js CHANGED
@@ -1,69 +1,29 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- require("core-js/modules/es.object.to-string.js");
9
-
10
- require("core-js/modules/es.regexp.to-string.js");
11
-
12
- var _kolmafia = require("kolmafia");
13
-
14
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
-
16
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17
-
18
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19
-
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
- var defaultHandlers = {
23
- info: message => (0, _kolmafia.printHtml)("<b>[Libram]</b> ".concat(message)),
24
- warning: message => (0, _kolmafia.printHtml)("<span style=\"background: orange; color: white;\"><b>[Libram]</b> ".concat(message, "</span>")),
25
- error: _error => (0, _kolmafia.printHtml)("<span style=\"background: red; color: white;\"><b>[Libram]</b> ".concat(_error.toString(), "</span>"))
1
+ import { printHtml } from "kolmafia";
2
+ const defaultHandlers = {
3
+ info: (message) => printHtml(`<b>[Libram]</b> ${message}`),
4
+ warning: (message) => printHtml(`<span style="background: orange; color: white;"><b>[Libram]</b> ${message}</span>`),
5
+ error: (error) => printHtml(`<span style="background: red; color: white;"><b>[Libram]</b> ${error.toString()}</span>`),
26
6
  };
27
-
28
- var Logger = /*#__PURE__*/function () {
29
- function Logger() {
30
- _classCallCheck(this, Logger);
31
-
32
- _defineProperty(this, "handlers", defaultHandlers);
33
- }
34
-
35
- _createClass(Logger, [{
36
- key: "setHandler",
37
- value: // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- function setHandler(level, callback) {
39
- this.handlers[level] = callback;
7
+ class Logger {
8
+ constructor() {
9
+ this.handlers = defaultHandlers;
40
10
  }
41
- }, {
42
- key: "log",
43
- value: // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- function log(level, message) {
45
- this.handlers[level](message);
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ setHandler(level, callback) {
13
+ this.handlers[level] = callback;
46
14
  }
47
- }, {
48
- key: "info",
49
- value: function info(message) {
50
- this.log("info", message);
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ log(level, message) {
17
+ this.handlers[level](message);
51
18
  }
52
- }, {
53
- key: "warning",
54
- value: function warning(message) {
55
- this.log("warning", message);
19
+ info(message) {
20
+ this.log("info", message);
56
21
  }
57
- }, {
58
- key: "error",
59
- value: function error(message) {
60
- this.log("error", message);
22
+ warning(message) {
23
+ this.log("warning", message);
61
24
  }
62
- }]);
63
-
64
- return Logger;
65
- }();
66
-
67
- var _default = new Logger();
68
-
69
- exports.default = _default;
25
+ error(message) {
26
+ this.log("error", message);
27
+ }
28
+ }
29
+ export default new Logger();
@@ -1,11 +1,12 @@
1
1
  export declare type MaximizeOptions = {
2
- updateOnFamiliarChange?: boolean;
3
- updateOnCanEquipChanged?: boolean;
4
- forceEquip?: Item[];
5
- preventEquip?: Item[];
6
- bonusEquip?: Map<Item, number>;
7
- onlySlot?: Slot[];
8
- preventSlot?: Slot[];
2
+ updateOnFamiliarChange: boolean;
3
+ updateOnCanEquipChanged: boolean;
4
+ useOutfitCaching: boolean;
5
+ forceEquip: Item[];
6
+ preventEquip: Item[];
7
+ bonusEquip: Map<Item, number>;
8
+ onlySlot: Slot[];
9
+ preventSlot: Slot[];
9
10
  };
10
11
  /**
11
12
  *
@@ -16,7 +17,7 @@ export declare type MaximizeOptions = {
16
17
  * @param options.preventEquip Equipment to prevent equipping ("-equip X").
17
18
  * @param options.bonusEquip Equipment to apply a bonus to ("200 bonus X").
18
19
  */
19
- export declare function setDefaultMaximizeOptions(options: MaximizeOptions): void;
20
+ export declare function setDefaultMaximizeOptions(options: Partial<MaximizeOptions>): void;
20
21
  /**
21
22
  * Run the maximizer, but only if the objective and certain pieces of game state haven't changed since it was last run.
22
23
  * @param objectives Objectives to maximize for.
@@ -27,7 +28,7 @@ export declare function setDefaultMaximizeOptions(options: MaximizeOptions): voi
27
28
  * @param options.preventEquip Equipment to prevent equipping ("-equip X").
28
29
  * @param options.bonusEquip Equipment to apply a bonus to ("200 bonus X").
29
30
  */
30
- export declare function maximizeCached(objectives: string[], options?: MaximizeOptions): void;
31
+ export declare function maximizeCached(objectives: string[], options?: Partial<MaximizeOptions>): void;
31
32
  export declare class Requirement {
32
33
  #private;
33
34
  /**
@@ -35,10 +36,26 @@ export declare class Requirement {
35
36
  * @param maximizeParameters Parameters you're attempting to maximize
36
37
  * @param maximizeOptions Object potentially containing forceEquips, bonusEquips, preventEquips, and preventSlots
37
38
  */
38
- constructor(maximizeParameters: string[], maximizeOptions: MaximizeOptions);
39
+ constructor(maximizeParameters: string[], maximizeOptions: Partial<MaximizeOptions>);
39
40
  get maximizeParameters(): string[];
40
- get maximizeOptions(): MaximizeOptions;
41
+ get maximizeOptions(): Partial<MaximizeOptions>;
42
+ /**
43
+ * Merges two requirements, concanating relevant arrays. Typically used in static form.
44
+ * @param other Requirement to merge with.
45
+ */
41
46
  merge(other: Requirement): Requirement;
47
+ /**
48
+ * Merges a set of requirements together, starting with an empty requirement.
49
+ * @param allRequirements Requirements to merge
50
+ */
42
51
  static merge(allRequirements: Requirement[]): Requirement;
52
+ /**
53
+ * Runs maximizeCached, using the maximizeParameters and maximizeOptions contained by this requirement.
54
+ */
55
+ maximize(): void;
56
+ /**
57
+ * Merges requirements, and then runs maximizeCached on the combined requirement.
58
+ * @param requirements Requirements to maximize on
59
+ */
60
+ static maximize(...requirements: Requirement[]): void;
43
61
  }
44
- export declare function maximizeRequirementsCached(requirements: Requirement[]): void;