isaacscript-common 84.1.2 → 84.2.1
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/classes/features/callbackLogic/PlayerCollectibleDetection.d.ts.map +1 -1
- package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.js +3 -2
- package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.lua +4 -2
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +9 -3
- package/dist/decorators.lua +9 -2
- package/dist/functions/array.d.ts +1 -1
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/array.js +2 -1
- package/dist/functions/array.lua +3 -1
- package/dist/functions/decorators.d.ts.map +1 -1
- package/dist/functions/decorators.js +10 -6
- package/dist/functions/decorators.lua +10 -6
- package/dist/functions/enums.d.ts.map +1 -1
- package/dist/functions/enums.js +7 -4
- package/dist/functions/enums.lua +9 -4
- package/dist/functions/logMisc.d.ts +2 -2
- package/dist/functions/logMisc.d.ts.map +1 -1
- package/dist/functions/logMisc.js +3 -4
- package/dist/functions/logMisc.lua +4 -3
- package/dist/functions/set.d.ts +3 -3
- package/dist/functions/set.d.ts.map +1 -1
- package/dist/functions/set.js +2 -1
- package/dist/functions/set.lua +3 -1
- package/dist/functions/sort.d.ts +2 -1
- package/dist/functions/sort.d.ts.map +1 -1
- package/dist/functions/sort.js +3 -2
- package/dist/functions/sort.lua +6 -6
- package/dist/functions/table.js +1 -1
- package/dist/functions/types.d.ts.map +1 -1
- package/dist/functions/types.js +7 -5
- package/dist/functions/types.lua +3 -1
- package/dist/index.rollup.d.ts +9 -7
- package/dist/isaacscript-common.lua +52 -27
- package/package.json +1 -1
- package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +3 -2
- package/src/decorators.ts +18 -9
- package/src/functions/array.ts +3 -2
- package/src/functions/decorators.ts +12 -13
- package/src/functions/enums.ts +7 -6
- package/src/functions/logMisc.ts +5 -6
- package/src/functions/set.ts +7 -4
- package/src/functions/sort.ts +2 -2
- package/src/functions/table.ts +1 -1
- package/src/functions/types.ts +7 -5
package/dist/functions/table.js
CHANGED
|
@@ -140,7 +140,7 @@ function iterateTableInOrder(luaMap, func, inOrder = true) {
|
|
|
140
140
|
}
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
keys.sort();
|
|
143
|
+
keys.sort(); // eslint-disable-line @typescript-eslint/require-array-sort-compare
|
|
144
144
|
for (const key of keys) {
|
|
145
145
|
const keyIndex = key;
|
|
146
146
|
const value = luaMap.get(keyIndex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/functions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,eAAe,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAE1C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAEtC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAEnD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,OAAO,CAEhE;AAGD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAElE;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,GAAG,CAM5D;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,CAE9D;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CACzB,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,OAAO,GAAG,MAAM,GAAG,MAAM,CAOvC;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,CAE9D;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/functions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,eAAe,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAE1C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAEtC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAEnD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,OAAO,CAEhE;AAGD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAElE;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,GAAG,CAM5D;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,CAE9D;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CACzB,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,OAAO,GAAG,MAAM,GAAG,MAAM,CAOvC;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,CAE9D;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAGxC;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,WAAW,CAGrE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAe5D"}
|
package/dist/functions/types.js
CHANGED
|
@@ -161,12 +161,12 @@ function asTrinketType(num) {
|
|
|
161
161
|
}
|
|
162
162
|
exports.asTrinketType = asTrinketType;
|
|
163
163
|
function isBoolean(variable) {
|
|
164
|
-
return
|
|
164
|
+
return typeof variable === "boolean";
|
|
165
165
|
}
|
|
166
166
|
exports.isBoolean = isBoolean;
|
|
167
167
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
168
168
|
function isFunction(variable) {
|
|
169
|
-
return
|
|
169
|
+
return typeof variable === "function";
|
|
170
170
|
}
|
|
171
171
|
exports.isFunction = isFunction;
|
|
172
172
|
function isInteger(variable) {
|
|
@@ -177,26 +177,28 @@ function isInteger(variable) {
|
|
|
177
177
|
}
|
|
178
178
|
exports.isInteger = isInteger;
|
|
179
179
|
function isNumber(variable) {
|
|
180
|
-
return
|
|
180
|
+
return typeof variable === "number";
|
|
181
181
|
}
|
|
182
182
|
exports.isNumber = isNumber;
|
|
183
183
|
/** Helper function to detect if a variable is a boolean, number, or string. */
|
|
184
184
|
function isPrimitive(variable) {
|
|
185
|
-
const variableType =
|
|
185
|
+
const variableType = typeof variable;
|
|
186
186
|
return (variableType === "boolean" ||
|
|
187
187
|
variableType === "number" ||
|
|
188
188
|
variableType === "string");
|
|
189
189
|
}
|
|
190
190
|
exports.isPrimitive = isPrimitive;
|
|
191
191
|
function isString(variable) {
|
|
192
|
-
return
|
|
192
|
+
return typeof variable === "string";
|
|
193
193
|
}
|
|
194
194
|
exports.isString = isString;
|
|
195
195
|
function isTable(variable) {
|
|
196
|
+
// We cannot use `typeof` here since "table" is not a JavaScript type.
|
|
196
197
|
return type(variable) === "table";
|
|
197
198
|
}
|
|
198
199
|
exports.isTable = isTable;
|
|
199
200
|
function isUserdata(variable) {
|
|
201
|
+
// We cannot use `typeof` here since "userdata" is not a JavaScript type.
|
|
200
202
|
return type(variable) === "userdata";
|
|
201
203
|
}
|
|
202
204
|
exports.isUserdata = isUserdata;
|
package/dist/functions/types.lua
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
1
3
|
local ____exports = {}
|
|
2
4
|
function ____exports.isNumber(self, variable)
|
|
3
5
|
return type(variable) == "number"
|
|
@@ -107,7 +109,7 @@ function ____exports.isInteger(self, variable)
|
|
|
107
109
|
end
|
|
108
110
|
--- Helper function to detect if a variable is a boolean, number, or string.
|
|
109
111
|
function ____exports.isPrimitive(self, variable)
|
|
110
|
-
local variableType =
|
|
112
|
+
local variableType = __TS__TypeOf(variable)
|
|
111
113
|
return variableType == "boolean" or variableType == "number" or variableType == "string"
|
|
112
114
|
end
|
|
113
115
|
function ____exports.isString(self, variable)
|
package/dist/index.rollup.d.ts
CHANGED
|
@@ -5047,7 +5047,7 @@ export declare function getArrayCombinations<T>(array: readonly T[], includeEmpt
|
|
|
5047
5047
|
* Helper function to get the duplicate elements in an array. Only one element for each value will
|
|
5048
5048
|
* be returned. The elements will be sorted before they are returned.
|
|
5049
5049
|
*/
|
|
5050
|
-
export declare function getArrayDuplicateElements<T>(array: readonly T[]): readonly T[];
|
|
5050
|
+
export declare function getArrayDuplicateElements<T extends number | string>(array: readonly T[]): readonly T[];
|
|
5051
5051
|
|
|
5052
5052
|
/**
|
|
5053
5053
|
* Helper function to get an array containing the indexes of an array.
|
|
@@ -7261,7 +7261,7 @@ export declare function getRandomSeed(): Seed;
|
|
|
7261
7261
|
* a random seed.
|
|
7262
7262
|
* @param exceptions Optional. An array of elements to skip over if selected.
|
|
7263
7263
|
*/
|
|
7264
|
-
export declare function getRandomSetElement<T>(set: ReadonlySet<T>, seedOrRNG: Seed | RNG | undefined, exceptions?: readonly T[]): T;
|
|
7264
|
+
export declare function getRandomSetElement<T extends number | string>(set: ReadonlySet<T>, seedOrRNG: Seed | RNG | undefined, exceptions?: readonly T[]): T;
|
|
7265
7265
|
|
|
7266
7266
|
/**
|
|
7267
7267
|
* Helper function to get a random vector between (-1, -1) and (1, 1).
|
|
@@ -7876,7 +7876,7 @@ export declare function getSeedEffects(): readonly SeedEffect[];
|
|
|
7876
7876
|
* @param set The set to get the combinations of.
|
|
7877
7877
|
* @param includeEmptyArray Whether to include an empty array in the combinations.
|
|
7878
7878
|
*/
|
|
7879
|
-
export declare function getSetCombinations<T>(set: ReadonlySet<T>, includeEmptyArray: boolean): ReadonlyArray<ReadonlySet<T>>;
|
|
7879
|
+
export declare function getSetCombinations<T extends number | string>(set: ReadonlySet<T>, includeEmptyArray: boolean): ReadonlyArray<ReadonlySet<T>>;
|
|
7880
7880
|
|
|
7881
7881
|
/**
|
|
7882
7882
|
* Helper function to get the shooting actions that the specified `ControllerIndex` is currently
|
|
@@ -7934,7 +7934,7 @@ export declare function getSlots(slotVariant?: SlotVariant | -1, subType?: numbe
|
|
|
7934
7934
|
* Normally, set values are returned in insertion order, so use this function when the ordering of
|
|
7935
7935
|
* the contents is important.
|
|
7936
7936
|
*/
|
|
7937
|
-
export declare function getSortedSetValues<T>(set: ReadonlySet<T>): T[];
|
|
7937
|
+
export declare function getSortedSetValues<T extends number | string>(set: ReadonlySet<T>): T[];
|
|
7938
7938
|
|
|
7939
7939
|
/** Helper function to get all of the `GridEntitySpikes` in the room. */
|
|
7940
7940
|
export declare function getSpikes(variant?: number): readonly GridEntitySpikes[];
|
|
@@ -10860,7 +10860,7 @@ export declare function logLevelStateFlags(this: void): void;
|
|
|
10860
10860
|
* @param map The TSTL `Map` to log.
|
|
10861
10861
|
* @param name Optional. The name of the map, which will be logged before the elements.
|
|
10862
10862
|
*/
|
|
10863
|
-
export declare function logMap(this: void, map: ReadonlyMap<
|
|
10863
|
+
export declare function logMap(this: void, map: ReadonlyMap<number | string, unknown>, name?: string): void;
|
|
10864
10864
|
|
|
10865
10865
|
export declare function logMusic(this: void): void;
|
|
10866
10866
|
|
|
@@ -10901,7 +10901,7 @@ export declare function logSeedEffects(this: void): void;
|
|
|
10901
10901
|
* @param set The TSTL `Set` to log.
|
|
10902
10902
|
* @param name Optional. The name of the set, which will be logged before the elements.
|
|
10903
10903
|
*/
|
|
10904
|
-
export declare function logSet(this: void, set: ReadonlySet<
|
|
10904
|
+
export declare function logSet(this: void, set: ReadonlySet<number | string>, name?: string): void;
|
|
10905
10905
|
|
|
10906
10906
|
/** Helper function for logging every sound effect that is currently playing. */
|
|
10907
10907
|
export declare function logSounds(this: void): void;
|
|
@@ -18189,6 +18189,8 @@ export declare function smeltTrinkets(player: EntityPlayer, ...trinketTypes: rea
|
|
|
18189
18189
|
*/
|
|
18190
18190
|
export declare function some<T>(array: readonly T[], func: (value: T, index: number, array: readonly T[]) => boolean): boolean;
|
|
18191
18191
|
|
|
18192
|
+
export declare function sortNormal(a: unknown, b: unknown): -1 | 0 | 1;
|
|
18193
|
+
|
|
18192
18194
|
/**
|
|
18193
18195
|
* Helper function to sort an array of objects by one of the object keys.
|
|
18194
18196
|
*
|
|
@@ -18217,7 +18219,7 @@ export declare function sortObjectArrayByKey(key: string): (a: unknown, b: unkno
|
|
|
18217
18219
|
*
|
|
18218
18220
|
* ```ts
|
|
18219
18221
|
* const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
18220
|
-
* myArray.sort(
|
|
18222
|
+
* myArray.sort(sortTwoDimensionalArray);
|
|
18221
18223
|
* ```
|
|
18222
18224
|
*
|
|
18223
18225
|
* This function also properly handles when the array elements are strings or numbers (instead of
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 84.
|
|
3
|
+
isaacscript-common 84.2.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -17055,6 +17055,8 @@ end
|
|
|
17055
17055
|
return ____exports
|
|
17056
17056
|
end,
|
|
17057
17057
|
["functions.types"] = function(...)
|
|
17058
|
+
local ____lualib = require("lualib_bundle")
|
|
17059
|
+
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
17058
17060
|
local ____exports = {}
|
|
17059
17061
|
function ____exports.isNumber(self, variable)
|
|
17060
17062
|
return type(variable) == "number"
|
|
@@ -17164,7 +17166,7 @@ function ____exports.isInteger(self, variable)
|
|
|
17164
17166
|
end
|
|
17165
17167
|
--- Helper function to detect if a variable is a boolean, number, or string.
|
|
17166
17168
|
function ____exports.isPrimitive(self, variable)
|
|
17167
|
-
local variableType =
|
|
17169
|
+
local variableType = __TS__TypeOf(variable)
|
|
17168
17170
|
return variableType == "boolean" or variableType == "number" or variableType == "string"
|
|
17169
17171
|
end
|
|
17170
17172
|
function ____exports.isString(self, variable)
|
|
@@ -17203,7 +17205,7 @@ local ____types = require("functions.types")
|
|
|
17203
17205
|
local isNumber = ____types.isNumber
|
|
17204
17206
|
local isString = ____types.isString
|
|
17205
17207
|
local isTable = ____types.isTable
|
|
17206
|
-
|
|
17208
|
+
function ____exports.sortNormal(self, a, b)
|
|
17207
17209
|
if not isNumber(nil, a) and not isString(nil, a) then
|
|
17208
17210
|
error("Failed to normal sort since the first value was not a number or string and was instead: " .. type(a))
|
|
17209
17211
|
end
|
|
@@ -17245,7 +17247,7 @@ function ____exports.sortObjectArrayByKey(self, key)
|
|
|
17245
17247
|
end
|
|
17246
17248
|
local aValue = a[key]
|
|
17247
17249
|
local bValue = b[key]
|
|
17248
|
-
return sortNormal(nil, aValue, bValue)
|
|
17250
|
+
return ____exports.sortNormal(nil, aValue, bValue)
|
|
17249
17251
|
end
|
|
17250
17252
|
end
|
|
17251
17253
|
--- Helper function to sort a two-dimensional array by the first element.
|
|
@@ -17254,7 +17256,7 @@ end
|
|
|
17254
17256
|
--
|
|
17255
17257
|
-- ```ts
|
|
17256
17258
|
-- const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
17257
|
-
-- myArray.sort(
|
|
17259
|
+
-- myArray.sort(sortTwoDimensionalArray);
|
|
17258
17260
|
-- ```
|
|
17259
17261
|
--
|
|
17260
17262
|
-- This function also properly handles when the array elements are strings or numbers (instead of
|
|
@@ -17269,7 +17271,7 @@ function ____exports.sortTwoDimensionalArray(self, a, b)
|
|
|
17269
17271
|
error(((((((("Failed to two-dimensional sort since the two elements were disparate types: " .. tostring(a)) .. " & ") .. tostring(b)) .. " (") .. aType) .. " & ") .. bType) .. ")")
|
|
17270
17272
|
end
|
|
17271
17273
|
if aType == "string" or aType == "number" then
|
|
17272
|
-
return sortNormal(nil, a, b)
|
|
17274
|
+
return ____exports.sortNormal(nil, a, b)
|
|
17273
17275
|
end
|
|
17274
17276
|
if aType ~= "table" then
|
|
17275
17277
|
error("Failed to two-dimensional sort since the first element was not a string, number, or table.")
|
|
@@ -17290,7 +17292,7 @@ function ____exports.sortTwoDimensionalArray(self, a, b)
|
|
|
17290
17292
|
if elementType1 ~= elementType2 then
|
|
17291
17293
|
error(((((((("Failed to two-dimensional sort since the first element of each array were disparate types: " .. tostring(firstElement1)) .. " & ") .. tostring(firstElement2)) .. " (") .. elementType1) .. " & ") .. elementType2) .. ")")
|
|
17292
17294
|
end
|
|
17293
|
-
return sortNormal(nil, firstElement1, firstElement2)
|
|
17295
|
+
return ____exports.sortNormal(nil, firstElement1, firstElement2)
|
|
17294
17296
|
end
|
|
17295
17297
|
--- Helper function to sort an array in a stable way.
|
|
17296
17298
|
--
|
|
@@ -17299,7 +17301,7 @@ end
|
|
|
17299
17301
|
-- Under the hood, this uses the merge sort algorithm.
|
|
17300
17302
|
function ____exports.stableSort(self, array, sortFunc)
|
|
17301
17303
|
if sortFunc == nil then
|
|
17302
|
-
sortFunc = sortNormal
|
|
17304
|
+
sortFunc = ____exports.sortNormal
|
|
17303
17305
|
end
|
|
17304
17306
|
if #array <= 1 then
|
|
17305
17307
|
return array
|
|
@@ -18702,6 +18704,8 @@ local getRandomInt = ____random.getRandomInt
|
|
|
18702
18704
|
local ____rng = require("functions.rng")
|
|
18703
18705
|
local isRNG = ____rng.isRNG
|
|
18704
18706
|
local newRNG = ____rng.newRNG
|
|
18707
|
+
local ____sort = require("functions.sort")
|
|
18708
|
+
local sortNormal = ____sort.sortNormal
|
|
18705
18709
|
local ____types = require("functions.types")
|
|
18706
18710
|
local isNumber = ____types.isNumber
|
|
18707
18711
|
local isTable = ____types.isTable
|
|
@@ -19060,7 +19064,7 @@ function ____exports.getArrayDuplicateElements(self, array)
|
|
|
19060
19064
|
set:add(element)
|
|
19061
19065
|
end
|
|
19062
19066
|
local values = {__TS__Spread(duplicateElements)}
|
|
19063
|
-
return __TS__ArraySort(values)
|
|
19067
|
+
return __TS__ArraySort(values, sortNormal)
|
|
19064
19068
|
end
|
|
19065
19069
|
--- Helper function to get an array containing the indexes of an array.
|
|
19066
19070
|
--
|
|
@@ -19272,6 +19276,7 @@ return ____exports
|
|
|
19272
19276
|
local ____lualib = require("lualib_bundle")
|
|
19273
19277
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
19274
19278
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
19279
|
+
local __TS__ArrayToSorted = ____lualib.__TS__ArrayToSorted
|
|
19275
19280
|
local __TS__ArrayAt = ____lualib.__TS__ArrayAt
|
|
19276
19281
|
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
|
|
19277
19282
|
local __TS__New = ____lualib.__TS__New
|
|
@@ -19280,6 +19285,8 @@ local ____ReadonlySet = require("types.ReadonlySet")
|
|
|
19280
19285
|
local ReadonlySet = ____ReadonlySet.ReadonlySet
|
|
19281
19286
|
local ____array = require("functions.array")
|
|
19282
19287
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
19288
|
+
local ____sort = require("functions.sort")
|
|
19289
|
+
local sortNormal = ____sort.sortNormal
|
|
19283
19290
|
local ____types = require("functions.types")
|
|
19284
19291
|
local isNumber = ____types.isNumber
|
|
19285
19292
|
local isString = ____types.isString
|
|
@@ -19415,8 +19422,9 @@ end
|
|
|
19415
19422
|
-- Throws an error if the provided enum is empty.
|
|
19416
19423
|
function ____exports.getHighestEnumValue(self, transpiledEnum)
|
|
19417
19424
|
local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
|
|
19418
|
-
local
|
|
19419
|
-
|
|
19425
|
+
local sortedValues = __TS__ArrayToSorted(enumValues, sortNormal)
|
|
19426
|
+
local lastElement = __TS__ArrayAt(sortedValues, -1)
|
|
19427
|
+
assertDefined(nil, lastElement, "Failed to get the highest value from an enum since the enum was empty.")
|
|
19420
19428
|
return lastElement
|
|
19421
19429
|
end
|
|
19422
19430
|
--- Helper function to get the enum value with the lowest value.
|
|
@@ -19427,8 +19435,9 @@ end
|
|
|
19427
19435
|
-- Throws an error if the provided enum is empty.
|
|
19428
19436
|
function ____exports.getLowestEnumValue(self, transpiledEnum)
|
|
19429
19437
|
local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
|
|
19430
|
-
local
|
|
19431
|
-
|
|
19438
|
+
local sortedValues = __TS__ArrayToSorted(enumValues, sortNormal)
|
|
19439
|
+
local firstElement = sortedValues[1]
|
|
19440
|
+
assertDefined(nil, firstElement, "Failed to get the lowest value from an enum since the enum was empty.")
|
|
19432
19441
|
return firstElement
|
|
19433
19442
|
end
|
|
19434
19443
|
--- Helper function to get a random value from the provided enum.
|
|
@@ -40290,6 +40299,8 @@ return ____exports
|
|
|
40290
40299
|
end,
|
|
40291
40300
|
["decorators"] = function(...)
|
|
40292
40301
|
local ____exports = {}
|
|
40302
|
+
local ____tstlClass = require("functions.tstlClass")
|
|
40303
|
+
local getTSTLClassName = ____tstlClass.getTSTLClassName
|
|
40293
40304
|
____exports.EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames"
|
|
40294
40305
|
--- A decorator function that signifies that the decorated class method should be added to the
|
|
40295
40306
|
-- `ModUpgraded` object.
|
|
@@ -40297,10 +40308,15 @@ ____exports.EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames"
|
|
|
40297
40308
|
-- This is only meant to be used internally.
|
|
40298
40309
|
function ____exports.Exported(self, target, propertyKey)
|
|
40299
40310
|
local constructor = target.constructor
|
|
40300
|
-
if
|
|
40301
|
-
|
|
40311
|
+
if constructor == nil then
|
|
40312
|
+
local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
|
|
40313
|
+
error(("Failed to get the constructor for class \"" .. tstlClassName) .. "\". Did you decorate a static method? You can only decorate non-static class methods.")
|
|
40302
40314
|
end
|
|
40303
40315
|
local exportedMethodNames = constructor[____exports.EXPORTED_METHOD_NAMES_KEY]
|
|
40316
|
+
if exportedMethodNames == nil then
|
|
40317
|
+
exportedMethodNames = {}
|
|
40318
|
+
constructor[____exports.EXPORTED_METHOD_NAMES_KEY] = exportedMethodNames
|
|
40319
|
+
end
|
|
40304
40320
|
exportedMethodNames[#exportedMethodNames + 1] = propertyKey
|
|
40305
40321
|
end
|
|
40306
40322
|
return ____exports
|
|
@@ -44332,6 +44348,8 @@ local ____array = require("functions.array")
|
|
|
44332
44348
|
local getArrayCombinations = ____array.getArrayCombinations
|
|
44333
44349
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
44334
44350
|
local sumArray = ____array.sumArray
|
|
44351
|
+
local ____sort = require("functions.sort")
|
|
44352
|
+
local sortNormal = ____sort.sortNormal
|
|
44335
44353
|
local ____types = require("functions.types")
|
|
44336
44354
|
local isPrimitive = ____types.isPrimitive
|
|
44337
44355
|
--- Helper function to get a sorted array based on the contents of a set.
|
|
@@ -44347,7 +44365,7 @@ function ____exports.getSortedSetValues(self, set)
|
|
|
44347
44365
|
error(("Failed to get the sorted set values because the provided set was of type \"" .. tostring(arrayType)) .. "\". Having sets with non-primitive types doesn't make much sense in general, so you might need to rethink what you are doing.")
|
|
44348
44366
|
end
|
|
44349
44367
|
end
|
|
44350
|
-
__TS__ArraySort(values)
|
|
44368
|
+
__TS__ArraySort(values, sortNormal)
|
|
44351
44369
|
return values
|
|
44352
44370
|
end
|
|
44353
44371
|
--- Helper function to convert the keys of an object to a set.
|
|
@@ -45388,6 +45406,8 @@ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
|
|
|
45388
45406
|
local mapSetPlayer = ____playerDataStructures.mapSetPlayer
|
|
45389
45407
|
local ____players = require("functions.players")
|
|
45390
45408
|
local getPlayerFromPtr = ____players.getPlayerFromPtr
|
|
45409
|
+
local ____sort = require("functions.sort")
|
|
45410
|
+
local sortNormal = ____sort.sortNormal
|
|
45391
45411
|
local ____utils = require("functions.utils")
|
|
45392
45412
|
local ____repeat = ____utils["repeat"]
|
|
45393
45413
|
local ____DefaultMap = require("classes.DefaultMap")
|
|
@@ -45511,8 +45531,8 @@ function PlayerCollectibleDetection.prototype.checkActiveItemsChanged(self, play
|
|
|
45511
45531
|
oldCollectibleTypes[#oldCollectibleTypes + 1] = oldCollectibleType
|
|
45512
45532
|
newCollectibleTypes[#newCollectibleTypes + 1] = newCollectibleType
|
|
45513
45533
|
end
|
|
45514
|
-
__TS__ArraySort(oldCollectibleTypes)
|
|
45515
|
-
__TS__ArraySort(newCollectibleTypes)
|
|
45534
|
+
__TS__ArraySort(oldCollectibleTypes, sortNormal)
|
|
45535
|
+
__TS__ArraySort(newCollectibleTypes, sortNormal)
|
|
45516
45536
|
if not arrayEquals(nil, oldCollectibleTypes, newCollectibleTypes) then
|
|
45517
45537
|
self:updateCollectibleMapAndFire(player, nil)
|
|
45518
45538
|
end
|
|
@@ -58456,15 +58476,14 @@ return ____exports
|
|
|
58456
58476
|
end,
|
|
58457
58477
|
["functions.logMisc"] = function(...)
|
|
58458
58478
|
local ____lualib = require("lualib_bundle")
|
|
58459
|
-
local Map = ____lualib.Map
|
|
58460
58479
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
58461
58480
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
58462
58481
|
local __TS__ArrayEntries = ____lualib.__TS__ArrayEntries
|
|
58463
58482
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
58464
|
-
local Set = ____lualib.Set
|
|
58465
58483
|
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
58466
58484
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
58467
58485
|
local __TS__New = ____lualib.__TS__New
|
|
58486
|
+
local Set = ____lualib.Set
|
|
58468
58487
|
local ____exports = {}
|
|
58469
58488
|
local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.index")
|
|
58470
58489
|
local BossID = ____isaac_2Dtypescript_2Ddefinitions.BossID
|
|
@@ -58521,6 +58540,8 @@ local getRoomListIndex = ____roomData.getRoomListIndex
|
|
|
58521
58540
|
local ____set = require("functions.set")
|
|
58522
58541
|
local combineSets = ____set.combineSets
|
|
58523
58542
|
local getSortedSetValues = ____set.getSortedSetValues
|
|
58543
|
+
local ____sort = require("functions.sort")
|
|
58544
|
+
local sortNormal = ____sort.sortNormal
|
|
58524
58545
|
local ____table = require("functions.table")
|
|
58525
58546
|
local iterateTableInOrder = ____table.iterateTableInOrder
|
|
58526
58547
|
local ____trinkets = require("functions.trinkets")
|
|
@@ -58689,7 +58710,7 @@ function ____exports.logMap(map, name)
|
|
|
58689
58710
|
local suffix = name == nil and "" or (" \"" .. name) .. "\""
|
|
58690
58711
|
log(("Logging a TSTL map" .. suffix) .. ":")
|
|
58691
58712
|
local mapKeys = {__TS__Spread(map:keys())}
|
|
58692
|
-
__TS__ArraySort(mapKeys)
|
|
58713
|
+
__TS__ArraySort(mapKeys, sortNormal)
|
|
58693
58714
|
for ____, key in ipairs(mapKeys) do
|
|
58694
58715
|
local value = map:get(key)
|
|
58695
58716
|
log(((" " .. tostring(key)) .. " --> ") .. tostring(value))
|
|
@@ -64945,10 +64966,12 @@ function ____exports.PriorityCallback(self, modCallback, priority, ...)
|
|
|
64945
64966
|
local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
|
|
64946
64967
|
error(("Failed to get the constructor for class \"" .. tstlClassName) .. "\". Did you decorate a static method? You can only decorate non-static class methods, because the \"Mod\" object is not present before the class is instantiated.")
|
|
64947
64968
|
end
|
|
64948
|
-
|
|
64949
|
-
|
|
64969
|
+
local key = MOD_FEATURE_CALLBACKS_KEY
|
|
64970
|
+
local callbackTuples = constructor[key]
|
|
64971
|
+
if callbackTuples == nil then
|
|
64972
|
+
callbackTuples = {}
|
|
64973
|
+
constructor[key] = callbackTuples
|
|
64950
64974
|
end
|
|
64951
|
-
local callbackTuples = constructor[MOD_FEATURE_CALLBACKS_KEY]
|
|
64952
64975
|
callbackTuples[#callbackTuples + 1] = callbackTuple
|
|
64953
64976
|
end
|
|
64954
64977
|
end
|
|
@@ -64968,10 +64991,12 @@ function ____exports.PriorityCallbackCustom(self, modCallbackCustom, priority, .
|
|
|
64968
64991
|
local tstlClassName = getTSTLClassName(nil, target) or "Unknown"
|
|
64969
64992
|
error(("Failed to get the constructor for class \"" .. tstlClassName) .. "\". Did you decorate a static method? You can only decorate non-static class methods, because the \"Mod\" object is not present before the class is instantiated.")
|
|
64970
64993
|
end
|
|
64971
|
-
|
|
64972
|
-
|
|
64994
|
+
local key = MOD_FEATURE_CUSTOM_CALLBACKS_KEY
|
|
64995
|
+
local callbackTuples = constructor[key]
|
|
64996
|
+
if callbackTuples == nil then
|
|
64997
|
+
callbackTuples = {}
|
|
64998
|
+
constructor[key] = callbackTuples
|
|
64973
64999
|
end
|
|
64974
|
-
local callbackTuples = constructor[MOD_FEATURE_CUSTOM_CALLBACKS_KEY]
|
|
64975
65000
|
callbackTuples[#callbackTuples + 1] = callbackTuple
|
|
64976
65001
|
end
|
|
64977
65002
|
end
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
mapSetPlayer,
|
|
17
17
|
} from "../../../functions/playerDataStructures";
|
|
18
18
|
import { getPlayerFromPtr } from "../../../functions/players";
|
|
19
|
+
import { sortNormal } from "../../../functions/sort";
|
|
19
20
|
import { repeat } from "../../../functions/utils";
|
|
20
21
|
import type { PickingUpItem } from "../../../types/PickingUpItem";
|
|
21
22
|
import type { PlayerIndex } from "../../../types/PlayerIndex";
|
|
@@ -262,8 +263,8 @@ export class PlayerCollectibleDetection extends Feature {
|
|
|
262
263
|
// For example, it is possible for the player to switch Schoolbag items, which will cause the
|
|
263
264
|
// collectibles in the array to be the same, but in a different order. Thus, we sort both arrays
|
|
264
265
|
// before comparing them.
|
|
265
|
-
oldCollectibleTypes.sort();
|
|
266
|
-
newCollectibleTypes.sort();
|
|
266
|
+
oldCollectibleTypes.sort(sortNormal);
|
|
267
|
+
newCollectibleTypes.sort(sortNormal);
|
|
267
268
|
|
|
268
269
|
if (!arrayEquals(oldCollectibleTypes, newCollectibleTypes)) {
|
|
269
270
|
// One or more active items have changed (with the player's total collectible count remaining
|
package/src/decorators.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Feature } from "./classes/private/Feature";
|
|
2
|
+
import { getTSTLClassName } from "./functions/tstlClass";
|
|
2
3
|
|
|
3
4
|
export const EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames";
|
|
4
5
|
|
|
@@ -14,16 +15,24 @@ export function Exported<Class extends Feature>(
|
|
|
14
15
|
): void {
|
|
15
16
|
// Since the decorator runs prior to instantiation, we only have access to get and set static
|
|
16
17
|
// properties, which are located on the "constructor" table.
|
|
17
|
-
const constructor = target.constructor as unknown as
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
18
|
+
const constructor = target.constructor as unknown as
|
|
19
|
+
| Record<string, unknown>
|
|
20
|
+
| undefined;
|
|
21
|
+
|
|
22
|
+
if (constructor === undefined) {
|
|
23
|
+
const tstlClassName = getTSTLClassName(target) ?? "Unknown";
|
|
24
|
+
error(
|
|
25
|
+
`Failed to get the constructor for class "${tstlClassName}". Did you decorate a static method? You can only decorate non-static class methods.`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let exportedMethodNames = constructor[EXPORTED_METHOD_NAMES_KEY] as
|
|
30
|
+
| unknown[]
|
|
31
|
+
| undefined;
|
|
32
|
+
if (exportedMethodNames === undefined) {
|
|
33
|
+
exportedMethodNames = [];
|
|
34
|
+
constructor[EXPORTED_METHOD_NAMES_KEY] = exportedMethodNames;
|
|
23
35
|
}
|
|
24
36
|
|
|
25
|
-
const exportedMethodNames = constructor.get(
|
|
26
|
-
EXPORTED_METHOD_NAMES_KEY,
|
|
27
|
-
) as string[];
|
|
28
37
|
exportedMethodNames.push(propertyKey as string);
|
|
29
38
|
}
|
package/src/functions/array.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ReadonlySet } from "../types/ReadonlySet";
|
|
|
2
2
|
import type { WidenLiteral } from "../types/WidenLiteral";
|
|
3
3
|
import { getRandomInt } from "./random";
|
|
4
4
|
import { isRNG, newRNG } from "./rng";
|
|
5
|
+
import { sortNormal } from "./sort";
|
|
5
6
|
import { isNumber, isTable } from "./types";
|
|
6
7
|
import { assertDefined, eRange } from "./utils";
|
|
7
8
|
|
|
@@ -359,7 +360,7 @@ function addCombinations<T>(
|
|
|
359
360
|
* Helper function to get the duplicate elements in an array. Only one element for each value will
|
|
360
361
|
* be returned. The elements will be sorted before they are returned.
|
|
361
362
|
*/
|
|
362
|
-
export function getArrayDuplicateElements<T>(
|
|
363
|
+
export function getArrayDuplicateElements<T extends number | string>(
|
|
363
364
|
array: readonly T[],
|
|
364
365
|
): readonly T[] {
|
|
365
366
|
const duplicateElements = new Set<T>();
|
|
@@ -373,7 +374,7 @@ export function getArrayDuplicateElements<T>(
|
|
|
373
374
|
}
|
|
374
375
|
|
|
375
376
|
const values = [...duplicateElements];
|
|
376
|
-
return values.sort();
|
|
377
|
+
return values.sort(sortNormal);
|
|
377
378
|
}
|
|
378
379
|
|
|
379
380
|
/**
|
|
@@ -99,7 +99,7 @@ export function PriorityCallback<T extends ModCallback>(
|
|
|
99
99
|
// properties, which are located on the "constructor" table. Thus, we store the callback
|
|
100
100
|
// arguments for later.
|
|
101
101
|
const constructor = target.constructor as unknown as
|
|
102
|
-
|
|
|
102
|
+
| Record<string, unknown>
|
|
103
103
|
| undefined;
|
|
104
104
|
|
|
105
105
|
if (constructor === undefined) {
|
|
@@ -109,13 +109,13 @@ export function PriorityCallback<T extends ModCallback>(
|
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
const key = MOD_FEATURE_CALLBACKS_KEY;
|
|
113
|
+
let callbackTuples = constructor[key] as unknown[] | undefined;
|
|
114
|
+
if (callbackTuples === undefined) {
|
|
115
|
+
callbackTuples = [];
|
|
116
|
+
constructor[key] = callbackTuples;
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
const callbackTuples = constructor.get(
|
|
117
|
-
MOD_FEATURE_CALLBACKS_KEY,
|
|
118
|
-
) as unknown[];
|
|
119
119
|
callbackTuples.push(callbackTuple);
|
|
120
120
|
};
|
|
121
121
|
}
|
|
@@ -150,7 +150,7 @@ export function PriorityCallbackCustom<T extends ModCallbackCustom>(
|
|
|
150
150
|
// properties, which are located on the "constructor" table. Thus, we store the callback
|
|
151
151
|
// arguments for later.
|
|
152
152
|
const constructor = target.constructor as unknown as
|
|
153
|
-
|
|
|
153
|
+
| Record<string, unknown>
|
|
154
154
|
| undefined;
|
|
155
155
|
|
|
156
156
|
if (constructor === undefined) {
|
|
@@ -160,13 +160,12 @@ export function PriorityCallbackCustom<T extends ModCallbackCustom>(
|
|
|
160
160
|
);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
const key = MOD_FEATURE_CUSTOM_CALLBACKS_KEY;
|
|
164
|
+
let callbackTuples = constructor[key] as unknown[] | undefined;
|
|
165
|
+
if (callbackTuples === undefined) {
|
|
166
|
+
callbackTuples = [];
|
|
167
|
+
constructor[key] = callbackTuples;
|
|
165
168
|
}
|
|
166
|
-
|
|
167
|
-
const callbackTuples = constructor.get(
|
|
168
|
-
MOD_FEATURE_CUSTOM_CALLBACKS_KEY,
|
|
169
|
-
) as unknown[];
|
|
170
169
|
callbackTuples.push(callbackTuple);
|
|
171
170
|
};
|
|
172
171
|
}
|
package/src/functions/enums.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReadonlySet } from "../types/ReadonlySet";
|
|
2
2
|
import { getRandomArrayElement } from "./array";
|
|
3
|
+
import { sortNormal } from "./sort";
|
|
3
4
|
import { isNumber, isString } from "./types";
|
|
4
5
|
import { assertDefined, iRange } from "./utils";
|
|
5
6
|
|
|
@@ -151,11 +152,11 @@ export function getHighestEnumValue<T extends TranspiledEnum>(
|
|
|
151
152
|
transpiledEnum: T,
|
|
152
153
|
): T[keyof T] {
|
|
153
154
|
const enumValues = getEnumValues(transpiledEnum);
|
|
154
|
-
|
|
155
|
-
const lastElement =
|
|
155
|
+
const sortedValues = enumValues.toSorted(sortNormal);
|
|
156
|
+
const lastElement = sortedValues.at(-1);
|
|
156
157
|
assertDefined(
|
|
157
158
|
lastElement,
|
|
158
|
-
"Failed to get the
|
|
159
|
+
"Failed to get the highest value from an enum since the enum was empty.",
|
|
159
160
|
);
|
|
160
161
|
|
|
161
162
|
return lastElement;
|
|
@@ -173,11 +174,11 @@ export function getLowestEnumValue<T extends TranspiledEnum>(
|
|
|
173
174
|
transpiledEnum: T,
|
|
174
175
|
): T[keyof T] {
|
|
175
176
|
const enumValues = getEnumValues(transpiledEnum);
|
|
176
|
-
|
|
177
|
-
const firstElement =
|
|
177
|
+
const sortedValues = enumValues.toSorted(sortNormal);
|
|
178
|
+
const firstElement = sortedValues[0];
|
|
178
179
|
assertDefined(
|
|
179
180
|
firstElement,
|
|
180
|
-
"Failed to get the
|
|
181
|
+
"Failed to get the lowest value from an enum since the enum was empty.",
|
|
181
182
|
);
|
|
182
183
|
|
|
183
184
|
return firstElement;
|
package/src/functions/logMisc.ts
CHANGED
|
@@ -38,6 +38,7 @@ import { getPlayerHealth } from "./playerHealth";
|
|
|
38
38
|
import { getPlayerName } from "./players";
|
|
39
39
|
import { getRoomData, getRoomGridIndex, getRoomListIndex } from "./roomData";
|
|
40
40
|
import { combineSets, getSortedSetValues } from "./set";
|
|
41
|
+
import { sortNormal } from "./sort";
|
|
41
42
|
import { iterateTableInOrder } from "./table";
|
|
42
43
|
import { getTrinketName } from "./trinkets";
|
|
43
44
|
import { isDefaultMap, isTSTLMap, isTSTLSet } from "./tstlClass";
|
|
@@ -257,7 +258,7 @@ export function logLevelStateFlags(this: void): void {
|
|
|
257
258
|
*/
|
|
258
259
|
export function logMap(
|
|
259
260
|
this: void,
|
|
260
|
-
map: ReadonlyMap<
|
|
261
|
+
map: ReadonlyMap<number | string, unknown>,
|
|
261
262
|
name?: string,
|
|
262
263
|
): void {
|
|
263
264
|
if (!isTSTLMap(map) && !isDefaultMap(map)) {
|
|
@@ -269,11 +270,10 @@ export function logMap(
|
|
|
269
270
|
log(`Logging a TSTL map${suffix}:`);
|
|
270
271
|
|
|
271
272
|
const mapKeys = [...map.keys()];
|
|
272
|
-
mapKeys.sort();
|
|
273
|
+
mapKeys.sort(sortNormal);
|
|
273
274
|
|
|
274
275
|
for (const key of mapKeys) {
|
|
275
276
|
const value = map.get(key);
|
|
276
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
277
277
|
log(` ${key} --> ${value}`);
|
|
278
278
|
}
|
|
279
279
|
|
|
@@ -405,7 +405,7 @@ export function logSeedEffects(this: void): void {
|
|
|
405
405
|
*/
|
|
406
406
|
export function logSet(
|
|
407
407
|
this: void,
|
|
408
|
-
set: ReadonlySet<
|
|
408
|
+
set: ReadonlySet<number | string>,
|
|
409
409
|
name?: string,
|
|
410
410
|
): void {
|
|
411
411
|
if (!isTSTLSet(set)) {
|
|
@@ -418,7 +418,6 @@ export function logSet(
|
|
|
418
418
|
|
|
419
419
|
const setValues = getSortedSetValues(set);
|
|
420
420
|
for (const value of setValues) {
|
|
421
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
422
421
|
log(` Value: ${value}`);
|
|
423
422
|
}
|
|
424
423
|
|
|
@@ -510,7 +509,7 @@ export function logTableDifferences<K extends AnyNotNil, V>(
|
|
|
510
509
|
|
|
511
510
|
const keysSet = combineSets(table1KeysSet, table2KeysSet);
|
|
512
511
|
const keys = [...keysSet.values()];
|
|
513
|
-
keys.sort();
|
|
512
|
+
keys.sort(); // eslint-disable-line @typescript-eslint/require-array-sort-compare
|
|
514
513
|
|
|
515
514
|
for (const key of keys) {
|
|
516
515
|
const value1 = table1.get(key);
|