isaacscript-common 2.0.21 → 2.0.22

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.
@@ -1,4 +1,6 @@
1
1
  import { Card, ItemConfigCardType } from "isaac-typescript-definitions";
2
+ /** Helper function to get an array with every valid card sub-type. This includes modded cards. */
3
+ export declare function getAllCards(): Card[];
2
4
  /**
3
5
  * Helper function to get a card description from a Card enum value.
4
6
  *
@@ -38,8 +38,7 @@ function initCardObjects(self)
38
38
  __TS__New(Set)
39
39
  )
40
40
  end
41
- for ____, cardInt in ipairs(irange(nil, FIRST_CARD, MAX_CARD)) do
42
- local card = cardInt
41
+ for ____, card in ipairs(____exports.getAllCards(nil)) do
43
42
  local cardType = ____exports.getCardType(nil, card)
44
43
  local cardTypeSet = CARD_TYPE_TO_CARDS_MAP:get(cardType)
45
44
  if cardTypeSet == nil then
@@ -56,6 +55,9 @@ function initCardObjects(self)
56
55
  )
57
56
  addSetsToSet(nil, CARD_SET, cards)
58
57
  end
58
+ function ____exports.getAllCards(self)
59
+ return irange(nil, FIRST_CARD, MAX_CARD)
60
+ end
59
61
  function ____exports.getCardType(self, card)
60
62
  local cardType = CARD_TYPES[card]
61
63
  return cardType == nil and DEFAULT_CARD_TYPE or cardType
@@ -5,25 +5,21 @@ local Set = ____lualib.Set
5
5
  local ____exports = {}
6
6
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
7
  local CacheFlag = ____isaac_2Dtypescript_2Ddefinitions.CacheFlag
8
- local ____constantsMax = require("constantsMax")
9
- local FIRST_COLLECTIBLE_TYPE = ____constantsMax.FIRST_COLLECTIBLE_TYPE
10
- local MAX_COLLECTIBLE_TYPE = ____constantsMax.MAX_COLLECTIBLE_TYPE
11
8
  local ____collectibles = require("functions.collectibles")
12
9
  local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
10
+ local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
13
11
  local ____enums = require("functions.enums")
14
12
  local getEnumValues = ____enums.getEnumValues
15
13
  local ____set = require("functions.set")
16
14
  local copySet = ____set.copySet
17
15
  local getSortedSetValues = ____set.getSortedSetValues
18
16
  local ____utils = require("functions.utils")
19
- local irange = ____utils.irange
20
17
  local ____repeat = ____utils["repeat"]
21
18
  local CACHE_FLAG_TO_COLLECTIBLES_MAP = __TS__New(Map)
22
19
  local function initCacheFlagMap(self)
23
20
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
24
21
  local collectiblesSet = __TS__New(Set)
25
- for ____, collectibleTypeInt in ipairs(irange(nil, FIRST_COLLECTIBLE_TYPE, MAX_COLLECTIBLE_TYPE)) do
26
- local collectibleType = collectibleTypeInt
22
+ for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
27
23
  if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
28
24
  collectiblesSet:add(collectibleType)
29
25
  end
@@ -4,17 +4,13 @@ local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
5
  local ____cachedClasses = require("cachedClasses")
6
6
  local itemConfig = ____cachedClasses.itemConfig
7
- local ____constantsMax = require("constantsMax")
8
- local FIRST_COLLECTIBLE_TYPE = ____constantsMax.FIRST_COLLECTIBLE_TYPE
9
- local MAX_COLLECTIBLE_TYPE = ____constantsMax.MAX_COLLECTIBLE_TYPE
7
+ local ____collectibles = require("functions.collectibles")
8
+ local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
10
9
  local ____set = require("functions.set")
11
10
  local copySet = ____set.copySet
12
- local ____utils = require("functions.utils")
13
- local irange = ____utils.irange
14
11
  local COLLECTIBLE_SET = __TS__New(Set)
15
12
  local function initCollectibleSet(self)
16
- for ____, collectibleTypeInt in ipairs(irange(nil, FIRST_COLLECTIBLE_TYPE, MAX_COLLECTIBLE_TYPE)) do
17
- local collectibleType = collectibleTypeInt
13
+ for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
18
14
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
19
15
  if itemConfigItem ~= nil then
20
16
  COLLECTIBLE_SET:add(collectibleType)
@@ -8,9 +8,8 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
8
8
  local ItemConfigTag = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTag
9
9
  local ____cachedClasses = require("cachedClasses")
10
10
  local itemConfig = ____cachedClasses.itemConfig
11
- local ____constantsMax = require("constantsMax")
12
- local FIRST_COLLECTIBLE_TYPE = ____constantsMax.FIRST_COLLECTIBLE_TYPE
13
- local MAX_COLLECTIBLE_TYPE = ____constantsMax.MAX_COLLECTIBLE_TYPE
11
+ local ____collectibles = require("functions.collectibles")
12
+ local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
14
13
  local ____enums = require("functions.enums")
15
14
  local getEnumValues = ____enums.getEnumValues
16
15
  local ____flag = require("functions.flag")
@@ -19,8 +18,6 @@ local ____player = require("functions.player")
19
18
  local getPlayerCollectibleCount = ____player.getPlayerCollectibleCount
20
19
  local ____set = require("functions.set")
21
20
  local copySet = ____set.copySet
22
- local ____utils = require("functions.utils")
23
- local irange = ____utils.irange
24
21
  function ____exports.collectibleHasTag(self, collectibleType, tag)
25
22
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
26
23
  if itemConfigItem == nil then
@@ -36,8 +33,7 @@ local function initTagMap(self)
36
33
  __TS__New(Set)
37
34
  )
38
35
  end
39
- for ____, collectibleTypeInt in ipairs(irange(nil, FIRST_COLLECTIBLE_TYPE, MAX_COLLECTIBLE_TYPE)) do
40
- local collectibleType = collectibleTypeInt
36
+ for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
41
37
  for ____, itemConfigTag in ipairs(getEnumValues(nil, ItemConfigTag)) do
42
38
  do
43
39
  if not ____exports.collectibleHasTag(nil, collectibleType, itemConfigTag) then
@@ -102,6 +102,15 @@ export declare function getCollectibleQuality(collectibleType: CollectibleType):
102
102
  * ```
103
103
  */
104
104
  export declare function getCollectibleTags(collectibleType: CollectibleType): BitFlags<ItemConfigTag>;
105
+ /**
106
+ * Helper function to get an array that represents the range from the first collectible type to the
107
+ * last collectible type. This will include integers that do not represent any valid collectible
108
+ * types.
109
+ *
110
+ * This function is only useful when building collectible type objects. For most purposes, you
111
+ * should use the `getCollectibleSet` helper function instead.
112
+ */
113
+ export declare function getCollectibleTypeRange(): CollectibleType[];
105
114
  /** Returns true if the item type in the item config is equal to `ItemType.ITEM_ACTIVE`. */
106
115
  export declare function isActiveCollectible(collectibleType: CollectibleType): boolean;
107
116
  /** Returns true if the collectible has a red question mark sprite. */
@@ -13,6 +13,9 @@ local game = ____cachedClasses.game
13
13
  local itemConfig = ____cachedClasses.itemConfig
14
14
  local ____constants = require("constants")
15
15
  local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
16
+ local ____constantsMax = require("constantsMax")
17
+ local FIRST_COLLECTIBLE_TYPE = ____constantsMax.FIRST_COLLECTIBLE_TYPE
18
+ local MAX_COLLECTIBLE_TYPE = ____constantsMax.MAX_COLLECTIBLE_TYPE
16
19
  local ____collectibleDescriptionMap = require("maps.collectibleDescriptionMap")
17
20
  local COLLECTIBLE_DESCRIPTION_MAP = ____collectibleDescriptionMap.COLLECTIBLE_DESCRIPTION_MAP
18
21
  local DEFAULT_COLLECTIBLE_DESCRIPTION = ____collectibleDescriptionMap.DEFAULT_COLLECTIBLE_DESCRIPTION
@@ -32,6 +35,8 @@ local getRoomListIndex = ____roomData.getRoomListIndex
32
35
  local ____sprite = require("functions.sprite")
33
36
  local clearSprite = ____sprite.clearSprite
34
37
  local spriteEquals = ____sprite.spriteEquals
38
+ local ____utils = require("functions.utils")
39
+ local irange = ____utils.irange
35
40
  function initQuestionMarkSprite(self)
36
41
  local sprite = Sprite()
37
42
  sprite:Load("gfx/005.100_collectible.anm2", false)
@@ -188,6 +193,9 @@ function ____exports.getCollectibleTags(self, collectibleType)
188
193
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
189
194
  return itemConfigItem == nil and ItemConfigTagZero or itemConfigItem.Tags
190
195
  end
196
+ function ____exports.getCollectibleTypeRange(self)
197
+ return irange(nil, FIRST_COLLECTIBLE_TYPE, MAX_COLLECTIBLE_TYPE)
198
+ end
191
199
  function ____exports.isActiveCollectible(self, collectibleType)
192
200
  local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
193
201
  return itemType == ItemType.ACTIVE
@@ -5,6 +5,10 @@ import { BossID, Dimension, Direction, DoorSlot, ItemPoolType, MinibossID, RoomS
5
5
  * not forget to set the `LeaveDoor` property and to prevent crashing on invalid room grid indexes.
6
6
  */
7
7
  export declare function changeRoom(roomGridIndex: int): void;
8
+ /**
9
+ * Helper function to get an array with every valid `Dimension` (not including `Dimension.CURRENT`).
10
+ */
11
+ export declare function getAllDimensions(): Dimension[];
8
12
  export declare function getAllRoomGridIndexes(): int[];
9
13
  /**
10
14
  * Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
@@ -114,6 +114,9 @@ function ____exports.changeRoom(self, roomGridIndex)
114
114
  level.LeaveDoor = DoorSlot.NO_DOOR_SLOT
115
115
  game:ChangeRoom(roomGridIndex)
116
116
  end
117
+ function ____exports.getAllDimensions(self)
118
+ return erange(nil, NUM_DIMENSIONS)
119
+ end
117
120
  function ____exports.getAllRoomGridIndexes(self)
118
121
  local rooms = ____exports.getRooms(nil)
119
122
  return __TS__ArrayMap(
@@ -129,8 +132,7 @@ function ____exports.getCurrentDimension(self)
129
132
  local startingRoomGridIndex = level:GetStartingRoomIndex()
130
133
  local startingRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, Dimension.CURRENT)
131
134
  local startingRoomHash = GetPtrHash(startingRoomDescription)
132
- for ____, dimensionInt in ipairs(erange(nil, NUM_DIMENSIONS)) do
133
- local dimension = dimensionInt
135
+ for ____, dimension in ipairs(____exports.getAllDimensions(nil)) do
134
136
  local dimensionRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, dimension)
135
137
  local dimensionRoomHash = GetPtrHash(dimensionRoomDescription)
136
138
  if dimensionRoomHash == startingRoomHash then
@@ -347,12 +349,12 @@ function ____exports.setRoomCleared(self)
347
349
  for ____, door in ipairs(getDoors(nil)) do
348
350
  do
349
351
  if isHiddenSecretRoomDoor(nil, door) then
350
- goto __continue67
352
+ goto __continue68
351
353
  end
352
354
  openDoorFast(nil, door)
353
355
  door.ExtraVisible = false
354
356
  end
355
- ::__continue67::
357
+ ::__continue68::
356
358
  end
357
359
  sfxManager:Stop(SoundEffect.DOOR_HEAVY_OPEN)
358
360
  game:ShakeScreen(0)
@@ -7,22 +7,17 @@ local ____exports = {}
7
7
  local initCacheFlagMap, CACHE_FLAG_TO_TRINKETS_MAP
8
8
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
9
  local CacheFlag = ____isaac_2Dtypescript_2Ddefinitions.CacheFlag
10
- local ____constantsMax = require("constantsMax")
11
- local FIRST_TRINKET_TYPE = ____constantsMax.FIRST_TRINKET_TYPE
12
- local MAX_TRINKET_TYPE = ____constantsMax.MAX_TRINKET_TYPE
13
10
  local ____enums = require("functions.enums")
14
11
  local getEnumValues = ____enums.getEnumValues
15
12
  local ____set = require("functions.set")
16
13
  local copySet = ____set.copySet
17
14
  local ____trinkets = require("functions.trinkets")
15
+ local getTrinketTypeRange = ____trinkets.getTrinketTypeRange
18
16
  local trinketHasCacheFlag = ____trinkets.trinketHasCacheFlag
19
- local ____utils = require("functions.utils")
20
- local irange = ____utils.irange
21
17
  function initCacheFlagMap(self)
22
18
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
23
19
  local trinketsSet = __TS__New(Set)
24
- for ____, trinketTypeInt in ipairs(irange(nil, FIRST_TRINKET_TYPE, MAX_TRINKET_TYPE)) do
25
- local trinketType = trinketTypeInt
20
+ for ____, trinketType in ipairs(getTrinketTypeRange(nil)) do
26
21
  if trinketHasCacheFlag(nil, trinketType, cacheFlag) then
27
22
  trinketsSet:add(trinketType)
28
23
  end
@@ -4,17 +4,13 @@ local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
5
  local ____cachedClasses = require("cachedClasses")
6
6
  local itemConfig = ____cachedClasses.itemConfig
7
- local ____constantsMax = require("constantsMax")
8
- local FIRST_TRINKET_TYPE = ____constantsMax.FIRST_TRINKET_TYPE
9
- local MAX_TRINKET_TYPE = ____constantsMax.MAX_TRINKET_TYPE
10
7
  local ____set = require("functions.set")
11
8
  local copySet = ____set.copySet
12
- local ____utils = require("functions.utils")
13
- local irange = ____utils.irange
9
+ local ____trinkets = require("functions.trinkets")
10
+ local getTrinketTypeRange = ____trinkets.getTrinketTypeRange
14
11
  local TRINKET_SET = __TS__New(Set)
15
12
  local function initTrinketSet(self)
16
- for ____, trinketTypeInt in ipairs(irange(nil, FIRST_TRINKET_TYPE, MAX_TRINKET_TYPE)) do
17
- local trinketType = trinketTypeInt
13
+ for ____, trinketType in ipairs(getTrinketTypeRange(nil)) do
18
14
  local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
19
15
  if itemConfigTrinket ~= nil then
20
16
  TRINKET_SET:add(trinketType)
@@ -38,6 +38,14 @@ export declare function getTrinketDescription(trinketType: TrinketType): string;
38
38
  * ```
39
39
  */
40
40
  export declare function getTrinketName(trinketType: TrinketType): string;
41
+ /**
42
+ * Helper function to get an array that represents the range from the first trinket type to the last
43
+ * trinket type. This will include integers that do not represent any valid trinket types.
44
+ *
45
+ * This function is only useful when building trinket type objects. For most purposes, you should
46
+ * use the `getTrinketSet` helper function instead.
47
+ */
48
+ export declare function getTrinketTypeRange(): TrinketType[];
41
49
  /**
42
50
  * Returns whether or not the player can hold an additional trinket, beyond what they are currently
43
51
  * carrying. This takes into account items that modify the max number of trinkets, like Mom's Purse.
@@ -5,6 +5,9 @@ local TrinketSlot = ____isaac_2Dtypescript_2Ddefinitions.TrinketSlot
5
5
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
6
6
  local ____cachedClasses = require("cachedClasses")
7
7
  local itemConfig = ____cachedClasses.itemConfig
8
+ local ____constantsMax = require("constantsMax")
9
+ local FIRST_TRINKET_TYPE = ____constantsMax.FIRST_TRINKET_TYPE
10
+ local MAX_TRINKET_TYPE = ____constantsMax.MAX_TRINKET_TYPE
8
11
  local ____trinketDescriptionMap = require("maps.trinketDescriptionMap")
9
12
  local DEFAULT_TRINKET_DESCRIPTION = ____trinketDescriptionMap.DEFAULT_TRINKET_DESCRIPTION
10
13
  local TRINKET_DESCRIPTION_MAP = ____trinketDescriptionMap.TRINKET_DESCRIPTION_MAP
@@ -21,6 +24,8 @@ local ____player = require("functions.player")
21
24
  local isCharacter = ____player.isCharacter
22
25
  local ____sprite = require("functions.sprite")
23
26
  local clearSprite = ____sprite.clearSprite
27
+ local ____utils = require("functions.utils")
28
+ local irange = ____utils.irange
24
29
  local GOLDEN_TRINKET_FLAG = 32767
25
30
  local GOLDEN_TRINKET_ADJUSTMENT = 32768
26
31
  local TRINKET_SPRITE_LAYER = 0
@@ -64,6 +69,9 @@ function ____exports.getTrinketName(self, trinketType)
64
69
  end
65
70
  return DEFAULT_TRINKET_NAME
66
71
  end
72
+ function ____exports.getTrinketTypeRange(self)
73
+ return irange(nil, FIRST_TRINKET_TYPE, MAX_TRINKET_TYPE)
74
+ end
67
75
  function ____exports.hasOpenTrinketSlot(self, player)
68
76
  if isCharacter(nil, player, PlayerType.THE_SOUL_B) then
69
77
  return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",