libram 0.4.1 → 0.4.5
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 +271 -485
- package/dist/Copier.js +15 -48
- package/dist/Dungeon.js +77 -157
- package/dist/Kmail.d.ts +3 -1
- package/dist/Kmail.js +99 -244
- package/dist/Path.js +77 -120
- package/dist/ascend.js +153 -172
- package/dist/combat.d.ts +98 -3
- package/dist/combat.js +349 -387
- package/dist/console.js +13 -36
- package/dist/diet/index.d.ts +32 -8
- package/dist/diet/index.js +420 -426
- package/dist/diet/knapsack.d.ts +1 -1
- package/dist/diet/knapsack.js +104 -100
- 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 +16 -4
- package/dist/freerun.js +92 -99
- package/dist/index.d.ts +5 -1
- package/dist/index.js +22 -300
- package/dist/lib.d.ts +4 -0
- package/dist/lib.js +284 -515
- package/dist/logger.js +21 -63
- package/dist/maximize.js +289 -562
- package/dist/modifier.js +35 -46
- package/dist/modifierTypes.js +8 -22
- package/dist/mood.d.ts +5 -0
- package/dist/mood.js +268 -551
- package/dist/property.d.ts +2 -0
- package/dist/property.js +100 -242
- package/dist/propertyTypes.d.ts +5 -4
- package/dist/propertyTypes.js +1 -0
- package/dist/propertyTyping.d.ts +4 -3
- package/dist/propertyTyping.js +52 -59
- 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 +9 -0
- package/dist/resources/2010/CrownOfThrones.js +550 -374
- 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 +1 -0
- package/dist/resources/2013/Florist.js +142 -207
- package/dist/resources/2013/PulledTaffy.d.ts +9 -0
- package/dist/resources/2013/PulledTaffy.js +33 -0
- package/dist/resources/2014/DNALab.d.ts +47 -0
- package/dist/resources/2014/DNALab.js +154 -0
- package/dist/resources/2014/WinterGarden.js +15 -43
- package/dist/resources/2015/ChateauMantegna.js +52 -86
- package/dist/resources/2015/MayoClinic.d.ts +3 -0
- package/dist/resources/2015/MayoClinic.js +36 -65
- 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/AsdonMartin.d.ts +27 -0
- package/dist/resources/2017/AsdonMartin.js +80 -0
- package/dist/resources/2017/TunnelOfLove.js +62 -111
- package/dist/resources/2018/SongBoom.js +32 -68
- package/dist/resources/2019/BeachComb.js +26 -44
- package/dist/resources/2019/Snapper.d.ts +28 -0
- package/dist/resources/2019/Snapper.js +69 -0
- package/dist/resources/2020/Guzzlr.d.ts +3 -0
- package/dist/resources/2020/Guzzlr.js +92 -163
- package/dist/resources/LibramSummon.d.ts +12 -0
- package/dist/resources/LibramSummon.js +66 -0
- package/dist/resources/index.d.ts +5 -1
- package/dist/resources/index.js +21 -105
- package/dist/resources/putty-likes.js +15 -30
- 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 +5 -0
- package/dist/utils.js +47 -134
- package/package.json +15 -9
package/dist/lib.js
CHANGED
|
@@ -1,135 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.description.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.reflect.construct.js");
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "__esModule", {
|
|
12
|
-
value: true
|
|
13
|
-
});
|
|
14
|
-
exports.getSongLimit = getSongLimit;
|
|
15
|
-
exports.isSong = isSong;
|
|
16
|
-
exports.getActiveEffects = getActiveEffects;
|
|
17
|
-
exports.getActiveSongs = getActiveSongs;
|
|
18
|
-
exports.getSongCount = getSongCount;
|
|
19
|
-
exports.canRememberSong = canRememberSong;
|
|
20
|
-
exports.getMonsterLocations = getMonsterLocations;
|
|
21
|
-
exports.getRemainingLiver = getRemainingLiver;
|
|
22
|
-
exports.getRemainingStomach = getRemainingStomach;
|
|
23
|
-
exports.getRemainingSpleen = getRemainingSpleen;
|
|
24
|
-
exports.have = have;
|
|
25
|
-
exports.haveInCampground = haveInCampground;
|
|
26
|
-
exports.haveCounter = haveCounter;
|
|
27
|
-
exports.haveWandererCounter = haveWandererCounter;
|
|
28
|
-
exports.isVoteWandererNow = isVoteWandererNow;
|
|
29
|
-
exports.isWandererNow = isWandererNow;
|
|
30
|
-
exports.getKramcoWandererChance = getKramcoWandererChance;
|
|
31
|
-
exports.getFamiliarWandererChance = getFamiliarWandererChance;
|
|
32
|
-
exports.getWandererChance = getWandererChance;
|
|
33
|
-
exports.isCurrentFamiliar = isCurrentFamiliar;
|
|
34
|
-
exports.getFoldGroup = getFoldGroup;
|
|
35
|
-
exports.getZapGroup = getZapGroup;
|
|
36
|
-
exports.getBanishedMonsters = getBanishedMonsters;
|
|
37
|
-
exports.canUse = canUse;
|
|
38
|
-
exports.noneToNull = noneToNull;
|
|
39
|
-
exports.getAverage = getAverage;
|
|
40
|
-
exports.getAverageAdventures = getAverageAdventures;
|
|
41
|
-
exports.uneffect = uneffect;
|
|
42
|
-
exports.getPlayerFromIdOrName = getPlayerFromIdOrName;
|
|
43
|
-
exports.questStep = questStep;
|
|
44
|
-
exports.ensureEffect = ensureEffect;
|
|
45
|
-
exports.getSaleValue = getSaleValue;
|
|
46
|
-
exports.findLeprechaunMultiplier = findLeprechaunMultiplier;
|
|
47
|
-
exports.findFairyMultiplier = findFairyMultiplier;
|
|
48
|
-
exports.Environment = exports.EnsureError = exports.Wanderer = void 0;
|
|
49
|
-
|
|
50
|
-
require("core-js/modules/es.array.map.js");
|
|
51
|
-
|
|
52
|
-
require("core-js/modules/es.array.filter.js");
|
|
53
|
-
|
|
54
|
-
require("core-js/modules/es.array.includes.js");
|
|
55
|
-
|
|
56
|
-
require("core-js/modules/es.string.includes.js");
|
|
57
|
-
|
|
58
|
-
require("core-js/modules/es.regexp.constructor.js");
|
|
59
|
-
|
|
60
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
61
|
-
|
|
62
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
63
|
-
|
|
64
|
-
require("core-js/modules/es.string.match.js");
|
|
65
|
-
|
|
66
|
-
require("core-js/modules/es.number.parse-int.js");
|
|
67
|
-
|
|
68
|
-
require("core-js/modules/es.array.sort.js");
|
|
69
|
-
|
|
70
|
-
require("core-js/modules/es.object.entries.js");
|
|
71
|
-
|
|
72
|
-
require("core-js/modules/es.string.split.js");
|
|
73
|
-
|
|
74
|
-
require("core-js/modules/es.array.iterator.js");
|
|
75
|
-
|
|
76
|
-
require("core-js/modules/es.object.to-string.js");
|
|
77
|
-
|
|
78
|
-
var _kolmafia = require("kolmafia");
|
|
79
|
-
|
|
80
|
-
var _templateString = require("./template-string");
|
|
81
|
-
|
|
82
|
-
var _property = require("./property");
|
|
83
|
-
|
|
84
|
-
var _utils = require("./utils");
|
|
85
|
-
|
|
86
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
87
|
-
|
|
88
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
89
|
-
|
|
90
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
91
|
-
|
|
92
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
93
|
-
|
|
94
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
95
|
-
|
|
96
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
97
|
-
|
|
98
|
-
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
99
|
-
|
|
100
|
-
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
101
|
-
|
|
102
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
103
|
-
|
|
104
|
-
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
105
|
-
|
|
106
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
107
|
-
|
|
108
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
109
|
-
|
|
110
|
-
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; } } }; }
|
|
111
|
-
|
|
112
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
113
|
-
|
|
114
|
-
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."); }
|
|
115
|
-
|
|
116
|
-
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); }
|
|
117
|
-
|
|
118
|
-
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; }
|
|
119
|
-
|
|
120
|
-
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; }
|
|
121
|
-
|
|
122
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
123
|
-
|
|
124
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
125
|
-
|
|
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, holiday, inebrietyLimit, mallPrice, myEffects, myFamiliar, myFullness, myInebriety, myPath, mySpleenUse, myThrall, myTurncount, numericModifier, spleenLimit, toItem, toSkill, totalTurnsPlayed, } from "kolmafia";
|
|
4
|
+
import { $class, $familiar, $item, $items, $monsters } from "./template-string";
|
|
5
|
+
import { get } from "./property";
|
|
6
|
+
import { chunk } from "./utils";
|
|
126
7
|
/**
|
|
127
8
|
* Returns the current maximum Accordion Thief songs the player can have in their head
|
|
128
9
|
*
|
|
129
10
|
* @category General
|
|
130
11
|
*/
|
|
131
|
-
function getSongLimit() {
|
|
132
|
-
|
|
12
|
+
export function getSongLimit() {
|
|
13
|
+
return (3 +
|
|
14
|
+
(booleanModifier("Four Songs") ? 1 : 0) +
|
|
15
|
+
numericModifier("Additional Song"));
|
|
133
16
|
}
|
|
134
17
|
/**
|
|
135
18
|
* Return whether the Skill or Effect provided is an Accordion Thief song
|
|
@@ -137,41 +20,33 @@ function getSongLimit() {
|
|
|
137
20
|
* @category General
|
|
138
21
|
* @param skillOrEffect The Skill or Effect
|
|
139
22
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var skill = skillOrEffect instanceof Effect ? (0, _kolmafia.toSkill)(skillOrEffect) : skillOrEffect;
|
|
144
|
-
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;
|
|
145
26
|
}
|
|
146
27
|
/**
|
|
147
28
|
* List all active Effects
|
|
148
29
|
*
|
|
149
30
|
* @category General
|
|
150
31
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
function getActiveEffects() {
|
|
154
|
-
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));
|
|
155
34
|
}
|
|
156
35
|
/**
|
|
157
36
|
* List currently active Accordion Thief songs
|
|
158
37
|
*
|
|
159
38
|
* @category General
|
|
160
39
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
function getActiveSongs() {
|
|
164
|
-
return getActiveEffects().filter(isSong);
|
|
40
|
+
export function getActiveSongs() {
|
|
41
|
+
return getActiveEffects().filter(isSong);
|
|
165
42
|
}
|
|
166
43
|
/**
|
|
167
44
|
* List number of active Accordion Thief songs
|
|
168
45
|
*
|
|
169
46
|
* @category General
|
|
170
47
|
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
function getSongCount() {
|
|
174
|
-
return getActiveSongs().length;
|
|
48
|
+
export function getSongCount() {
|
|
49
|
+
return getActiveSongs().length;
|
|
175
50
|
}
|
|
176
51
|
/**
|
|
177
52
|
* Returns true if the player can remember another Accordion Thief song
|
|
@@ -179,11 +54,8 @@ function getSongCount() {
|
|
|
179
54
|
* @category General
|
|
180
55
|
* @param quantity Number of songs to test the space for
|
|
181
56
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
function canRememberSong() {
|
|
185
|
-
var quantity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
186
|
-
return getSongLimit() - getSongCount() >= quantity;
|
|
57
|
+
export function canRememberSong(quantity = 1) {
|
|
58
|
+
return getSongLimit() - getSongCount() >= quantity;
|
|
187
59
|
}
|
|
188
60
|
/**
|
|
189
61
|
* Return the locations in which the given monster can be encountered naturally
|
|
@@ -191,40 +63,32 @@ function canRememberSong() {
|
|
|
191
63
|
* @category General
|
|
192
64
|
* @param monster Monster to find
|
|
193
65
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
function getMonsterLocations(monster) {
|
|
197
|
-
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));
|
|
198
68
|
}
|
|
199
69
|
/**
|
|
200
70
|
* Return the player's remaining liver space
|
|
201
71
|
*
|
|
202
72
|
* @category General
|
|
203
73
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
function getRemainingLiver() {
|
|
207
|
-
return (0, _kolmafia.inebrietyLimit)() - (0, _kolmafia.myInebriety)();
|
|
74
|
+
export function getRemainingLiver() {
|
|
75
|
+
return inebrietyLimit() - myInebriety();
|
|
208
76
|
}
|
|
209
77
|
/**
|
|
210
78
|
* Return the player's remaining stomach space
|
|
211
79
|
*
|
|
212
80
|
* @category General
|
|
213
81
|
*/
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
function getRemainingStomach() {
|
|
217
|
-
return (0, _kolmafia.fullnessLimit)() - (0, _kolmafia.myFullness)();
|
|
82
|
+
export function getRemainingStomach() {
|
|
83
|
+
return fullnessLimit() - myFullness();
|
|
218
84
|
}
|
|
219
85
|
/**
|
|
220
86
|
* Return the player's remaining spleen space
|
|
221
87
|
*
|
|
222
88
|
* @category General
|
|
223
89
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
function getRemainingSpleen() {
|
|
227
|
-
return (0, _kolmafia.spleenLimit)() - (0, _kolmafia.mySpleenUse)();
|
|
90
|
+
export function getRemainingSpleen() {
|
|
91
|
+
return spleenLimit() - mySpleenUse();
|
|
228
92
|
}
|
|
229
93
|
/**
|
|
230
94
|
* Return whether the player "has" any entity which one could feasibly "have".
|
|
@@ -233,37 +97,27 @@ function getRemainingSpleen() {
|
|
|
233
97
|
* @param thing Thing to check
|
|
234
98
|
* @param quantity Number to check that the player has
|
|
235
99
|
*/
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
if (thing instanceof Skill) {
|
|
258
|
-
return (0, _kolmafia.haveSkill)(thing);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (thing instanceof Thrall) {
|
|
262
|
-
var thrall = (0, _kolmafia.myThrall)();
|
|
263
|
-
return thrall.id === thing.id && thrall.level >= quantity;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
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;
|
|
267
121
|
}
|
|
268
122
|
/**
|
|
269
123
|
* Return whether an item is in the player's campground
|
|
@@ -271,54 +125,44 @@ function have(thing) {
|
|
|
271
125
|
* @category General
|
|
272
126
|
* @param item The item mafia uses to represent the campground item
|
|
273
127
|
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
128
|
+
export function haveInCampground(item) {
|
|
129
|
+
return Object.keys(getCampground())
|
|
130
|
+
.map((i) => Item.get(i))
|
|
131
|
+
.includes(item);
|
|
278
132
|
}
|
|
279
|
-
|
|
280
|
-
var Wanderer;
|
|
281
|
-
exports.Wanderer = Wanderer;
|
|
282
|
-
|
|
133
|
+
export var Wanderer;
|
|
283
134
|
(function (Wanderer) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
})(Wanderer || (
|
|
294
|
-
|
|
295
|
-
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];
|
|
296
146
|
/**
|
|
297
147
|
* Return whether the player has the queried counter
|
|
298
148
|
*
|
|
299
149
|
* @category General
|
|
300
150
|
*/
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
var minTurns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
304
|
-
var maxTurns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
|
|
305
|
-
return (0, _kolmafia.getCounters)(counterName, minTurns, maxTurns) === counterName;
|
|
151
|
+
export function haveCounter(counterName, minTurns = 0, maxTurns = 500) {
|
|
152
|
+
return getCounters(counterName, minTurns, maxTurns) === counterName;
|
|
306
153
|
}
|
|
307
154
|
/**
|
|
308
155
|
* Return whether the player has the queried wandering counter
|
|
309
156
|
*
|
|
310
157
|
* @category Wanderers
|
|
311
158
|
*/
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
var begin = wanderer + " window begin";
|
|
320
|
-
var end = wanderer + " window end";
|
|
321
|
-
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);
|
|
322
166
|
}
|
|
323
167
|
/**
|
|
324
168
|
* Returns whether the player will encounter a vote wanderer on the next turn,
|
|
@@ -326,10 +170,8 @@ function haveWandererCounter(wanderer) {
|
|
|
326
170
|
*
|
|
327
171
|
* @category Wanderers
|
|
328
172
|
*/
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
function isVoteWandererNow() {
|
|
332
|
-
return (0, _kolmafia.totalTurnsPlayed)() % 11 == 1;
|
|
173
|
+
export function isVoteWandererNow() {
|
|
174
|
+
return totalTurnsPlayed() % 11 == 1;
|
|
333
175
|
}
|
|
334
176
|
/**
|
|
335
177
|
* Tells us whether we can expect a given wanderer now. Behaves differently
|
|
@@ -347,28 +189,22 @@ function isVoteWandererNow() {
|
|
|
347
189
|
* @category Wanderers
|
|
348
190
|
* @param wanderer Wanderer to check
|
|
349
191
|
*/
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
return (0, _property.get)("_hipsterAdv") < 7;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
var begin = wanderer + " window begin";
|
|
370
|
-
var end = wanderer + " window end";
|
|
371
|
-
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);
|
|
372
208
|
}
|
|
373
209
|
/**
|
|
374
210
|
* Returns the float chance the player will encounter a sausage goblin on the
|
|
@@ -376,19 +212,15 @@ function isWandererNow(wanderer) {
|
|
|
376
212
|
*
|
|
377
213
|
* @category Wanderers
|
|
378
214
|
*/
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
var turnsSinceLastFight = totalTurns - lastFight;
|
|
391
|
-
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));
|
|
392
224
|
}
|
|
393
225
|
/**
|
|
394
226
|
* Returns the float chance the player will encounter an Artistic Goth Kid or
|
|
@@ -400,17 +232,13 @@ function getKramcoWandererChance() {
|
|
|
400
232
|
*
|
|
401
233
|
* @category Wanderers
|
|
402
234
|
*/
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
return probability[totalFights];
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
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;
|
|
414
242
|
}
|
|
415
243
|
/**
|
|
416
244
|
* Returns the float chance the player will encounter the queried wanderer
|
|
@@ -419,42 +247,32 @@ function getFamiliarWandererChance() {
|
|
|
419
247
|
* @category Wanderers
|
|
420
248
|
* @param wanderer Wanderer to check
|
|
421
249
|
*/
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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
|
+
}
|
|
445
275
|
return 0.0;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
var counters = (0, _property.get)("relayCounters");
|
|
449
|
-
var re = new RegExp("(\\d+):" + end);
|
|
450
|
-
var matches = counters.match(re);
|
|
451
|
-
|
|
452
|
-
if (matches && matches.length === 2) {
|
|
453
|
-
var window = Number.parseInt(matches[1]) - (0, _kolmafia.myTurncount)();
|
|
454
|
-
return 1.0 / window;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
return 0.0;
|
|
458
276
|
}
|
|
459
277
|
/**
|
|
460
278
|
* Returns true if the player's current familiar is equal to the one supplied
|
|
@@ -462,10 +280,8 @@ function getWandererChance(wanderer) {
|
|
|
462
280
|
* @category General
|
|
463
281
|
* @param familiar Familiar to check
|
|
464
282
|
*/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
function isCurrentFamiliar(familiar) {
|
|
468
|
-
return (0, _kolmafia.myFamiliar)() === familiar;
|
|
283
|
+
export function isCurrentFamiliar(familiar) {
|
|
284
|
+
return myFamiliar() === familiar;
|
|
469
285
|
}
|
|
470
286
|
/**
|
|
471
287
|
* Returns the fold group (if any) of which the given item is a part
|
|
@@ -473,23 +289,10 @@ function isCurrentFamiliar(familiar) {
|
|
|
473
289
|
* @category General
|
|
474
290
|
* @param item Item that is part of the required fold group
|
|
475
291
|
*/
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
var _ref3 = _slicedToArray(_ref, 2),
|
|
481
|
-
a = _ref3[1];
|
|
482
|
-
|
|
483
|
-
var _ref4 = _slicedToArray(_ref2, 2),
|
|
484
|
-
b = _ref4[1];
|
|
485
|
-
|
|
486
|
-
return a - b;
|
|
487
|
-
}).map(_ref5 => {
|
|
488
|
-
var _ref6 = _slicedToArray(_ref5, 1),
|
|
489
|
-
i = _ref6[0];
|
|
490
|
-
|
|
491
|
-
return Item.get(i);
|
|
492
|
-
});
|
|
292
|
+
export function getFoldGroup(item) {
|
|
293
|
+
return Object.entries(getRelated(item, "fold"))
|
|
294
|
+
.sort(([, a], [, b]) => a - b)
|
|
295
|
+
.map(([i]) => Item.get(i));
|
|
493
296
|
}
|
|
494
297
|
/**
|
|
495
298
|
* Returns the zap group (if any) of which the given item is a part
|
|
@@ -497,44 +300,28 @@ function getFoldGroup(item) {
|
|
|
497
300
|
* @category General
|
|
498
301
|
* @param item Item that is part of the required zap group
|
|
499
302
|
*/
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
function getZapGroup(item) {
|
|
503
|
-
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));
|
|
504
305
|
}
|
|
505
306
|
/**
|
|
506
307
|
* Get a map of banished monsters keyed by what banished them
|
|
507
308
|
*
|
|
508
309
|
* @category General
|
|
509
310
|
*/
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
foe = _step$value[0],
|
|
523
|
-
banisher = _step$value[1];
|
|
524
|
-
|
|
525
|
-
if (foe === undefined || banisher === undefined) break; // toItem doesn"t error if the item doesn"t exist, so we have to use that.
|
|
526
|
-
|
|
527
|
-
var banisherItem = (0, _kolmafia.toItem)(banisher);
|
|
528
|
-
var banisherObject = [Item.get("none"), null].includes(banisherItem) ? Skill.get(banisher) : banisherItem;
|
|
529
|
-
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));
|
|
530
323
|
}
|
|
531
|
-
|
|
532
|
-
_iterator.e(err);
|
|
533
|
-
} finally {
|
|
534
|
-
_iterator.f();
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
return result;
|
|
324
|
+
return result;
|
|
538
325
|
}
|
|
539
326
|
/**
|
|
540
327
|
* Returns true if the item is usable
|
|
@@ -543,67 +330,54 @@ function getBanishedMonsters() {
|
|
|
543
330
|
*
|
|
544
331
|
* @param item Item to check
|
|
545
332
|
*/
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
if ((0, _templateString.$items)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["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)) {
|
|
553
|
-
return false;
|
|
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
|
+
}
|
|
554
339
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
return true;
|
|
340
|
+
if (path === "G-Lover") {
|
|
341
|
+
if (!item.name.toLowerCase().includes("g"))
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
if (path === "Bees Hate You") {
|
|
345
|
+
if (item.name.toLowerCase().includes("b"))
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
return true;
|
|
566
349
|
}
|
|
567
350
|
/**
|
|
568
351
|
* Turn KoLmafia `none`s to JavaScript `null`s
|
|
569
352
|
*
|
|
570
353
|
* @param thing Thing that can have a mafia "none" value
|
|
571
354
|
*/
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
if (thing instanceof Item) {
|
|
584
|
-
return thing === Item.get("none") ? null : thing;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
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;
|
|
588
366
|
}
|
|
589
367
|
/**
|
|
590
368
|
* Return the average value from the sort of range that KoLmafia encodes as a string
|
|
591
369
|
*
|
|
592
370
|
* @param range KoLmafia-style range string
|
|
593
371
|
*/
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
lower = _ref8[1],
|
|
604
|
-
upper = _ref8[2];
|
|
605
|
-
|
|
606
|
-
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;
|
|
607
381
|
}
|
|
608
382
|
/**
|
|
609
383
|
* Return average adventures expected from consuming an item
|
|
@@ -612,10 +386,8 @@ function getAverage(range) {
|
|
|
612
386
|
*
|
|
613
387
|
* @param item Consumable item
|
|
614
388
|
*/
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
function getAverageAdventures(item) {
|
|
618
|
-
return getAverage(item.adventures);
|
|
389
|
+
export function getAverageAdventures(item) {
|
|
390
|
+
return getAverage(item.adventures);
|
|
619
391
|
}
|
|
620
392
|
/**
|
|
621
393
|
* Remove an effect
|
|
@@ -623,125 +395,102 @@ function getAverageAdventures(item) {
|
|
|
623
395
|
* @category General
|
|
624
396
|
* @param effect Effect to remove
|
|
625
397
|
*/
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
function uneffect(effect) {
|
|
629
|
-
return (0, _kolmafia.cliExecute)("uneffect ".concat(effect.name));
|
|
398
|
+
export function uneffect(effect) {
|
|
399
|
+
return cliExecute(`uneffect ${effect.name}`);
|
|
630
400
|
}
|
|
631
|
-
|
|
632
401
|
/**
|
|
633
402
|
* Get both the name and id of a player from either their name or id
|
|
634
403
|
*
|
|
635
404
|
* @param idOrName Id or name of player
|
|
636
405
|
* @returns Object containing id and name of player
|
|
637
406
|
*/
|
|
638
|
-
function getPlayerFromIdOrName(idOrName) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
id: idOrName
|
|
645
|
-
};
|
|
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
|
+
};
|
|
646
413
|
}
|
|
647
414
|
/**
|
|
648
415
|
* Return the step as a number for a given quest property.
|
|
649
416
|
*
|
|
650
417
|
* @param questName Name of quest property to check.
|
|
651
418
|
*/
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
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";
|
|
659
438
|
}
|
|
660
|
-
|
|
661
|
-
return parseInt(stringStep.substring(4), 10);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
var EnsureError = /*#__PURE__*/function (_Error) {
|
|
666
|
-
_inherits(EnsureError, _Error);
|
|
667
|
-
|
|
668
|
-
var _super = _createSuper(EnsureError);
|
|
669
|
-
|
|
670
|
-
function EnsureError(cause) {
|
|
671
|
-
var _this;
|
|
672
|
-
|
|
673
|
-
_classCallCheck(this, EnsureError);
|
|
674
|
-
|
|
675
|
-
_this = _super.call(this, "Failed to ensure ".concat(cause.name, "!"));
|
|
676
|
-
_this.name = "Ensure Error";
|
|
677
|
-
return _this;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
return EnsureError;
|
|
681
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
439
|
+
}
|
|
682
440
|
/**
|
|
683
441
|
* Tries to get an effect using the default method
|
|
684
442
|
* @param ef effect to try to get
|
|
685
443
|
* @param turns turns to aim for; default of 1
|
|
686
444
|
*/
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
var turns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
693
|
-
|
|
694
|
-
if ((0, _kolmafia.haveEffect)(ef) < turns) {
|
|
695
|
-
if (!(0, _kolmafia.cliExecute)(ef.default) || (0, _kolmafia.haveEffect)(ef) === 0) {
|
|
696
|
-
throw new EnsureError(ef);
|
|
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
|
+
}
|
|
697
450
|
}
|
|
698
|
-
}
|
|
699
451
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
var MALL_VALUE_MODIFIER = 0.9;
|
|
452
|
+
const valueMap = new Map();
|
|
453
|
+
const MALL_VALUE_MODIFIER = 0.9;
|
|
703
454
|
/**
|
|
704
455
|
* Returns the average value--based on mallprice and autosell--of a collection of items
|
|
705
456
|
* @param items items whose value you care about
|
|
706
457
|
*/
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
Underground: "underground",
|
|
730
|
-
Underwater: "underwater"
|
|
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",
|
|
731
480
|
};
|
|
732
|
-
exports.Environment = Environment;
|
|
733
|
-
|
|
734
481
|
/**
|
|
735
482
|
* Returns the weight-coefficient of any leprechaunning that this familiar may find itself doing
|
|
736
483
|
* Assumes the familiar is nude and thus fails for hatrack & pantsrack
|
|
737
484
|
* For the Mutant Cactus Bud, returns the efficacy-multiplier instead
|
|
738
485
|
* @param familiar The familiar whose leprechaun multiplier you're interested in
|
|
739
486
|
*/
|
|
740
|
-
function findLeprechaunMultiplier(familiar) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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);
|
|
745
494
|
}
|
|
746
495
|
/**
|
|
747
496
|
* Returns the weight-coefficient of any baby gravy fairying that this familiar may find itself doing
|
|
@@ -749,11 +498,31 @@ function findLeprechaunMultiplier(familiar) {
|
|
|
749
498
|
* For the Mutant Fire Ant, returns the efficacy-multiplier instead
|
|
750
499
|
* @param familiar The familiar whose fairy multiplier you're interested in
|
|
751
500
|
*/
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
}
|
|
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
|
+
}
|
|
509
|
+
export const holidayWanderers = new Map([
|
|
510
|
+
[
|
|
511
|
+
"El Dia De Los Muertos Borrachos",
|
|
512
|
+
$monsters `Novia Cadáver, Novio Cadáver, Padre Cadáver, Persona Inocente Cadáver`,
|
|
513
|
+
],
|
|
514
|
+
[
|
|
515
|
+
"Feast of Boris",
|
|
516
|
+
$monsters `Candied Yam Golem, Malevolent Tofurkey, Possessed Can of Cranberry Sauce, Stuffing Golem`,
|
|
517
|
+
],
|
|
518
|
+
[
|
|
519
|
+
"Talk Like a Pirate Day",
|
|
520
|
+
$monsters `ambulatory pirate, migratory pirate, peripatetic pirate`,
|
|
521
|
+
],
|
|
522
|
+
]);
|
|
523
|
+
export function getTodaysHolidayWanderers() {
|
|
524
|
+
return holiday()
|
|
525
|
+
.split("/")
|
|
526
|
+
.map((holiday) => holidayWanderers.get(holiday) ?? [])
|
|
527
|
+
.flat();
|
|
528
|
+
}
|