isaacscript-common 2.0.25 → 2.0.26

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,27 +1,103 @@
1
1
  import { Card, CollectibleType, PillColor, PillEffect, PlayerType, TrinketType } from "isaac-typescript-definitions";
2
+ /** Equal to `Card.FOOL`. */
2
3
  export declare const FIRST_CARD = Card.FOOL;
4
+ /**
5
+ * Will change depending on how many modded cards there are.
6
+ *
7
+ * Equal to `itemConfig.GetCards().Size - 1`. (We subtract one to account for `Card.NULL`.)
8
+ */
3
9
  export declare const NUM_CARDS: number;
10
+ /**
11
+ * Will change depending on how many modded cards there are.
12
+ *
13
+ * Equal to `itemConfig.GetCards().Size - 1`. (We subtract one to account for `Card.NULL`.)
14
+ */
4
15
  export declare const MAX_CARD: Card;
16
+ /** Calculated from the `Card` enum. `Card.NULL` is not included. */
5
17
  export declare const NUM_VANILLA_CARDS: number;
18
+ /** Calculated from the `Card` enum. */
6
19
  export declare const MAX_VANILLA_CARD: Card;
20
+ /** Equal to `CollectibleType.SAD_ONION`. */
7
21
  export declare const FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION;
8
- export declare const NUM_COLLECTIBLE_TYPES: number;
22
+ /**
23
+ * Will change depending on how many modded collectibles there are.
24
+ *
25
+ * Equal to `itemConfig.GetCollectibles().Size - 1`. (`Size` includes invalid collectibles. We
26
+ * subtract one to account for `CollectibleType.NULL`.)
27
+ */
9
28
  export declare const MAX_COLLECTIBLE_TYPE: CollectibleType;
10
- export declare const NUM_VANILLA_COLLECTIBLE_TYPES: CollectibleType;
29
+ /** Calculated from the `CollectibleType` enum. `CollectibleType.NULL` is not included. */
30
+ export declare const NUM_VANILLA_COLLECTIBLE_TYPES: number;
31
+ /**
32
+ * Calculated from the `CollectibleType` enum.
33
+ *
34
+ * Note that this cannot be calculated from the length of the enum, because unlike all of the other
35
+ * enums, the collectible types are not contiguous.
36
+ */
11
37
  export declare const MAX_VANILLA_COLLECTIBLE_TYPE: CollectibleType;
38
+ /** Equal to `PillEffect.BAD_GAS`. */
12
39
  export declare const FIRST_PILL_EFFECT = PillEffect.BAD_GAS;
40
+ /**
41
+ * Will change depending on how many modded pill effects there are.
42
+ *
43
+ * Equal to `itemConfig.GetPillEffects().Size - 1`. (We subtract one to account for
44
+ * `PillEffect.NULL`.)
45
+ */
13
46
  export declare const NUM_PILL_EFFECTS: number;
47
+ /**
48
+ * Will change depending on how many modded pill effects there are.
49
+ *
50
+ * Equal to `itemConfig.GetPillEffects().Size - 1`. (We subtract one to account for
51
+ * `PillEffect.NULL`.)
52
+ */
14
53
  export declare const MAX_PILL_EFFECT: PillEffect;
54
+ /**
55
+ * Calculated from the `PillEffect` enum.
56
+ *
57
+ * (There is no `PillEffect.NULL` in the custom enum, so we don't have to subtract one here.)
58
+ */
15
59
  export declare const NUM_VANILLA_PILL_EFFECTS: number;
60
+ /** Calculated from the `PillEffect` enum. */
16
61
  export declare const MAX_VANILLA_PILL_EFFECT: PillEffect;
62
+ /** Equal to `TrinketType.SWALLOWED_PENNY`. */
17
63
  export declare const FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY;
64
+ /**
65
+ * Will change depending on how many modded cards there are.
66
+ *
67
+ * Equal to `itemConfig.GetTrinkets().Size - 1`. (We subtract one to account for
68
+ * `TrinketType.NULL`.)
69
+ */
18
70
  export declare const NUM_TRINKET_TYPES: number;
71
+ /**
72
+ * Will change depending on how many modded cards there are.
73
+ *
74
+ * Equal to `itemConfig.GetTrinkets().Size - 1`. (We subtract one to account for
75
+ * `TrinketType.NULL`.)
76
+ */
19
77
  export declare const MAX_TRINKET_TYPE: TrinketType;
78
+ /** Calculated from the `TrinketType` enum. `TrinketType.NULL` is not included. */
20
79
  export declare const NUM_VANILLA_TRINKET_TYPES: number;
80
+ /** Calculated from the `TrinketType` enum. */
21
81
  export declare const MAX_VANILLA_TRINKET_TYPE: TrinketType;
82
+ /** Equal to `PlayerType.ISAAC`. */
22
83
  export declare const FIRST_CHARACTER = PlayerType.ISAAC;
84
+ /** Calculated from the `PlayerType` enum. */
23
85
  export declare const MAX_VANILLA_CHARACTER: PlayerType;
86
+ /** Equal to `PillColor.BLUE_BLUE`. */
24
87
  export declare const FIRST_PILL_COLOR = PillColor.BLUE_BLUE;
88
+ /**
89
+ * Equal to `PillColor.WHITE_YELLOW`.
90
+ *
91
+ * Note that `PillColor.GOLD` is technically higher, but that is not considered for the purposes of
92
+ * this constant.
93
+ */
25
94
  export declare const MAX_NORMAL_PILL_COLOR = PillColor.WHITE_YELLOW;
95
+ /** Equal to `PillColor.HORSE_BLUE_BLUE`. */
26
96
  export declare const FIRST_HORSE_PILL_COLOR = PillColor.HORSE_BLUE_BLUE;
97
+ /**
98
+ * Equal to `PillColor.HORSE_WHITE_YELLOW`.
99
+ *
100
+ * Note that `PillColor.HORSE_GOLD` is technically higher, but that is not considered for the
101
+ * purposes of this constant.
102
+ */
27
103
  export declare const MAX_HORSE_PILL_COLOR = PillColor.HORSE_WHITE_YELLOW;
@@ -15,22 +15,21 @@ ____exports.FIRST_CARD = Card.FOOL
15
15
  ____exports.NUM_CARDS = itemConfig:GetCards().Size - 1
16
16
  ____exports.MAX_CARD = ____exports.NUM_CARDS
17
17
  ____exports.NUM_VANILLA_CARDS = getEnumLength(nil, Card) - 1
18
- ____exports.MAX_VANILLA_CARD = ____exports.NUM_VANILLA_CARDS
18
+ ____exports.MAX_VANILLA_CARD = getLastEnumValue(nil, Card)
19
19
  ____exports.FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION
20
- ____exports.NUM_COLLECTIBLE_TYPES = itemConfig:GetCollectibles().Size - 1
21
- ____exports.MAX_COLLECTIBLE_TYPE = ____exports.NUM_COLLECTIBLE_TYPES
22
- ____exports.NUM_VANILLA_COLLECTIBLE_TYPES = getLastEnumValue(nil, CollectibleType)
23
- ____exports.MAX_VANILLA_COLLECTIBLE_TYPE = ____exports.NUM_VANILLA_COLLECTIBLE_TYPES
20
+ ____exports.MAX_COLLECTIBLE_TYPE = itemConfig:GetCollectibles().Size - 1
21
+ ____exports.NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(nil, CollectibleType) - 1
22
+ ____exports.MAX_VANILLA_COLLECTIBLE_TYPE = getLastEnumValue(nil, CollectibleType)
24
23
  ____exports.FIRST_PILL_EFFECT = PillEffect.BAD_GAS
25
24
  ____exports.NUM_PILL_EFFECTS = itemConfig:GetPillEffects().Size - 1
26
25
  ____exports.MAX_PILL_EFFECT = ____exports.NUM_PILL_EFFECTS
27
26
  ____exports.NUM_VANILLA_PILL_EFFECTS = getEnumLength(nil, PillEffect)
28
- ____exports.MAX_VANILLA_PILL_EFFECT = ____exports.NUM_VANILLA_PILL_EFFECTS
27
+ ____exports.MAX_VANILLA_PILL_EFFECT = getLastEnumValue(nil, PillEffect)
29
28
  ____exports.FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY
30
29
  ____exports.NUM_TRINKET_TYPES = itemConfig:GetTrinkets().Size - 1
31
30
  ____exports.MAX_TRINKET_TYPE = ____exports.NUM_TRINKET_TYPES
32
31
  ____exports.NUM_VANILLA_TRINKET_TYPES = getEnumLength(nil, TrinketType) - 1
33
- ____exports.MAX_VANILLA_TRINKET_TYPE = ____exports.NUM_VANILLA_TRINKET_TYPES
32
+ ____exports.MAX_VANILLA_TRINKET_TYPE = getLastEnumValue(nil, TrinketType)
34
33
  ____exports.FIRST_CHARACTER = PlayerType.ISAAC
35
34
  ____exports.MAX_VANILLA_CHARACTER = getLastEnumValue(nil, PlayerType)
36
35
  ____exports.FIRST_PILL_COLOR = PillColor.BLUE_BLUE
@@ -1,4 +1,5 @@
1
1
  import { CacheFlag, CollectibleType } from "isaac-typescript-definitions";
2
+ export declare function collectibleHasCacheFlag(collectibleType: CollectibleType, cacheFlag: CacheFlag): boolean;
2
3
  /**
3
4
  * Returns a set containing every collectible type with the given cache flag, including modded
4
5
  * collectibles.
@@ -5,22 +5,32 @@ 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 ____cachedClasses = require("cachedClasses")
9
+ local itemConfig = ____cachedClasses.itemConfig
8
10
  local ____collectibles = require("functions.collectibles")
9
- local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
10
11
  local getCollectibleTypeRange = ____collectibles.getCollectibleTypeRange
11
12
  local ____enums = require("functions.enums")
12
13
  local getEnumValues = ____enums.getEnumValues
14
+ local ____flag = require("functions.flag")
15
+ local hasFlag = ____flag.hasFlag
13
16
  local ____set = require("functions.set")
14
17
  local copySet = ____set.copySet
15
18
  local getSortedSetValues = ____set.getSortedSetValues
16
19
  local ____utils = require("functions.utils")
17
20
  local ____repeat = ____utils["repeat"]
21
+ function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
22
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
23
+ if itemConfigItem == nil then
24
+ return false
25
+ end
26
+ return hasFlag(nil, itemConfigItem.CacheFlags, cacheFlag)
27
+ end
18
28
  local CACHE_FLAG_TO_COLLECTIBLES_MAP = __TS__New(Map)
19
29
  local function initCacheFlagMap(self)
20
30
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
21
31
  local collectiblesSet = __TS__New(Set)
22
32
  for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
23
- if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
33
+ if ____exports.collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
24
34
  collectiblesSet:add(collectibleType)
25
35
  end
26
36
  end
@@ -1,3 +1,11 @@
1
1
  import { CollectibleType } from "isaac-typescript-definitions";
2
2
  /** Returns a set containing every valid collectible type in the game, including modded items. */
3
3
  export declare function getCollectibleSet(): Set<CollectibleType>;
4
+ /**
5
+ * Helper function to get the number of valid collectibles that exist. (This is not simply equal to
6
+ * the highest collectible type, because collectible types are not contiguous.)
7
+ *
8
+ * Note that there is no corresponding `getTrinketsNum` function because trinket types are
9
+ * contiguous. Use the `NUM_TRINKET_TYPES` constant instead.
10
+ */
11
+ export declare function getCollectiblesNum(): int;
@@ -23,4 +23,10 @@ function ____exports.getCollectibleSet(self)
23
23
  end
24
24
  return copySet(nil, COLLECTIBLE_SET)
25
25
  end
26
+ function ____exports.getCollectiblesNum(self)
27
+ if COLLECTIBLE_SET.size == 0 then
28
+ initCollectibleSet(nil)
29
+ end
30
+ return COLLECTIBLE_SET.size
31
+ end
26
32
  return ____exports
@@ -1,7 +1,6 @@
1
- import { CacheFlag, CollectiblePedestalType, CollectibleType, ItemConfigTag, ItemType, PickupPrice } from "isaac-typescript-definitions";
1
+ import { CollectiblePedestalType, CollectibleType, ItemConfigTag, ItemType, PickupPrice } from "isaac-typescript-definitions";
2
2
  import { CollectibleIndex } from "../types/CollectibleIndex";
3
3
  export declare function clearCollectibleSprite(collectible: EntityPickup): void;
4
- export declare function collectibleHasCacheFlag(collectibleType: CollectibleType, cacheFlag: CacheFlag): boolean;
5
4
  /** Helper function to check if two collectible sprites have the same sprite sheet loaded. */
6
5
  export declare function collectibleSpriteEquals(sprite1: Sprite, sprite2: Sprite): boolean;
7
6
  /**
@@ -26,8 +26,6 @@ local ____singleUseActiveCollectibleTypesSet = require("sets.singleUseActiveColl
26
26
  local SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES_SET = ____singleUseActiveCollectibleTypesSet.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES_SET
27
27
  local ____entity = require("functions.entity")
28
28
  local getEntityID = ____entity.getEntityID
29
- local ____flag = require("functions.flag")
30
- local hasFlag = ____flag.hasFlag
31
29
  local ____pickupVariants = require("functions.pickupVariants")
32
30
  local isCollectible = ____pickupVariants.isCollectible
33
31
  local ____roomData = require("functions.roomData")
@@ -64,13 +62,6 @@ local questionMarkSprite = initQuestionMarkSprite(nil)
64
62
  function ____exports.clearCollectibleSprite(self, collectible)
65
63
  ____exports.setCollectibleSprite(nil, collectible, nil)
66
64
  end
67
- function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
68
- local itemConfigItem = itemConfig:GetCollectible(collectibleType)
69
- if itemConfigItem == nil then
70
- return false
71
- end
72
- return hasFlag(nil, itemConfigItem.CacheFlags, cacheFlag)
73
- end
74
65
  function ____exports.collectibleSpriteEquals(self, sprite1, sprite2)
75
66
  local xStart = -1
76
67
  local xFinish = 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "2.0.25",
3
+ "version": "2.0.26",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",