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.
- package/dist/Clan.js +268 -485
- package/dist/Copier.js +11 -48
- package/dist/Dungeon.js +77 -157
- package/dist/Kmail.d.ts +13 -7
- package/dist/Kmail.js +92 -233
- package/dist/Path.js +68 -120
- package/dist/ascend.js +153 -172
- package/dist/combat.d.ts +86 -1
- package/dist/combat.js +295 -387
- package/dist/console.js +13 -36
- package/dist/diet/index.d.ts +31 -0
- package/dist/diet/index.js +333 -0
- package/dist/diet/knapsack.d.ts +7 -0
- package/dist/diet/knapsack.js +106 -0
- package/dist/dungeons/Dreadsylvania.d.ts +4 -0
- package/dist/dungeons/Dreadsylvania.js +14 -0
- package/dist/dungeons/Dungeon.d.ts +28 -0
- package/dist/dungeons/Dungeon.js +99 -0
- package/dist/dungeons/Hobopolis.d.ts +4 -0
- package/dist/dungeons/Hobopolis.js +14 -0
- package/dist/dungeons/SlimeTube.d.ts +4 -0
- package/dist/dungeons/SlimeTube.js +14 -0
- package/dist/freerun.d.ts +23 -0
- package/dist/freerun.js +92 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +21 -263
- package/dist/lib.d.ts +43 -0
- package/dist/lib.js +296 -405
- package/dist/logger.js +23 -63
- package/dist/maximize.d.ts +29 -12
- package/dist/maximize.js +318 -421
- package/dist/modifier.d.ts +13 -0
- package/dist/modifier.js +35 -0
- package/dist/modifierTypes.d.ts +16 -0
- package/dist/modifierTypes.js +9 -0
- package/dist/mood.js +220 -531
- package/dist/property.d.ts +2 -0
- package/dist/property.js +96 -242
- package/dist/propertyTypes.d.ts +9 -0
- package/dist/propertyTypes.js +1 -0
- package/dist/propertyTyping.d.ts +2 -9
- package/dist/propertyTyping.js +42 -53
- package/dist/resources/2007/CandyHearts.d.ts +9 -0
- package/dist/resources/2007/CandyHearts.js +24 -0
- package/dist/resources/2008/DivineFavors.d.ts +9 -0
- package/dist/resources/2008/DivineFavors.js +27 -0
- package/dist/resources/2009/Bandersnatch.js +37 -112
- package/dist/resources/2009/LoveSongs.d.ts +9 -0
- package/dist/resources/2009/LoveSongs.js +24 -0
- package/dist/resources/2009/SpookyPutty.js +20 -46
- package/dist/resources/2010/Brickos.d.ts +9 -0
- package/dist/resources/2010/Brickos.js +21 -0
- package/dist/resources/2010/CrownOfThrones.d.ts +18 -0
- package/dist/resources/2010/CrownOfThrones.js +550 -0
- package/dist/resources/2011/Gygaxian.d.ts +9 -0
- package/dist/resources/2011/Gygaxian.js +24 -0
- package/dist/resources/2011/ObtuseAngel.js +21 -63
- package/dist/resources/2012/RainDoh.js +14 -40
- package/dist/resources/2012/Resolutions.d.ts +9 -0
- package/dist/resources/2012/Resolutions.js +28 -0
- package/dist/resources/2013/Florist.d.ts +61 -0
- package/dist/resources/2013/Florist.js +149 -0
- package/dist/resources/2013/PulledTaffy.d.ts +9 -0
- package/dist/resources/2013/PulledTaffy.js +33 -0
- package/dist/resources/2014/WinterGarden.js +15 -43
- package/dist/resources/2015/ChateauMantegna.js +52 -86
- package/dist/resources/2015/MayoClinic.d.ts +13 -0
- package/dist/resources/2015/MayoClinic.js +36 -0
- package/dist/resources/2016/SourceTerminal.d.ts +1 -0
- package/dist/resources/2016/SourceTerminal.js +114 -237
- package/dist/resources/2016/Witchess.js +33 -59
- package/dist/resources/2017/TunnelOfLove.js +62 -111
- package/dist/resources/2018/SongBoom.js +32 -68
- package/dist/resources/2019/BeachComb.d.ts +2 -0
- package/dist/resources/2019/BeachComb.js +26 -0
- package/dist/resources/2019/Snapper.d.ts +28 -0
- package/dist/resources/2019/Snapper.js +70 -0
- package/dist/resources/2020/Guzzlr.js +79 -163
- package/dist/resources/LibramSummon.d.ts +12 -0
- package/dist/resources/LibramSummon.js +66 -0
- package/dist/resources/index.d.ts +18 -11
- package/dist/resources/index.js +19 -85
- package/dist/resources/putty-likes.js +15 -30
- package/dist/ring-buffer.d.ts +24 -0
- package/dist/ring-buffer.js +135 -0
- package/dist/since.d.ts +1 -0
- package/dist/since.js +56 -112
- package/dist/template-string.js +40 -132
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +50 -114
- package/package.json +5 -3
- package/dist/libram-example-briefcase.js +0 -16073
- package/dist/libram-example-clan.js +0 -8898
- package/dist/libram-example-consult.js +0 -6179
- package/dist/libram-example-item.js +0 -3248
- package/dist/libram-example-kmail.js +0 -2065
- package/dist/libram-example-lib.js +0 -7608
- package/dist/libram-example-props.js +0 -4770
- package/dist/libram-example-resources.js +0 -12226
package/dist/lib.js
CHANGED
|
@@ -1,106 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.description.js");
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: true
|
|
11
|
-
});
|
|
12
|
-
exports.getSongLimit = getSongLimit;
|
|
13
|
-
exports.isSong = isSong;
|
|
14
|
-
exports.getActiveEffects = getActiveEffects;
|
|
15
|
-
exports.getActiveSongs = getActiveSongs;
|
|
16
|
-
exports.getSongCount = getSongCount;
|
|
17
|
-
exports.canRememberSong = canRememberSong;
|
|
18
|
-
exports.getMonsterLocations = getMonsterLocations;
|
|
19
|
-
exports.getRemainingLiver = getRemainingLiver;
|
|
20
|
-
exports.getRemainingStomach = getRemainingStomach;
|
|
21
|
-
exports.getRemainingSpleen = getRemainingSpleen;
|
|
22
|
-
exports.have = have;
|
|
23
|
-
exports.haveInCampground = haveInCampground;
|
|
24
|
-
exports.haveCounter = haveCounter;
|
|
25
|
-
exports.haveWandererCounter = haveWandererCounter;
|
|
26
|
-
exports.isVoteWandererNow = isVoteWandererNow;
|
|
27
|
-
exports.isWandererNow = isWandererNow;
|
|
28
|
-
exports.getKramcoWandererChance = getKramcoWandererChance;
|
|
29
|
-
exports.getFamiliarWandererChance = getFamiliarWandererChance;
|
|
30
|
-
exports.getWandererChance = getWandererChance;
|
|
31
|
-
exports.isCurrentFamiliar = isCurrentFamiliar;
|
|
32
|
-
exports.getFoldGroup = getFoldGroup;
|
|
33
|
-
exports.getZapGroup = getZapGroup;
|
|
34
|
-
exports.getBanishedMonsters = getBanishedMonsters;
|
|
35
|
-
exports.canUse = canUse;
|
|
36
|
-
exports.noneToNull = noneToNull;
|
|
37
|
-
exports.getAverage = getAverage;
|
|
38
|
-
exports.getAverageAdventures = getAverageAdventures;
|
|
39
|
-
exports.uneffect = uneffect;
|
|
40
|
-
exports.getPlayerFromIdOrName = getPlayerFromIdOrName;
|
|
41
|
-
exports.Wanderer = void 0;
|
|
42
|
-
|
|
43
|
-
require("core-js/modules/es.array.map.js");
|
|
44
|
-
|
|
45
|
-
require("core-js/modules/es.array.filter.js");
|
|
46
|
-
|
|
47
|
-
require("core-js/modules/es.array.includes.js");
|
|
48
|
-
|
|
49
|
-
require("core-js/modules/es.string.includes.js");
|
|
50
|
-
|
|
51
|
-
require("core-js/modules/es.regexp.constructor.js");
|
|
52
|
-
|
|
53
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
54
|
-
|
|
55
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
56
|
-
|
|
57
|
-
require("core-js/modules/es.string.match.js");
|
|
58
|
-
|
|
59
|
-
require("core-js/modules/es.number.parse-int.js");
|
|
60
|
-
|
|
61
|
-
require("core-js/modules/es.array.sort.js");
|
|
62
|
-
|
|
63
|
-
require("core-js/modules/es.object.entries.js");
|
|
64
|
-
|
|
65
|
-
require("core-js/modules/es.string.split.js");
|
|
66
|
-
|
|
67
|
-
require("core-js/modules/es.array.iterator.js");
|
|
68
|
-
|
|
69
|
-
require("core-js/modules/es.object.to-string.js");
|
|
70
|
-
|
|
71
|
-
var _kolmafia = require("kolmafia");
|
|
72
|
-
|
|
73
|
-
var _templateString = require("./template-string");
|
|
74
|
-
|
|
75
|
-
var _property = require("./property");
|
|
76
|
-
|
|
77
|
-
var _utils = require("./utils");
|
|
78
|
-
|
|
79
|
-
var _templateObject, _templateObject2;
|
|
80
|
-
|
|
81
|
-
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(_e2) { throw _e2; }, 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(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
82
|
-
|
|
83
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
84
|
-
|
|
85
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
86
|
-
|
|
87
|
-
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); }
|
|
88
|
-
|
|
89
|
-
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; }
|
|
90
|
-
|
|
91
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
92
|
-
|
|
93
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
94
|
-
|
|
95
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
96
|
-
|
|
1
|
+
/** @module GeneralLibrary */
|
|
2
|
+
import "core-js/modules/es.object.entries";
|
|
3
|
+
import { appearanceRates, autosellPrice, availableAmount, booleanModifier, cliExecute, fullnessLimit, getCampground, getCounters, getPlayerId, getPlayerName, getRelated, haveEffect, haveFamiliar, haveServant, haveSkill, inebrietyLimit, mallPrice, myEffects, myFamiliar, myFullness, myInebriety, myPath, mySpleenUse, myThrall, myTurncount, numericModifier, spleenLimit, toItem, toSkill, totalTurnsPlayed, } from "kolmafia";
|
|
4
|
+
import { $class, $familiar, $item, $items } from "./template-string";
|
|
5
|
+
import { get } from "./property";
|
|
6
|
+
import { chunk } from "./utils";
|
|
97
7
|
/**
|
|
98
8
|
* Returns the current maximum Accordion Thief songs the player can have in their head
|
|
99
9
|
*
|
|
100
10
|
* @category General
|
|
101
11
|
*/
|
|
102
|
-
function getSongLimit() {
|
|
103
|
-
|
|
12
|
+
export function getSongLimit() {
|
|
13
|
+
return (3 +
|
|
14
|
+
(booleanModifier("Four Songs") ? 1 : 0) +
|
|
15
|
+
numericModifier("Additional Song"));
|
|
104
16
|
}
|
|
105
17
|
/**
|
|
106
18
|
* Return whether the Skill or Effect provided is an Accordion Thief song
|
|
@@ -108,41 +20,33 @@ function getSongLimit() {
|
|
|
108
20
|
* @category General
|
|
109
21
|
* @param skillOrEffect The Skill or Effect
|
|
110
22
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var skill = skillOrEffect instanceof Effect ? (0, _kolmafia.toSkill)(skillOrEffect) : skillOrEffect;
|
|
115
|
-
return skill.class === (0, _templateString.$class)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Accordion Thief"]))) && skill.buff;
|
|
23
|
+
export function isSong(skillOrEffect) {
|
|
24
|
+
const skill = skillOrEffect instanceof Effect ? toSkill(skillOrEffect) : skillOrEffect;
|
|
25
|
+
return skill.class === $class `Accordion Thief` && skill.buff;
|
|
116
26
|
}
|
|
117
27
|
/**
|
|
118
28
|
* List all active Effects
|
|
119
29
|
*
|
|
120
30
|
* @category General
|
|
121
31
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
function getActiveEffects() {
|
|
125
|
-
return Object.keys((0, _kolmafia.myEffects)()).map(e => Effect.get(e));
|
|
32
|
+
export function getActiveEffects() {
|
|
33
|
+
return Object.keys(myEffects()).map((e) => Effect.get(e));
|
|
126
34
|
}
|
|
127
35
|
/**
|
|
128
36
|
* List currently active Accordion Thief songs
|
|
129
37
|
*
|
|
130
38
|
* @category General
|
|
131
39
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
function getActiveSongs() {
|
|
135
|
-
return getActiveEffects().filter(isSong);
|
|
40
|
+
export function getActiveSongs() {
|
|
41
|
+
return getActiveEffects().filter(isSong);
|
|
136
42
|
}
|
|
137
43
|
/**
|
|
138
44
|
* List number of active Accordion Thief songs
|
|
139
45
|
*
|
|
140
46
|
* @category General
|
|
141
47
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
function getSongCount() {
|
|
145
|
-
return getActiveSongs().length;
|
|
48
|
+
export function getSongCount() {
|
|
49
|
+
return getActiveSongs().length;
|
|
146
50
|
}
|
|
147
51
|
/**
|
|
148
52
|
* Returns true if the player can remember another Accordion Thief song
|
|
@@ -150,11 +54,8 @@ function getSongCount() {
|
|
|
150
54
|
* @category General
|
|
151
55
|
* @param quantity Number of songs to test the space for
|
|
152
56
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
function canRememberSong() {
|
|
156
|
-
var quantity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
157
|
-
return getSongLimit() - getSongCount() >= quantity;
|
|
57
|
+
export function canRememberSong(quantity = 1) {
|
|
58
|
+
return getSongLimit() - getSongCount() >= quantity;
|
|
158
59
|
}
|
|
159
60
|
/**
|
|
160
61
|
* Return the locations in which the given monster can be encountered naturally
|
|
@@ -162,40 +63,32 @@ function canRememberSong() {
|
|
|
162
63
|
* @category General
|
|
163
64
|
* @param monster Monster to find
|
|
164
65
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
function getMonsterLocations(monster) {
|
|
168
|
-
return Location.all().filter(location => monster.name in (0, _kolmafia.appearanceRates)(location));
|
|
66
|
+
export function getMonsterLocations(monster) {
|
|
67
|
+
return Location.all().filter((location) => monster.name in appearanceRates(location));
|
|
169
68
|
}
|
|
170
69
|
/**
|
|
171
70
|
* Return the player's remaining liver space
|
|
172
71
|
*
|
|
173
72
|
* @category General
|
|
174
73
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
function getRemainingLiver() {
|
|
178
|
-
return (0, _kolmafia.inebrietyLimit)() - (0, _kolmafia.myInebriety)();
|
|
74
|
+
export function getRemainingLiver() {
|
|
75
|
+
return inebrietyLimit() - myInebriety();
|
|
179
76
|
}
|
|
180
77
|
/**
|
|
181
78
|
* Return the player's remaining stomach space
|
|
182
79
|
*
|
|
183
80
|
* @category General
|
|
184
81
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
function getRemainingStomach() {
|
|
188
|
-
return (0, _kolmafia.fullnessLimit)() - (0, _kolmafia.myFullness)();
|
|
82
|
+
export function getRemainingStomach() {
|
|
83
|
+
return fullnessLimit() - myFullness();
|
|
189
84
|
}
|
|
190
85
|
/**
|
|
191
86
|
* Return the player's remaining spleen space
|
|
192
87
|
*
|
|
193
88
|
* @category General
|
|
194
89
|
*/
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
function getRemainingSpleen() {
|
|
198
|
-
return (0, _kolmafia.spleenLimit)() - (0, _kolmafia.mySpleenUse)();
|
|
90
|
+
export function getRemainingSpleen() {
|
|
91
|
+
return spleenLimit() - mySpleenUse();
|
|
199
92
|
}
|
|
200
93
|
/**
|
|
201
94
|
* Return whether the player "has" any entity which one could feasibly "have".
|
|
@@ -204,37 +97,27 @@ function getRemainingSpleen() {
|
|
|
204
97
|
* @param thing Thing to check
|
|
205
98
|
* @param quantity Number to check that the player has
|
|
206
99
|
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (thing instanceof Skill) {
|
|
229
|
-
return (0, _kolmafia.haveSkill)(thing);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (thing instanceof Thrall) {
|
|
233
|
-
var thrall = (0, _kolmafia.myThrall)();
|
|
234
|
-
return thrall.id === thing.id && thrall.level >= quantity;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return false;
|
|
100
|
+
export function have(thing, quantity = 1) {
|
|
101
|
+
if (thing instanceof Effect) {
|
|
102
|
+
return haveEffect(thing) >= quantity;
|
|
103
|
+
}
|
|
104
|
+
if (thing instanceof Familiar) {
|
|
105
|
+
return haveFamiliar(thing);
|
|
106
|
+
}
|
|
107
|
+
if (thing instanceof Item) {
|
|
108
|
+
return availableAmount(thing) >= quantity;
|
|
109
|
+
}
|
|
110
|
+
if (thing instanceof Servant) {
|
|
111
|
+
return haveServant(thing);
|
|
112
|
+
}
|
|
113
|
+
if (thing instanceof Skill) {
|
|
114
|
+
return haveSkill(thing);
|
|
115
|
+
}
|
|
116
|
+
if (thing instanceof Thrall) {
|
|
117
|
+
const thrall = myThrall();
|
|
118
|
+
return thrall.id === thing.id && thrall.level >= quantity;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
238
121
|
}
|
|
239
122
|
/**
|
|
240
123
|
* Return whether an item is in the player's campground
|
|
@@ -242,54 +125,44 @@ function have(thing) {
|
|
|
242
125
|
* @category General
|
|
243
126
|
* @param item The item mafia uses to represent the campground item
|
|
244
127
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
128
|
+
export function haveInCampground(item) {
|
|
129
|
+
return Object.keys(getCampground())
|
|
130
|
+
.map((i) => Item.get(i))
|
|
131
|
+
.includes(item);
|
|
249
132
|
}
|
|
250
|
-
|
|
251
|
-
var Wanderer;
|
|
252
|
-
exports.Wanderer = Wanderer;
|
|
253
|
-
|
|
133
|
+
export var Wanderer;
|
|
254
134
|
(function (Wanderer) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
})(Wanderer || (
|
|
265
|
-
|
|
266
|
-
var deterministicWanderers = [Wanderer.Digitize, Wanderer.Portscan];
|
|
135
|
+
Wanderer["Digitize"] = "Digitize Monster";
|
|
136
|
+
Wanderer["Enamorang"] = "Enamorang Monster";
|
|
137
|
+
Wanderer["Familiar"] = "Familiar";
|
|
138
|
+
Wanderer["Holiday"] = "Holiday Monster";
|
|
139
|
+
Wanderer["Kramco"] = "Kramco";
|
|
140
|
+
Wanderer["Nemesis"] = "Nemesis Assassin";
|
|
141
|
+
Wanderer["Portscan"] = "portscan.edu";
|
|
142
|
+
Wanderer["Romantic"] = "Romantic Monster";
|
|
143
|
+
Wanderer["Vote"] = "Vote Monster";
|
|
144
|
+
})(Wanderer || (Wanderer = {}));
|
|
145
|
+
const deterministicWanderers = [Wanderer.Digitize, Wanderer.Portscan];
|
|
267
146
|
/**
|
|
268
147
|
* Return whether the player has the queried counter
|
|
269
148
|
*
|
|
270
149
|
* @category General
|
|
271
150
|
*/
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var minTurns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
275
|
-
var maxTurns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
|
276
|
-
return (0, _kolmafia.getCounters)(counterName, minTurns, maxTurns) === counterName;
|
|
151
|
+
export function haveCounter(counterName, minTurns = 0, maxTurns = 500) {
|
|
152
|
+
return getCounters(counterName, minTurns, maxTurns) === counterName;
|
|
277
153
|
}
|
|
278
154
|
/**
|
|
279
155
|
* Return whether the player has the queried wandering counter
|
|
280
156
|
*
|
|
281
157
|
* @category Wanderers
|
|
282
158
|
*/
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
var begin = wanderer + " window begin";
|
|
291
|
-
var end = wanderer + " window end";
|
|
292
|
-
return haveCounter(begin) || haveCounter(end);
|
|
159
|
+
export function haveWandererCounter(wanderer) {
|
|
160
|
+
if (deterministicWanderers.includes(wanderer)) {
|
|
161
|
+
return haveCounter(wanderer);
|
|
162
|
+
}
|
|
163
|
+
const begin = wanderer + " window begin";
|
|
164
|
+
const end = wanderer + " window end";
|
|
165
|
+
return haveCounter(begin) || haveCounter(end);
|
|
293
166
|
}
|
|
294
167
|
/**
|
|
295
168
|
* Returns whether the player will encounter a vote wanderer on the next turn,
|
|
@@ -297,10 +170,8 @@ function haveWandererCounter(wanderer) {
|
|
|
297
170
|
*
|
|
298
171
|
* @category Wanderers
|
|
299
172
|
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
function isVoteWandererNow() {
|
|
303
|
-
return (0, _kolmafia.totalTurnsPlayed)() % 11 == 1;
|
|
173
|
+
export function isVoteWandererNow() {
|
|
174
|
+
return totalTurnsPlayed() % 11 == 1;
|
|
304
175
|
}
|
|
305
176
|
/**
|
|
306
177
|
* Tells us whether we can expect a given wanderer now. Behaves differently
|
|
@@ -318,28 +189,22 @@ function isVoteWandererNow() {
|
|
|
318
189
|
* @category Wanderers
|
|
319
190
|
* @param wanderer Wanderer to check
|
|
320
191
|
*/
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return (0, _property.get)("_hipsterAdv") < 7;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
var begin = wanderer + " window begin";
|
|
341
|
-
var end = wanderer + " window end";
|
|
342
|
-
return !haveCounter(begin, 1) && haveCounter(end);
|
|
192
|
+
export function isWandererNow(wanderer) {
|
|
193
|
+
if (deterministicWanderers.includes(wanderer)) {
|
|
194
|
+
return haveCounter(wanderer, 0, 0);
|
|
195
|
+
}
|
|
196
|
+
if (wanderer == Wanderer.Kramco) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
if (wanderer === Wanderer.Vote) {
|
|
200
|
+
return isVoteWandererNow();
|
|
201
|
+
}
|
|
202
|
+
if (wanderer === Wanderer.Familiar) {
|
|
203
|
+
return get("_hipsterAdv") < 7;
|
|
204
|
+
}
|
|
205
|
+
const begin = wanderer + " window begin";
|
|
206
|
+
const end = wanderer + " window end";
|
|
207
|
+
return !haveCounter(begin, 1) && haveCounter(end);
|
|
343
208
|
}
|
|
344
209
|
/**
|
|
345
210
|
* Returns the float chance the player will encounter a sausage goblin on the
|
|
@@ -347,19 +212,15 @@ function isWandererNow(wanderer) {
|
|
|
347
212
|
*
|
|
348
213
|
* @category Wanderers
|
|
349
214
|
*/
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
var turnsSinceLastFight = totalTurns - lastFight;
|
|
362
|
-
return Math.min(1.0, (turnsSinceLastFight + 1) / (5 + fights * 3 + Math.pow(Math.max(0, fights - 5), 3)));
|
|
215
|
+
export function getKramcoWandererChance() {
|
|
216
|
+
const fights = get("_sausageFights");
|
|
217
|
+
const lastFight = get("_lastSausageMonsterTurn");
|
|
218
|
+
const totalTurns = totalTurnsPlayed();
|
|
219
|
+
if (fights < 1) {
|
|
220
|
+
return lastFight === totalTurns && myTurncount() < 1 ? 0.5 : 1.0;
|
|
221
|
+
}
|
|
222
|
+
const turnsSinceLastFight = totalTurns - lastFight;
|
|
223
|
+
return Math.min(1.0, (turnsSinceLastFight + 1) / (5 + fights * 3 + Math.max(0, fights - 5) ** 3));
|
|
363
224
|
}
|
|
364
225
|
/**
|
|
365
226
|
* Returns the float chance the player will encounter an Artistic Goth Kid or
|
|
@@ -371,17 +232,13 @@ function getKramcoWandererChance() {
|
|
|
371
232
|
*
|
|
372
233
|
* @category Wanderers
|
|
373
234
|
*/
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
return probability[totalFights];
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
return totalFights > 7 ? 0.0 : 0.1;
|
|
235
|
+
export function getFamiliarWandererChance() {
|
|
236
|
+
const totalFights = get("_hipsterAdv");
|
|
237
|
+
const probability = [0.5, 0.4, 0.3, 0.2];
|
|
238
|
+
if (totalFights < 4) {
|
|
239
|
+
return probability[totalFights];
|
|
240
|
+
}
|
|
241
|
+
return totalFights > 7 ? 0.0 : 0.1;
|
|
385
242
|
}
|
|
386
243
|
/**
|
|
387
244
|
* Returns the float chance the player will encounter the queried wanderer
|
|
@@ -390,42 +247,32 @@ function getFamiliarWandererChance() {
|
|
|
390
247
|
* @category Wanderers
|
|
391
248
|
* @param wanderer Wanderer to check
|
|
392
249
|
*/
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
250
|
+
export function getWandererChance(wanderer) {
|
|
251
|
+
if (deterministicWanderers.includes(wanderer)) {
|
|
252
|
+
return haveCounter(wanderer, 0, 0) ? 1.0 : 0.0;
|
|
253
|
+
}
|
|
254
|
+
if (wanderer === Wanderer.Kramco) {
|
|
255
|
+
getKramcoWandererChance();
|
|
256
|
+
}
|
|
257
|
+
if (wanderer === Wanderer.Vote) {
|
|
258
|
+
return isVoteWandererNow() ? 1.0 : 0.0;
|
|
259
|
+
}
|
|
260
|
+
if (wanderer === Wanderer.Familiar) {
|
|
261
|
+
getFamiliarWandererChance();
|
|
262
|
+
}
|
|
263
|
+
const begin = wanderer + " window begin";
|
|
264
|
+
const end = wanderer + " window end";
|
|
265
|
+
if (haveCounter(begin, 1, 100)) {
|
|
266
|
+
return 0.0;
|
|
267
|
+
}
|
|
268
|
+
const counters = get("relayCounters");
|
|
269
|
+
const re = new RegExp("(\\d+):" + end);
|
|
270
|
+
const matches = counters.match(re);
|
|
271
|
+
if (matches && matches.length === 2) {
|
|
272
|
+
const window = Number.parseInt(matches[1]) - myTurncount();
|
|
273
|
+
return 1.0 / window;
|
|
274
|
+
}
|
|
416
275
|
return 0.0;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
var counters = (0, _property.get)("relayCounters");
|
|
420
|
-
var re = new RegExp("(\\d+):" + end);
|
|
421
|
-
var matches = counters.match(re);
|
|
422
|
-
|
|
423
|
-
if (matches && matches.length === 2) {
|
|
424
|
-
var window = Number.parseInt(matches[1]) - (0, _kolmafia.myTurncount)();
|
|
425
|
-
return 1.0 / window;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
return 0.0;
|
|
429
276
|
}
|
|
430
277
|
/**
|
|
431
278
|
* Returns true if the player's current familiar is equal to the one supplied
|
|
@@ -433,10 +280,8 @@ function getWandererChance(wanderer) {
|
|
|
433
280
|
* @category General
|
|
434
281
|
* @param familiar Familiar to check
|
|
435
282
|
*/
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
function isCurrentFamiliar(familiar) {
|
|
439
|
-
return (0, _kolmafia.myFamiliar)() === familiar;
|
|
283
|
+
export function isCurrentFamiliar(familiar) {
|
|
284
|
+
return myFamiliar() === familiar;
|
|
440
285
|
}
|
|
441
286
|
/**
|
|
442
287
|
* Returns the fold group (if any) of which the given item is a part
|
|
@@ -444,23 +289,10 @@ function isCurrentFamiliar(familiar) {
|
|
|
444
289
|
* @category General
|
|
445
290
|
* @param item Item that is part of the required fold group
|
|
446
291
|
*/
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
var _ref3 = _slicedToArray(_ref, 2),
|
|
452
|
-
a = _ref3[1];
|
|
453
|
-
|
|
454
|
-
var _ref4 = _slicedToArray(_ref2, 2),
|
|
455
|
-
b = _ref4[1];
|
|
456
|
-
|
|
457
|
-
return a - b;
|
|
458
|
-
}).map(_ref5 => {
|
|
459
|
-
var _ref6 = _slicedToArray(_ref5, 1),
|
|
460
|
-
i = _ref6[0];
|
|
461
|
-
|
|
462
|
-
return Item.get(i);
|
|
463
|
-
});
|
|
292
|
+
export function getFoldGroup(item) {
|
|
293
|
+
return Object.entries(getRelated(item, "fold"))
|
|
294
|
+
.sort(([, a], [, b]) => a - b)
|
|
295
|
+
.map(([i]) => Item.get(i));
|
|
464
296
|
}
|
|
465
297
|
/**
|
|
466
298
|
* Returns the zap group (if any) of which the given item is a part
|
|
@@ -468,44 +300,28 @@ function getFoldGroup(item) {
|
|
|
468
300
|
* @category General
|
|
469
301
|
* @param item Item that is part of the required zap group
|
|
470
302
|
*/
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
function getZapGroup(item) {
|
|
474
|
-
return Object.keys((0, _kolmafia.getRelated)(item, "zap")).map(i => Item.get(i));
|
|
303
|
+
export function getZapGroup(item) {
|
|
304
|
+
return Object.keys(getRelated(item, "zap")).map((i) => Item.get(i));
|
|
475
305
|
}
|
|
476
306
|
/**
|
|
477
307
|
* Get a map of banished monsters keyed by what banished them
|
|
478
308
|
*
|
|
479
309
|
* @category General
|
|
480
310
|
*/
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
foe = _step$value[0],
|
|
494
|
-
banisher = _step$value[1];
|
|
495
|
-
|
|
496
|
-
if (foe === undefined || banisher === undefined) break; // toItem doesn"t error if the item doesn"t exist, so we have to use that.
|
|
497
|
-
|
|
498
|
-
var banisherItem = (0, _kolmafia.toItem)(banisher);
|
|
499
|
-
var banisherObject = [Item.get("none"), null].includes(banisherItem) ? Skill.get(banisher) : banisherItem;
|
|
500
|
-
result.set(banisherObject, Monster.get(foe));
|
|
311
|
+
export function getBanishedMonsters() {
|
|
312
|
+
const banishes = chunk(get("banishedMonsters").split(":"), 3);
|
|
313
|
+
const result = new Map();
|
|
314
|
+
for (const [foe, banisher] of banishes) {
|
|
315
|
+
if (foe === undefined || banisher === undefined)
|
|
316
|
+
break;
|
|
317
|
+
// toItem doesn"t error if the item doesn"t exist, so we have to use that.
|
|
318
|
+
const banisherItem = toItem(banisher);
|
|
319
|
+
const banisherObject = [Item.get("none"), null].includes(banisherItem)
|
|
320
|
+
? Skill.get(banisher)
|
|
321
|
+
: banisherItem;
|
|
322
|
+
result.set(banisherObject, Monster.get(foe));
|
|
501
323
|
}
|
|
502
|
-
|
|
503
|
-
_iterator.e(err);
|
|
504
|
-
} finally {
|
|
505
|
-
_iterator.f();
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
return result;
|
|
324
|
+
return result;
|
|
509
325
|
}
|
|
510
326
|
/**
|
|
511
327
|
* Returns true if the item is usable
|
|
@@ -514,67 +330,54 @@ function getBanishedMonsters() {
|
|
|
514
330
|
*
|
|
515
331
|
* @param item Item to check
|
|
516
332
|
*/
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
333
|
+
export function canUse(item) {
|
|
334
|
+
const path = myPath();
|
|
335
|
+
if (path !== "Nuclear Autumn") {
|
|
336
|
+
if ($items `Shrieking Weasel holo-record, Power-Guy 2000 holo-record, Lucky Strikes holo-record, EMD holo-record, Superdrifter holo-record, The Pigs holo-record, Drunk Uncles holo-record`.includes(item)) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (path === "G-Lover") {
|
|
341
|
+
if (!item.name.toLowerCase().includes("g"))
|
|
342
|
+
return false;
|
|
525
343
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
if (path === "Bees Hate You") {
|
|
533
|
-
if (item.name.toLowerCase().includes("b")) return false;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
return true;
|
|
344
|
+
if (path === "Bees Hate You") {
|
|
345
|
+
if (item.name.toLowerCase().includes("b"))
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
return true;
|
|
537
349
|
}
|
|
538
350
|
/**
|
|
539
351
|
* Turn KoLmafia `none`s to JavaScript `null`s
|
|
540
352
|
*
|
|
541
353
|
* @param thing Thing that can have a mafia "none" value
|
|
542
354
|
*/
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
if (thing instanceof Item) {
|
|
555
|
-
return thing === Item.get("none") ? null : thing;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
return thing;
|
|
355
|
+
export function noneToNull(thing) {
|
|
356
|
+
if (thing instanceof Effect) {
|
|
357
|
+
return thing === Effect.get("none") ? null : thing;
|
|
358
|
+
}
|
|
359
|
+
if (thing instanceof Familiar) {
|
|
360
|
+
return thing === Familiar.get("none") ? null : thing;
|
|
361
|
+
}
|
|
362
|
+
if (thing instanceof Item) {
|
|
363
|
+
return thing === Item.get("none") ? null : thing;
|
|
364
|
+
}
|
|
365
|
+
return thing;
|
|
559
366
|
}
|
|
560
367
|
/**
|
|
561
368
|
* Return the average value from the sort of range that KoLmafia encodes as a string
|
|
562
369
|
*
|
|
563
370
|
* @param range KoLmafia-style range string
|
|
564
371
|
*/
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
lower = _ref8[1],
|
|
575
|
-
upper = _ref8[2];
|
|
576
|
-
|
|
577
|
-
return (Number(lower) + Number(upper)) / 2;
|
|
372
|
+
export function getAverage(range) {
|
|
373
|
+
if (range.indexOf("-") < 0)
|
|
374
|
+
return Number(range);
|
|
375
|
+
const [, lower, upper] = range.match(/(-?[0-9]+)-(-?[0-9]+)/) ?? [
|
|
376
|
+
"0",
|
|
377
|
+
"0",
|
|
378
|
+
"0",
|
|
379
|
+
];
|
|
380
|
+
return (Number(lower) + Number(upper)) / 2;
|
|
578
381
|
}
|
|
579
382
|
/**
|
|
580
383
|
* Return average adventures expected from consuming an item
|
|
@@ -583,10 +386,8 @@ function getAverage(range) {
|
|
|
583
386
|
*
|
|
584
387
|
* @param item Consumable item
|
|
585
388
|
*/
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
function getAverageAdventures(item) {
|
|
589
|
-
return getAverage(item.adventures);
|
|
389
|
+
export function getAverageAdventures(item) {
|
|
390
|
+
return getAverage(item.adventures);
|
|
590
391
|
}
|
|
591
392
|
/**
|
|
592
393
|
* Remove an effect
|
|
@@ -594,24 +395,114 @@ function getAverageAdventures(item) {
|
|
|
594
395
|
* @category General
|
|
595
396
|
* @param effect Effect to remove
|
|
596
397
|
*/
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
function uneffect(effect) {
|
|
600
|
-
return (0, _kolmafia.cliExecute)("uneffect ".concat(effect.name));
|
|
398
|
+
export function uneffect(effect) {
|
|
399
|
+
return cliExecute(`uneffect ${effect.name}`);
|
|
601
400
|
}
|
|
602
|
-
|
|
603
401
|
/**
|
|
604
402
|
* Get both the name and id of a player from either their name or id
|
|
605
403
|
*
|
|
606
404
|
* @param idOrName Id or name of player
|
|
607
405
|
* @returns Object containing id and name of player
|
|
608
406
|
*/
|
|
609
|
-
function getPlayerFromIdOrName(idOrName) {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
407
|
+
export function getPlayerFromIdOrName(idOrName) {
|
|
408
|
+
const id = typeof idOrName === "number" ? idOrName : parseInt(getPlayerId(idOrName));
|
|
409
|
+
return {
|
|
410
|
+
name: getPlayerName(id),
|
|
411
|
+
id: id,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Return the step as a number for a given quest property.
|
|
416
|
+
*
|
|
417
|
+
* @param questName Name of quest property to check.
|
|
418
|
+
*/
|
|
419
|
+
export function questStep(questName) {
|
|
420
|
+
const stringStep = get(questName);
|
|
421
|
+
if (stringStep === "unstarted")
|
|
422
|
+
return -1;
|
|
423
|
+
else if (stringStep === "started")
|
|
424
|
+
return 0;
|
|
425
|
+
else if (stringStep === "finished" || stringStep === "")
|
|
426
|
+
return 999;
|
|
427
|
+
else {
|
|
428
|
+
if (stringStep.substring(0, 4) !== "step") {
|
|
429
|
+
throw new Error("Quest state parsing error.");
|
|
430
|
+
}
|
|
431
|
+
return parseInt(stringStep.substring(4), 10);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
export class EnsureError extends Error {
|
|
435
|
+
constructor(cause) {
|
|
436
|
+
super(`Failed to ensure ${cause.name}!`);
|
|
437
|
+
this.name = "Ensure Error";
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Tries to get an effect using the default method
|
|
442
|
+
* @param ef effect to try to get
|
|
443
|
+
* @param turns turns to aim for; default of 1
|
|
444
|
+
*/
|
|
445
|
+
export function ensureEffect(ef, turns = 1) {
|
|
446
|
+
if (haveEffect(ef) < turns) {
|
|
447
|
+
if (!cliExecute(ef.default) || haveEffect(ef) === 0) {
|
|
448
|
+
throw new EnsureError(ef);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
const valueMap = new Map();
|
|
453
|
+
const MALL_VALUE_MODIFIER = 0.9;
|
|
454
|
+
/**
|
|
455
|
+
* Returns the average value--based on mallprice and autosell--of a collection of items
|
|
456
|
+
* @param items items whose value you care about
|
|
457
|
+
*/
|
|
458
|
+
export function getSaleValue(...items) {
|
|
459
|
+
return (items
|
|
460
|
+
.map((item) => {
|
|
461
|
+
if (valueMap.has(item))
|
|
462
|
+
return valueMap.get(item) || 0;
|
|
463
|
+
if (item.discardable) {
|
|
464
|
+
valueMap.set(item, mallPrice(item) > Math.max(2 * autosellPrice(item), 100)
|
|
465
|
+
? MALL_VALUE_MODIFIER * mallPrice(item)
|
|
466
|
+
: autosellPrice(item));
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
valueMap.set(item, mallPrice(item) > 100 ? MALL_VALUE_MODIFIER * mallPrice(item) : 0);
|
|
470
|
+
}
|
|
471
|
+
return valueMap.get(item) || 0;
|
|
472
|
+
})
|
|
473
|
+
.reduce((s, price) => s + price, 0) / items.length);
|
|
474
|
+
}
|
|
475
|
+
export const Environment = {
|
|
476
|
+
Outdoor: "outdoor",
|
|
477
|
+
Indoor: "indoor",
|
|
478
|
+
Underground: "underground",
|
|
479
|
+
Underwater: "underwater",
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* Returns the weight-coefficient of any leprechaunning that this familiar may find itself doing
|
|
483
|
+
* Assumes the familiar is nude and thus fails for hatrack & pantsrack
|
|
484
|
+
* For the Mutant Cactus Bud, returns the efficacy-multiplier instead
|
|
485
|
+
* @param familiar The familiar whose leprechaun multiplier you're interested in
|
|
486
|
+
*/
|
|
487
|
+
export function findLeprechaunMultiplier(familiar) {
|
|
488
|
+
if (familiar === $familiar `Mutant Cactus Bud`)
|
|
489
|
+
return numericModifier(familiar, "Leprechaun Effectiveness", 1, $item `none`);
|
|
490
|
+
const meatBonus = numericModifier(familiar, "Meat Drop", 1, $item `none`);
|
|
491
|
+
if (meatBonus === 0)
|
|
492
|
+
return 0;
|
|
493
|
+
return Math.pow(Math.sqrt(meatBonus / 2 + 55 / 4 + 3) - Math.sqrt(55) / 2, 2);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Returns the weight-coefficient of any baby gravy fairying that this familiar may find itself doing
|
|
497
|
+
* Assumes the familiar is nude and thus fails for hatrack & pantsrack
|
|
498
|
+
* For the Mutant Fire Ant, returns the efficacy-multiplier instead
|
|
499
|
+
* @param familiar The familiar whose fairy multiplier you're interested in
|
|
500
|
+
*/
|
|
501
|
+
export function findFairyMultiplier(familiar) {
|
|
502
|
+
if (familiar === $familiar `Mutant Fire Ant`)
|
|
503
|
+
return numericModifier(familiar, "Fairy Effectiveness", 1, $item `none`);
|
|
504
|
+
const itemBonus = numericModifier(familiar, "Item Drop", 1, $item `none`);
|
|
505
|
+
if (itemBonus === 0)
|
|
506
|
+
return 0;
|
|
507
|
+
return Math.pow(Math.sqrt(itemBonus + 55 / 4 + 3) - Math.sqrt(55) / 2, 2);
|
|
508
|
+
}
|