isaacscript-common 1.2.196 → 1.2.199

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.
@@ -7,8 +7,8 @@ local ____featuresInitialized = require("featuresInitialized")
7
7
  local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
8
8
  local ____cacheFlag = require("functions.cacheFlag")
9
9
  local getDefaultPlayerStat = ____cacheFlag.getDefaultPlayerStat
10
- local ____tears = require("functions.tears")
11
- local addTearsStat = ____tears.addTearsStat
10
+ local ____player = require("functions.player")
11
+ local addStat = ____player.addStat
12
12
  function evaluateCache(self, player, cacheFlag)
13
13
  local character = player:GetPlayerType()
14
14
  local statMap = charactersStatMap:get(character)
@@ -21,49 +21,7 @@ function evaluateCache(self, player, cacheFlag)
21
21
  return
22
22
  end
23
23
  local delta = stat - defaultStat
24
- repeat
25
- local ____switch6 = cacheFlag
26
- local ____cond6 = ____switch6 == CacheFlag.CACHE_DAMAGE
27
- if ____cond6 then
28
- do
29
- player.Damage = player.Damage + delta
30
- return
31
- end
32
- end
33
- ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_FIREDELAY
34
- if ____cond6 then
35
- do
36
- addTearsStat(nil, player, delta)
37
- return
38
- end
39
- end
40
- ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_SHOTSPEED
41
- if ____cond6 then
42
- do
43
- player.ShotSpeed = player.ShotSpeed + delta
44
- break
45
- end
46
- end
47
- ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_RANGE
48
- if ____cond6 then
49
- do
50
- player.TearHeight = player.TearHeight + delta
51
- break
52
- end
53
- end
54
- ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_SPEED
55
- if ____cond6 then
56
- do
57
- player.MoveSpeed = player.MoveSpeed + delta
58
- break
59
- end
60
- end
61
- do
62
- do
63
- break
64
- end
65
- end
66
- until true
24
+ addStat(nil, player, cacheFlag, delta)
67
25
  end
68
26
  local FEATURE_NAME = "character stat manager"
69
27
  charactersStatMap = __TS__New(Map)
@@ -8,7 +8,7 @@ import { JSONRoom } from "../types/JSONRoom";
8
8
  * This function is meant to be used in the PostNewRoom callback.
9
9
  *
10
10
  * @param jsonRoom The JSON room to deploy. In practice, this will be something like:
11
- * ```
11
+ * ```ts
12
12
  * import customRooms from "./customRooms";
13
13
  *
14
14
  * const firstJSONRoom = customRooms.rooms.room[0];
@@ -36,7 +36,7 @@ export declare function deployJSONRoom(jsonRoom: JSONRoom, seed?: Seed, verbose?
36
36
  *
37
37
  * @param jsonRooms An array of JSON rooms to randomly select from. In practice, this will be
38
38
  * something like:
39
- * ```
39
+ * ```ts
40
40
  * import customRooms from "./customRooms";
41
41
  *
42
42
  * const jsonRooms = customRooms.rooms.room;
@@ -9,7 +9,7 @@ import { SaveData } from "../../types/private/SaveData";
9
9
  * variables that are properly scoped.
10
10
  *
11
11
  * Example:
12
- * ```
12
+ * ```ts
13
13
  * // in file: feature1.ts
14
14
  * import { saveDataManager } from "isaacscript-common";
15
15
  *
@@ -61,7 +61,7 @@ export declare function getRandomArrayIndex<T>(array: T[] | readonly T[], seed?:
61
61
  * Initializes an array with all elements containing the specified default value.
62
62
  *
63
63
  * Example:
64
- * ```
64
+ * ```ts
65
65
  * const playerTransformations = initArray(false, PlayerForm.NUM_PLAYER_FORMS - 1);
66
66
  * ```
67
67
  */
@@ -4,7 +4,7 @@ import { CardType } from "../enums/CardType";
4
4
  * Helper function to get a card description from a Card enum value.
5
5
  *
6
6
  * Example:
7
- * ```
7
+ * ```ts
8
8
  * const card = Card.CARD_FOOL;
9
9
  * const cardDescription = getCardDescription(card); // cardDescription is "Where journey begins"
10
10
  * ```
@@ -14,7 +14,7 @@ export declare function getCardDescription(card: Card | int): string;
14
14
  * Helper function to get a card name from a Card.
15
15
  *
16
16
  * Example:
17
- * ```
17
+ * ```ts
18
18
  * const card = Card.CARD_FOOL;
19
19
  * const cardName = getCardName(card); // cardName is "0 - The Fool"
20
20
  * ```
@@ -76,7 +76,7 @@ export declare function getCollectibleMaxCharges(collectibleType: CollectibleTyp
76
76
  * type is not valid.
77
77
  *
78
78
  * Example:
79
- * ```
79
+ * ```ts
80
80
  * const collectibleType = CollectibleType.COLLECTIBLE_SAD_ONION;
81
81
  * const collectibleName = getCollectibleName(collectibleType); // collectibleName is "Sad Onion"
82
82
  * ```
@@ -32,7 +32,7 @@ export declare function getClosestEntityTo<T extends AnyEntity>(referenceEntity:
32
32
  * will be used instead.)
33
33
  *
34
34
  * Example:
35
- * ```
35
+ * ```ts
36
36
  * // Make all of the entities in the room invisible
37
37
  * for (const entity of getEntities()) {
38
38
  * entity.Visible = false;
@@ -3,7 +3,7 @@
3
3
  * Helper function to get all of the bombs in the room.
4
4
  *
5
5
  * Example:
6
- * ```
6
+ * ```ts
7
7
  * // Make all of the bombs in the room invisible
8
8
  * for (const bomb of getBombs()) {
9
9
  * bomb.Visible = false;
@@ -15,7 +15,7 @@ export declare function getBombs(matchingVariant?: BombVariant | int, matchingSu
15
15
  * Helper function to get all of the effects in the room.
16
16
  *
17
17
  * Example:
18
- * ```
18
+ * ```ts
19
19
  * // Make all of the effects in the room invisible
20
20
  * for (const effect of getEffects()) {
21
21
  * effect.Visible = false;
@@ -27,7 +27,7 @@ export declare function getEffects(matchingVariant?: EffectVariant | int, matchi
27
27
  * Helper function to get all of the knives in the room.
28
28
  *
29
29
  * Example:
30
- * ```
30
+ * ```ts
31
31
  * // Make all of the knives in the room invisible
32
32
  * for (const knife of getKnives()) {
33
33
  * knife.Visible = false;
@@ -39,7 +39,7 @@ export declare function getKnives(matchingVariant?: KnifeVariant | int, matching
39
39
  * Helper function to get all of the lasers in the room.
40
40
  *
41
41
  * Example:
42
- * ```
42
+ * ```ts
43
43
  * // Make all of the lasers in the room invisible
44
44
  * for (const laser of getLasers()) {
45
45
  * laser.Visible = false;
@@ -51,7 +51,7 @@ export declare function getLasers(matchingVariant?: LaserVariant | int, matching
51
51
  * Helper function to get all of the projectiles in the room.
52
52
  *
53
53
  * Example:
54
- * ```
54
+ * ```ts
55
55
  * // Make all of the projectiles in the room invisible
56
56
  * for (const projectile of getProjectiles()) {
57
57
  * projectile.Visible = false;
@@ -63,7 +63,7 @@ export declare function getProjectiles(matchingVariant?: ProjectileVariant | int
63
63
  * Helper function to get all of the slots in the room.
64
64
  *
65
65
  * Example:
66
- * ```
66
+ * ```ts
67
67
  * // Make all of the slots in the room invisible
68
68
  * for (const slot of getSlots()) {
69
69
  * slot.Visible = false;
@@ -75,7 +75,7 @@ export declare function getSlots(matchingVariant?: SlotVariant | int, matchingSu
75
75
  * Helper function to get all of the tears in the room.
76
76
  *
77
77
  * Example:
78
- * ```
78
+ * ```ts
79
79
  * // Make all of the tears in the room invisible
80
80
  * for (const tear of getTears()) {
81
81
  * tear.Visible = false;
@@ -52,7 +52,7 @@ export declare function checkFamiliarFromCollectibles(player: EntityPlayer, coll
52
52
  * Helper function to get all of the familiars in the room.
53
53
  *
54
54
  * Example:
55
- * ```
55
+ * ```ts
56
56
  * // Make all of the familiars in the room invisible
57
57
  * for (const familiar of getFamiliars()) {
58
58
  * familiar.Visible = false;
@@ -4,14 +4,14 @@
4
4
  * This is a variadic function, so pass as many flags as you want to add.
5
5
  *
6
6
  * Example 1:
7
- * ```
7
+ * ```ts
8
8
  * // Give the player spectral tears
9
9
  * const player = Isaac.GetPlayer();
10
10
  * player.TearFlags = addFlag(player.TearFlags, TearFlags.TEAR_SPECTRAL);
11
11
  * ```
12
12
  *
13
13
  * Example 2:
14
- * ```
14
+ * ```ts
15
15
  * // Give the player spectral and homing tears
16
16
  * const player = Isaac.GetPlayer();
17
17
  * player.TearFlags = addFlag(player.TearFlags, TearFlags.TEAR_SPECTRAL, TearFlags.TEAR_HOMING);
@@ -28,7 +28,7 @@ export declare function addFlag(flags: int, ...flag: int[]): int;
28
28
  * If passed multiple flags, it will only return true if all of the flags are set.
29
29
  *
30
30
  * Example:
31
- * ```
31
+ * ```ts
32
32
  * const player = Isaac.GetPlayer();
33
33
  * if (hasFlag(player.TearFlags, TearFlags.TEAR_SPECTRAL) {
34
34
  * // The player currently has spectral tears
@@ -50,7 +50,7 @@ export declare function isSelfDamage(damageFlags: int): boolean;
50
50
  * This is a variadic function, so pass as many flags as you want to remove.
51
51
  *
52
52
  * Example:
53
- * ```
53
+ * ```ts
54
54
  * // Remove spectral tears from the player, if present
55
55
  * const player = Isaac.GetPlayer();
56
56
  * player.TearFlags = removeFlag(player.TearFlags, TearFlags.TEAR_SPECTRAL);
@@ -20,14 +20,14 @@ export declare function getCollidingEntitiesWithGridEntity(gridEntity: GridEntit
20
20
  * arguments to match specific grid entity types.
21
21
  *
22
22
  * Example:
23
- * ```
23
+ * ```ts
24
24
  * for (const gridEntity of getGridEntities()) {
25
25
  * print(gridEntity.GetType())
26
26
  * }
27
27
  * ```
28
28
  *
29
29
  * Example:
30
- * ```
30
+ * ```ts
31
31
  * const rocks = getGridEntities(
32
32
  * GridEntityType.GRID_ROCK,
33
33
  * GridEntityType.GRID_ROCKB,
@@ -76,7 +76,7 @@ export declare function isPostBossVoidPortal(gridEntity: GridEntity): boolean;
76
76
  * provided.
77
77
  *
78
78
  * Example:
79
- * ```
79
+ * ```ts
80
80
  * removeAllGridEntitiesExceptFor(
81
81
  * GridEntityType.GRID_WALL,
82
82
  * GridEntityType.GRID_DOOR,
@@ -91,7 +91,7 @@ export declare function removeAllGridEntitiesExceptFor(...gridEntityTypes: GridE
91
91
  * provided.
92
92
  *
93
93
  * Example:
94
- * ```
94
+ * ```ts
95
95
  * removeAllMatchingGridEntities(
96
96
  * GridEntityType.GRID_ROCK,
97
97
  * GridEntityType.GRID_ROCKB,
@@ -6,7 +6,7 @@ export declare function getKeys(matchingSubType?: number): EntityPickup[];
6
6
  * Helper function to get all of the pickups in the room.
7
7
  *
8
8
  * Example:
9
- * ```
9
+ * ```ts
10
10
  * // Make all of the pickups in the room invisible
11
11
  * for (const pickup of getPickups()) {
12
12
  * pickup.Visible = false;
@@ -20,7 +20,7 @@ export declare function getPillEffectClass(pillEffect: PillEffect | int): PillEf
20
20
  * Helper function to get a pill effect name from a PillEffect enum value.
21
21
  *
22
22
  * Example:
23
- * ```
23
+ * ```ts
24
24
  * const pillEffect = PillEffect.PILLEFFECT_BAD_GAS;
25
25
  * const pillEffectName = getPillEffectName(pillEffect); // trinketName is "Bad Gas"
26
26
  * ```
@@ -1,6 +1,22 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { HealthType } from "../enums/HealthType";
3
3
  export declare function addCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType | int): void;
4
+ /**
5
+ * Helper function to add a stat to a player based on the `CacheFlag` provided. Call this function
6
+ * from the EvaluateCache callback.
7
+ *
8
+ * Note that for `CacheFlag.CACHE_FIREDELAY`, the "amount" argument will be interpreted as the tear
9
+ * stat to add (and not the amount to mutate `EntityPlayer.MaxFireDelay` by).
10
+ *
11
+ * This function supports the following cache flags:
12
+ * - CacheFlag.CACHE_DAMAGE (1 << 0)
13
+ * - CacheFlag.CACHE_FIREDELAY (1 << 1)
14
+ * - CacheFlag.CACHE_SHOTSPEED (1 << 2)
15
+ * - CacheFlag.CACHE_RANGE (1 << 3)
16
+ * - CacheFlag.CACHE_SPEED (1 << 4)
17
+ * - CacheFlag.CACHE_LUCK (1 << 10)
18
+ */
19
+ export declare function addStat(player: EntityPlayer, cacheFlag: CacheFlag, amount: number): void;
4
20
  export declare function addTrinketCostume(player: EntityPlayer, trinketType: TrinketType | int): void;
5
21
  export declare function anyPlayerHasCollectible(collectibleType: CollectibleType | int): boolean;
6
22
  export declare function anyPlayerHasTrinket(trinketType: TrinketType | int): boolean;
@@ -1,7 +1,7 @@
1
1
  local ____lualib = require("lualib_bundle")
2
- local __TS__ArraySome = ____lualib.__TS__ArraySome
3
2
  local Set = ____lualib.Set
4
3
  local __TS__New = ____lualib.__TS__New
4
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
5
5
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
6
6
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
7
7
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
@@ -35,6 +35,8 @@ local getCollectibleSet = ____collectibleSet.getCollectibleSet
35
35
  local ____playerIndex = require("functions.playerIndex")
36
36
  local getPlayerIndexVanilla = ____playerIndex.getPlayerIndexVanilla
37
37
  local getPlayers = ____playerIndex.getPlayers
38
+ local ____tears = require("functions.tears")
39
+ local addTearsStat = ____tears.addTearsStat
38
40
  local ____utils = require("functions.utils")
39
41
  local ensureAllCases = ____utils.ensureAllCases
40
42
  local getEnumValues = ____utils.getEnumValues
@@ -79,6 +81,14 @@ end
79
81
  function ____exports.isVanillaCharacter(self, player)
80
82
  return not ____exports.isModdedCharacter(nil, player)
81
83
  end
84
+ local STAT_CACHE_FLAGS_SET = __TS__New(Set, {
85
+ CacheFlag.CACHE_DAMAGE,
86
+ CacheFlag.CACHE_FIREDELAY,
87
+ CacheFlag.CACHE_SHOTSPEED,
88
+ CacheFlag.CACHE_RANGE,
89
+ CacheFlag.CACHE_SPEED,
90
+ CacheFlag.CACHE_LUCK
91
+ })
82
92
  function ____exports.addCollectibleCostume(self, player, collectibleType)
83
93
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
84
94
  if itemConfigItem == nil then
@@ -86,6 +96,61 @@ function ____exports.addCollectibleCostume(self, player, collectibleType)
86
96
  end
87
97
  player:AddCostume(itemConfigItem, false)
88
98
  end
99
+ function ____exports.addStat(self, player, cacheFlag, amount)
100
+ if not STAT_CACHE_FLAGS_SET:has(cacheFlag) then
101
+ error("You cannot add a stat to a player with the cache flag of: " .. tostring(cacheFlag))
102
+ end
103
+ repeat
104
+ local ____switch6 = cacheFlag
105
+ local ____cond6 = ____switch6 == CacheFlag.CACHE_DAMAGE
106
+ if ____cond6 then
107
+ do
108
+ player.Damage = player.Damage + amount
109
+ break
110
+ end
111
+ end
112
+ ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_FIREDELAY
113
+ if ____cond6 then
114
+ do
115
+ addTearsStat(nil, player, amount)
116
+ break
117
+ end
118
+ end
119
+ ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_SHOTSPEED
120
+ if ____cond6 then
121
+ do
122
+ player.ShotSpeed = player.ShotSpeed + amount
123
+ break
124
+ end
125
+ end
126
+ ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_RANGE
127
+ if ____cond6 then
128
+ do
129
+ player.TearHeight = player.TearHeight + amount
130
+ break
131
+ end
132
+ end
133
+ ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_SPEED
134
+ if ____cond6 then
135
+ do
136
+ player.MoveSpeed = player.MoveSpeed + amount
137
+ break
138
+ end
139
+ end
140
+ ____cond6 = ____cond6 or ____switch6 == CacheFlag.CACHE_LUCK
141
+ if ____cond6 then
142
+ do
143
+ player.Luck = player.Luck + amount
144
+ break
145
+ end
146
+ end
147
+ do
148
+ do
149
+ break
150
+ end
151
+ end
152
+ until true
153
+ end
89
154
  function ____exports.addTrinketCostume(self, player, trinketType)
90
155
  local itemConfigTrinket = itemConfig:GetTrinket(trinketType)
91
156
  if itemConfigTrinket == nil then
@@ -413,9 +478,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
413
478
  itemPool:RemoveCollectible(collectibleType)
414
479
  end
415
480
  repeat
416
- local ____switch90 = activeSlot
417
- local ____cond90 = ____switch90 == ActiveSlot.SLOT_PRIMARY
418
- if ____cond90 then
481
+ local ____switch100 = activeSlot
482
+ local ____cond100 = ____switch100 == ActiveSlot.SLOT_PRIMARY
483
+ if ____cond100 then
419
484
  do
420
485
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
421
486
  player:RemoveCollectible(primaryCollectibleType)
@@ -424,8 +489,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
424
489
  break
425
490
  end
426
491
  end
427
- ____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_SECONDARY
428
- if ____cond90 then
492
+ ____cond100 = ____cond100 or ____switch100 == ActiveSlot.SLOT_SECONDARY
493
+ if ____cond100 then
429
494
  do
430
495
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
431
496
  player:RemoveCollectible(primaryCollectibleType)
@@ -440,16 +505,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
440
505
  break
441
506
  end
442
507
  end
443
- ____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_POCKET
444
- if ____cond90 then
508
+ ____cond100 = ____cond100 or ____switch100 == ActiveSlot.SLOT_POCKET
509
+ if ____cond100 then
445
510
  do
446
511
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
447
512
  player:SetActiveCharge(charge, activeSlot)
448
513
  break
449
514
  end
450
515
  end
451
- ____cond90 = ____cond90 or ____switch90 == ActiveSlot.SLOT_POCKET2
452
- if ____cond90 then
516
+ ____cond100 = ____cond100 or ____switch100 == ActiveSlot.SLOT_POCKET2
517
+ if ____cond100 then
453
518
  do
454
519
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
455
520
  break
@@ -11,7 +11,7 @@ export declare function getRandom(seed?: Seed): float;
11
11
  * will never return a value of exactly 1.)
12
12
  *
13
13
  * Example:
14
- * ```
14
+ * ```ts
15
15
  * const realNumberBetweenOneAndThree = getRandomFloat(1, 3, seed);
16
16
  * ```
17
17
  */
@@ -20,7 +20,7 @@ export declare function getRandomFloat(min: int, max: int, seed?: Seed): float;
20
20
  * This returns a random integer between min and max, inclusive.
21
21
  *
22
22
  * Example:
23
- * ```
23
+ * ```ts
24
24
  * const oneTwoOrThree = getRandomInt(1, 3, seed);
25
25
  * ```
26
26
  */
@@ -29,7 +29,7 @@ export declare function getRandomInt(min: int, max: int, seed?: Seed): int;
29
29
  * Helper function to initialize an RNG object.
30
30
  *
31
31
  * Example:
32
- * ```
32
+ * ```ts
33
33
  * const startSeed = Game():GetSeeds():GetStartSeed();
34
34
  * const rng = initRNG(startSeed);
35
35
  * const fiftyFiftyChance = rng.RandomInt(2) === 0;
@@ -6,7 +6,7 @@ export declare function getPlayerNumTransformationCollectibles(player: EntityPla
6
6
  * Helper function to get a transformation name from a PlayerForm enum.
7
7
  *
8
8
  * Example:
9
- * ```
9
+ * ```ts
10
10
  * const transformationName = getTransformationName(PlayerForm.PLAYERFORM_LORD_OF_THE_FLIES);
11
11
  * // transformationName is "Beelzebub"
12
12
  * ```
@@ -8,7 +8,7 @@ export declare function getMaxTrinketType(): int;
8
8
  * Returns the slot number corresponding to where a trinket can be safely inserted.
9
9
  *
10
10
  * Example:
11
- * ```
11
+ * ```ts
12
12
  * const player = Isaac.GetPlayer();
13
13
  * const trinketSlot = getOpenTrinketSlotNum(player);
14
14
  * if (trinketSlot !== undefined) {
@@ -28,7 +28,7 @@ export declare function getTrinketDescription(trinketType: TrinketType | int): s
28
28
  * not valid.
29
29
  *
30
30
  * Example:
31
- * ```
31
+ * ```ts
32
32
  * const trinketType = TrinketType.TRINKET_SWALLOWED_PENNY;
33
33
  * const trinketName = getTrinketName(trinketType); // trinketName is "Swallowed Penny"
34
34
  * ```
@@ -2,34 +2,34 @@
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
3
  /**
4
4
  * Helper function to get type safety on a switch statement.
5
+ *
5
6
  * Very useful to be future-safe against people adding values to a type or an enum.
6
7
  *
7
8
  * Example:
8
- * ```
9
+ * ```ts
9
10
  * enum Situations {
10
- * Situation1,
11
- * Situation2,
12
- * Situation3,
13
- * // Situation4, // If we uncomment this line, the program will no longer compile
11
+ * ONE,
12
+ * TWO,
13
+ * THREE,
14
+ * // FOUR, // If we uncomment this line, the program will no longer compile
14
15
  * }
15
16
  *
16
17
  * function doThingBasedOnSituation(situation: Situation) {
17
18
  * switch (situation) {
18
- * case Situation1: {
19
+ * case Situation.ONE: {
19
20
  * return 41;
20
21
  * }
21
22
  *
22
- * case Situation2: {
23
+ * case Situation.TWO: {
23
24
  * return 68;
24
25
  * }
25
26
  *
26
- * case Situation3: {
27
+ * case Situation.THREE: {
27
28
  * return 12;
28
29
  * }
29
30
  *
30
31
  * default: {
31
- * ensureAllCases(situation);
32
- * return 0;
32
+ * return ensureAllCases(situation);
33
33
  * }
34
34
  * }
35
35
  * }
@@ -119,3 +119,8 @@ export declare function printConsole(msg: string): void;
119
119
  * ```
120
120
  */
121
121
  export declare function repeat(n: int, func: (i: int) => void): void;
122
+ /**
123
+ * Helper function to check every value of a custom enum for -1. This is helpful as a run-time check
124
+ * because many methods of the Isaac class return -1 if they fail.
125
+ */
126
+ export declare function validateCustomEnum(transpiledEnumName: string, transpiledEnum: unknown): void;
@@ -3,6 +3,8 @@ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
3
3
  local __TS__ArraySort = ____lualib.__TS__ArraySort
4
4
  local __TS__StringReplace = ____lualib.__TS__StringReplace
5
5
  local __TS__StringSubstr = ____lualib.__TS__StringSubstr
6
+ local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
7
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
8
  local ____exports = {}
7
9
  local ____directionNames = require("objects.directionNames")
8
10
  local DIRECTION_NAMES = ____directionNames.DIRECTION_NAMES
@@ -76,4 +78,22 @@ ____exports["repeat"] = function(self, n, func)
76
78
  end
77
79
  end
78
80
  end
81
+ function ____exports.validateCustomEnum(self, transpiledEnumName, transpiledEnum)
82
+ local customEnumType = type(transpiledEnum)
83
+ if customEnumType ~= "table" then
84
+ return
85
+ end
86
+ local ____table = transpiledEnum
87
+ local keys = __TS__ArrayFilter(
88
+ __TS__ObjectKeys(____table),
89
+ function(____, key) return type(key) == "string" end
90
+ )
91
+ __TS__ArraySort(keys)
92
+ for ____, key in ipairs(keys) do
93
+ local value = ____table[key]
94
+ if value == -1 then
95
+ error((("Failed to find: " .. transpiledEnumName) .. ".") .. key)
96
+ end
97
+ end
98
+ end
79
99
  return ____exports
@@ -4,7 +4,7 @@
4
4
  * using this type.
5
5
  *
6
6
  * Example:
7
- * ```
7
+ * ```ts
8
8
  * const collectiblesNameMap = new Map<CollectibleIndex, string>();
9
9
  * ```
10
10
  *
@@ -4,7 +4,7 @@
4
4
  * function. Mods can signify that data structures handle `EntityPlayer` by using this type.
5
5
  *
6
6
  * Example:
7
- * ```
7
+ * ```ts
8
8
  * const playersNameMap = new Map<PlayerIndex, string>();
9
9
  * ```
10
10
  *
@@ -4,7 +4,7 @@ import { ModUpgraded } from "./classes/ModUpgraded";
4
4
  * Use this function to enable the custom features and callbacks provided by `isaacscript-common`.
5
5
  *
6
6
  * Example:
7
- * ```
7
+ * ```ts
8
8
  * const modVanilla = RegisterMod("My Mod", 1);
9
9
  * const mod = upgradeMod(modVanilla);
10
10
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.196",
3
+ "version": "1.2.199",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",