isaacscript-common 8.9.1 → 9.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.
Files changed (62) hide show
  1. package/dist/core/constantsFirstLast.d.ts +4 -4
  2. package/dist/core/constantsFirstLast.d.ts.map +1 -1
  3. package/dist/core/constantsFirstLast.lua +4 -4
  4. package/dist/features/extraConsoleCommands/listCommands.lua +14 -14
  5. package/dist/features/firstLast.d.ts +9 -9
  6. package/dist/features/firstLast.d.ts.map +1 -1
  7. package/dist/features/firstLast.lua +26 -26
  8. package/dist/features/preventCollectibleRotation.lua +2 -2
  9. package/dist/functions/cards.d.ts +27 -36
  10. package/dist/functions/cards.d.ts.map +1 -1
  11. package/dist/functions/cards.lua +70 -79
  12. package/dist/functions/collectibles.d.ts +1 -6
  13. package/dist/functions/collectibles.d.ts.map +1 -1
  14. package/dist/functions/collectibles.lua +1 -6
  15. package/dist/functions/pickupsSpecific.d.ts +9 -9
  16. package/dist/functions/pickupsSpecific.d.ts.map +1 -1
  17. package/dist/functions/pickupsSpecific.lua +16 -16
  18. package/dist/functions/pills.d.ts +1 -6
  19. package/dist/functions/pills.d.ts.map +1 -1
  20. package/dist/functions/pills.lua +1 -6
  21. package/dist/functions/pocketItems.lua +4 -4
  22. package/dist/functions/rockAlt.lua +2 -2
  23. package/dist/functions/trinkets.d.ts +1 -6
  24. package/dist/functions/trinkets.d.ts.map +1 -1
  25. package/dist/functions/trinkets.lua +1 -6
  26. package/dist/functions/types.d.ts +3 -3
  27. package/dist/functions/types.d.ts.map +1 -1
  28. package/dist/functions/types.lua +2 -2
  29. package/dist/index.d.ts +53 -77
  30. package/dist/maps/cardMap.d.ts +2 -2
  31. package/dist/maps/cardMap.d.ts.map +1 -1
  32. package/dist/maps/cardMap.lua +203 -203
  33. package/dist/objects/cardDescriptions.d.ts +2 -2
  34. package/dist/objects/cardDescriptions.d.ts.map +1 -1
  35. package/dist/objects/cardDescriptions.lua +99 -99
  36. package/dist/objects/cardNames.d.ts +2 -2
  37. package/dist/objects/cardNames.d.ts.map +1 -1
  38. package/dist/objects/cardNames.lua +99 -99
  39. package/dist/objects/cardTypeToItemConfigCardType.d.ts +6 -0
  40. package/dist/objects/cardTypeToItemConfigCardType.d.ts.map +1 -0
  41. package/dist/objects/cardTypeToItemConfigCardType.lua +106 -0
  42. package/package.json +2 -2
  43. package/src/core/constantsFirstLast.ts +4 -4
  44. package/src/features/extraConsoleCommands/listCommands.ts +16 -16
  45. package/src/features/firstLast.ts +26 -26
  46. package/src/features/preventCollectibleRotation.ts +2 -2
  47. package/src/functions/cards.ts +102 -88
  48. package/src/functions/collectibles.ts +1 -6
  49. package/src/functions/pickupsSpecific.ts +16 -13
  50. package/src/functions/pills.ts +1 -6
  51. package/src/functions/pocketItems.ts +4 -4
  52. package/src/functions/rockAlt.ts +2 -2
  53. package/src/functions/trinkets.ts +1 -6
  54. package/src/functions/types.ts +3 -3
  55. package/src/maps/cardMap.ts +204 -204
  56. package/src/objects/cardDescriptions.ts +100 -100
  57. package/src/objects/cardNames.ts +100 -100
  58. package/src/objects/cardTypeToItemConfigCardType.ts +106 -0
  59. package/dist/objects/cardTypes.d.ts +0 -6
  60. package/dist/objects/cardTypes.d.ts.map +0 -1
  61. package/dist/objects/cardTypes.lua +0 -106
  62. package/src/objects/cardTypes.ts +0 -104
@@ -24,7 +24,7 @@
24
24
  import {
25
25
  ActiveSlot,
26
26
  CacheFlag,
27
- Card,
27
+ CardType,
28
28
  Challenge,
29
29
  CollectibleType,
30
30
  Direction,
@@ -43,7 +43,7 @@ import {
43
43
  import { game, sfxManager } from "../../core/cachedClasses";
44
44
  import { MAX_LEVEL_GRID_INDEX } from "../../core/constants";
45
45
  import {
46
- FIRST_CARD,
46
+ FIRST_CARD_TYPE,
47
47
  FIRST_CHARACTER,
48
48
  FIRST_PILL_EFFECT,
49
49
  FIRST_ROOM_TYPE,
@@ -88,13 +88,13 @@ import { gridCoordinatesToWorldPosition } from "../../functions/roomGrid";
88
88
  import { changeRoom } from "../../functions/rooms";
89
89
  import { onSetSeed, restart, setUnseeded } from "../../functions/run";
90
90
  import { getGoldenTrinketType } from "../../functions/trinkets";
91
- import { asCard } from "../../functions/types";
91
+ import { asCardType } from "../../functions/types";
92
92
  import { irange, printConsole, printEnabled } from "../../functions/utils";
93
93
  import { CARD_MAP } from "../../maps/cardMap";
94
94
  import { CHARACTER_MAP } from "../../maps/characterMap";
95
95
  import { PILL_EFFECT_MAP } from "../../maps/pillEffectMap";
96
96
  import { ROOM_TYPE_MAP } from "../../maps/roomTypeMap";
97
- import { getLastCard, getLastPillEffect } from "../firstLast";
97
+ import { getLastCardType, getLastPillEffect } from "../firstLast";
98
98
  import {
99
99
  addHeart,
100
100
  devilAngel,
@@ -326,8 +326,8 @@ export function card(params: string): void {
326
326
  return;
327
327
  }
328
328
 
329
- let cardNum: Card;
330
- const num = tonumber(params) as Card | undefined;
329
+ let cardType: CardType;
330
+ const num = tonumber(params) as CardType | undefined;
331
331
  if (num === undefined) {
332
332
  const match = getMapPartialMatch(params, CARD_MAP);
333
333
  if (match === undefined) {
@@ -335,35 +335,35 @@ export function card(params: string): void {
335
335
  return;
336
336
  }
337
337
 
338
- cardNum = match[1];
338
+ cardType = match[1];
339
339
  } else {
340
- const lastCard = getLastCard();
341
- if (num < FIRST_CARD || num > lastCard) {
340
+ const lastCardType = getLastCardType();
341
+ if (num < FIRST_CARD_TYPE || num > lastCardType) {
342
342
  printConsole(`Invalid card sub-type: ${num}`);
343
343
  return;
344
344
  }
345
345
 
346
- cardNum = num;
346
+ cardType = num;
347
347
  }
348
348
 
349
- const cardName = getCardName(cardNum);
350
- Isaac.ExecuteCommand(`g k${cardNum}`);
351
- printConsole(`Gave card: ${cardName} (${cardNum})`);
349
+ const cardName = getCardName(cardType);
350
+ Isaac.ExecuteCommand(`g k${cardType}`);
351
+ printConsole(`Gave card: ${cardName} (${cardType})`);
352
352
  }
353
353
 
354
354
  /** Spawns every card on the ground, starting at the top-left-most tile. */
355
355
  export function cards(): void {
356
- const lastCard = getLastCard();
356
+ const lastCardType = getLastCardType();
357
357
 
358
358
  let cardType = 1;
359
359
  for (let y = 0; y <= 6; y++) {
360
360
  for (let x = 0; x <= 12; x++) {
361
- if (asCard(cardType) === lastCard) {
361
+ if (asCardType(cardType) === lastCardType) {
362
362
  return;
363
363
  }
364
364
 
365
365
  const position = gridCoordinatesToWorldPosition(x, y);
366
- spawnCard(asCard(cardType), position);
366
+ spawnCard(asCardType(cardType), position);
367
367
  cardType++;
368
368
  }
369
369
  }
@@ -1,5 +1,5 @@
1
1
  import {
2
- Card,
2
+ CardType,
3
3
  CollectibleType,
4
4
  PillEffect,
5
5
  TrinketType,
@@ -7,14 +7,14 @@ import {
7
7
  import { ModUpgraded } from "../classes/ModUpgraded";
8
8
  import { itemConfig } from "../core/cachedClasses";
9
9
  import {
10
- FIRST_CARD,
10
+ FIRST_CARD_TYPE,
11
11
  FIRST_PILL_EFFECT,
12
12
  FIRST_TRINKET_TYPE,
13
- LAST_VANILLA_CARD,
13
+ LAST_VANILLA_CARD_TYPE,
14
14
  LAST_VANILLA_COLLECTIBLE_TYPE,
15
15
  LAST_VANILLA_PILL_EFFECT,
16
16
  LAST_VANILLA_TRINKET_TYPE,
17
- NUM_VANILLA_CARDS,
17
+ NUM_VANILLA_CARD_TYPES,
18
18
  NUM_VANILLA_COLLECTIBLE_TYPES,
19
19
  NUM_VANILLA_PILL_EFFECTS,
20
20
  NUM_VANILLA_TRINKET_TYPES,
@@ -22,7 +22,7 @@ import {
22
22
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
23
23
  import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
24
24
  import {
25
- asCard,
25
+ asCardType,
26
26
  asCollectibleType,
27
27
  asNumber,
28
28
  asPillEffect,
@@ -168,7 +168,7 @@ export function getFirstModdedTrinketType(): TrinketType | undefined {
168
168
  }
169
169
 
170
170
  /**
171
- * Will change depending on how many modded cards there are.
171
+ * Will change depending on how many modded trinkets there are.
172
172
  *
173
173
  * This is equal to the number of trinket types, since all trinket types are contiguous (unlike
174
174
  * collectibles).
@@ -206,7 +206,7 @@ export function getModdedTrinketTypes(): TrinketType[] {
206
206
  }
207
207
 
208
208
  /**
209
- * Will change depending on how many modded cards there are.
209
+ * Will change depending on how many modded trinkets there are.
210
210
  *
211
211
  * Equal to `itemConfig.GetTrinkets().Size - 1`. (We subtract one to account for
212
212
  * `TrinketType.NULL`.)
@@ -254,9 +254,9 @@ export function getTrinketTypes(): TrinketType[] {
254
254
  * This function can only be called if at least one callback has been executed. This is because not
255
255
  * all cards will necessarily be present when a mod first loads (due to mod load order).
256
256
  */
257
- export function getAllCards(): Card[] {
258
- const lastCard = getLastCard();
259
- return irange(FIRST_CARD, lastCard);
257
+ export function getAllCardTypes(): CardType[] {
258
+ const lastCardType = getLastCardType();
259
+ return irange(FIRST_CARD_TYPE, lastCardType);
260
260
  }
261
261
 
262
262
  /**
@@ -265,13 +265,13 @@ export function getAllCards(): Card[] {
265
265
  * This function can only be called if at least one callback has been executed. This is because not
266
266
  * all cards will necessarily be present when a mod first loads (due to mod load order).
267
267
  */
268
- export function getFirstModdedCard(): Card | undefined {
268
+ export function getFirstModdedCardType(): CardType | undefined {
269
269
  errorIfFeaturesNotInitialized(FEATURE_NAME);
270
270
  errorIfNoCallbacksFired("card");
271
271
 
272
- const firstModdedCard = asCard(asNumber(LAST_VANILLA_CARD) + 1);
273
- const itemConfigCard = itemConfig.GetCard(firstModdedCard);
274
- return itemConfigCard === undefined ? undefined : firstModdedCard;
272
+ const firstModdedCardType = asCardType(asNumber(LAST_VANILLA_CARD_TYPE) + 1);
273
+ const itemConfigCard = itemConfig.GetCard(firstModdedCardType);
274
+ return itemConfigCard === undefined ? undefined : firstModdedCardType;
275
275
  }
276
276
 
277
277
  /**
@@ -283,12 +283,12 @@ export function getFirstModdedCard(): Card | undefined {
283
283
  * This function can only be called if at least one callback has been executed. This is because not
284
284
  * all cards will necessarily be present when a mod first loads (due to mod load order).
285
285
  */
286
- export function getLastCard(): Card {
286
+ export function getLastCardType(): CardType {
287
287
  errorIfFeaturesNotInitialized(FEATURE_NAME);
288
288
  errorIfNoCallbacksFired("card");
289
289
 
290
- const numCards = getNumCards();
291
- return asCard(numCards);
290
+ const numCards = getNumCardTypes();
291
+ return asCardType(numCards);
292
292
  }
293
293
 
294
294
  /**
@@ -299,14 +299,14 @@ export function getLastCard(): Card {
299
299
  * This function can only be called if at least one callback has been executed. This is because not
300
300
  * all cards will necessarily be present when a mod first loads (due to mod load order).
301
301
  */
302
- export function getModdedCards(): Card[] {
303
- const firstModdedCard = getFirstModdedCard();
304
- if (firstModdedCard === undefined) {
302
+ export function getModdedCardTypes(): CardType[] {
303
+ const firstModdedCardType = getFirstModdedCardType();
304
+ if (firstModdedCardType === undefined) {
305
305
  return [];
306
306
  }
307
307
 
308
- const lastCard = getLastCard();
309
- return irange(firstModdedCard, lastCard);
308
+ const lastCardType = getLastCardType();
309
+ return irange(firstModdedCardType, lastCardType);
310
310
  }
311
311
 
312
312
  /**
@@ -317,7 +317,7 @@ export function getModdedCards(): Card[] {
317
317
  * This function can only be called if at least one callback has been executed. This is because not
318
318
  * all cards will necessarily be present when a mod first loads (due to mod load order).
319
319
  */
320
- export function getNumCards(): int {
320
+ export function getNumCardTypes(): int {
321
321
  errorIfFeaturesNotInitialized(FEATURE_NAME);
322
322
  errorIfNoCallbacksFired("card");
323
323
 
@@ -328,12 +328,12 @@ export function getNumCards(): int {
328
328
  * This function can only be called if at least one callback has been executed. This is because not
329
329
  * all trinkets will necessarily be present when a mod first loads (due to mod load order).
330
330
  */
331
- export function getNumModdedCards(): int {
331
+ export function getNumModdedCardTypes(): int {
332
332
  errorIfFeaturesNotInitialized(FEATURE_NAME);
333
333
  errorIfNoCallbacksFired("card");
334
334
 
335
- const numCards = getNumCards();
336
- return numCards - NUM_VANILLA_CARDS;
335
+ const numCardTypes = getNumCardTypes();
336
+ return numCardTypes - NUM_VANILLA_CARD_TYPES;
337
337
  }
338
338
 
339
339
  // ------------
@@ -2,7 +2,7 @@
2
2
  // switching mechanic.
3
3
 
4
4
  import {
5
- Card,
5
+ CardType,
6
6
  CollectibleType,
7
7
  ModCallback,
8
8
  PickupVariant,
@@ -39,7 +39,7 @@ export function preventCollectibleRotationInit(mod: Mod): void {
39
39
  mod.AddCallback(
40
40
  ModCallback.POST_USE_CARD,
41
41
  useCardSoulOfIsaac,
42
- Card.SOUL_ISAAC,
42
+ CardType.SOUL_ISAAC,
43
43
  ); // 5
44
44
 
45
45
  mod.AddCallback(
@@ -1,40 +1,52 @@
1
- import { Card, ItemConfigCardType } from "isaac-typescript-definitions";
1
+ import { CardType, ItemConfigCardType } from "isaac-typescript-definitions";
2
2
  import { itemConfig } from "../core/cachedClasses";
3
- import { FIRST_CARD, LAST_VANILLA_CARD } from "../core/constantsFirstLast";
3
+ import {
4
+ FIRST_CARD_TYPE,
5
+ LAST_VANILLA_CARD_TYPE,
6
+ } from "../core/constantsFirstLast";
4
7
  import {
5
8
  CARD_DESCRIPTIONS,
6
9
  DEFAULT_CARD_DESCRIPTION,
7
10
  } from "../objects/cardDescriptions";
8
11
  import { CARD_NAMES, DEFAULT_CARD_NAME } from "../objects/cardNames";
9
- import { CARD_TYPES, DEFAULT_CARD_TYPE } from "../objects/cardTypes";
12
+ import {
13
+ CARD_TYPE_TO_ITEM_CONFIG_CARD_TYPE,
14
+ DEFAULT_CARD_TYPE,
15
+ } from "../objects/cardTypeToItemConfigCardType";
10
16
  import { getEnumValues } from "./enums";
11
17
  import { getRandomSeed } from "./rng";
12
18
  import { addSetsToSet, getRandomSetElement } from "./set";
13
19
  import { irange } from "./utils";
14
20
 
15
- const CARD_TYPE_TO_CARDS_MAP = new Map<ItemConfigCardType, Set<Card>>();
21
+ const ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP = new Map<
22
+ ItemConfigCardType,
23
+ Set<CardType>
24
+ >();
16
25
 
17
26
  /**
18
- * Contains all of the entries in the `Card` enum with the following types:
27
+ * Contains all of the entries in the `CardType` enum with the following types:
19
28
  * - ItemConfigCardType.TAROT
20
29
  * - ItemConfigCardType.SUIT
21
30
  * - ItemConfigCardType.SPECIAL
22
31
  * - ItemConfigCardType.TAROT_REVERSE
23
32
  */
24
- const CARD_SET = new Set<Card>();
33
+ const CARD_SET = new Set<CardType>();
25
34
 
26
35
  function lazyInitCardMapsSets() {
27
36
  // The card type to cards map should be valid for every card type, so we initialize it with empty
28
37
  // sets.
29
38
  for (const cardType of getEnumValues(ItemConfigCardType)) {
30
- CARD_TYPE_TO_CARDS_MAP.set(cardType, new Set<Card>());
39
+ ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP.set(cardType, new Set<CardType>());
31
40
  }
32
41
 
33
- for (const card of getVanillaCards()) {
34
- const cardType = getCardType(card);
35
- const cardTypeSet = CARD_TYPE_TO_CARDS_MAP.get(cardType);
42
+ for (const card of getVanillaCardTypes()) {
43
+ const itemConfigCardType = getItemConfigCardType(card);
44
+ const cardTypeSet =
45
+ ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP.get(itemConfigCardType);
36
46
  if (cardTypeSet === undefined) {
37
- error(`Failed to get the card set for card type: ${cardType}`);
47
+ error(
48
+ `Failed to get the card set for item config card type: ${itemConfigCardType}`,
49
+ );
38
50
  }
39
51
  cardTypeSet.add(card);
40
52
  }
@@ -43,7 +55,7 @@ function lazyInitCardMapsSets() {
43
55
  // - ItemConfigCardType.RUNE
44
56
  // - ItemConfigCardType.SPECIAL_OBJECT
45
57
  // - ItemConfigCardType.MODDED
46
- const cards = getCardsOfType(
58
+ const cards = getCardTypesOfType(
47
59
  ItemConfigCardType.TAROT,
48
60
  ItemConfigCardType.SUIT,
49
61
  ItemConfigCardType.SPECIAL,
@@ -55,23 +67,18 @@ function lazyInitCardMapsSets() {
55
67
  /**
56
68
  * Helper function to get a card description from a Card enum value.
57
69
  *
58
- * For example:
59
- *
60
- * ```ts
61
- * const card = Card.FOOL;
62
- * const cardDescription = getCardDescription(card); // cardDescription is "Where journey begins"
63
- * ```
70
+ * For example, `getCardDescription(card)` returns "Where journey begins".
64
71
  */
65
- export function getCardDescription(card: Card): string {
72
+ export function getCardDescription(cardType: CardType): string {
66
73
  // "ItemConfigCard.Description" is bugged with vanilla cards on patch v1.7.6, so we use a
67
74
  // hard-coded map as a workaround.
68
- const cardDescription = CARD_DESCRIPTIONS[card];
69
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
75
+ const cardDescription = CARD_DESCRIPTIONS[cardType];
76
+
70
77
  if (cardDescription !== undefined) {
71
78
  return cardDescription;
72
79
  }
73
80
 
74
- const itemConfigCard = itemConfig.GetCard(card);
81
+ const itemConfigCard = itemConfig.GetCard(cardType);
75
82
  if (itemConfigCard !== undefined) {
76
83
  return itemConfigCard.Description;
77
84
  }
@@ -82,23 +89,18 @@ export function getCardDescription(card: Card): string {
82
89
  /**
83
90
  * Helper function to get a card name from a Card.
84
91
  *
85
- * For example:
86
- *
87
- * ```ts
88
- * const card = Card.FOOL;
89
- * const cardName = getCardName(card); // cardName is "0 - The Fool"
90
- * ```
92
+ * For example, `getCardName(Card.FOOL)` would return "0 - The Fool".
91
93
  */
92
- export function getCardName(card: Card): string {
94
+ export function getCardName(cardType: CardType): string {
93
95
  // "ItemConfigCard.Name" is bugged with vanilla cards on patch v1.7.6, so we use a hard-coded map
94
96
  // as a workaround.
95
- const cardName = CARD_NAMES[card];
96
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
97
+ const cardName = CARD_NAMES[cardType];
98
+
97
99
  if (cardName !== undefined) {
98
100
  return cardName;
99
101
  }
100
102
 
101
- const itemConfigCard = itemConfig.GetCard(card);
103
+ const itemConfigCard = itemConfig.GetCard(cardType);
102
104
  if (itemConfigCard !== undefined) {
103
105
  return itemConfigCard.Name;
104
106
  }
@@ -106,37 +108,45 @@ export function getCardName(card: Card): string {
106
108
  return DEFAULT_CARD_NAME;
107
109
  }
108
110
 
109
- export function getCardType(card: Card): ItemConfigCardType {
110
- const cardType = CARD_TYPES[card];
111
- // Handle modded cards.
112
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
113
- return cardType === undefined ? DEFAULT_CARD_TYPE : cardType;
114
- }
115
-
116
111
  /**
117
- * Helper function to get a set of cards matching the type. Also see the `CardType` enum.
112
+ * Helper function to get a set of card types matching the `ItemConfigCardType`.
118
113
  *
119
114
  * This function is variadic, meaning that you can you can specify N card types to get a set
120
115
  * containing cards that match any of the specified types.
121
116
  */
122
- export function getCardsOfType(...cardTypes: ItemConfigCardType[]): Set<Card> {
123
- if (CARD_TYPE_TO_CARDS_MAP.size === 0) {
117
+ export function getCardTypesOfType(
118
+ ...itemConfigCardTypes: ItemConfigCardType[]
119
+ ): Set<CardType> {
120
+ if (ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP.size === 0) {
124
121
  lazyInitCardMapsSets();
125
122
  }
126
123
 
127
- const matchingCards = new Set<Card>();
128
- for (const cardType of cardTypes) {
129
- const cardSet = CARD_TYPE_TO_CARDS_MAP.get(cardType);
130
- if (cardSet === undefined) {
131
- error(`Failed to get the cards for type: ${cardType}`);
124
+ const matchingCardTypes = new Set<CardType>();
125
+ for (const itemConfigCardType of itemConfigCardTypes) {
126
+ const cardTypeSet =
127
+ ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP.get(itemConfigCardType);
128
+ if (cardTypeSet === undefined) {
129
+ error(
130
+ `Failed to get the card type set for item config type: ${itemConfigCardType}`,
131
+ );
132
132
  }
133
133
 
134
- for (const card of cardSet.values()) {
135
- matchingCards.add(card);
134
+ for (const cardType of cardTypeSet.values()) {
135
+ matchingCardTypes.add(cardType);
136
136
  }
137
137
  }
138
138
 
139
- return matchingCards;
139
+ return matchingCardTypes;
140
+ }
141
+
142
+ export function getItemConfigCardType(cardType: CardType): ItemConfigCardType {
143
+ const itemConfigCardType = CARD_TYPE_TO_ITEM_CONFIG_CARD_TYPE[cardType];
144
+
145
+ // Handle modded cards.
146
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
147
+ return itemConfigCardType === undefined
148
+ ? DEFAULT_CARD_TYPE
149
+ : itemConfigCardType;
140
150
  }
141
151
 
142
152
  /**
@@ -154,24 +164,25 @@ export function getCardsOfType(...cardTypes: ItemConfigCardType[]): Set<Card> {
154
164
  */
155
165
  export function getRandomCard(
156
166
  seedOrRNG: Seed | RNG = getRandomSeed(),
157
- exceptions: Card[] = [],
158
- ): Card {
167
+ exceptions: CardType[] = [],
168
+ ): CardType {
159
169
  return getRandomSetElement(CARD_SET, seedOrRNG, exceptions);
160
170
  }
161
171
 
162
172
  /**
163
- * @param cardType The card type that represents the pool of cards to select from.
173
+ * @param itemConfigCardType The item config card type that represents the pool of cards to select
174
+ * from.
164
175
  * @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
165
176
  * `RNG.Next` method will be called. Default is `getRandomSeed()`.
166
177
  * @param exceptions Optional. An array of cards to not select.
167
178
  */
168
- export function getRandomCardOfType(
169
- cardType: ItemConfigCardType,
179
+ export function getRandomCardTypeOfType(
180
+ itemConfigCardType: ItemConfigCardType,
170
181
  seedOrRNG: Seed | RNG = getRandomSeed(),
171
- exceptions: Card[] = [],
172
- ): Card {
173
- const cardSet = getCardsOfType(cardType);
174
- return getRandomSetElement(cardSet, seedOrRNG, exceptions);
182
+ exceptions: CardType[] = [],
183
+ ): CardType {
184
+ const cardTypeSet = getCardTypesOfType(itemConfigCardType);
185
+ return getRandomSetElement(cardTypeSet, seedOrRNG, exceptions);
175
186
  }
176
187
 
177
188
  /**
@@ -184,16 +195,16 @@ export function getRandomCardOfType(
184
195
  */
185
196
  export function getRandomRune(
186
197
  seedOrRNG: Seed | RNG = getRandomSeed(),
187
- exceptions: Card[] = [],
188
- ): Card {
189
- const runesSet = getCardsOfType(ItemConfigCardType.RUNE);
190
- runesSet.delete(Card.RUNE_SHARD);
198
+ exceptions: CardType[] = [],
199
+ ): CardType {
200
+ const runesSet = getCardTypesOfType(ItemConfigCardType.RUNE);
201
+ runesSet.delete(CardType.RUNE_SHARD);
191
202
  return getRandomSetElement(runesSet, seedOrRNG, exceptions);
192
203
  }
193
204
 
194
205
  /** Helper function to get an array with every valid vanilla card sub-type. */
195
- export function getVanillaCards(): Card[] {
196
- return irange(FIRST_CARD, LAST_VANILLA_CARD);
206
+ export function getVanillaCardTypes(): CardType[] {
207
+ return irange(FIRST_CARD_TYPE, LAST_VANILLA_CARD_TYPE);
197
208
  }
198
209
 
199
210
  /**
@@ -203,51 +214,54 @@ export function getVanillaCards(): Card[] {
203
214
  * - CardType.SPECIAL
204
215
  * - CardType.TAROT_REVERSE
205
216
  */
206
- export function isCard(card: Card): boolean {
207
- return CARD_SET.has(card);
217
+ export function isCard(cardType: CardType): boolean {
218
+ return CARD_SET.has(cardType);
208
219
  }
209
220
 
210
- /** Returns whether or not the given card matches the specified card type. */
211
- export function isCardType(card: Card, cardType: ItemConfigCardType): boolean {
212
- return cardType === getCardType(card);
221
+ /** Returns whether or not the given card type matches the specified item config card type. */
222
+ export function isCardType(
223
+ cardType: CardType,
224
+ itemConfigCardType: ItemConfigCardType,
225
+ ): boolean {
226
+ return itemConfigCardType === getItemConfigCardType(cardType);
213
227
  }
214
228
 
215
229
  /** Returns true for any card or rune added by a mod. */
216
- export function isModdedCard(card: Card): boolean {
217
- return !isVanillaCard(card);
230
+ export function isModdedCardType(cardType: CardType): boolean {
231
+ return !isVanillaCardType(cardType);
218
232
  }
219
233
 
220
- /** Returns true for cards that have `CardType.SPECIAL_OBJECT`. */
221
- export function isPocketItemObject(card: Card): boolean {
222
- return isCardType(card, ItemConfigCardType.SPECIAL_OBJECT);
234
+ /** Returns true for cards that have `ItemConfigCardType.SPECIAL_OBJECT`. */
235
+ export function isPocketItemObject(cardType: CardType): boolean {
236
+ return isCardType(cardType, ItemConfigCardType.SPECIAL_OBJECT);
223
237
  }
224
238
 
225
- /** Returns true for cards that have `CardType.TAROT_REVERSE`. */
226
- export function isReverseTarotCard(card: Card): boolean {
227
- return isCardType(card, ItemConfigCardType.TAROT_REVERSE);
239
+ /** Returns true for cards that have `ItemConfigCardType.TAROT_REVERSE`. */
240
+ export function isReverseTarotCard(cardType: CardType): boolean {
241
+ return isCardType(cardType, ItemConfigCardType.TAROT_REVERSE);
228
242
  }
229
243
 
230
244
  /** Returns true for cards that have `CardType.RUNE`. */
231
- export function isRune(card: Card): boolean {
232
- return isCardType(card, ItemConfigCardType.RUNE);
245
+ export function isRune(cardType: CardType): boolean {
246
+ return isCardType(cardType, ItemConfigCardType.RUNE);
233
247
  }
234
248
 
235
249
  /** Returns true for cards that have `CardType.SPECIAL`. */
236
- export function isSpecialCard(card: Card): boolean {
237
- return isCardType(card, ItemConfigCardType.SPECIAL);
250
+ export function isSpecialCard(cardType: CardType): boolean {
251
+ return isCardType(cardType, ItemConfigCardType.SPECIAL);
238
252
  }
239
253
 
240
254
  /** Returns true for cards that have `CardType.SUIT`. */
241
- export function isSuitCard(card: Card): boolean {
242
- return isCardType(card, ItemConfigCardType.SUIT);
255
+ export function isSuitCard(cardType: CardType): boolean {
256
+ return isCardType(cardType, ItemConfigCardType.SUIT);
243
257
  }
244
258
 
245
259
  /** Returns true for cards that have `CardType.TAROT`. */
246
- export function isTarotCard(card: Card): boolean {
247
- return isCardType(card, ItemConfigCardType.TAROT);
260
+ export function isTarotCard(cardType: CardType): boolean {
261
+ return isCardType(cardType, ItemConfigCardType.TAROT);
248
262
  }
249
263
 
250
264
  /** Returns true for any vanilla card or rune. */
251
- export function isVanillaCard(card: Card): boolean {
252
- return card <= LAST_VANILLA_CARD;
265
+ export function isVanillaCardType(cardType: CardType): boolean {
266
+ return cardType <= LAST_VANILLA_CARD_TYPE;
253
267
  }
@@ -303,12 +303,7 @@ export function getCollectibleMaxCharges(
303
303
  * Helper function to get the name of a collectible. Returns "Unknown" if the provided collectible
304
304
  * type is not valid.
305
305
  *
306
- * For example:
307
- *
308
- * ```ts
309
- * const collectibleType = CollectibleType.SAD_ONION;
310
- * const collectibleName = getCollectibleName(collectibleType); // collectibleName is "Sad Onion"
311
- * ```
306
+ * For example, `getCollectibleName(CollectibleType.SAD_ONION)` would return "Sad Onion".
312
307
  */
313
308
  export function getCollectibleName(collectibleType: CollectibleType): string {
314
309
  // "ItemConfigItem.Name" is bugged with vanilla items on patch v1.7.6, so we use a hard-coded map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BatterySubType,
3
3
  BombSubType,
4
- Card,
4
+ CardType,
5
5
  CoinSubType,
6
6
  CollectibleType,
7
7
  HeartSubType,
@@ -45,11 +45,11 @@ export function getBombPickups(
45
45
  /**
46
46
  * Helper function to get all of the card entities in the room.
47
47
  *
48
- * @param card Optional. If specified, will only get the cards that match the sub-type. Default is
49
- * -1, which matches every sub-type.
48
+ * @param cardType Optional. If specified, will only get the cards that match the sub-type. Default
49
+ * is -1, which matches every sub-type.
50
50
  */
51
- export function getCards(card: Card = -1): EntityPickupCard[] {
52
- return getPickups(PickupVariant.TAROT_CARD, card) as EntityPickupCard[];
51
+ export function getCards(cardType: CardType = -1): EntityPickupCard[] {
52
+ return getPickups(PickupVariant.TAROT_CARD, cardType) as EntityPickupCard[];
53
53
  }
54
54
 
55
55
  /**
@@ -176,15 +176,18 @@ export function removeAllBombPickups(
176
176
  /**
177
177
  * Helper function to remove all of the cards in the room.
178
178
  *
179
- * @param card Optional. If specified, will only remove cards that match this sub-type. Default is
180
- * -1, which matches every sub-type.
179
+ * @param cardType Optional. If specified, will only remove cards that match this sub-type. Default
180
+ * is -1, which matches every sub-type.
181
181
  * @param cap Optional. If specified, will only remove the given amount of cards.
182
182
  * @returns The cards that were removed.
183
183
  */
184
- export function removeAllCards(card: Card = -1, cap?: int): EntityPickupCard[] {
184
+ export function removeAllCards(
185
+ cardType: CardType = -1,
186
+ cap?: int,
187
+ ): EntityPickupCard[] {
185
188
  return removeAllPickups(
186
189
  PickupVariant.TAROT_CARD,
187
- card,
190
+ cardType,
188
191
  cap,
189
192
  ) as EntityPickupCard[];
190
193
  }
@@ -392,7 +395,7 @@ export function spawnBombPickupWithSeed(
392
395
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TAROT_CARD` (300).
393
396
  */
394
397
  export function spawnCard(
395
- card: Card,
398
+ cardType: CardType,
396
399
  position: Vector,
397
400
  velocity: Vector = VectorZero,
398
401
  spawner: Entity | undefined = undefined,
@@ -400,7 +403,7 @@ export function spawnCard(
400
403
  ): EntityPickupCard {
401
404
  return spawnPickup(
402
405
  PickupVariant.TAROT_CARD,
403
- card,
406
+ cardType,
404
407
  position,
405
408
  velocity,
406
409
  spawner,
@@ -413,13 +416,13 @@ export function spawnCard(
413
416
  * and a specific seed.
414
417
  */
415
418
  export function spawnCardWithSeed(
416
- card: Card,
419
+ cardType: CardType,
417
420
  position: Vector,
418
421
  seedOrRNG: Seed | RNG,
419
422
  velocity: Vector = VectorZero,
420
423
  spawner: Entity | undefined = undefined,
421
424
  ): EntityPickupCard {
422
- return spawnCard(card, position, velocity, spawner, seedOrRNG);
425
+ return spawnCard(cardType, position, velocity, spawner, seedOrRNG);
423
426
  }
424
427
 
425
428
  /** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.COIN` (20). */