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/Kmail.js
CHANGED
|
@@ -1,181 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
exports.default = void 0;
|
|
13
|
-
|
|
14
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
15
|
-
|
|
16
|
-
require("core-js/modules/es.string.match.js");
|
|
17
|
-
|
|
18
|
-
require("core-js/modules/es.array.iterator.js");
|
|
19
|
-
|
|
20
|
-
require("core-js/modules/es.object.to-string.js");
|
|
21
|
-
|
|
22
|
-
require("core-js/modules/es.array.map.js");
|
|
23
|
-
|
|
24
|
-
require("core-js/modules/es.object.entries.js");
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.array.filter.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.array.concat.js");
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.array.includes.js");
|
|
31
|
-
|
|
32
|
-
require("core-js/modules/es.string.includes.js");
|
|
33
|
-
|
|
34
|
-
var _kolmafia = require("kolmafia");
|
|
35
|
-
|
|
36
|
-
var _utils = require("./utils");
|
|
37
|
-
|
|
38
|
-
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; } } }; }
|
|
39
|
-
|
|
40
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
41
|
-
|
|
42
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
43
|
-
|
|
44
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
45
|
-
|
|
46
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
47
|
-
|
|
48
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
49
|
-
|
|
50
|
-
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."); }
|
|
51
|
-
|
|
52
|
-
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); }
|
|
53
|
-
|
|
54
|
-
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; }
|
|
55
|
-
|
|
56
|
-
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; }
|
|
57
|
-
|
|
58
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
59
|
-
|
|
60
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
61
|
-
|
|
62
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
63
|
-
|
|
64
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
65
|
-
|
|
66
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
67
|
-
|
|
68
|
-
var Kmail = /*#__PURE__*/function () {
|
|
69
|
-
function Kmail(rawKmail) {
|
|
70
|
-
_classCallCheck(this, Kmail);
|
|
71
|
-
|
|
72
|
-
_defineProperty(this, "id", void 0);
|
|
73
|
-
|
|
74
|
-
_defineProperty(this, "date", void 0);
|
|
75
|
-
|
|
76
|
-
_defineProperty(this, "type", void 0);
|
|
77
|
-
|
|
78
|
-
_defineProperty(this, "senderId", void 0);
|
|
79
|
-
|
|
80
|
-
_defineProperty(this, "senderName", void 0);
|
|
81
|
-
|
|
82
|
-
_defineProperty(this, "rawMessage", void 0);
|
|
83
|
-
|
|
84
|
-
this.id = Number(rawKmail.id);
|
|
85
|
-
this.date = new Date(rawKmail.localtime);
|
|
86
|
-
this.type = rawKmail.type;
|
|
87
|
-
this.senderId = Number(rawKmail.fromid);
|
|
88
|
-
this.senderName = rawKmail.fromname;
|
|
89
|
-
this.rawMessage = rawKmail.message;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Delete the kmail
|
|
93
|
-
*
|
|
94
|
-
* @returns Whether the kmail was deleted
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_createClass(Kmail, [{
|
|
99
|
-
key: "delete",
|
|
100
|
-
value: function _delete() {
|
|
101
|
-
return Kmail.delete([this]) === 1;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Message contents without any HTML from items or meat
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
}, {
|
|
108
|
-
key: "message",
|
|
109
|
-
get: function get() {
|
|
110
|
-
var match = this.rawMessage.match(/^(.*?)</);
|
|
111
|
-
return match ? match[1] : this.rawMessage;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Get items attached to the kmail
|
|
115
|
-
*
|
|
116
|
-
* @returns Map of items attached to the kmail and their quantities
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
}, {
|
|
120
|
-
key: "items",
|
|
121
|
-
value: function items() {
|
|
122
|
-
return new Map(Object.entries((0, _kolmafia.extractItems)(this.message)).map(_ref => {
|
|
123
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
124
|
-
itemName = _ref2[0],
|
|
125
|
-
quantity = _ref2[1];
|
|
126
|
-
|
|
127
|
-
return [Item.get(itemName), quantity];
|
|
128
|
-
}));
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Get meat attached to the kmail
|
|
132
|
-
*
|
|
133
|
-
* @returns Meat attached to the kmail
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
}, {
|
|
137
|
-
key: "meat",
|
|
138
|
-
value: function meat() {
|
|
139
|
-
return (0, _kolmafia.extractMeat)(this.message);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Reply to kmail
|
|
143
|
-
*
|
|
144
|
-
* @see Kmail.send
|
|
145
|
-
*
|
|
146
|
-
* @returns True if the kmail was successfully sent
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
}, {
|
|
150
|
-
key: "reply",
|
|
151
|
-
value: function reply() {
|
|
152
|
-
var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
153
|
-
var items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
154
|
-
var meat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
155
|
-
return Kmail.send(this.senderId, message, items, meat);
|
|
156
|
-
}
|
|
157
|
-
}], [{
|
|
158
|
-
key: "parse",
|
|
159
|
-
value:
|
|
1
|
+
import "core-js/modules/es.object.entries";
|
|
2
|
+
import { extractItems, extractMeat, isGiftable, toInt, visitUrl, } from "kolmafia";
|
|
3
|
+
import { arrayToCountedMap, chunk } from "./utils";
|
|
4
|
+
export default class Kmail {
|
|
5
|
+
id;
|
|
6
|
+
date;
|
|
7
|
+
type;
|
|
8
|
+
senderId;
|
|
9
|
+
senderName;
|
|
10
|
+
rawMessage;
|
|
160
11
|
/**
|
|
161
12
|
* Parses a kmail from KoL's native format
|
|
162
13
|
*
|
|
163
14
|
* @param rawKmail Kmail in the format supplies by api.php
|
|
164
15
|
* @returns Parsed kmail
|
|
165
16
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
17
|
+
static parse(rawKmail) {
|
|
18
|
+
return new Kmail(rawKmail);
|
|
168
19
|
}
|
|
169
20
|
/**
|
|
170
21
|
* Returns all of the player's kmails
|
|
171
22
|
*
|
|
23
|
+
* @param count Number of kmails to fetch
|
|
172
24
|
* @returns Parsed kmails
|
|
173
25
|
*/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
key: "inbox",
|
|
177
|
-
value: function inbox() {
|
|
178
|
-
return JSON.parse((0, _kolmafia.visitUrl)("api.php?what=kmail&for=libram")).map(Kmail.parse);
|
|
26
|
+
static inbox(count = 100) {
|
|
27
|
+
return JSON.parse(visitUrl(`api.php?what=kmail&for=libram&count=${count}`)).map(Kmail.parse);
|
|
179
28
|
}
|
|
180
29
|
/**
|
|
181
30
|
* Bulk delete kmails
|
|
@@ -183,62 +32,33 @@ var Kmail = /*#__PURE__*/function () {
|
|
|
183
32
|
* @param kmails Kmails to delete
|
|
184
33
|
* @returns Number of kmails deleted
|
|
185
34
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
var results = (0, _kolmafia.visitUrl)("messages.php?the_action=delete&box=Inbox&pwd&".concat(kmails.map(k => "sel".concat(k.id, "=on")).join("&")));
|
|
193
|
-
return Number((_results$match$ = (_results$match = results.match(/<td>(\d) messages? deleted.<\/td>/)) === null || _results$match === void 0 ? void 0 : _results$match[1]) !== null && _results$match$ !== void 0 ? _results$match$ : 0);
|
|
35
|
+
static delete(kmails) {
|
|
36
|
+
const results = visitUrl(`messages.php?the_action=delete&box=Inbox&pwd&${kmails
|
|
37
|
+
.map((k) => `sel${k.id}=on`)
|
|
38
|
+
.join("&")}`);
|
|
39
|
+
return Number(results.match(/<td>(\d) messages? deleted.<\/td>/)?.[1] ?? 0);
|
|
194
40
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
215
|
-
var c = _step.value;
|
|
216
|
-
|
|
217
|
-
var _itemsQuery = c === null ? [] : c.map((_ref5, index) => {
|
|
218
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
219
|
-
item = _ref6[0],
|
|
220
|
-
quantity = _ref6[1];
|
|
221
|
-
|
|
222
|
-
return "whichitem".concat(index + 1, "=").concat((0, _kolmafia.toInt)(item), "&howmany").concat(index + 1, "=").concat(quantity);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
var r = (0, _kolmafia.visitUrl)(constructUrl(m, _itemsQuery.join("&"), _itemsQuery.length));
|
|
226
|
-
|
|
227
|
-
if (r.includes("That player cannot receive Meat or items")) {
|
|
228
|
-
return Kmail.gift(to, message, items, meat);
|
|
229
|
-
} // Make sure we don't send the same batch of meat with every chunk
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
m = 0;
|
|
233
|
-
result && (result = r.includes(successString));
|
|
41
|
+
static _genericSend(to, message, items, meat, chunkSize, constructUrl, successString) {
|
|
42
|
+
let m = meat;
|
|
43
|
+
const sendableItems = [
|
|
44
|
+
...arrayToCountedMap(items).entries(),
|
|
45
|
+
].filter(([item]) => isGiftable(item));
|
|
46
|
+
let result = true;
|
|
47
|
+
const chunks = chunk(sendableItems, chunkSize);
|
|
48
|
+
// Split the items to be sent into chunks of max 11 item types
|
|
49
|
+
for (const c of chunks.length > 0 ? chunks : [null]) {
|
|
50
|
+
const itemsQuery = c === null
|
|
51
|
+
? []
|
|
52
|
+
: c.map(([item, quantity], index) => `whichitem${index + 1}=${toInt(item)}&howmany${index + 1}=${quantity}`);
|
|
53
|
+
const r = visitUrl(constructUrl(m, itemsQuery.join("&"), itemsQuery.length));
|
|
54
|
+
if (r.includes("That player cannot receive Meat or items")) {
|
|
55
|
+
return Kmail.gift(to, message, items, meat);
|
|
56
|
+
}
|
|
57
|
+
// Make sure we don't send the same batch of meat with every chunk
|
|
58
|
+
m = 0;
|
|
59
|
+
result &&= r.includes(successString);
|
|
234
60
|
}
|
|
235
|
-
|
|
236
|
-
_iterator.e(err);
|
|
237
|
-
} finally {
|
|
238
|
-
_iterator.f();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return result;
|
|
61
|
+
return result;
|
|
242
62
|
}
|
|
243
63
|
/**
|
|
244
64
|
* Sends a kmail to a player
|
|
@@ -253,14 +73,8 @@ var Kmail = /*#__PURE__*/function () {
|
|
|
253
73
|
* @param meat The quantity of meat to be attached
|
|
254
74
|
* @returns True if the kmail was successfully sent
|
|
255
75
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
key: "send",
|
|
259
|
-
value: function send(to) {
|
|
260
|
-
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
261
|
-
var items = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
262
|
-
var meat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
263
|
-
return Kmail._genericSend(to, message, items, meat, 11, (meat, itemsQuery) => "sendmessage.php?action=send&pwd&towho=".concat(to, "&message=").concat(message).concat(itemsQuery ? "&".concat(itemsQuery) : "", "&sendmeat=").concat(meat), ">Message sent.</");
|
|
76
|
+
static send(to, message = "", items = [], meat = 0) {
|
|
77
|
+
return Kmail._genericSend(to, message, items, meat, 11, (meat, itemsQuery) => `sendmessage.php?action=send&pwd&towho=${to}&message=${message}${itemsQuery ? `&${itemsQuery}` : ""}&sendmeat=${meat}`, ">Message sent.</");
|
|
264
78
|
}
|
|
265
79
|
/**
|
|
266
80
|
* Sends a gift to a player
|
|
@@ -275,20 +89,61 @@ var Kmail = /*#__PURE__*/function () {
|
|
|
275
89
|
* @param insideNode The note on the inside of the gift
|
|
276
90
|
* @returns True if the gift was successfully sent
|
|
277
91
|
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
92
|
+
static gift(to, message = "", items = [], meat = 0, insideNote = "") {
|
|
93
|
+
const baseUrl = `town_sendgift.php?action=Yep.&pwd&fromwhere=0¬e=${message}&insidenote=${insideNote}&towho=${to}`;
|
|
94
|
+
return Kmail._genericSend(to, message, items, meat, 3, (m, itemsQuery, chunkSize) => `${baseUrl}&whichpackage=${chunkSize}${itemsQuery ? `&${itemsQuery}` : ""}&sendmeat=${m}`, ">Package sent.</");
|
|
95
|
+
}
|
|
96
|
+
constructor(rawKmail) {
|
|
97
|
+
const date = new Date(rawKmail.localtime);
|
|
98
|
+
// Date come from KoL formatted with YY and so will be parsed 19YY, which is wrong.
|
|
99
|
+
// We can safely add 100 because if 19YY was a leap year, 20YY will be too!
|
|
100
|
+
date.setFullYear(date.getFullYear() + 100);
|
|
101
|
+
this.id = Number(rawKmail.id);
|
|
102
|
+
this.date = date;
|
|
103
|
+
this.type = rawKmail.type;
|
|
104
|
+
this.senderId = Number(rawKmail.fromid);
|
|
105
|
+
this.senderName = rawKmail.fromname;
|
|
106
|
+
this.rawMessage = rawKmail.message;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Delete the kmail
|
|
110
|
+
*
|
|
111
|
+
* @returns Whether the kmail was deleted
|
|
112
|
+
*/
|
|
113
|
+
delete() {
|
|
114
|
+
return Kmail.delete([this]) === 1;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Message contents without any HTML from items or meat
|
|
118
|
+
*/
|
|
119
|
+
get message() {
|
|
120
|
+
const match = this.rawMessage.match(/^(.*?)</s);
|
|
121
|
+
return match ? match[1] : this.rawMessage;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get items attached to the kmail
|
|
125
|
+
*
|
|
126
|
+
* @returns Map of items attached to the kmail and their quantities
|
|
127
|
+
*/
|
|
128
|
+
items() {
|
|
129
|
+
return new Map(Object.entries(extractItems(this.rawMessage)).map(([itemName, quantity]) => [Item.get(itemName), quantity]));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get meat attached to the kmail
|
|
133
|
+
*
|
|
134
|
+
* @returns Meat attached to the kmail
|
|
135
|
+
*/
|
|
136
|
+
meat() {
|
|
137
|
+
return extractMeat(this.rawMessage);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Reply to kmail
|
|
141
|
+
*
|
|
142
|
+
* @see Kmail.send
|
|
143
|
+
*
|
|
144
|
+
* @returns True if the kmail was successfully sent
|
|
145
|
+
*/
|
|
146
|
+
reply(message = "", items = [], meat = 0) {
|
|
147
|
+
return Kmail.send(this.senderId, message, items, meat);
|
|
288
148
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return Kmail;
|
|
292
|
-
}();
|
|
293
|
-
|
|
294
|
-
exports.default = Kmail;
|
|
149
|
+
}
|
package/dist/Path.js
CHANGED
|
@@ -1,121 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
1
|
+
import { $classes } from "./template-string";
|
|
2
|
+
export class Path {
|
|
3
|
+
name;
|
|
4
|
+
id;
|
|
5
|
+
hasAllPerms; //here, we define avatar-ness around being its own class
|
|
6
|
+
hasCampground;
|
|
7
|
+
hasTerrarium;
|
|
8
|
+
stomachSize;
|
|
9
|
+
liverSize; //Defined as the lowest inebriety that makes you unable to drink more, just to make it fifteens across the board
|
|
10
|
+
spleenSize;
|
|
11
|
+
classes;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param name Name of path
|
|
15
|
+
* @param id Path ID
|
|
16
|
+
* @param hasAllPerms Does the player have immediate access to all permed skills>
|
|
17
|
+
* @param hasCampground Does the player have access to the campground?
|
|
18
|
+
* @param hasTerrarium Does the player have access to terrarium.php
|
|
19
|
+
* @param stomachSize Maximum fullness achievable at turn 0
|
|
20
|
+
* @param liverSize The lowest inebriety that makes you unable to drink more
|
|
21
|
+
* @param spleenSize Maximum spleen achievable at turn 0
|
|
22
|
+
* @param classes Classes available in this path
|
|
23
|
+
*/
|
|
24
|
+
constructor(name, id, hasAllPerms = true, hasCampground = true, hasTerrarium = true, stomachSize = 15, liverSize = 15, spleenSize = 15, classes = $classes `Seal Clubber, Turtle Tamer, Sauceror, Pastamancer, Disco Bandit, Accordion Thief`) {
|
|
25
|
+
this.name = name;
|
|
26
|
+
this.id = id;
|
|
27
|
+
this.hasAllPerms = hasAllPerms;
|
|
28
|
+
this.hasCampground = hasCampground;
|
|
29
|
+
this.hasTerrarium = hasTerrarium;
|
|
30
|
+
this.stomachSize = stomachSize;
|
|
31
|
+
this.liverSize = liverSize;
|
|
32
|
+
this.spleenSize = spleenSize;
|
|
33
|
+
this.classes = classes;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const Paths = {
|
|
37
|
+
Unrestricted: new Path("Unrestricted", 0),
|
|
38
|
+
Boozetafarian: new Path("Boozetafarian", 1, false, true, true, 0),
|
|
39
|
+
Teetotaler: new Path("Teetotaler", 2, false, true, true, 15, 0),
|
|
40
|
+
Oxygenarian: new Path("Oxygenarian", 3, false, true, true, 0, 0),
|
|
41
|
+
BeesHateYou: new Path("Bees Hate You", 4),
|
|
42
|
+
WayOfTheSurprisingFist: new Path("Way of the Surprising Fist", 6),
|
|
43
|
+
Trendy: new Path("Trendy", 6),
|
|
44
|
+
AvatarOfBoris: new Path("Avatar of Boris", 8, false, true, false, 20, 5, 15, $classes `Avatar of Boris`),
|
|
45
|
+
BugbearInvasion: new Path("Bugbear Invasion", 9),
|
|
46
|
+
ZombieSlayer: new Path("Zombie Slayer", 10, false, true, true, 15, 5, 15, $classes `Zombie Master`),
|
|
47
|
+
ClassAct: new Path("Class Act", 11, false),
|
|
48
|
+
AvatarofJarlsberg: new Path("Avatar of Jarlsberg", 12, false, true, false, 10, 10, 15, $classes `Avatar of Jarlsberg`),
|
|
49
|
+
Big: new Path("BIG!", 14),
|
|
50
|
+
KolHs: new Path("KOLHS", 15),
|
|
51
|
+
ClassAct2: new Path("Class Act II: A Class For Pigs", 16, false),
|
|
52
|
+
AvatarofSneakyPete: new Path("Avatar of Sneaky Pete", 17, false, true, false, 5, 20, 15, $classes `Avatar of Sneaky Pete`),
|
|
53
|
+
SlowAndSteady: new Path("Slow and Steady", 18),
|
|
54
|
+
HeavyRains: new Path("Heavy Rains", 19),
|
|
55
|
+
Picky: new Path("Picky", 21, false),
|
|
56
|
+
Standard: new Path("Standard", 22),
|
|
57
|
+
ActuallyEdTheUndying: new Path("Actually Ed the Undying", 23, false, false, false, 0, 0, 5, $classes `Ed`),
|
|
58
|
+
OneCrazyRandomSummer: new Path("One Crazy Random Summer", 24),
|
|
59
|
+
CommunityService: new Path("Community Service", 25),
|
|
60
|
+
AvatarOfWestOfLoathing: new Path("Avatar of West of Loathing", 26, false, true, true, 10, 10, 10, $classes `Cow Puncher, Snake Oiler, Beanslinger`),
|
|
61
|
+
TheSource: new Path("The Source", 27),
|
|
62
|
+
NuclearAutumn: new Path("Nuclear Autumn", 28, false, false, true, 3, 3, 3),
|
|
63
|
+
GelatinousNoob: new Path("Gelatinous Noob", 29, false, true, true, 0, 0, 0, $classes `Gelatinous Noob`),
|
|
64
|
+
LicenseToAdventure: new Path("License to Adventure", 30, true, true, false, 0, 2, 15),
|
|
65
|
+
LiveAscendRepeat: new Path("Live. Ascend. Repeat.", 31),
|
|
66
|
+
PocketFamiliars: new Path("Pocket Familiars", 32, false, true, false),
|
|
67
|
+
GLover: new Path("G-Lover", 33),
|
|
68
|
+
DisguisesDelimit: new Path("Disguises Delimit", 34),
|
|
69
|
+
DarkGyffte: new Path("Dark Gyffte", 35, false, true, false, 5, 5, 15, $classes `Vampyre`),
|
|
70
|
+
TwoCrazyRandomSummer: new Path("Two Crazy Random Summer", 36),
|
|
71
|
+
KingdomOfExploathing: new Path("Kingdom of Exploathing", 37),
|
|
72
|
+
PathOfThePlumber: new Path("Path of the Plumber", 38, false, true, true, 20, 0, 5, $classes `Plumber`),
|
|
73
|
+
LowKeySummer: new Path("Low Key Summer", 40),
|
|
74
|
+
GreyGoo: new Path("Grey Goo", 40),
|
|
75
|
+
YouRobot: new Path("You, Robot", 41, false, false, true, 0, 0, 0),
|
|
76
|
+
QuantumTerrarium: new Path("Quantum Terrarium", 42, true, true, false),
|
|
77
|
+
Wildfire: new Path("Wildfire", 43),
|
|
73
78
|
};
|
|
74
|
-
|
|
75
|
-
exports.Path = Path;
|
|
76
|
-
var Paths = {
|
|
77
|
-
Unrestricted: new Path("Unrestricted", 0),
|
|
78
|
-
Boozetafarian: new Path("Boozetafarian", 1, false, true, true, 0),
|
|
79
|
-
Teetotaler: new Path("Teetotaler", 2, false, true, true, 15, 0),
|
|
80
|
-
Oxygenarian: new Path("Oxygenarian", 3, false, true, true, 0, 0),
|
|
81
|
-
BeesHateYou: new Path("Bees Hate You", 4),
|
|
82
|
-
WayOfTheSurprisingFist: new Path("Way of the Surprising Fist", 6),
|
|
83
|
-
Trendy: new Path("Trendy", 6),
|
|
84
|
-
AvatarOfBoris: new Path("Avatar of Boris", 8, false, true, false, 20, 5, 15, (0, _templateString.$classes)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Avatar of Boris"])))),
|
|
85
|
-
BugbearInvasion: new Path("Bugbear Invasion", 9),
|
|
86
|
-
ZombieSlayer: new Path("Zombie Slayer", 10, false, true, true, 15, 5, 15, (0, _templateString.$classes)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Zombie Master"])))),
|
|
87
|
-
ClassAct: new Path("Class Act", 11, false),
|
|
88
|
-
AvatarofJarlsberg: new Path("Avatar of Jarlsberg", 12, false, true, false, 10, 10, 15, (0, _templateString.$classes)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Avatar of Jarlsberg"])))),
|
|
89
|
-
Big: new Path("BIG!", 14),
|
|
90
|
-
KolHs: new Path("KOLHS", 15),
|
|
91
|
-
ClassAct2: new Path("Class Act II: A Class For Pigs", 16, false),
|
|
92
|
-
AvatarofSneakyPete: new Path("Avatar of Sneaky Pete", 17, false, true, false, 5, 20, 15, (0, _templateString.$classes)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Avatar of Sneaky Pete"])))),
|
|
93
|
-
SlowAndSteady: new Path("Slow and Steady", 18),
|
|
94
|
-
HeavyRains: new Path("Heavy Rains", 19),
|
|
95
|
-
Picky: new Path("Picky", 21, false),
|
|
96
|
-
Standard: new Path("Standard", 22),
|
|
97
|
-
ActuallyEdTheUndying: new Path("Actually Ed the Undying", 23, false, false, false, 0, 0, 5, (0, _templateString.$classes)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Ed"])))),
|
|
98
|
-
OneCrazyRandomSummer: new Path("One Crazy Random Summer", 24),
|
|
99
|
-
CommunityService: new Path("Community Service", 25),
|
|
100
|
-
AvatarOfWestOfLoathing: new Path("Avatar of West of Loathing", 26, false, true, true, 10, 10, 10, (0, _templateString.$classes)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Cow Puncher, Snake Oiler, Beanslinger"])))),
|
|
101
|
-
TheSource: new Path("The Source", 27),
|
|
102
|
-
NuclearAutumn: new Path("Nuclear Autumn", 28, false, false, true, 3, 3, 3),
|
|
103
|
-
GelatinousNoob: new Path("Gelatinous Noob", 29, false, true, true, 0, 0, 0, (0, _templateString.$classes)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Gelatinous Noob"])))),
|
|
104
|
-
LicenseToAdventure: new Path("License to Adventure", 30, true, true, false, 0, 2, 15),
|
|
105
|
-
//Unsure how to log liver size here
|
|
106
|
-
LiveAscendRepeat: new Path("Live. Ascend. Repeat.", 31),
|
|
107
|
-
PocketFamiliars: new Path("Pocket Familiars", 32, false, true, false),
|
|
108
|
-
//This is my opinion on the matter
|
|
109
|
-
GLover: new Path("G-Lover", 33),
|
|
110
|
-
DisguisesDelimit: new Path("Disguises Delimit", 34),
|
|
111
|
-
DarkGyffte: new Path("Dark Gyffte", 35, false, true, false, 5, 5, 15, (0, _templateString.$classes)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Vampyre"])))),
|
|
112
|
-
TwoCrazyRandomSummer: new Path("Two Crazy Random Summer", 36),
|
|
113
|
-
KingdomOfExploathing: new Path("Kingdom of Exploathing", 37),
|
|
114
|
-
PathOfThePlumber: new Path("Path of the Plumber", 38, false, true, true, 20, 0, 5, (0, _templateString.$classes)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Plumber"])))),
|
|
115
|
-
LowKeySummer: new Path("Low Key Summer", 40),
|
|
116
|
-
GreyGoo: new Path("Grey Goo", 40),
|
|
117
|
-
YouRobot: new Path("You, Robot", 41, false, false, true, 0, 0, 0),
|
|
118
|
-
QuantumTerrarium: new Path("Quantum Terrarium", 42, true, true, false),
|
|
119
|
-
Wildfire: new Path("Wildfire", 43)
|
|
120
|
-
};
|
|
121
|
-
exports.Paths = Paths;
|