libram 0.4.0 → 0.4.4

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 (103) 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 +3 -1
  5. package/dist/Kmail.js +92 -243
  6. package/dist/Path.js +68 -120
  7. package/dist/ascend.js +153 -172
  8. package/dist/combat.d.ts +100 -4
  9. package/dist/combat.js +352 -387
  10. package/dist/console.js +13 -36
  11. package/dist/diet/index.d.ts +31 -0
  12. package/dist/diet/index.js +390 -0
  13. package/dist/diet/knapsack.d.ts +7 -0
  14. package/dist/diet/knapsack.js +119 -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 +16 -4
  24. package/dist/freerun.js +88 -99
  25. package/dist/index.d.ts +5 -1
  26. package/dist/index.js +22 -300
  27. package/dist/lib.d.ts +24 -0
  28. package/dist/lib.js +304 -488
  29. package/dist/logger.js +23 -63
  30. package/dist/maximize.js +289 -556
  31. package/dist/modifier.d.ts +4 -0
  32. package/dist/modifier.js +35 -46
  33. package/dist/modifierTypes.js +8 -22
  34. package/dist/mood.d.ts +5 -0
  35. package/dist/mood.js +260 -551
  36. package/dist/property.d.ts +2 -0
  37. package/dist/property.js +99 -242
  38. package/dist/propertyTypes.d.ts +4 -3
  39. package/dist/propertyTypes.js +1 -0
  40. package/dist/propertyTyping.d.ts +4 -3
  41. package/dist/propertyTyping.js +52 -59
  42. package/dist/resources/2007/CandyHearts.d.ts +9 -0
  43. package/dist/resources/2007/CandyHearts.js +24 -0
  44. package/dist/resources/2008/DivineFavors.d.ts +9 -0
  45. package/dist/resources/2008/DivineFavors.js +27 -0
  46. package/dist/resources/2009/Bandersnatch.js +37 -112
  47. package/dist/resources/2009/LoveSongs.d.ts +9 -0
  48. package/dist/resources/2009/LoveSongs.js +24 -0
  49. package/dist/resources/2009/SpookyPutty.js +20 -46
  50. package/dist/resources/2010/Brickos.d.ts +9 -0
  51. package/dist/resources/2010/Brickos.js +21 -0
  52. package/dist/resources/2010/CrownOfThrones.d.ts +18 -0
  53. package/dist/resources/2010/CrownOfThrones.js +550 -0
  54. package/dist/resources/2011/Gygaxian.d.ts +9 -0
  55. package/dist/resources/2011/Gygaxian.js +24 -0
  56. package/dist/resources/2011/ObtuseAngel.js +21 -63
  57. package/dist/resources/2012/RainDoh.js +14 -40
  58. package/dist/resources/2012/Resolutions.d.ts +9 -0
  59. package/dist/resources/2012/Resolutions.js +28 -0
  60. package/dist/resources/2013/Florist.d.ts +1 -0
  61. package/dist/resources/2013/Florist.js +137 -207
  62. package/dist/resources/2013/PulledTaffy.d.ts +9 -0
  63. package/dist/resources/2013/PulledTaffy.js +33 -0
  64. package/dist/resources/2014/DNALab.d.ts +47 -0
  65. package/dist/resources/2014/DNALab.js +154 -0
  66. package/dist/resources/2014/WinterGarden.js +15 -43
  67. package/dist/resources/2015/ChateauMantegna.js +52 -86
  68. package/dist/resources/2015/MayoClinic.d.ts +3 -0
  69. package/dist/resources/2015/MayoClinic.js +36 -65
  70. package/dist/resources/2016/SourceTerminal.d.ts +1 -0
  71. package/dist/resources/2016/SourceTerminal.js +114 -237
  72. package/dist/resources/2016/Witchess.js +33 -59
  73. package/dist/resources/2017/AsdonMartin.d.ts +27 -0
  74. package/dist/resources/2017/AsdonMartin.js +80 -0
  75. package/dist/resources/2017/TunnelOfLove.js +62 -111
  76. package/dist/resources/2018/SongBoom.js +32 -68
  77. package/dist/resources/2019/BeachComb.js +26 -44
  78. package/dist/resources/2019/Snapper.d.ts +28 -0
  79. package/dist/resources/2019/Snapper.js +69 -0
  80. package/dist/resources/2020/Guzzlr.d.ts +3 -0
  81. package/dist/resources/2020/Guzzlr.js +92 -163
  82. package/dist/resources/LibramSummon.d.ts +12 -0
  83. package/dist/resources/LibramSummon.js +66 -0
  84. package/dist/resources/index.d.ts +20 -14
  85. package/dist/resources/index.js +21 -100
  86. package/dist/resources/putty-likes.js +15 -30
  87. package/dist/ring-buffer.d.ts +24 -0
  88. package/dist/ring-buffer.js +135 -0
  89. package/dist/since.d.ts +1 -0
  90. package/dist/since.js +56 -112
  91. package/dist/template-string.js +40 -132
  92. package/dist/utils.d.ts +12 -0
  93. package/dist/utils.js +54 -123
  94. package/package.json +8 -3
  95. package/dist/libram-example-briefcase.js +0 -16073
  96. package/dist/libram-example-clan.js +0 -7050
  97. package/dist/libram-example-consult.js +0 -5032
  98. package/dist/libram-example-item.js +0 -2870
  99. package/dist/libram-example-kmail.js +0 -2065
  100. package/dist/libram-example-lib.js +0 -6369
  101. package/dist/libram-example-modifier.js +0 -4495
  102. package/dist/libram-example-props.js +0 -3996
  103. package/dist/libram-example-resources.js +0 -10461
@@ -1,68 +1,21 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.array.slice.js");
4
-
5
- require("core-js/modules/es.object.to-string.js");
6
-
7
- require("core-js/modules/es.symbol.js");
8
-
9
- require("core-js/modules/es.symbol.description.js");
10
-
11
- require("core-js/modules/es.array.iterator.js");
12
-
13
- Object.defineProperty(exports, "__esModule", {
14
- value: true
15
- });
16
- exports.have = have;
17
- exports.getRunaways = getRunaways;
18
- exports.getMaxRunaways = getMaxRunaways;
19
- exports.getRemainingRunaways = getRemainingRunaways;
20
- exports.couldRunaway = couldRunaway;
21
- exports.canRunaway = canRunaway;
22
- exports.prepareRunaway = prepareRunaway;
23
- exports.familiar = void 0;
24
-
25
- require("core-js/modules/es.array.includes.js");
26
-
27
- require("core-js/modules/es.string.includes.js");
28
-
29
- var _kolmafia = require("kolmafia");
30
-
31
- var _property = require("../../property");
32
-
33
- var _templateString = require("../../template-string");
34
-
35
- var _lib = require("../../lib");
36
-
37
- var _templateObject, _templateObject2, _templateObject3;
38
-
39
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
40
-
41
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
42
-
43
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
44
-
45
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
46
-
47
- var familiar = (0, _templateString.$familiar)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Frumious Bandersnatch"])));
1
+ import { familiarWeight, useFamiliar, useSkill, weightAdjustment, } from "kolmafia";
2
+ import { get } from "../../property";
3
+ import { $effect, $familiar, $skill } from "../../template-string";
4
+ import { have as _have, canRememberSong, getActiveSongs, isCurrentFamiliar, uneffect, } from "../../lib";
5
+ export const familiar = $familiar `Frumious Bandersnatch`;
48
6
  /**
49
7
  * Returns true if the player has the Frumious Bandersnatch in their
50
8
  * terrariukm
51
9
  */
52
-
53
- exports.familiar = familiar;
54
-
55
- function have() {
56
- return (0, _lib.have)(familiar);
10
+ export function have() {
11
+ return _have(familiar);
57
12
  }
58
13
  /**
59
14
  * Returns the number of free runaways that have already been used
60
15
  * @see StompingBoots with which the Bandersnatch shares a counter
61
16
  */
62
-
63
-
64
- function getRunaways() {
65
- return (0, _property.get)("_banderRunaways");
17
+ export function getRunaways() {
18
+ return get("_banderRunaways");
66
19
  }
67
20
  /**
68
21
  * Returns the total number of free runaways that the player can
@@ -70,12 +23,9 @@ function getRunaways() {
70
23
  *
71
24
  * @param considerWeightAdjustment Include familiar weight modifiers
72
25
  */
73
-
74
-
75
- function getMaxRunaways() {
76
- var considerWeightAdjustment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
77
- var weightBuffs = considerWeightAdjustment ? (0, _kolmafia.weightAdjustment)() : 0;
78
- return Math.floor(((0, _kolmafia.familiarWeight)(familiar) + weightBuffs) / 5);
26
+ export function getMaxRunaways(considerWeightAdjustment = true) {
27
+ const weightBuffs = considerWeightAdjustment ? weightAdjustment() : 0;
28
+ return Math.floor((familiarWeight(familiar) + weightBuffs) / 5);
79
29
  }
80
30
  /**
81
31
  * Returns the number of remaining free runaways the player can
@@ -83,11 +33,8 @@ function getMaxRunaways() {
83
33
  *
84
34
  * @param considerWeightAdjustment
85
35
  */
86
-
87
-
88
- function getRemainingRunaways() {
89
- var considerWeightAdjustment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
90
- return Math.max(0, getMaxRunaways(considerWeightAdjustment) - getRunaways());
36
+ export function getRemainingRunaways(considerWeightAdjustment = true) {
37
+ return Math.max(0, getMaxRunaways(considerWeightAdjustment) - getRunaways());
91
38
  }
92
39
  /**
93
40
  * Returns true if the player could use their Bandersnatch to
@@ -95,22 +42,17 @@ function getRemainingRunaways() {
95
42
  *
96
43
  * @param considerWeightAdjustment Include familiar weight modifiers
97
44
  */
98
-
99
-
100
- function couldRunaway() {
101
- var considerWeightAdjustment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
102
- return have() && getRemainingRunaways(considerWeightAdjustment) > 0;
45
+ export function couldRunaway(considerWeightAdjustment = true) {
46
+ return have() && getRemainingRunaways(considerWeightAdjustment) > 0;
103
47
  }
104
-
105
- var odeSkill = (0, _templateString.$skill)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["The Ode to Booze"])));
106
- var odeEffect = (0, _templateString.$effect)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Ode to Booze"])));
48
+ const odeSkill = $skill `The Ode to Booze`;
49
+ const odeEffect = $effect `Ode to Booze`;
107
50
  /**
108
51
  * Returns true if the player can use their Bandersnatch to get a
109
52
  * free run right now
110
53
  */
111
-
112
- function canRunaway() {
113
- return (0, _lib.isCurrentFamiliar)(familiar) && couldRunaway() && (0, _lib.have)(odeEffect);
54
+ export function canRunaway() {
55
+ return isCurrentFamiliar(familiar) && couldRunaway() && _have(odeEffect);
114
56
  }
115
57
  /**
116
58
  * Prepare a Bandersnatch runaway.
@@ -120,39 +62,22 @@ function canRunaway() {
120
62
  *
121
63
  * @param songsToRemove Ordered list of songs that could be shrugged to make room for Ode to Booze
122
64
  */
123
-
124
-
125
- function prepareRunaway(songsToRemove) {
126
- if (!(0, _lib.have)(odeEffect)) {
127
- if (!(0, _lib.have)(odeSkill)) {
128
- return false;
129
- }
130
-
131
- if (!(0, _lib.canRememberSong)()) {
132
- var activeSongs = (0, _lib.getActiveSongs)();
133
-
134
- var _iterator = _createForOfIteratorHelper(songsToRemove),
135
- _step;
136
-
137
- try {
138
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
139
- var song = _step.value;
140
-
141
- if (activeSongs.includes(song) && (0, _lib.uneffect)(song)) {
142
- break;
143
- }
65
+ export function prepareRunaway(songsToRemove) {
66
+ if (!_have(odeEffect)) {
67
+ if (!_have(odeSkill)) {
68
+ return false;
69
+ }
70
+ if (!canRememberSong()) {
71
+ const activeSongs = getActiveSongs();
72
+ for (const song of songsToRemove) {
73
+ if (activeSongs.includes(song) && uneffect(song)) {
74
+ break;
75
+ }
76
+ }
77
+ }
78
+ if (!useSkill(odeSkill)) {
79
+ return false;
144
80
  }
145
- } catch (err) {
146
- _iterator.e(err);
147
- } finally {
148
- _iterator.f();
149
- }
150
- }
151
-
152
- if (!(0, _kolmafia.useSkill)(odeSkill)) {
153
- return false;
154
81
  }
155
- }
156
-
157
- return (0, _kolmafia.useFamiliar)(familiar);
158
- }
82
+ return useFamiliar(familiar);
83
+ }
@@ -0,0 +1,9 @@
1
+ export declare const summonSkill: Skill;
2
+ /**
3
+ * @returns true if the player can Summon Love Song
4
+ */
5
+ export declare function have(): boolean;
6
+ /**
7
+ * @returns map containing the chance of an item to be summoned
8
+ */
9
+ export declare function expected(): Map<Item, number>;
@@ -0,0 +1,24 @@
1
+ import { $item, $skill } from "../../template-string";
2
+ import { have as _have } from "../../lib";
3
+ export const summonSkill = $skill `Summon Love Song`;
4
+ const libramChance = 1.0 / 6;
5
+ const libramExpected = new Map([
6
+ [$item `love song of disturbing obsession`, libramChance],
7
+ [$item `love song of icy revenge`, libramChance],
8
+ [$item `love song of naughty innuendo`, libramChance],
9
+ [$item `love song of smoldering passion`, libramChance],
10
+ [$item `love song of sugary cuteness`, libramChance],
11
+ [$item `love song of vague ambiguity`, libramChance],
12
+ ]);
13
+ /**
14
+ * @returns true if the player can Summon Love Song
15
+ */
16
+ export function have() {
17
+ return _have(summonSkill);
18
+ }
19
+ /**
20
+ * @returns map containing the chance of an item to be summoned
21
+ */
22
+ export function expected() {
23
+ return libramExpected;
24
+ }
@@ -1,50 +1,24 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.array.slice.js");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.have = have;
9
- exports.getSpookyPuttySheetCopiesMade = getSpookyPuttySheetCopiesMade;
10
- exports.prepareSpookyPuttySheet = prepareSpookyPuttySheet;
11
- exports.getSpookyPuttySheetMonster = getSpookyPuttySheetMonster;
12
- exports.useSpookyPuttySheet = useSpookyPuttySheet;
13
- exports.sheet = void 0;
14
-
15
- var _kolmafia = require("kolmafia");
16
-
17
- var _lib = require("../../lib");
18
-
19
- var _property = require("../../property");
20
-
21
- var _templateString = require("../../template-string");
22
-
23
- var _templateObject;
24
-
25
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
26
-
27
- var sheet = (0, _templateString.$item)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Spooky Putty sheet"])));
28
- exports.sheet = sheet;
29
-
30
- function have() {
31
- return (0, _lib.getFoldGroup)(sheet).some(item => (0, _lib.have)(item));
1
+ import { cliExecute, use } from "kolmafia";
2
+ import { getFoldGroup, have as haveItem } from "../../lib";
3
+ import { get } from "../../property";
4
+ import { $item } from "../../template-string";
5
+ export const sheet = $item `Spooky Putty sheet`;
6
+ export function have() {
7
+ return getFoldGroup(sheet).some((item) => haveItem(item));
32
8
  }
33
-
34
- function getSpookyPuttySheetCopiesMade() {
35
- return Math.max(0, (0, _property.get)("spookyPuttyCopiesMade"));
9
+ export function getSpookyPuttySheetCopiesMade() {
10
+ return Math.max(0, get("spookyPuttyCopiesMade"));
36
11
  }
37
-
38
- function prepareSpookyPuttySheet() {
39
- if (!have()) return false;
40
- if ((0, _lib.have)(sheet)) return true;
41
- return (0, _kolmafia.cliExecute)("fold Spooky putty sheet");
12
+ export function prepareSpookyPuttySheet() {
13
+ if (!have())
14
+ return false;
15
+ if (haveItem(sheet))
16
+ return true;
17
+ return cliExecute("fold Spooky putty sheet");
42
18
  }
43
-
44
- function getSpookyPuttySheetMonster() {
45
- return (0, _property.get)("spookyPuttyMonster");
19
+ export function getSpookyPuttySheetMonster() {
20
+ return get("spookyPuttyMonster");
21
+ }
22
+ export function useSpookyPuttySheet() {
23
+ return use(sheet);
46
24
  }
47
-
48
- function useSpookyPuttySheet() {
49
- return (0, _kolmafia.use)(sheet);
50
- }
@@ -0,0 +1,9 @@
1
+ export declare const summonSkill: Skill;
2
+ /**
3
+ * @returns true if the player can Summon BRICKOs
4
+ */
5
+ export declare function have(): boolean;
6
+ /**
7
+ * @returns map containing the chance of an item to be summoned
8
+ */
9
+ export declare function expected(): Map<Item, number>;
@@ -0,0 +1,21 @@
1
+ import { get } from "../../property";
2
+ import { $item, $skill } from "../../template-string";
3
+ import { have as _have } from "../../lib";
4
+ export const summonSkill = $skill `Summon BRICKOs`;
5
+ /**
6
+ * @returns true if the player can Summon BRICKOs
7
+ */
8
+ export function have() {
9
+ return _have(summonSkill);
10
+ }
11
+ /**
12
+ * @returns map containing the chance of an item to be summoned
13
+ */
14
+ export function expected() {
15
+ const eyeSummons = get("_brickoEyeSummons");
16
+ const eyeChance = eyeSummons === 3 ? 0.0 : eyeSummons === 0 ? 0.5 : 1.0 / 3.0;
17
+ return new Map([
18
+ [$item `BRICKO eye brick`, eyeChance],
19
+ [$item `BRICKO brick`, 3.0 - eyeChance],
20
+ ]);
21
+ }
@@ -0,0 +1,18 @@
1
+ import { Modifiers } from "../../modifier";
2
+ export declare type FamiliarRider = {
3
+ familiar: Familiar;
4
+ meatVal: () => number;
5
+ probability: number;
6
+ modifier: Modifiers;
7
+ dropPredicate?: () => boolean;
8
+ };
9
+ export declare const ridingFamiliars: FamiliarRider[];
10
+ export declare function valueRider(rider: FamiliarRider, modifierValueFunction: (modifiers: Modifiers) => number, ignoreLimitedDrops?: boolean): number;
11
+ declare type RiderMode = {
12
+ modifierValueFunction: (modifiers: Modifiers) => number;
13
+ ignoreLimitedDrops: boolean;
14
+ excludeCurrentFamiliar: boolean;
15
+ };
16
+ export declare function createRiderMode(name: string, modifierValueFunction: (modifiers: Modifiers) => number, ignoreLimitedDrops?: boolean, excludeCurrentFamiliar?: boolean): Map<string, RiderMode>;
17
+ export declare function pickRider(mode: string): FamiliarRider | null;
18
+ export {};