isaacscript-common 33.12.1 → 33.14.0

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.
@@ -1131,36 +1131,52 @@ export declare function arrayToBitFlags<T extends BitFlag | BitFlag128>(array: T
1131
1131
  export declare function arrayToString(array: unknown[]): string;
1132
1132
 
1133
1133
  /**
1134
- * Helper function to safely cast a `number` to a `CardType`. (This is better than using the `as`
1134
+ * Helper function to safely cast an `int` to a `CardType`. (This is better than using the `as`
1135
1135
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1136
1136
  *
1137
1137
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1138
1138
  */
1139
- export declare function asCardType(num: number): CardType;
1139
+ export declare function asCardType(num: int): CardType;
1140
1140
 
1141
1141
  /**
1142
- * Helper function to safely cast a `number` to a `CollectibleType`. (This is better than using the
1142
+ * Helper function to safely cast an `int` to a `CollectibleType`. (This is better than using the
1143
1143
  * `as` TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1144
1144
  *
1145
1145
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1146
1146
  */
1147
- export declare function asCollectibleType(num: number): CollectibleType;
1147
+ export declare function asCollectibleType(num: int): CollectibleType;
1148
1148
 
1149
1149
  /**
1150
- * Helper function to safely cast a `number` to a `LevelStage`. (This is better than using the `as`
1150
+ * Helper function to safely cast an enum to an `int`. (This is better than using the `as`
1151
1151
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1152
1152
  *
1153
1153
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1154
1154
  */
1155
- export declare function asLevelStage(num: number): LevelStage;
1155
+ export declare function asFloat(num: number): float;
1156
1156
 
1157
1157
  /**
1158
- * Helper function to safely cast a `number` to a `NPCState`. (This is better than using the `as`
1158
+ * Helper function to safely cast an enum to an `int`. (This is better than using the `as`
1159
1159
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1160
1160
  *
1161
1161
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1162
1162
  */
1163
- export declare function asNPCState(num: number): NPCState;
1163
+ export declare function asInt(num: number): int;
1164
+
1165
+ /**
1166
+ * Helper function to safely cast an `int` to a `LevelStage`. (This is better than using the `as`
1167
+ * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1168
+ *
1169
+ * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1170
+ */
1171
+ export declare function asLevelStage(num: int): LevelStage;
1172
+
1173
+ /**
1174
+ * Helper function to safely cast an `int` to a `NPCState`. (This is better than using the `as`
1175
+ * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1176
+ *
1177
+ * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1178
+ */
1179
+ export declare function asNPCState(num: int): NPCState;
1164
1180
 
1165
1181
  /**
1166
1182
  * Helper function to safely cast an enum to a `number`. (This is better than using the `as`
@@ -1171,28 +1187,28 @@ export declare function asNPCState(num: number): NPCState;
1171
1187
  export declare function asNumber(num: number): number;
1172
1188
 
1173
1189
  /**
1174
- * Helper function to safely cast a `number` to a `PillColor`. (This is better than using the `as`
1190
+ * Helper function to safely cast an `int` to a `PillColor`. (This is better than using the `as`
1175
1191
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1176
1192
  *
1177
1193
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1178
1194
  */
1179
- export declare function asPillColor(num: number): PillColor;
1195
+ export declare function asPillColor(num: int): PillColor;
1180
1196
 
1181
1197
  /**
1182
- * Helper function to safely cast a `number` to a `PillEffect`. (This is better than using the `as`
1198
+ * Helper function to safely cast an `int` to a `PillEffect`. (This is better than using the `as`
1183
1199
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1184
1200
  *
1185
1201
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1186
1202
  */
1187
- export declare function asPillEffect(num: number): PillEffect;
1203
+ export declare function asPillEffect(num: int): PillEffect;
1188
1204
 
1189
1205
  /**
1190
- * Helper function to safely cast a `number` to a `PlayerType`. (This is better than using the `as`
1206
+ * Helper function to safely cast an `int` to a `PlayerType`. (This is better than using the `as`
1191
1207
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1192
1208
  *
1193
1209
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1194
1210
  */
1195
- export declare function asPlayerType(num: number): PlayerType;
1211
+ export declare function asPlayerType(num: int): PlayerType;
1196
1212
 
1197
1213
  /**
1198
1214
  * Helper function to throw an error (using the `error` Lua function) if the provided value is equal
@@ -1213,12 +1229,12 @@ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends
1213
1229
  export declare function asString(str: string): string;
1214
1230
 
1215
1231
  /**
1216
- * Helper function to safely cast a `number` to a `TrinketType`. (This is better than using the `as`
1232
+ * Helper function to safely cast an `int` to a `TrinketType`. (This is better than using the `as`
1217
1233
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
1218
1234
  *
1219
1235
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
1220
1236
  */
1221
- export declare function asTrinketType(num: number): TrinketType;
1237
+ export declare function asTrinketType(num: int): TrinketType;
1222
1238
 
1223
1239
  /**
1224
1240
  * The distance of the laser when Azazel does not have any range up items yet. For more info, see
@@ -4292,7 +4308,7 @@ declare abstract class Feature {
4292
4308
  constructor();
4293
4309
  }
4294
4310
 
4295
- /** Helper function to fill every possible square with a red room. */
4311
+ /** Helper function to fill every possible level grid square with a red room. */
4296
4312
  export declare function fillLevelWithRedRooms(): void;
4297
4313
 
4298
4314
  /**
@@ -5724,6 +5740,15 @@ export declare function getLastElement<T>(array: T[]): T | undefined;
5724
5740
  */
5725
5741
  export declare function getLastFrameOfAnimation(sprite: Sprite, animation?: string): int;
5726
5742
 
5743
+ /**
5744
+ * Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
5745
+ * to the sub-type of the room data.)
5746
+ *
5747
+ * Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
5748
+ * rooms will not count.
5749
+ */
5750
+ export declare function getLevelBossIDs(): BossID[];
5751
+
5727
5752
  /**
5728
5753
  * Helper function to get the lowest value in an array. Returns undefined if there were no elements
5729
5754
  * in the array.
@@ -6672,7 +6697,7 @@ export declare function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor>;
6672
6697
  * Helper function to get an array of all of the room descriptors for rooms that match the specified
6673
6698
  * room type.
6674
6699
  *
6675
- * This function only searches through rooms in the current dimension.
6700
+ * This function only searches through rooms in the current dimension and rooms inside the grid.
6676
6701
  *
6677
6702
  * This function is variadic, meaning that you can specify N arguments to get the combined room
6678
6703
  * descriptors for N room types.
@@ -9498,6 +9523,14 @@ export declare const LEVEL_GRID_COLUMN_HEIGHT = 13;
9498
9523
  */
9499
9524
  export declare const LEVEL_GRID_ROW_WIDTH = 13;
9500
9525
 
9526
+ /**
9527
+ * Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
9528
+ *
9529
+ * This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
9530
+ * It will return true if one or more of the boss IDs are matched.
9531
+ */
9532
+ export declare function levelHasBossID(...bossIDs: BossID[]): boolean;
9533
+
9501
9534
  /**
9502
9535
  * Helper function to check to see if the current floor has one or more of a specific room type in
9503
9536
  * it.
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 33.12.1
3
+ isaacscript-common 33.14.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -15731,6 +15731,12 @@ end
15731
15731
  function ____exports.asCollectibleType(self, num)
15732
15732
  return num
15733
15733
  end
15734
+ function ____exports.asFloat(self, num)
15735
+ return num
15736
+ end
15737
+ function ____exports.asInt(self, num)
15738
+ return num
15739
+ end
15734
15740
  function ____exports.asLevelStage(self, num)
15735
15741
  return num
15736
15742
  end
@@ -27737,8 +27743,8 @@ function ____exports.changeRoom(self, roomGridIndex)
27737
27743
  game:ChangeRoom(roomGridIndex)
27738
27744
  end
27739
27745
  function ____exports.getNumRooms(self)
27740
- local rooms = ____exports.getRoomsInsideGrid(nil)
27741
- return #rooms
27746
+ local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
27747
+ return #roomsInsideGrid
27742
27748
  end
27743
27749
  function ____exports.getRoomDataForTypeVariant(self, roomType, roomVariant, cancelRoomTransition, useSpecialRoomsForRoomTypeDefault)
27744
27750
  if cancelRoomTransition == nil then
@@ -27879,14 +27885,14 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes, includeSecretAndS
27879
27885
  if includeUltraSecretRoom == nil then
27880
27886
  includeUltraSecretRoom = false
27881
27887
  end
27882
- local rooms = ____exports.getRoomsInsideGrid(nil)
27888
+ local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
27883
27889
  local matchingRooms
27884
27890
  if onlyCheckRoomTypes == nil then
27885
- matchingRooms = rooms
27891
+ matchingRooms = roomsInsideGrid
27886
27892
  else
27887
27893
  local roomTypeWhitelist = __TS__New(ReadonlySet, onlyCheckRoomTypes)
27888
27894
  matchingRooms = __TS__ArrayFilter(
27889
- rooms,
27895
+ roomsInsideGrid,
27890
27896
  function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypeWhitelist:has(roomDescriptor.Data.Type) end
27891
27897
  )
27892
27898
  end
@@ -48156,12 +48162,12 @@ function ____exports.getNewRoomCandidatesForLevel(self, ensureDeadEnd)
48156
48162
  if ensureDeadEnd == nil then
48157
48163
  ensureDeadEnd = true
48158
48164
  end
48159
- local rooms = getRoomsInsideGrid(nil)
48165
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
48160
48166
  local normalRooms = __TS__ArrayFilter(
48161
- rooms,
48167
+ roomsInsideGrid,
48162
48168
  function(____, room) return room.Data ~= nil and room.Data.Type == RoomType.DEFAULT and not isMirrorRoom(nil, room.Data) and not isMineShaft(nil, room.Data) end
48163
48169
  )
48164
- local roomsToLookThrough = ensureDeadEnd and normalRooms or rooms
48170
+ local roomsToLookThrough = ensureDeadEnd and normalRooms or roomsInsideGrid
48165
48171
  local newRoomCandidates = {}
48166
48172
  for ____, room in ipairs(roomsToLookThrough) do
48167
48173
  local newRoomCandidatesBesideRoom = ____exports.getNewRoomCandidatesBesideRoom(nil, room.SafeGridIndex, ensureDeadEnd)
@@ -48279,9 +48285,9 @@ end
48279
48285
  function ____exports.getRoomDescriptorsForType(self, ...)
48280
48286
  local roomTypes = {...}
48281
48287
  local roomTypesSet = __TS__New(Set, roomTypes)
48282
- local rooms = getRoomsInsideGrid(nil)
48288
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
48283
48289
  return __TS__ArrayFilter(
48284
- rooms,
48290
+ roomsInsideGrid,
48285
48291
  function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypesSet:has(roomDescriptor.Data.Type) end
48286
48292
  )
48287
48293
  end
@@ -53740,11 +53746,20 @@ end
53740
53746
  return ____exports
53741
53747
  end,
53742
53748
  ["src.functions.level"] = function(...)
53749
+ local ____lualib = require("lualib_bundle")
53750
+ local Set = ____lualib.Set
53751
+ local __TS__New = ____lualib.__TS__New
53752
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
53743
53753
  local ____exports = {}
53754
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
53755
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
53756
+ local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
53744
53757
  local ____cachedEnumValues = require("src.arrays.cachedEnumValues")
53745
53758
  local DOOR_SLOT_VALUES = ____cachedEnumValues.DOOR_SLOT_VALUES
53746
53759
  local ____cachedClasses = require("src.core.cachedClasses")
53747
53760
  local game = ____cachedClasses.game
53761
+ local ____array = require("src.functions.array")
53762
+ local filterMap = ____array.filterMap
53748
53763
  local ____levelGrid = require("src.functions.levelGrid")
53749
53764
  local getRoomDescriptorsForType = ____levelGrid.getRoomDescriptorsForType
53750
53765
  local isDoorSlotValidAtGridIndexForRedRoom = ____levelGrid.isDoorSlotValidAtGridIndexForRedRoom
@@ -53768,6 +53783,23 @@ function ____exports.fillLevelWithRedRooms(self)
53768
53783
  end
53769
53784
  until not (numRoomsInGrid ~= getNumRooms(nil))
53770
53785
  end
53786
+ function ____exports.getLevelBossIDs(self)
53787
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
53788
+ return filterMap(
53789
+ nil,
53790
+ roomsInsideGrid,
53791
+ function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomDescriptor.Data.Type == RoomType.BOSS and roomDescriptor.Data.StageID == StageID.SPECIAL_ROOMS and roomDescriptor.Data.Subtype or nil end
53792
+ )
53793
+ end
53794
+ function ____exports.levelHasBossID(self, ...)
53795
+ local bossIDs = {...}
53796
+ local levelBossIDs = ____exports.getLevelBossIDs(nil)
53797
+ local levelBossIDsSet = __TS__New(Set, levelBossIDs)
53798
+ return __TS__ArraySome(
53799
+ bossIDs,
53800
+ function(____, bossID) return levelBossIDsSet:has(bossID) end
53801
+ )
53802
+ end
53771
53803
  function ____exports.levelHasRoomType(self, ...)
53772
53804
  local roomDescriptors = getRoomDescriptorsForType(nil, ...)
53773
53805
  return #roomDescriptors > 0
@@ -1,6 +1,22 @@
1
- import type { RoomType } from "isaac-typescript-definitions";
2
- /** Helper function to fill every possible square with a red room. */
1
+ import type { BossID } from "isaac-typescript-definitions";
2
+ import { RoomType } from "isaac-typescript-definitions";
3
+ /** Helper function to fill every possible level grid square with a red room. */
3
4
  export declare function fillLevelWithRedRooms(): void;
5
+ /**
6
+ * Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
7
+ * to the sub-type of the room data.)
8
+ *
9
+ * Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
10
+ * rooms will not count.
11
+ */
12
+ export declare function getLevelBossIDs(): BossID[];
13
+ /**
14
+ * Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
15
+ *
16
+ * This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
17
+ * It will return true if one or more of the boss IDs are matched.
18
+ */
19
+ export declare function levelHasBossID(...bossIDs: BossID[]): boolean;
4
20
  /**
5
21
  * Helper function to check to see if the current floor has one or more of a specific room type in
6
22
  * it.
@@ -1 +1 @@
1
- {"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../../../src/functions/level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAS7D,qEAAqE;AACrE,wBAAgB,qBAAqB,IAAI,IAAI,CAqB5C;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAGlE"}
1
+ {"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../../../src/functions/level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAW,MAAM,8BAA8B,CAAC;AAUjE,gFAAgF;AAChF,wBAAgB,qBAAqB,IAAI,IAAI,CAqB5C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAU1C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAK5D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAGlE"}
@@ -1,15 +1,24 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
1
5
  local ____exports = {}
6
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
8
+ local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
2
9
  local ____cachedEnumValues = require("src.arrays.cachedEnumValues")
3
10
  local DOOR_SLOT_VALUES = ____cachedEnumValues.DOOR_SLOT_VALUES
4
11
  local ____cachedClasses = require("src.core.cachedClasses")
5
12
  local game = ____cachedClasses.game
13
+ local ____array = require("src.functions.array")
14
+ local filterMap = ____array.filterMap
6
15
  local ____levelGrid = require("src.functions.levelGrid")
7
16
  local getRoomDescriptorsForType = ____levelGrid.getRoomDescriptorsForType
8
17
  local isDoorSlotValidAtGridIndexForRedRoom = ____levelGrid.isDoorSlotValidAtGridIndexForRedRoom
9
18
  local ____rooms = require("src.functions.rooms")
10
19
  local getNumRooms = ____rooms.getNumRooms
11
20
  local getRoomsInsideGrid = ____rooms.getRoomsInsideGrid
12
- --- Helper function to fill every possible square with a red room.
21
+ --- Helper function to fill every possible level grid square with a red room.
13
22
  function ____exports.fillLevelWithRedRooms(self)
14
23
  local level = game:GetLevel()
15
24
  local numRoomsInGrid
@@ -27,6 +36,32 @@ function ____exports.fillLevelWithRedRooms(self)
27
36
  end
28
37
  until not (numRoomsInGrid ~= getNumRooms(nil))
29
38
  end
39
+ --- Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
40
+ -- to the sub-type of the room data.)
41
+ --
42
+ -- Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
43
+ -- rooms will not count.
44
+ function ____exports.getLevelBossIDs(self)
45
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
46
+ return filterMap(
47
+ nil,
48
+ roomsInsideGrid,
49
+ function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomDescriptor.Data.Type == RoomType.BOSS and roomDescriptor.Data.StageID == StageID.SPECIAL_ROOMS and roomDescriptor.Data.Subtype or nil end
50
+ )
51
+ end
52
+ --- Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
53
+ --
54
+ -- This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
55
+ -- It will return true if one or more of the boss IDs are matched.
56
+ function ____exports.levelHasBossID(self, ...)
57
+ local bossIDs = {...}
58
+ local levelBossIDs = ____exports.getLevelBossIDs(nil)
59
+ local levelBossIDsSet = __TS__New(Set, levelBossIDs)
60
+ return __TS__ArraySome(
61
+ bossIDs,
62
+ function(____, bossID) return levelBossIDsSet:has(bossID) end
63
+ )
64
+ end
30
65
  --- Helper function to check to see if the current floor has one or more of a specific room type in
31
66
  -- it.
32
67
  --
@@ -102,7 +102,7 @@ export declare function getRoomAdjacentGridIndexes(roomGridIndex?: int): Readonl
102
102
  * Helper function to get an array of all of the room descriptors for rooms that match the specified
103
103
  * room type.
104
104
  *
105
- * This function only searches through rooms in the current dimension.
105
+ * This function only searches through rooms in the current dimension and rooms inside the grid.
106
106
  *
107
107
  * This function is variadic, meaning that you can specify N arguments to get the combined room
108
108
  * descriptors for N room types.
@@ -136,12 +136,12 @@ function ____exports.getNewRoomCandidatesForLevel(self, ensureDeadEnd)
136
136
  if ensureDeadEnd == nil then
137
137
  ensureDeadEnd = true
138
138
  end
139
- local rooms = getRoomsInsideGrid(nil)
139
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
140
140
  local normalRooms = __TS__ArrayFilter(
141
- rooms,
141
+ roomsInsideGrid,
142
142
  function(____, room) return room.Data ~= nil and room.Data.Type == RoomType.DEFAULT and not isMirrorRoom(nil, room.Data) and not isMineShaft(nil, room.Data) end
143
143
  )
144
- local roomsToLookThrough = ensureDeadEnd and normalRooms or rooms
144
+ local roomsToLookThrough = ensureDeadEnd and normalRooms or roomsInsideGrid
145
145
  local newRoomCandidates = {}
146
146
  for ____, room in ipairs(roomsToLookThrough) do
147
147
  local newRoomCandidatesBesideRoom = ____exports.getNewRoomCandidatesBesideRoom(nil, room.SafeGridIndex, ensureDeadEnd)
@@ -324,16 +324,16 @@ end
324
324
  --- Helper function to get an array of all of the room descriptors for rooms that match the specified
325
325
  -- room type.
326
326
  --
327
- -- This function only searches through rooms in the current dimension.
327
+ -- This function only searches through rooms in the current dimension and rooms inside the grid.
328
328
  --
329
329
  -- This function is variadic, meaning that you can specify N arguments to get the combined room
330
330
  -- descriptors for N room types.
331
331
  function ____exports.getRoomDescriptorsForType(self, ...)
332
332
  local roomTypes = {...}
333
333
  local roomTypesSet = __TS__New(Set, roomTypes)
334
- local rooms = getRoomsInsideGrid(nil)
334
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
335
335
  return __TS__ArrayFilter(
336
- rooms,
336
+ roomsInsideGrid,
337
337
  function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypesSet:has(roomDescriptor.Data.Type) end
338
338
  )
339
339
  end
@@ -259,8 +259,8 @@ end
259
259
  --- Helper function to get the number of rooms that are currently on the floor layout. This does not
260
260
  -- include off-grid rooms, like the Devil Room.
261
261
  function ____exports.getNumRooms(self)
262
- local rooms = ____exports.getRoomsInsideGrid(nil)
263
- return #rooms
262
+ local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
263
+ return #roomsInsideGrid
264
264
  end
265
265
  --- Helper function to get the room data for a specific room type and variant combination. This is
266
266
  -- accomplished by using the "goto" console command to load the specified room into the
@@ -507,14 +507,14 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes, includeSecretAndS
507
507
  if includeUltraSecretRoom == nil then
508
508
  includeUltraSecretRoom = false
509
509
  end
510
- local rooms = ____exports.getRoomsInsideGrid(nil)
510
+ local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
511
511
  local matchingRooms
512
512
  if onlyCheckRoomTypes == nil then
513
- matchingRooms = rooms
513
+ matchingRooms = roomsInsideGrid
514
514
  else
515
515
  local roomTypeWhitelist = __TS__New(ReadonlySet, onlyCheckRoomTypes)
516
516
  matchingRooms = __TS__ArrayFilter(
517
- rooms,
517
+ roomsInsideGrid,
518
518
  function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypeWhitelist:has(roomDescriptor.Data.Type) end
519
519
  )
520
520
  end
@@ -2,33 +2,47 @@
2
2
  /// <reference types="lua-types/5.3" />
3
3
  import type { CardType, CollectibleType, LevelStage, NPCState, PillColor, PillEffect, PlayerType, TrinketType } from "isaac-typescript-definitions";
4
4
  /**
5
- * Helper function to safely cast a `number` to a `CardType`. (This is better than using the `as`
5
+ * Helper function to safely cast an `int` to a `CardType`. (This is better than using the `as`
6
6
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
7
7
  *
8
8
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
9
9
  */
10
- export declare function asCardType(num: number): CardType;
10
+ export declare function asCardType(num: int): CardType;
11
11
  /**
12
- * Helper function to safely cast a `number` to a `CollectibleType`. (This is better than using the
12
+ * Helper function to safely cast an `int` to a `CollectibleType`. (This is better than using the
13
13
  * `as` TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
14
14
  *
15
15
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
16
16
  */
17
- export declare function asCollectibleType(num: number): CollectibleType;
17
+ export declare function asCollectibleType(num: int): CollectibleType;
18
18
  /**
19
- * Helper function to safely cast a `number` to a `LevelStage`. (This is better than using the `as`
19
+ * Helper function to safely cast an enum to an `int`. (This is better than using the `as`
20
20
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
21
21
  *
22
22
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
23
23
  */
24
- export declare function asLevelStage(num: number): LevelStage;
24
+ export declare function asFloat(num: number): float;
25
25
  /**
26
- * Helper function to safely cast a `number` to a `NPCState`. (This is better than using the `as`
26
+ * Helper function to safely cast an enum to an `int`. (This is better than using the `as`
27
27
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
28
28
  *
29
29
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
30
30
  */
31
- export declare function asNPCState(num: number): NPCState;
31
+ export declare function asInt(num: number): int;
32
+ /**
33
+ * Helper function to safely cast an `int` to a `LevelStage`. (This is better than using the `as`
34
+ * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
35
+ *
36
+ * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
37
+ */
38
+ export declare function asLevelStage(num: int): LevelStage;
39
+ /**
40
+ * Helper function to safely cast an `int` to a `NPCState`. (This is better than using the `as`
41
+ * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
42
+ *
43
+ * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
44
+ */
45
+ export declare function asNPCState(num: int): NPCState;
32
46
  /**
33
47
  * Helper function to safely cast an enum to a `number`. (This is better than using the `as`
34
48
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
@@ -37,26 +51,26 @@ export declare function asNPCState(num: number): NPCState;
37
51
  */
38
52
  export declare function asNumber(num: number): number;
39
53
  /**
40
- * Helper function to safely cast a `number` to a `PillColor`. (This is better than using the `as`
54
+ * Helper function to safely cast an `int` to a `PillColor`. (This is better than using the `as`
41
55
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
42
56
  *
43
57
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
44
58
  */
45
- export declare function asPillColor(num: number): PillColor;
59
+ export declare function asPillColor(num: int): PillColor;
46
60
  /**
47
- * Helper function to safely cast a `number` to a `PillEffect`. (This is better than using the `as`
61
+ * Helper function to safely cast an `int` to a `PillEffect`. (This is better than using the `as`
48
62
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
49
63
  *
50
64
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
51
65
  */
52
- export declare function asPillEffect(num: number): PillEffect;
66
+ export declare function asPillEffect(num: int): PillEffect;
53
67
  /**
54
- * Helper function to safely cast a `number` to a `PlayerType`. (This is better than using the `as`
68
+ * Helper function to safely cast an `int` to a `PlayerType`. (This is better than using the `as`
55
69
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
56
70
  *
57
71
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
58
72
  */
59
- export declare function asPlayerType(num: number): PlayerType;
73
+ export declare function asPlayerType(num: int): PlayerType;
60
74
  /**
61
75
  * Helper function to safely cast an enum to a `string`. (This is better than using the `as`
62
76
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
@@ -65,12 +79,12 @@ export declare function asPlayerType(num: number): PlayerType;
65
79
  */
66
80
  export declare function asString(str: string): string;
67
81
  /**
68
- * Helper function to safely cast a `number` to a `TrinketType`. (This is better than using the `as`
82
+ * Helper function to safely cast an `int` to a `TrinketType`. (This is better than using the `as`
69
83
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
70
84
  *
71
85
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
72
86
  */
73
- export declare function asTrinketType(num: number): TrinketType;
87
+ export declare function asTrinketType(num: int): TrinketType;
74
88
  export declare function isBoolean(variable: unknown): variable is boolean;
75
89
  export declare function isFunction(variable: unknown): variable is Function;
76
90
  export declare function isInteger(variable: unknown): variable is int;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/functions/types.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAElD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAEtD;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,CAExC;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,WAAW,CAErE"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/functions/types.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,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,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,CAExC;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,WAAW,CAErE"}
@@ -2,28 +2,42 @@ local ____exports = {}
2
2
  function ____exports.isNumber(self, variable)
3
3
  return type(variable) == "number"
4
4
  end
5
- --- Helper function to safely cast a `number` to a `CardType`. (This is better than using the `as`
5
+ --- Helper function to safely cast an `int` to a `CardType`. (This is better than using the `as`
6
6
  -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
7
7
  --
8
8
  -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
9
9
  function ____exports.asCardType(self, num)
10
10
  return num
11
11
  end
12
- --- Helper function to safely cast a `number` to a `CollectibleType`. (This is better than using the
12
+ --- Helper function to safely cast an `int` to a `CollectibleType`. (This is better than using the
13
13
  -- `as` TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
14
14
  --
15
15
  -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
16
16
  function ____exports.asCollectibleType(self, num)
17
17
  return num
18
18
  end
19
- --- Helper function to safely cast a `number` to a `LevelStage`. (This is better than using the `as`
19
+ --- Helper function to safely cast an enum to an `int`. (This is better than using the `as`
20
+ -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
21
+ --
22
+ -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
23
+ function ____exports.asFloat(self, num)
24
+ return num
25
+ end
26
+ --- Helper function to safely cast an enum to an `int`. (This is better than using the `as`
27
+ -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
28
+ --
29
+ -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
30
+ function ____exports.asInt(self, num)
31
+ return num
32
+ end
33
+ --- Helper function to safely cast an `int` to a `LevelStage`. (This is better than using the `as`
20
34
  -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
21
35
  --
22
36
  -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
23
37
  function ____exports.asLevelStage(self, num)
24
38
  return num
25
39
  end
26
- --- Helper function to safely cast a `number` to a `NPCState`. (This is better than using the `as`
40
+ --- Helper function to safely cast an `int` to a `NPCState`. (This is better than using the `as`
27
41
  -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
28
42
  --
29
43
  -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
@@ -37,21 +51,21 @@ end
37
51
  function ____exports.asNumber(self, num)
38
52
  return num
39
53
  end
40
- --- Helper function to safely cast a `number` to a `PillColor`. (This is better than using the `as`
54
+ --- Helper function to safely cast an `int` to a `PillColor`. (This is better than using the `as`
41
55
  -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
42
56
  --
43
57
  -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
44
58
  function ____exports.asPillColor(self, num)
45
59
  return num
46
60
  end
47
- --- Helper function to safely cast a `number` to a `PillEffect`. (This is better than using the `as`
61
+ --- Helper function to safely cast an `int` to a `PillEffect`. (This is better than using the `as`
48
62
  -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
49
63
  --
50
64
  -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
51
65
  function ____exports.asPillEffect(self, num)
52
66
  return num
53
67
  end
54
- --- Helper function to safely cast a `number` to a `PlayerType`. (This is better than using the `as`
68
+ --- Helper function to safely cast an `int` to a `PlayerType`. (This is better than using the `as`
55
69
  -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
56
70
  --
57
71
  -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
@@ -65,7 +79,7 @@ end
65
79
  function ____exports.asString(self, str)
66
80
  return str
67
81
  end
68
- --- Helper function to safely cast a `number` to a `TrinketType`. (This is better than using the `as`
82
+ --- Helper function to safely cast an `int` to a `TrinketType`. (This is better than using the `as`
69
83
  -- TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
70
84
  --
71
85
  -- This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "33.12.1",
3
+ "version": "33.14.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,13 +1,15 @@
1
- import type { RoomType } from "isaac-typescript-definitions";
1
+ import type { BossID } from "isaac-typescript-definitions";
2
+ import { RoomType, StageID } from "isaac-typescript-definitions";
2
3
  import { DOOR_SLOT_VALUES } from "../arrays/cachedEnumValues";
3
4
  import { game } from "../core/cachedClasses";
5
+ import { filterMap } from "./array";
4
6
  import {
5
7
  getRoomDescriptorsForType,
6
8
  isDoorSlotValidAtGridIndexForRedRoom,
7
9
  } from "./levelGrid";
8
10
  import { getNumRooms, getRoomsInsideGrid } from "./rooms";
9
11
 
10
- /** Helper function to fill every possible square with a red room. */
12
+ /** Helper function to fill every possible level grid square with a red room. */
11
13
  export function fillLevelWithRedRooms(): void {
12
14
  const level = game.GetLevel();
13
15
 
@@ -31,6 +33,38 @@ export function fillLevelWithRedRooms(): void {
31
33
  } while (numRoomsInGrid !== getNumRooms());
32
34
  }
33
35
 
36
+ /**
37
+ * Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
38
+ * to the sub-type of the room data.)
39
+ *
40
+ * Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
41
+ * rooms will not count.
42
+ */
43
+ export function getLevelBossIDs(): BossID[] {
44
+ const roomsInsideGrid = getRoomsInsideGrid();
45
+
46
+ return filterMap(roomsInsideGrid, (roomDescriptor) =>
47
+ roomDescriptor.Data !== undefined &&
48
+ roomDescriptor.Data.Type === RoomType.BOSS &&
49
+ roomDescriptor.Data.StageID === StageID.SPECIAL_ROOMS
50
+ ? roomDescriptor.Data.Subtype
51
+ : undefined,
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
57
+ *
58
+ * This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
59
+ * It will return true if one or more of the boss IDs are matched.
60
+ */
61
+ export function levelHasBossID(...bossIDs: BossID[]): boolean {
62
+ const levelBossIDs = getLevelBossIDs();
63
+ const levelBossIDsSet = new Set(levelBossIDs);
64
+
65
+ return bossIDs.some((bossID) => levelBossIDsSet.has(bossID));
66
+ }
67
+
34
68
  /**
35
69
  * Helper function to check to see if the current floor has one or more of a specific room type in
36
70
  * it.
@@ -231,10 +231,10 @@ export function getNewRoomCandidatesForLevel(
231
231
  readonly newRoomGridIndex: int;
232
232
  }> {
233
233
  // We want to iterate over every room on the floor and search for potential new room spots.
234
- const rooms = getRoomsInsideGrid();
234
+ const roomsInsideGrid = getRoomsInsideGrid();
235
235
 
236
236
  // However, we want to filter out special rooms because they are supposed to be dead ends.
237
- const normalRooms = rooms.filter(
237
+ const normalRooms = roomsInsideGrid.filter(
238
238
  (room) =>
239
239
  room.Data !== undefined &&
240
240
  room.Data.Type === RoomType.DEFAULT &&
@@ -242,7 +242,7 @@ export function getNewRoomCandidatesForLevel(
242
242
  !isMineShaft(room.Data), // Mineshaft rooms do not count as special rooms.
243
243
  );
244
244
 
245
- const roomsToLookThrough = ensureDeadEnd ? normalRooms : rooms;
245
+ const roomsToLookThrough = ensureDeadEnd ? normalRooms : roomsInsideGrid;
246
246
 
247
247
  const newRoomCandidates: Array<{
248
248
  readonly adjacentRoomGridIndex: int;
@@ -301,7 +301,7 @@ export function getRoomAdjacentGridIndexes(
301
301
  * Helper function to get an array of all of the room descriptors for rooms that match the specified
302
302
  * room type.
303
303
  *
304
- * This function only searches through rooms in the current dimension.
304
+ * This function only searches through rooms in the current dimension and rooms inside the grid.
305
305
  *
306
306
  * This function is variadic, meaning that you can specify N arguments to get the combined room
307
307
  * descriptors for N room types.
@@ -311,8 +311,8 @@ export function getRoomDescriptorsForType(
311
311
  ): RoomDescriptor[] {
312
312
  const roomTypesSet = new Set<RoomType>(roomTypes);
313
313
 
314
- const rooms = getRoomsInsideGrid();
315
- return rooms.filter(
314
+ const roomsInsideGrid = getRoomsInsideGrid();
315
+ return roomsInsideGrid.filter(
316
316
  (roomDescriptor) =>
317
317
  roomDescriptor.Data !== undefined &&
318
318
  roomTypesSet.has(roomDescriptor.Data.Type),
@@ -82,8 +82,8 @@ export function changeRoom(roomGridIndex: int): void {
82
82
  * include off-grid rooms, like the Devil Room.
83
83
  */
84
84
  export function getNumRooms(): int {
85
- const rooms = getRoomsInsideGrid();
86
- return rooms.length;
85
+ const roomsInsideGrid = getRoomsInsideGrid();
86
+ return roomsInsideGrid.length;
87
87
  }
88
88
 
89
89
  /**
@@ -199,7 +199,7 @@ export function getRoomTypeName(roomType: RoomType): string {
199
199
  export function getRooms(
200
200
  includeExtraDimensionalRooms = false,
201
201
  ): RoomDescriptor[] {
202
- // The obvious way to get all of the rooms would be to iterate over the `RoomList` from the
202
+ // The naive way to get all of the rooms would be to iterate over the `RoomList` from the
203
203
  // `Level.GetRooms` method. However, this results in read-only data, and we want to return a
204
204
  // writable object. Instead, we let the heavy lifting be handled by other functions.
205
205
  const roomsInGrid = getRoomsInsideGrid(includeExtraDimensionalRooms);
@@ -497,14 +497,14 @@ export function isAllRoomsClear(
497
497
  includeSecretAndSuperSecretRoom = false,
498
498
  includeUltraSecretRoom = false,
499
499
  ): boolean {
500
- const rooms = getRoomsInsideGrid();
500
+ const roomsInsideGrid = getRoomsInsideGrid();
501
501
 
502
502
  let matchingRooms: RoomDescriptor[];
503
503
  if (onlyCheckRoomTypes === undefined) {
504
- matchingRooms = rooms;
504
+ matchingRooms = roomsInsideGrid;
505
505
  } else {
506
506
  const roomTypeWhitelist = new ReadonlySet(onlyCheckRoomTypes);
507
- matchingRooms = rooms.filter(
507
+ matchingRooms = roomsInsideGrid.filter(
508
508
  (roomDescriptor) =>
509
509
  roomDescriptor.Data !== undefined &&
510
510
  roomTypeWhitelist.has(roomDescriptor.Data.Type),
@@ -10,42 +10,62 @@ import type {
10
10
  } from "isaac-typescript-definitions";
11
11
 
12
12
  /**
13
- * Helper function to safely cast a `number` to a `CardType`. (This is better than using the `as`
13
+ * Helper function to safely cast an `int` to a `CardType`. (This is better than using the `as`
14
14
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
15
15
  *
16
16
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
17
17
  */
18
- export function asCardType(num: number): CardType {
18
+ export function asCardType(num: int): CardType {
19
19
  return num;
20
20
  }
21
21
 
22
22
  /**
23
- * Helper function to safely cast a `number` to a `CollectibleType`. (This is better than using the
23
+ * Helper function to safely cast an `int` to a `CollectibleType`. (This is better than using the
24
24
  * `as` TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
25
25
  *
26
26
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
27
27
  */
28
- export function asCollectibleType(num: number): CollectibleType {
28
+ export function asCollectibleType(num: int): CollectibleType {
29
29
  return num;
30
30
  }
31
31
 
32
32
  /**
33
- * Helper function to safely cast a `number` to a `LevelStage`. (This is better than using the `as`
33
+ * Helper function to safely cast an enum to an `int`. (This is better than using the `as`
34
34
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
35
35
  *
36
36
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
37
37
  */
38
- export function asLevelStage(num: number): LevelStage {
38
+ export function asFloat(num: number): float {
39
39
  return num;
40
40
  }
41
41
 
42
42
  /**
43
- * Helper function to safely cast a `number` to a `NPCState`. (This is better than using the `as`
43
+ * Helper function to safely cast an enum to an `int`. (This is better than using the `as`
44
44
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
45
45
  *
46
46
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
47
47
  */
48
- export function asNPCState(num: number): NPCState {
48
+ export function asInt(num: number): int {
49
+ return num;
50
+ }
51
+
52
+ /**
53
+ * Helper function to safely cast an `int` to a `LevelStage`. (This is better than using the `as`
54
+ * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
55
+ *
56
+ * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
57
+ */
58
+ export function asLevelStage(num: int): LevelStage {
59
+ return num;
60
+ }
61
+
62
+ /**
63
+ * Helper function to safely cast an `int` to a `NPCState`. (This is better than using the `as`
64
+ * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
65
+ *
66
+ * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
67
+ */
68
+ export function asNPCState(num: int): NPCState {
49
69
  return num;
50
70
  }
51
71
 
@@ -60,32 +80,32 @@ export function asNumber(num: number): number {
60
80
  }
61
81
 
62
82
  /**
63
- * Helper function to safely cast a `number` to a `PillColor`. (This is better than using the `as`
83
+ * Helper function to safely cast an `int` to a `PillColor`. (This is better than using the `as`
64
84
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
65
85
  *
66
86
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
67
87
  */
68
- export function asPillColor(num: number): PillColor {
88
+ export function asPillColor(num: int): PillColor {
69
89
  return num;
70
90
  }
71
91
 
72
92
  /**
73
- * Helper function to safely cast a `number` to a `PillEffect`. (This is better than using the `as`
93
+ * Helper function to safely cast an `int` to a `PillEffect`. (This is better than using the `as`
74
94
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
75
95
  *
76
96
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
77
97
  */
78
- export function asPillEffect(num: number): PillEffect {
98
+ export function asPillEffect(num: int): PillEffect {
79
99
  return num;
80
100
  }
81
101
 
82
102
  /**
83
- * Helper function to safely cast a `number` to a `PlayerType`. (This is better than using the `as`
103
+ * Helper function to safely cast an `int` to a `PlayerType`. (This is better than using the `as`
84
104
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
85
105
  *
86
106
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
87
107
  */
88
- export function asPlayerType(num: number): PlayerType {
108
+ export function asPlayerType(num: int): PlayerType {
89
109
  return num;
90
110
  }
91
111
 
@@ -100,12 +120,12 @@ export function asString(str: string): string {
100
120
  }
101
121
 
102
122
  /**
103
- * Helper function to safely cast a `number` to a `TrinketType`. (This is better than using the `as`
123
+ * Helper function to safely cast an `int` to a `TrinketType`. (This is better than using the `as`
104
124
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
105
125
  *
106
126
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
107
127
  */
108
- export function asTrinketType(num: number): TrinketType {
128
+ export function asTrinketType(num: int): TrinketType {
109
129
  return num;
110
130
  }
111
131