isaacscript-common 24.1.0 → 25.0.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.
@@ -5106,6 +5106,14 @@ export declare function getHearts(heartSubType?: HeartSubType): EntityPickupHear
5106
5106
  */
5107
5107
  export declare function getHeartsUIWidth(): int;
5108
5108
 
5109
+ /**
5110
+ * Helper function to get the enum value with the highest value.
5111
+ *
5112
+ * Note that this is not necessarily the enum value that is declared last, since there is no way to
5113
+ * infer that at run-time.
5114
+ */
5115
+ export declare function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T];
5116
+
5109
5117
  /**
5110
5118
  * Helper function to get the corresponding horse pill color from a normal pill color.
5111
5119
  *
@@ -5246,14 +5254,6 @@ export declare function getLasers(laserVariant?: LaserVariant, subType?: number)
5246
5254
  */
5247
5255
  export declare function getLastElement<T>(array: T[]): T | undefined;
5248
5256
 
5249
- /**
5250
- * Helper function to get the enum value with the highest value.
5251
- *
5252
- * Note that this is not necessarily the enum value that is declared last, since there is no way to
5253
- * infer that at run-time.
5254
- */
5255
- export declare function getLastEnumValue<T>(transpiledEnum: T): T[keyof T];
5256
-
5257
5257
  /**
5258
5258
  * Helper function that returns the number of the final frame in a particular animation for a
5259
5259
  * sprite. By default, it will use the currently playing animation, but you can also specify a
@@ -12030,9 +12030,8 @@ export declare const NUM_VANILLA_CARD_TYPES: number;
12030
12030
  export declare const NUM_VANILLA_COLLECTIBLE_TYPES: number;
12031
12031
 
12032
12032
  /**
12033
- * Calculated from the `PillEffect` enum.
12034
- *
12035
- * (There is no `PillEffect.NULL` in the custom enum, so we do not have to subtract one here.)
12033
+ * Calculated from the `PillEffect` enum. (There is no `PillEffect.NULL` in the custom enum, so we
12034
+ * do not have to subtract one here.)
12036
12035
  */
12037
12036
  export declare const NUM_VANILLA_PILL_EFFECTS: number;
12038
12037
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 24.1.0
3
+ isaacscript-common 25.0.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -16717,7 +16717,7 @@ function ____exports.getEnumValues(self, transpiledEnum)
16717
16717
  end
16718
16718
  )
16719
16719
  end
16720
- function ____exports.getLastEnumValue(self, transpiledEnum)
16720
+ function ____exports.getHighestEnumValue(self, transpiledEnum)
16721
16721
  local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
16722
16722
  local lastElement = enumValues[#enumValues]
16723
16723
  if lastElement == nil then
@@ -17313,30 +17313,32 @@ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
17313
17313
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
17314
17314
  local ____enums = require("src.functions.enums")
17315
17315
  local getEnumLength = ____enums.getEnumLength
17316
- local getLastEnumValue = ____enums.getLastEnumValue
17316
+ local getHighestEnumValue = ____enums.getHighestEnumValue
17317
+ local ____utils = require("src.functions.utils")
17318
+ local iRange = ____utils.iRange
17317
17319
  ____exports.FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION
17318
- ____exports.LAST_VANILLA_COLLECTIBLE_TYPE = getLastEnumValue(nil, CollectibleType)
17320
+ ____exports.LAST_VANILLA_COLLECTIBLE_TYPE = getHighestEnumValue(nil, CollectibleType)
17319
17321
  ____exports.NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(nil, CollectibleType) - 1
17320
17322
  ____exports.FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY
17321
- ____exports.LAST_VANILLA_TRINKET_TYPE = getLastEnumValue(nil, TrinketType)
17323
+ ____exports.LAST_VANILLA_TRINKET_TYPE = getHighestEnumValue(nil, TrinketType)
17322
17324
  ____exports.NUM_VANILLA_TRINKET_TYPES = getEnumLength(nil, TrinketType) - 1
17323
17325
  ____exports.FIRST_CARD_TYPE = CardType.FOOL
17324
- ____exports.LAST_VANILLA_CARD_TYPE = getLastEnumValue(nil, CardType)
17326
+ ____exports.LAST_VANILLA_CARD_TYPE = getHighestEnumValue(nil, CardType)
17325
17327
  ____exports.NUM_VANILLA_CARD_TYPES = getEnumLength(nil, CardType) - 1
17326
17328
  ____exports.FIRST_PILL_EFFECT = PillEffect.BAD_GAS
17327
- ____exports.LAST_VANILLA_PILL_EFFECT = getLastEnumValue(nil, PillEffect)
17329
+ ____exports.LAST_VANILLA_PILL_EFFECT = getHighestEnumValue(nil, PillEffect)
17328
17330
  ____exports.NUM_VANILLA_PILL_EFFECTS = getEnumLength(nil, PillEffect)
17329
17331
  ____exports.FIRST_PILL_COLOR = PillColor.BLUE_BLUE
17330
17332
  ____exports.LAST_NORMAL_PILL_COLOR = PillColor.WHITE_YELLOW
17331
17333
  ____exports.FIRST_HORSE_PILL_COLOR = PillColor.HORSE_BLUE_BLUE
17332
17334
  ____exports.LAST_HORSE_PILL_COLOR = PillColor.HORSE_WHITE_YELLOW
17333
- ____exports.NUM_NORMAL_PILL_COLORS = ____exports.LAST_NORMAL_PILL_COLOR - ____exports.FIRST_PILL_COLOR
17335
+ ____exports.NUM_NORMAL_PILL_COLORS = #iRange(nil, ____exports.FIRST_PILL_COLOR, ____exports.LAST_NORMAL_PILL_COLOR)
17334
17336
  ____exports.FIRST_CHARACTER = PlayerType.ISAAC
17335
- ____exports.LAST_VANILLA_CHARACTER = getLastEnumValue(nil, PlayerType)
17337
+ ____exports.LAST_VANILLA_CHARACTER = getHighestEnumValue(nil, PlayerType)
17336
17338
  ____exports.FIRST_ROOM_TYPE = RoomType.DEFAULT
17337
- ____exports.LAST_ROOM_TYPE = getLastEnumValue(nil, RoomType)
17339
+ ____exports.LAST_ROOM_TYPE = getHighestEnumValue(nil, RoomType)
17338
17340
  ____exports.FIRST_STAGE = LevelStage.BASEMENT_1
17339
- ____exports.LAST_STAGE = getLastEnumValue(nil, LevelStage)
17341
+ ____exports.LAST_STAGE = getHighestEnumValue(nil, LevelStage)
17340
17342
  return ____exports
17341
17343
  end,
17342
17344
  ["src.core.constants"] = function(...)
@@ -27,9 +27,8 @@ export declare const FIRST_PILL_EFFECT = PillEffect.BAD_GAS;
27
27
  /** Calculated from the `PillEffect` enum. */
28
28
  export declare const LAST_VANILLA_PILL_EFFECT: PillEffect;
29
29
  /**
30
- * Calculated from the `PillEffect` enum.
31
- *
32
- * (There is no `PillEffect.NULL` in the custom enum, so we do not have to subtract one here.)
30
+ * Calculated from the `PillEffect` enum. (There is no `PillEffect.NULL` in the custom enum, so we
31
+ * do not have to subtract one here.)
33
32
  */
34
33
  export declare const NUM_VANILLA_PILL_EFFECTS: number;
35
34
  /** Equal to `PillColor.BLUE_BLUE`. */
@@ -1 +1 @@
1
- {"version":3,"file":"constantsFirstLast.d.ts","sourceRoot":"","sources":["../../../src/core/constantsFirstLast.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAOtC,4CAA4C;AAC5C,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,iBAAoC,CAAC;AAE/E,4FAA4F;AAC5F,eAAO,MAAM,6BAA6B,QAAqC,CAAC;AAMhF,8CAA8C;AAC9C,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAE9D,8CAA8C;AAC9C,eAAO,MAAM,yBAAyB,aAAgC,CAAC;AAEvE,oFAAoF;AACpF,eAAO,MAAM,yBAAyB,QAAiC,CAAC;AAMxE,4BAA4B;AAC5B,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,uCAAuC;AACvC,eAAO,MAAM,sBAAsB,UAA6B,CAAC;AAEjE,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,QAA8B,CAAC;AAMlE,qCAAqC;AACrC,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AAEpD,6CAA6C;AAC7C,eAAO,MAAM,wBAAwB,YAA+B,CAAC;AAErE;;;;G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UAAgC,CAAC;AAEpE,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,QAA8B,CAAC;AAMlE,qCAAqC;AACrC,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AAEpD,6CAA6C;AAC7C,eAAO,MAAM,wBAAwB,YAAkC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,QAA4B,CAAC;AAMlE,sCAAsC;AACtC,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAE7D,4CAA4C;AAC5C,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,+BAA+B,CAAC;AAElE,eAAO,MAAM,sBAAsB,QAG3B,CAAC;AAMT,mCAAmC;AACnC,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAIhD,6CAA6C;AAC7C,eAAO,MAAM,sBAAsB,YAAkC,CAAC;AAMtE,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,cAAc,UAAgC,CAAC;AAM5D,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,UAAU,YAAkC,CAAC"}
@@ -10,35 +10,36 @@ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
10
10
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
11
11
  local ____enums = require("src.functions.enums")
12
12
  local getEnumLength = ____enums.getEnumLength
13
- local getLastEnumValue = ____enums.getLastEnumValue
13
+ local getHighestEnumValue = ____enums.getHighestEnumValue
14
+ local ____utils = require("src.functions.utils")
15
+ local iRange = ____utils.iRange
14
16
  --- Equal to `CollectibleType.SAD_ONION`.
15
17
  ____exports.FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION
16
18
  --- Calculated from the `CollectibleType` enum.
17
19
  --
18
20
  -- Note that this cannot be calculated from the length of the enum, because unlike all of the other
19
21
  -- enums, collectible types are not contiguous.
20
- ____exports.LAST_VANILLA_COLLECTIBLE_TYPE = getLastEnumValue(nil, CollectibleType)
22
+ ____exports.LAST_VANILLA_COLLECTIBLE_TYPE = getHighestEnumValue(nil, CollectibleType)
21
23
  --- Calculated from the `CollectibleType` enum. (`CollectibleType.NULL` is not included.)
22
24
  ____exports.NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(nil, CollectibleType) - 1
23
25
  --- Equal to `TrinketType.SWALLOWED_PENNY`.
24
26
  ____exports.FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY
25
27
  --- Calculated from the `TrinketType` enum.
26
- ____exports.LAST_VANILLA_TRINKET_TYPE = getLastEnumValue(nil, TrinketType)
28
+ ____exports.LAST_VANILLA_TRINKET_TYPE = getHighestEnumValue(nil, TrinketType)
27
29
  --- Calculated from the `TrinketType` enum. (`TrinketType.NULL` is not included.)
28
30
  ____exports.NUM_VANILLA_TRINKET_TYPES = getEnumLength(nil, TrinketType) - 1
29
31
  --- Equal to `Card.FOOL`.
30
32
  ____exports.FIRST_CARD_TYPE = CardType.FOOL
31
33
  --- Calculated from the `Card` enum.
32
- ____exports.LAST_VANILLA_CARD_TYPE = getLastEnumValue(nil, CardType)
34
+ ____exports.LAST_VANILLA_CARD_TYPE = getHighestEnumValue(nil, CardType)
33
35
  --- Calculated from the `Card` enum. `Card.NULL` is not included.
34
36
  ____exports.NUM_VANILLA_CARD_TYPES = getEnumLength(nil, CardType) - 1
35
37
  --- Equal to `PillEffect.BAD_GAS`.
36
38
  ____exports.FIRST_PILL_EFFECT = PillEffect.BAD_GAS
37
39
  --- Calculated from the `PillEffect` enum.
38
- ____exports.LAST_VANILLA_PILL_EFFECT = getLastEnumValue(nil, PillEffect)
39
- --- Calculated from the `PillEffect` enum.
40
- --
41
- -- (There is no `PillEffect.NULL` in the custom enum, so we do not have to subtract one here.)
40
+ ____exports.LAST_VANILLA_PILL_EFFECT = getHighestEnumValue(nil, PillEffect)
41
+ --- Calculated from the `PillEffect` enum. (There is no `PillEffect.NULL` in the custom enum, so we
42
+ -- do not have to subtract one here.)
42
43
  ____exports.NUM_VANILLA_PILL_EFFECTS = getEnumLength(nil, PillEffect)
43
44
  --- Equal to `PillColor.BLUE_BLUE`.
44
45
  ____exports.FIRST_PILL_COLOR = PillColor.BLUE_BLUE
@@ -54,13 +55,13 @@ ____exports.FIRST_HORSE_PILL_COLOR = PillColor.HORSE_BLUE_BLUE
54
55
  -- Note that `PillColor.HORSE_GOLD` is technically higher, but that is not considered for the
55
56
  -- purposes of this constant.
56
57
  ____exports.LAST_HORSE_PILL_COLOR = PillColor.HORSE_WHITE_YELLOW
57
- ____exports.NUM_NORMAL_PILL_COLORS = ____exports.LAST_NORMAL_PILL_COLOR - ____exports.FIRST_PILL_COLOR
58
+ ____exports.NUM_NORMAL_PILL_COLORS = #iRange(nil, ____exports.FIRST_PILL_COLOR, ____exports.LAST_NORMAL_PILL_COLOR)
58
59
  --- Equal to `PlayerType.ISAAC`.
59
60
  ____exports.FIRST_CHARACTER = PlayerType.ISAAC
60
61
  --- Calculated from the `PlayerType` enum.
61
- ____exports.LAST_VANILLA_CHARACTER = getLastEnumValue(nil, PlayerType)
62
+ ____exports.LAST_VANILLA_CHARACTER = getHighestEnumValue(nil, PlayerType)
62
63
  ____exports.FIRST_ROOM_TYPE = RoomType.DEFAULT
63
- ____exports.LAST_ROOM_TYPE = getLastEnumValue(nil, RoomType)
64
+ ____exports.LAST_ROOM_TYPE = getHighestEnumValue(nil, RoomType)
64
65
  ____exports.FIRST_STAGE = LevelStage.BASEMENT_1
65
- ____exports.LAST_STAGE = getLastEnumValue(nil, LevelStage)
66
+ ____exports.LAST_STAGE = getHighestEnumValue(nil, LevelStage)
66
67
  return ____exports
@@ -61,7 +61,7 @@ export declare function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]>;
61
61
  * Note that this is not necessarily the enum value that is declared last, since there is no way to
62
62
  * infer that at run-time.
63
63
  */
64
- export declare function getLastEnumValue<T>(transpiledEnum: T): T[keyof T];
64
+ export declare function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T];
65
65
  /**
66
66
  * Helper function to get a random value from the provided enum.
67
67
  *
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/functions/enums.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,cAAc,EAAE,CAAC,GAChB,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAmBzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,GAAG,MAAM,EAAE,CAG1D;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,GAAG,GAAG,CAGvD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAGrE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAWjE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,cAAc,EAAE,CAAC,EACjB,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,UAAU,GAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,GAC7D,CAAC,CAAC,MAAM,CAAC,CAAC,CAGZ;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAA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C,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,GAC7D,CAAC,CAAC,MAAM,CAAC,CAAC,CAGZ;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,OAAO,GACtB,IAAI,CAQN;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,CAAC,GAChB,IAAI,CAsBN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAE1C,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAC/B,IAAI,SAAS,MAAM,GAAG,MAAM,KACzB,IAAI,CAAG"}
@@ -109,7 +109,7 @@ end
109
109
  --
110
110
  -- Note that this is not necessarily the enum value that is declared last, since there is no way to
111
111
  -- infer that at run-time.
112
- function ____exports.getLastEnumValue(self, transpiledEnum)
112
+ function ____exports.getHighestEnumValue(self, transpiledEnum)
113
113
  local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
114
114
  local lastElement = enumValues[#enumValues]
115
115
  if lastElement == nil then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "24.1.0",
3
+ "version": "25.0.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -10,7 +10,8 @@ import {
10
10
  RoomType,
11
11
  TrinketType,
12
12
  } from "isaac-typescript-definitions";
13
- import { getEnumLength, getLastEnumValue } from "../functions/enums";
13
+ import { getEnumLength, getHighestEnumValue } from "../functions/enums";
14
+ import { iRange } from "../functions/utils";
14
15
 
15
16
  // ------------
16
17
  // Collectibles
@@ -25,7 +26,8 @@ export const FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION;
25
26
  * Note that this cannot be calculated from the length of the enum, because unlike all of the other
26
27
  * enums, collectible types are not contiguous.
27
28
  */
28
- export const LAST_VANILLA_COLLECTIBLE_TYPE = getLastEnumValue(CollectibleType);
29
+ export const LAST_VANILLA_COLLECTIBLE_TYPE =
30
+ getHighestEnumValue(CollectibleType);
29
31
 
30
32
  /** Calculated from the `CollectibleType` enum. (`CollectibleType.NULL` is not included.) */
31
33
  export const NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(CollectibleType) - 1;
@@ -38,7 +40,7 @@ export const NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(CollectibleType) - 1;
38
40
  export const FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY;
39
41
 
40
42
  /** Calculated from the `TrinketType` enum. */
41
- export const LAST_VANILLA_TRINKET_TYPE = getLastEnumValue(TrinketType);
43
+ export const LAST_VANILLA_TRINKET_TYPE = getHighestEnumValue(TrinketType);
42
44
 
43
45
  /** Calculated from the `TrinketType` enum. (`TrinketType.NULL` is not included.) */
44
46
  export const NUM_VANILLA_TRINKET_TYPES = getEnumLength(TrinketType) - 1;
@@ -51,7 +53,7 @@ export const NUM_VANILLA_TRINKET_TYPES = getEnumLength(TrinketType) - 1;
51
53
  export const FIRST_CARD_TYPE = CardType.FOOL;
52
54
 
53
55
  /** Calculated from the `Card` enum. */
54
- export const LAST_VANILLA_CARD_TYPE = getLastEnumValue(CardType);
56
+ export const LAST_VANILLA_CARD_TYPE = getHighestEnumValue(CardType);
55
57
 
56
58
  /** Calculated from the `Card` enum. `Card.NULL` is not included. */
57
59
  export const NUM_VANILLA_CARD_TYPES = getEnumLength(CardType) - 1;
@@ -64,12 +66,11 @@ export const NUM_VANILLA_CARD_TYPES = getEnumLength(CardType) - 1;
64
66
  export const FIRST_PILL_EFFECT = PillEffect.BAD_GAS;
65
67
 
66
68
  /** Calculated from the `PillEffect` enum. */
67
- export const LAST_VANILLA_PILL_EFFECT = getLastEnumValue(PillEffect);
69
+ export const LAST_VANILLA_PILL_EFFECT = getHighestEnumValue(PillEffect);
68
70
 
69
71
  /**
70
- * Calculated from the `PillEffect` enum.
71
- *
72
- * (There is no `PillEffect.NULL` in the custom enum, so we do not have to subtract one here.)
72
+ * Calculated from the `PillEffect` enum. (There is no `PillEffect.NULL` in the custom enum, so we
73
+ * do not have to subtract one here.)
73
74
  */
74
75
  export const NUM_VANILLA_PILL_EFFECTS = getEnumLength(PillEffect);
75
76
 
@@ -99,7 +100,10 @@ export const FIRST_HORSE_PILL_COLOR = PillColor.HORSE_BLUE_BLUE;
99
100
  */
100
101
  export const LAST_HORSE_PILL_COLOR = PillColor.HORSE_WHITE_YELLOW;
101
102
 
102
- export const NUM_NORMAL_PILL_COLORS = LAST_NORMAL_PILL_COLOR - FIRST_PILL_COLOR;
103
+ export const NUM_NORMAL_PILL_COLORS = iRange(
104
+ FIRST_PILL_COLOR,
105
+ LAST_NORMAL_PILL_COLOR,
106
+ ).length;
103
107
 
104
108
  // -------
105
109
  // Players
@@ -111,18 +115,18 @@ export const FIRST_CHARACTER = PlayerType.ISAAC;
111
115
  // It is not possible to determine "LAST_PLAYER_TYPE", since there is no associated config.
112
116
 
113
117
  /** Calculated from the `PlayerType` enum. */
114
- export const LAST_VANILLA_CHARACTER = getLastEnumValue(PlayerType);
118
+ export const LAST_VANILLA_CHARACTER = getHighestEnumValue(PlayerType);
115
119
 
116
120
  // ----------
117
121
  // Room Types
118
122
  // ----------
119
123
 
120
124
  export const FIRST_ROOM_TYPE = RoomType.DEFAULT;
121
- export const LAST_ROOM_TYPE = getLastEnumValue(RoomType);
125
+ export const LAST_ROOM_TYPE = getHighestEnumValue(RoomType);
122
126
 
123
127
  // ------
124
128
  // Stages
125
129
  // ------
126
130
 
127
131
  export const FIRST_STAGE = LevelStage.BASEMENT_1;
128
- export const LAST_STAGE = getLastEnumValue(LevelStage);
132
+ export const LAST_STAGE = getHighestEnumValue(LevelStage);
@@ -97,7 +97,7 @@ export function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]> {
97
97
  * Note that this is not necessarily the enum value that is declared last, since there is no way to
98
98
  * infer that at run-time.
99
99
  */
100
- export function getLastEnumValue<T>(transpiledEnum: T): T[keyof T] {
100
+ export function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T] {
101
101
  const enumValues = getEnumValues(transpiledEnum);
102
102
 
103
103
  const lastElement = enumValues[enumValues.length - 1];