libram 0.3.2 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/Clan.js +268 -485
  2. package/dist/Copier.js +11 -48
  3. package/dist/Dungeon.js +77 -157
  4. package/dist/Kmail.d.ts +13 -7
  5. package/dist/Kmail.js +92 -233
  6. package/dist/Path.js +68 -120
  7. package/dist/ascend.js +153 -172
  8. package/dist/combat.d.ts +86 -1
  9. package/dist/combat.js +295 -387
  10. package/dist/console.js +13 -36
  11. package/dist/diet/index.d.ts +31 -0
  12. package/dist/diet/index.js +333 -0
  13. package/dist/diet/knapsack.d.ts +7 -0
  14. package/dist/diet/knapsack.js +106 -0
  15. package/dist/dungeons/Dreadsylvania.d.ts +4 -0
  16. package/dist/dungeons/Dreadsylvania.js +14 -0
  17. package/dist/dungeons/Dungeon.d.ts +28 -0
  18. package/dist/dungeons/Dungeon.js +99 -0
  19. package/dist/dungeons/Hobopolis.d.ts +4 -0
  20. package/dist/dungeons/Hobopolis.js +14 -0
  21. package/dist/dungeons/SlimeTube.d.ts +4 -0
  22. package/dist/dungeons/SlimeTube.js +14 -0
  23. package/dist/freerun.d.ts +23 -0
  24. package/dist/freerun.js +92 -0
  25. package/dist/index.d.ts +6 -1
  26. package/dist/index.js +21 -263
  27. package/dist/lib.d.ts +43 -0
  28. package/dist/lib.js +296 -405
  29. package/dist/logger.js +23 -63
  30. package/dist/maximize.d.ts +29 -12
  31. package/dist/maximize.js +318 -421
  32. package/dist/modifier.d.ts +13 -0
  33. package/dist/modifier.js +35 -0
  34. package/dist/modifierTypes.d.ts +16 -0
  35. package/dist/modifierTypes.js +9 -0
  36. package/dist/mood.js +220 -531
  37. package/dist/property.d.ts +2 -0
  38. package/dist/property.js +96 -242
  39. package/dist/propertyTypes.d.ts +9 -0
  40. package/dist/propertyTypes.js +1 -0
  41. package/dist/propertyTyping.d.ts +2 -9
  42. package/dist/propertyTyping.js +42 -53
  43. package/dist/resources/2007/CandyHearts.d.ts +9 -0
  44. package/dist/resources/2007/CandyHearts.js +24 -0
  45. package/dist/resources/2008/DivineFavors.d.ts +9 -0
  46. package/dist/resources/2008/DivineFavors.js +27 -0
  47. package/dist/resources/2009/Bandersnatch.js +37 -112
  48. package/dist/resources/2009/LoveSongs.d.ts +9 -0
  49. package/dist/resources/2009/LoveSongs.js +24 -0
  50. package/dist/resources/2009/SpookyPutty.js +20 -46
  51. package/dist/resources/2010/Brickos.d.ts +9 -0
  52. package/dist/resources/2010/Brickos.js +21 -0
  53. package/dist/resources/2010/CrownOfThrones.d.ts +18 -0
  54. package/dist/resources/2010/CrownOfThrones.js +550 -0
  55. package/dist/resources/2011/Gygaxian.d.ts +9 -0
  56. package/dist/resources/2011/Gygaxian.js +24 -0
  57. package/dist/resources/2011/ObtuseAngel.js +21 -63
  58. package/dist/resources/2012/RainDoh.js +14 -40
  59. package/dist/resources/2012/Resolutions.d.ts +9 -0
  60. package/dist/resources/2012/Resolutions.js +28 -0
  61. package/dist/resources/2013/Florist.d.ts +61 -0
  62. package/dist/resources/2013/Florist.js +149 -0
  63. package/dist/resources/2013/PulledTaffy.d.ts +9 -0
  64. package/dist/resources/2013/PulledTaffy.js +33 -0
  65. package/dist/resources/2014/WinterGarden.js +15 -43
  66. package/dist/resources/2015/ChateauMantegna.js +52 -86
  67. package/dist/resources/2015/MayoClinic.d.ts +13 -0
  68. package/dist/resources/2015/MayoClinic.js +36 -0
  69. package/dist/resources/2016/SourceTerminal.d.ts +1 -0
  70. package/dist/resources/2016/SourceTerminal.js +114 -237
  71. package/dist/resources/2016/Witchess.js +33 -59
  72. package/dist/resources/2017/TunnelOfLove.js +62 -111
  73. package/dist/resources/2018/SongBoom.js +32 -68
  74. package/dist/resources/2019/BeachComb.d.ts +2 -0
  75. package/dist/resources/2019/BeachComb.js +26 -0
  76. package/dist/resources/2019/Snapper.d.ts +28 -0
  77. package/dist/resources/2019/Snapper.js +70 -0
  78. package/dist/resources/2020/Guzzlr.js +79 -163
  79. package/dist/resources/LibramSummon.d.ts +12 -0
  80. package/dist/resources/LibramSummon.js +66 -0
  81. package/dist/resources/index.d.ts +18 -11
  82. package/dist/resources/index.js +19 -85
  83. package/dist/resources/putty-likes.js +15 -30
  84. package/dist/ring-buffer.d.ts +24 -0
  85. package/dist/ring-buffer.js +135 -0
  86. package/dist/since.d.ts +1 -0
  87. package/dist/since.js +56 -112
  88. package/dist/template-string.js +40 -132
  89. package/dist/utils.d.ts +14 -0
  90. package/dist/utils.js +50 -114
  91. package/package.json +5 -3
  92. package/dist/libram-example-briefcase.js +0 -16073
  93. package/dist/libram-example-clan.js +0 -8898
  94. package/dist/libram-example-consult.js +0 -6179
  95. package/dist/libram-example-item.js +0 -3248
  96. package/dist/libram-example-kmail.js +0 -2065
  97. package/dist/libram-example-lib.js +0 -7608
  98. package/dist/libram-example-props.js +0 -4770
  99. package/dist/libram-example-resources.js +0 -12226
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.symbol.js");
4
+
5
+ require("core-js/modules/es.symbol.description.js");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.RingBuffer = void 0;
11
+
12
+ require("core-js/modules/es.array.concat.js");
13
+
14
+ require("core-js/modules/es.array.slice.js");
15
+
16
+ require("core-js/modules/es.array.iterator.js");
17
+
18
+ require("core-js/modules/es.object.to-string.js");
19
+
20
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
+
22
+ 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."); }
23
+
24
+ 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); }
25
+
26
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
27
+
28
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
29
+
30
+ 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; }
31
+
32
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
+
34
+ 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); } }
35
+
36
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
37
+
38
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
39
+
40
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
41
+
42
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
43
+
44
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
45
+
46
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
47
+
48
+ var _entries = /*#__PURE__*/new WeakMap();
49
+
50
+ var _pointer = /*#__PURE__*/new WeakMap();
51
+
52
+ var _maxLength = /*#__PURE__*/new WeakMap();
53
+
54
+ var RingBuffer = /*#__PURE__*/function () {
55
+ function RingBuffer(maxLength) {
56
+ _classCallCheck(this, RingBuffer);
57
+
58
+ _entries.set(this, {
59
+ writable: true,
60
+ value: []
61
+ });
62
+
63
+ _pointer.set(this, {
64
+ writable: true,
65
+ value: 0
66
+ });
67
+
68
+ _maxLength.set(this, {
69
+ writable: true,
70
+ value: void 0
71
+ });
72
+
73
+ _classPrivateFieldSet(this, _maxLength, maxLength);
74
+ }
75
+ /**
76
+ * Get length of structure.
77
+ */
78
+
79
+
80
+ _createClass(RingBuffer, [{
81
+ key: "length",
82
+ get: function get() {
83
+ return _classPrivateFieldGet(this, _entries).length;
84
+ }
85
+ /**
86
+ * Get maximium length of structure.
87
+ */
88
+
89
+ }, {
90
+ key: "maxSize",
91
+ get: function get() {
92
+ return _classPrivateFieldGet(this, _maxLength);
93
+ }
94
+ }, {
95
+ key: "entries",
96
+ value: function entries() {
97
+ return [].concat(_toConsumableArray(_classPrivateFieldGet(this, _entries).slice(_classPrivateFieldGet(this, _pointer))), _toConsumableArray(_classPrivateFieldGet(this, _entries).slice(0, _classPrivateFieldGet(this, _pointer))));
98
+ }
99
+ /**
100
+ * Get element at index {index}.
101
+ * @param index Index to check.
102
+ */
103
+
104
+ }, {
105
+ key: "get",
106
+ value: function get(index) {
107
+ return _classPrivateFieldGet(this, _entries)[index];
108
+ }
109
+ /**
110
+ * Insert a value and evict last value if buffer is full.
111
+ * @param value Value to insert.
112
+ * @returns Evicted element and index of inserted value.
113
+ */
114
+
115
+ }, {
116
+ key: "insert",
117
+ value: function insert(value) {
118
+ if (this.length < this.maxSize) {
119
+ return [undefined, _classPrivateFieldGet(this, _entries).push(value) - 1];
120
+ } else {
121
+ var _this$pointer;
122
+
123
+ var out = _classPrivateFieldGet(this, _entries)[_classPrivateFieldGet(this, _pointer)];
124
+
125
+ _classPrivateFieldGet(this, _entries)[_classPrivateFieldGet(this, _pointer)] = value;
126
+ _classPrivateFieldSet(this, _pointer, (_this$pointer = +_classPrivateFieldGet(this, _pointer)) + 1), _this$pointer;
127
+ return [out, _classPrivateFieldGet(this, _pointer) - 1];
128
+ }
129
+ }
130
+ }]);
131
+
132
+ return RingBuffer;
133
+ }();
134
+
135
+ exports.RingBuffer = RingBuffer;
package/dist/since.d.ts CHANGED
@@ -34,6 +34,7 @@ export declare function sinceKolmafiaRevision(revision: number): void;
34
34
  * This behaves like the `since X.Y;` statement in ASH.
35
35
  * @param majorVersion Major version number
36
36
  * @param minorVersion Minor version number
37
+ * @deprecated Point versions are no longer released by KoLmafia
37
38
  * @throws {KolmafiaVersionError}
38
39
  * If KoLmafia's major version is less than `majorVersion`, or if the major
39
40
  * versions are equal but the minor version is less than `minorVersion`
package/dist/since.js CHANGED
@@ -1,76 +1,23 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.object.to-string.js");
4
-
5
- require("core-js/modules/es.regexp.to-string.js");
6
-
7
- require("core-js/modules/es.reflect.construct.js");
8
-
9
- require("core-js/modules/es.array.iterator.js");
10
-
11
- Object.defineProperty(exports, "__esModule", {
12
- value: true
13
- });
14
- exports.sinceKolmafiaRevision = sinceKolmafiaRevision;
15
- exports.sinceKolmafiaVersion = sinceKolmafiaVersion;
16
- exports.KolmafiaVersionError = void 0;
17
-
18
- require("core-js/modules/es.array.concat.js");
19
-
20
- require("core-js/modules/es.regexp.exec.js");
21
-
22
- var _kolmafia = require("kolmafia");
23
-
24
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
-
26
- 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); }
27
-
28
- 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); }; }
29
-
30
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
31
-
32
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
-
34
- 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); }
35
-
36
- 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); }
37
-
38
- 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; } }
39
-
40
- function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
41
-
42
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
43
-
44
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
45
-
1
+ /**
2
+ * Provides functions for checking KoLmafia's version and revision.
3
+ * @packageDocumentation
4
+ */
5
+ import { getRevision, getVersion } from "kolmafia";
46
6
  /**
47
7
  * Represents an exception thrown when the current KoLmafia version does not
48
8
  * match an expected condition.
49
9
  */
50
- var KolmafiaVersionError = /*#__PURE__*/function (_Error) {
51
- _inherits(KolmafiaVersionError, _Error);
52
-
53
- var _super = _createSuper(KolmafiaVersionError);
54
-
55
- function KolmafiaVersionError(message) {
56
- var _this;
57
-
58
- _classCallCheck(this, KolmafiaVersionError);
59
-
60
- _this = _super.call(this, message); // Explicitly set the prototype, so that 'instanceof' still works in Node.js
61
- // even when the class is transpiled down to ES5
62
- // See: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
63
- // Note that this code isn't needed for Rhino.
64
-
65
- Object.setPrototypeOf(_assertThisInitialized(_this), KolmafiaVersionError.prototype);
66
- return _this;
67
- }
68
-
69
- return KolmafiaVersionError;
70
- }( /*#__PURE__*/_wrapNativeSuper(Error)); // Manually set class name, so that the stack trace shows proper name in Rhino
71
-
72
-
73
- exports.KolmafiaVersionError = KolmafiaVersionError;
10
+ export class KolmafiaVersionError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ // Explicitly set the prototype, so that 'instanceof' still works in Node.js
14
+ // even when the class is transpiled down to ES5
15
+ // See: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
16
+ // Note that this code isn't needed for Rhino.
17
+ Object.setPrototypeOf(this, KolmafiaVersionError.prototype);
18
+ }
19
+ }
20
+ // Manually set class name, so that the stack trace shows proper name in Rhino
74
21
  KolmafiaVersionError.prototype.name = "KolmafiaVersionError";
75
22
  /**
76
23
  * Returns the currently executing script name, suitable for embedding in an
@@ -78,13 +25,10 @@ KolmafiaVersionError.prototype.name = "KolmafiaVersionError";
78
25
  * @returns Path of the main script wrapped in single-quotes, or `"This script"`
79
26
  * if the path cannot be determined
80
27
  */
81
-
82
28
  function getScriptName() {
83
- var _require$main;
84
-
85
- // In Rhino, the current script name is available in require.main.id
86
- var scriptName = (_require$main = require.main) === null || _require$main === void 0 ? void 0 : _require$main.id;
87
- return scriptName ? "'".concat(scriptName, "'") : "This script";
29
+ // In Rhino, the current script name is available in require.main.id
30
+ const scriptName = require.main?.id;
31
+ return scriptName ? `'${scriptName}'` : "This script";
88
32
  }
89
33
  /**
90
34
  * If KoLmafia's revision number is less than `revision`, throws an exception.
@@ -102,17 +46,15 @@ function getScriptName() {
102
46
  * sinceKolmafiaRevision(20500);
103
47
  * ```
104
48
  */
105
-
106
-
107
- function sinceKolmafiaRevision(revision) {
108
- if (!Number.isInteger(revision)) {
109
- throw new TypeError("Invalid revision number ".concat(revision, " (must be an integer)"));
110
- } // Based on net.sourceforge.kolmafia.textui.Parser.sinceException()
111
-
112
-
113
- if ((0, _kolmafia.getRevision)() < revision) {
114
- throw new KolmafiaVersionError("".concat(getScriptName(), " requires revision r").concat(revision, " of kolmafia or higher (current: ").concat((0, _kolmafia.getRevision)(), "). Up-to-date builds can be found at https://ci.kolmafia.us/."));
115
- }
49
+ export function sinceKolmafiaRevision(revision) {
50
+ if (!Number.isInteger(revision)) {
51
+ throw new TypeError(`Invalid revision number ${revision} (must be an integer)`);
52
+ }
53
+ // Based on net.sourceforge.kolmafia.textui.Parser.sinceException()
54
+ const currentRevision = getRevision();
55
+ if (currentRevision > 0 && currentRevision < revision) {
56
+ throw new KolmafiaVersionError(`${getScriptName()} requires revision r${revision} of kolmafia or higher (current: ${getRevision()}). Up-to-date builds can be found at https://ci.kolmafia.us/.`);
57
+ }
116
58
  }
117
59
  /**
118
60
  * If KoLmafia's version is less than `majorVersion.minorVersion`, throws an
@@ -122,6 +64,7 @@ function sinceKolmafiaRevision(revision) {
122
64
  * This behaves like the `since X.Y;` statement in ASH.
123
65
  * @param majorVersion Major version number
124
66
  * @param minorVersion Minor version number
67
+ * @deprecated Point versions are no longer released by KoLmafia
125
68
  * @throws {KolmafiaVersionError}
126
69
  * If KoLmafia's major version is less than `majorVersion`, or if the major
127
70
  * versions are equal but the minor version is less than `minorVersion`
@@ -134,29 +77,30 @@ function sinceKolmafiaRevision(revision) {
134
77
  * sinceKolmafiaVersion(20, 7);
135
78
  * ```
136
79
  */
137
-
138
-
139
- function sinceKolmafiaVersion(majorVersion, minorVersion) {
140
- if (!Number.isInteger(majorVersion)) {
141
- throw new TypeError("Invalid major version number ".concat(majorVersion, " (must be an integer)"));
142
- }
143
-
144
- if (!Number.isInteger(minorVersion)) {
145
- throw new TypeError("Invalid minor version number ".concat(minorVersion, " (must be an integer)"));
146
- }
147
-
148
- var versionStr = (0, _kolmafia.getVersion)();
149
- var versionStrMatch = /v(\d+)\.(\d+)/.exec(versionStr);
150
-
151
- if (!versionStrMatch) {
152
- // This is not something the user should handle
153
- throw new Error("Unexpected KoLmafia version string: \"".concat(versionStr, "\". You may need to update the script."));
154
- }
155
-
156
- var currentMajorVersion = Number(versionStrMatch[1]);
157
- var currentMinorVersion = Number(versionStrMatch[2]); // Based on net.sourceforge.kolmafia.textui.Parser.sinceException()
158
-
159
- if (currentMajorVersion < majorVersion || currentMajorVersion === majorVersion && currentMinorVersion < minorVersion) {
160
- throw new KolmafiaVersionError("".concat(getScriptName(), " requires version ").concat(majorVersion, ".").concat(minorVersion, " of kolmafia or higher (current: ").concat(currentMajorVersion, ".").concat(currentMinorVersion, "). Up-to-date builds can be found at https://ci.kolmafia.us/."));
161
- }
162
- }
80
+ export function sinceKolmafiaVersion(majorVersion, minorVersion) {
81
+ if (getRevision() >= 25720) {
82
+ return;
83
+ }
84
+ if (!Number.isInteger(majorVersion)) {
85
+ throw new TypeError(`Invalid major version number ${majorVersion} (must be an integer)`);
86
+ }
87
+ if (!Number.isInteger(minorVersion)) {
88
+ throw new TypeError(`Invalid minor version number ${minorVersion} (must be an integer)`);
89
+ }
90
+ if (majorVersion > 21 || (majorVersion === 20 && minorVersion > 9)) {
91
+ throw new Error(`There were no versions released after 21.09. This command will always fail`);
92
+ }
93
+ const versionStr = getVersion();
94
+ const versionStrMatch = /v(\d+)\.(\d+)/.exec(versionStr);
95
+ if (!versionStrMatch) {
96
+ // This is not something the user should handle
97
+ throw new Error(`Unexpected KoLmafia version string: "${versionStr}". You may need to update the script.`);
98
+ }
99
+ const currentMajorVersion = Number(versionStrMatch[1]);
100
+ const currentMinorVersion = Number(versionStrMatch[2]);
101
+ // Based on net.sourceforge.kolmafia.textui.Parser.sinceException()
102
+ if (currentMajorVersion < majorVersion ||
103
+ (currentMajorVersion === majorVersion && currentMinorVersion < minorVersion)) {
104
+ throw new KolmafiaVersionError(`${getScriptName()} requires version ${majorVersion}.${minorVersion} of kolmafia or higher (current: ${currentMajorVersion}.${currentMinorVersion}). Up-to-date builds can be found at https://ci.kolmafia.us/.`);
105
+ }
106
+ }