isaacscript-common 7.18.0 → 8.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 (67) hide show
  1. package/dist/core/constantsFirstLast.d.ts +10 -85
  2. package/dist/core/constantsFirstLast.d.ts.map +1 -1
  3. package/dist/core/constantsFirstLast.lua +10 -90
  4. package/dist/enums/ModCallbackCustom.d.ts +21 -0
  5. package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
  6. package/dist/features/characterStats.lua +2 -2
  7. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  8. package/dist/features/extraConsoleCommands/listCommands.lua +9 -5
  9. package/dist/features/firstLast.d.ts +190 -0
  10. package/dist/features/firstLast.d.ts.map +1 -0
  11. package/dist/features/firstLast.lua +341 -0
  12. package/dist/functions/array.d.ts +1 -9
  13. package/dist/functions/array.d.ts.map +1 -1
  14. package/dist/functions/array.lua +0 -6
  15. package/dist/functions/cards.d.ts +0 -8
  16. package/dist/functions/cards.d.ts.map +1 -1
  17. package/dist/functions/cards.lua +9 -24
  18. package/dist/functions/{cacheFlag.d.ts → collectibleCacheFlag.d.ts} +8 -8
  19. package/dist/functions/collectibleCacheFlag.d.ts.map +1 -0
  20. package/dist/functions/{cacheFlag.lua → collectibleCacheFlag.lua} +12 -13
  21. package/dist/functions/collectibleSet.d.ts +18 -0
  22. package/dist/functions/collectibleSet.d.ts.map +1 -1
  23. package/dist/functions/collectibleSet.lua +29 -9
  24. package/dist/functions/collectibles.d.ts +0 -13
  25. package/dist/functions/collectibles.d.ts.map +1 -1
  26. package/dist/functions/collectibles.lua +0 -18
  27. package/dist/functions/flying.lua +2 -2
  28. package/dist/functions/pills.d.ts +0 -10
  29. package/dist/functions/pills.d.ts.map +1 -1
  30. package/dist/functions/pills.lua +0 -15
  31. package/dist/functions/random.d.ts.map +1 -1
  32. package/dist/functions/random.lua +2 -0
  33. package/dist/functions/stats.d.ts +9 -0
  34. package/dist/functions/stats.d.ts.map +1 -0
  35. package/dist/functions/stats.lua +11 -0
  36. package/dist/functions/trinketCacheFlag.d.ts +9 -1
  37. package/dist/functions/trinketCacheFlag.d.ts.map +1 -1
  38. package/dist/functions/trinketCacheFlag.lua +28 -10
  39. package/dist/functions/trinketSet.d.ts +18 -0
  40. package/dist/functions/trinketSet.d.ts.map +1 -1
  41. package/dist/functions/trinketSet.lua +29 -9
  42. package/dist/functions/trinkets.d.ts +1 -10
  43. package/dist/functions/trinkets.d.ts.map +1 -1
  44. package/dist/functions/trinkets.lua +0 -24
  45. package/dist/index.d.ts +245 -117
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.lua +14 -6
  48. package/package.json +1 -1
  49. package/src/core/constantsFirstLast.ts +12 -125
  50. package/src/enums/ModCallbackCustom.ts +21 -0
  51. package/src/features/characterStats.ts +1 -1
  52. package/src/features/extraConsoleCommands/listCommands.ts +8 -5
  53. package/src/features/firstLast.ts +429 -0
  54. package/src/functions/array.ts +1 -9
  55. package/src/functions/cards.ts +5 -28
  56. package/src/functions/{cacheFlag.ts → collectibleCacheFlag.ts} +13 -16
  57. package/src/functions/collectibleSet.ts +28 -21
  58. package/src/functions/collectibles.ts +0 -22
  59. package/src/functions/flying.ts +1 -1
  60. package/src/functions/pills.ts +0 -22
  61. package/src/functions/random.ts +3 -0
  62. package/src/functions/stats.ts +12 -0
  63. package/src/functions/trinketCacheFlag.ts +29 -7
  64. package/src/functions/trinketSet.ts +28 -21
  65. package/src/functions/trinkets.ts +0 -34
  66. package/src/index.ts +2 -1
  67. package/dist/functions/cacheFlag.d.ts.map +0 -1
@@ -0,0 +1,429 @@
1
+ import {
2
+ Card,
3
+ CollectibleType,
4
+ PillEffect,
5
+ TrinketType,
6
+ } from "isaac-typescript-definitions";
7
+ import { ModUpgraded } from "../classes/ModUpgraded";
8
+ import { itemConfig } from "../core/cachedClasses";
9
+ import {
10
+ FIRST_CARD,
11
+ FIRST_PILL_EFFECT,
12
+ FIRST_TRINKET_TYPE,
13
+ LAST_VANILLA_CARD,
14
+ LAST_VANILLA_COLLECTIBLE_TYPE,
15
+ LAST_VANILLA_PILL_EFFECT,
16
+ LAST_VANILLA_TRINKET_TYPE,
17
+ NUM_VANILLA_CARDS,
18
+ NUM_VANILLA_COLLECTIBLE_TYPES,
19
+ NUM_VANILLA_PILL_EFFECTS,
20
+ NUM_VANILLA_TRINKET_TYPES,
21
+ } from "../core/constantsFirstLast";
22
+ import { ModCallbackCustom } from "../enums/ModCallbackCustom";
23
+ import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
24
+ import {
25
+ asCard,
26
+ asCollectibleType,
27
+ asNumber,
28
+ asPillEffect,
29
+ asTrinketType,
30
+ } from "../functions/types";
31
+ import { irange } from "../functions/utils";
32
+
33
+ const FEATURE_NAME = "firstLast";
34
+
35
+ let atLeastOneCallbackFired = false;
36
+
37
+ /** @internal */
38
+ export function firstLastInit(mod: ModUpgraded): void {
39
+ mod.AddCallbackCustom(
40
+ ModCallbackCustom.POST_NEW_ROOM_EARLY,
41
+ postNewRoomEarly,
42
+ );
43
+ }
44
+
45
+ // ModCallbackCustom.POST_NEW_ROOM_EARLY
46
+ function postNewRoomEarly() {
47
+ atLeastOneCallbackFired = true;
48
+ }
49
+
50
+ function errorIfNoCallbacksFired(constantType: string) {
51
+ if (!atLeastOneCallbackFired) {
52
+ error(
53
+ `Failed to retrieve a ${constantType} constant. Since not all mods have been loaded yet, any constants of this type will be inaccurate. Thus, you must wait until at least one callback fires before retrieving these types of constants.`,
54
+ );
55
+ }
56
+ }
57
+
58
+ // ------------
59
+ // Collectibles
60
+ // ------------
61
+
62
+ /**
63
+ * Returns the first modded collectible type, or undefined if there are no modded collectibles.
64
+ *
65
+ * This function can only be called if at least one callback has been executed. This is because not
66
+ * all collectibles will necessarily be present when a mod first loads (due to mod load order).
67
+ */
68
+ export function getFirstModdedCollectibleType(): CollectibleType | undefined {
69
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
70
+ errorIfNoCallbacksFired("collectible");
71
+
72
+ const firstModdedCollectibleType = asCollectibleType(
73
+ asNumber(LAST_VANILLA_COLLECTIBLE_TYPE) + 1,
74
+ );
75
+ const itemConfigItem = itemConfig.GetCollectible(firstModdedCollectibleType);
76
+ return itemConfigItem === undefined ? undefined : firstModdedCollectibleType;
77
+ }
78
+
79
+ /**
80
+ * Will change depending on how many modded collectibles there are.
81
+ *
82
+ * Equal to `itemConfig.GetCollectibles().Size - 1`. (`Size` includes invalid collectibles, like
83
+ * 666. We subtract one to account for `CollectibleType.NULL`.)
84
+ *
85
+ * This function can only be called if at least one callback has been executed. This is because not
86
+ * all collectibles will necessarily be present when a mod first loads (due to mod load order).
87
+ */
88
+ export function getLastCollectibleType(): CollectibleType {
89
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
90
+ errorIfNoCallbacksFired("collectible");
91
+
92
+ return itemConfig.GetCollectibles().Size - 1;
93
+ }
94
+
95
+ /**
96
+ * Helper function to get an array that represents the all modded collectible types.
97
+ *
98
+ * This function is only useful when building collectible type objects. For most purposes, you
99
+ * should use the `getModdedCollectibleSet` helper function instead.
100
+ *
101
+ * Returns an empty array if there are no modded collectible types.
102
+ *
103
+ * (This function is named differently from the `getVanillaCollectibleTypeRange` function because
104
+ * all modded collectible types are contiguous. Thus, each value represents a real
105
+ * `CollectibleType`.)
106
+ *
107
+ * This function can only be called if at least one callback has been executed. This is because not
108
+ * all collectibles will necessarily be present when a mod first loads (due to mod load order).
109
+ */
110
+ export function getModdedCollectibleTypes(): CollectibleType[] {
111
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
112
+ errorIfNoCallbacksFired("collectible");
113
+
114
+ const firstModdedCollectibleType = getFirstModdedCollectibleType();
115
+ if (firstModdedCollectibleType === undefined) {
116
+ return [];
117
+ }
118
+
119
+ const lastCollectibleType = getLastCollectibleType();
120
+ return irange(firstModdedCollectibleType, lastCollectibleType);
121
+ }
122
+
123
+ /**
124
+ * This function can only be called if at least one callback has been executed. This is because not
125
+ * all collectibles will necessarily be present when a mod first loads (due to mod load order).
126
+ */
127
+ export function getNumCollectibleTypes(): int {
128
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
129
+ errorIfNoCallbacksFired("collectible");
130
+
131
+ const numModdedCollectibleTypes = getNumModdedCollectibleTypes();
132
+ return NUM_VANILLA_COLLECTIBLE_TYPES + numModdedCollectibleTypes;
133
+ }
134
+
135
+ /**
136
+ * Unlike vanilla collectible types, modded collectible types are always contiguous.
137
+ *
138
+ * This function can only be called if at least one callback has been executed. This is because not
139
+ * all collectibles will necessarily be present when a mod first loads (due to mod load order).
140
+ */
141
+ export function getNumModdedCollectibleTypes(): int {
142
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
143
+ errorIfNoCallbacksFired("collectible");
144
+
145
+ const lastCollectibleType = getLastCollectibleType();
146
+ return lastCollectibleType - LAST_VANILLA_COLLECTIBLE_TYPE;
147
+ }
148
+
149
+ // --------
150
+ // Trinkets
151
+ // --------
152
+
153
+ /**
154
+ * Returns the first modded trinket type, or undefined if there are no modded trinkets.
155
+ *
156
+ * This function can only be called if at least one callback has been executed. This is because not
157
+ * all trinkets will necessarily be present when a mod first loads (due to mod load order).
158
+ */
159
+ export function getFirstModdedTrinketType(): TrinketType | undefined {
160
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
161
+ errorIfNoCallbacksFired("trinket");
162
+
163
+ const firstModdedTrinketType = asTrinketType(
164
+ asNumber(LAST_VANILLA_TRINKET_TYPE) + 1,
165
+ );
166
+ const itemConfigItem = itemConfig.GetTrinket(firstModdedTrinketType);
167
+ return itemConfigItem === undefined ? undefined : firstModdedTrinketType;
168
+ }
169
+
170
+ /**
171
+ * Will change depending on how many modded cards there are.
172
+ *
173
+ * This is equal to the number of trinket types, since all trinket types are contiguous (unlike
174
+ * collectibles).
175
+ *
176
+ * This function can only be called if at least one callback has been executed. This is because not
177
+ * all trinkets will necessarily be present when a mod first loads (due to mod load order).
178
+ */
179
+ export function getLastTrinketType(): TrinketType {
180
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
181
+ errorIfNoCallbacksFired("trinket");
182
+
183
+ const numTrinketTypes = getNumTrinketTypes();
184
+ return asTrinketType(numTrinketTypes);
185
+ }
186
+
187
+ /**
188
+ * Helper function to get an array that represents every modded trinket type.
189
+ *
190
+ * Returns an empty array if there are no modded trinket types.
191
+ *
192
+ * This function can only be called if at least one callback has been executed. This is because not
193
+ * all trinkets will necessarily be present when a mod first loads (due to mod load order).
194
+ */
195
+ export function getModdedTrinketTypes(): TrinketType[] {
196
+ const firstModdedTrinketType = getFirstModdedTrinketType();
197
+ if (firstModdedTrinketType === undefined) {
198
+ return [];
199
+ }
200
+
201
+ const lastTrinketType = getLastTrinketType();
202
+ return irange(firstModdedTrinketType, lastTrinketType);
203
+ }
204
+
205
+ /**
206
+ * Will change depending on how many modded cards there are.
207
+ *
208
+ * Equal to `itemConfig.GetTrinkets().Size - 1`. (We subtract one to account for
209
+ * `TrinketType.NULL`.)
210
+ *
211
+ * This function can only be called if at least one callback has been executed. This is because not
212
+ * all trinkets will necessarily be present when a mod first loads (due to mod load order).
213
+ */
214
+ export function getNumTrinketTypes(): int {
215
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
216
+ errorIfNoCallbacksFired("trinket");
217
+
218
+ return itemConfig.GetTrinkets().Size - 1;
219
+ }
220
+
221
+ /**
222
+ * This function can only be called if at least one callback has been executed. This is because not
223
+ * all trinkets will necessarily be present when a mod first loads (due to mod load order).
224
+ */
225
+ export function getNumModdedTrinketTypes(): int {
226
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
227
+ errorIfNoCallbacksFired("trinket");
228
+
229
+ const numTrinketTypes = getNumTrinketTypes();
230
+ return numTrinketTypes - NUM_VANILLA_TRINKET_TYPES;
231
+ }
232
+
233
+ /**
234
+ * Helper function to get an array that contains every trinket type.
235
+ *
236
+ * This function can only be called if at least one callback has been executed. This is because not
237
+ * all trinkets will necessarily be present when a mod first loads (due to mod load order).
238
+ */
239
+ export function getTrinketTypes(): TrinketType[] {
240
+ const lastTrinketType = getLastTrinketType();
241
+ return irange(FIRST_TRINKET_TYPE, lastTrinketType);
242
+ }
243
+
244
+ // -----
245
+ // Cards
246
+ // -----
247
+
248
+ /**
249
+ * Helper function to get an array with every valid card sub-type. This includes modded cards.
250
+ *
251
+ * This function can only be called if at least one callback has been executed. This is because not
252
+ * all cards will necessarily be present when a mod first loads (due to mod load order).
253
+ */
254
+ export function getAllCards(): Card[] {
255
+ const lastCard = getLastCard();
256
+ return irange(FIRST_CARD, lastCard);
257
+ }
258
+
259
+ /**
260
+ * Returns the first modded card sub-type, or undefined if there are no modded cards.
261
+ *
262
+ * This function can only be called if at least one callback has been executed. This is because not
263
+ * all cards will necessarily be present when a mod first loads (due to mod load order).
264
+ */
265
+ export function getFirstModdedCard(): Card | undefined {
266
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
267
+ errorIfNoCallbacksFired("card");
268
+
269
+ const firstModdedCard = asCard(asNumber(LAST_VANILLA_CARD) + 1);
270
+ const itemConfigCard = itemConfig.GetCard(firstModdedCard);
271
+ return itemConfigCard === undefined ? undefined : firstModdedCard;
272
+ }
273
+
274
+ /**
275
+ * Will change depending on how many modded cards there are.
276
+ *
277
+ * This is equal to the number of cards, since all card sub-types are contiguous (unlike
278
+ * collectibles).
279
+ *
280
+ * This function can only be called if at least one callback has been executed. This is because not
281
+ * all cards will necessarily be present when a mod first loads (due to mod load order).
282
+ */
283
+ export function getLastCard(): Card {
284
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
285
+ errorIfNoCallbacksFired("card");
286
+
287
+ const numCards = getNumCards();
288
+ return asCard(numCards);
289
+ }
290
+
291
+ /**
292
+ * Helper function to get an array with every modded card sub-type.
293
+ *
294
+ * Returns an empty array if there are no modded cards.
295
+ *
296
+ * This function can only be called if at least one callback has been executed. This is because not
297
+ * all cards will necessarily be present when a mod first loads (due to mod load order).
298
+ */
299
+ export function getModdedCards(): Card[] {
300
+ const firstModdedCard = getFirstModdedCard();
301
+ if (firstModdedCard === undefined) {
302
+ return [];
303
+ }
304
+
305
+ const lastCard = getLastCard();
306
+ return irange(firstModdedCard, lastCard);
307
+ }
308
+
309
+ /**
310
+ * Will change depending on how many modded cards there are.
311
+ *
312
+ * Equal to `itemConfig.GetCards().Size - 1`. (We subtract one to account for `Card.NULL`.)
313
+ *
314
+ * This function can only be called if at least one callback has been executed. This is because not
315
+ * all cards will necessarily be present when a mod first loads (due to mod load order).
316
+ */
317
+ export function getNumCards(): int {
318
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
319
+ errorIfNoCallbacksFired("card");
320
+
321
+ return itemConfig.GetCards().Size - 1;
322
+ }
323
+
324
+ /**
325
+ * This function can only be called if at least one callback has been executed. This is because not
326
+ * all trinkets will necessarily be present when a mod first loads (due to mod load order).
327
+ */
328
+ export function getNumModdedCards(): int {
329
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
330
+ errorIfNoCallbacksFired("card");
331
+
332
+ const numCards = getNumCards();
333
+ return numCards - NUM_VANILLA_CARDS;
334
+ }
335
+
336
+ // ------------
337
+ // Pill Effects
338
+ // ------------
339
+
340
+ /**
341
+ * Helper function to get an array with every valid pill effect. This includes modded pill effects.
342
+ *
343
+ * This function can only be called if at least one callback has been executed. This is because not
344
+ * all pill effects will necessarily be present when a mod first loads (due to mod load order).
345
+ */
346
+ export function getAllPillEffects(): PillEffect[] {
347
+ const lastPillEffect = getLastPillEffect();
348
+ return irange(FIRST_PILL_EFFECT, lastPillEffect);
349
+ }
350
+
351
+ /**
352
+ * Returns the first modded pill effect, or undefined if there are no modded pill effects.
353
+ *
354
+ * This function can only be called if at least one callback has been executed. This is because not
355
+ * all pill effects will necessarily be present when a mod first loads (due to mod load order).
356
+ */
357
+ export function getFirstModdedPillEffect(): PillEffect | undefined {
358
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
359
+ errorIfNoCallbacksFired("pill");
360
+
361
+ const firstModdedPillEffect = asPillEffect(
362
+ asNumber(LAST_VANILLA_PILL_EFFECT) + 1,
363
+ );
364
+ const itemConfigPillEffect = itemConfig.GetPillEffect(firstModdedPillEffect);
365
+ return itemConfigPillEffect === undefined ? undefined : firstModdedPillEffect;
366
+ }
367
+
368
+ /**
369
+ * Will change depending on how many modded pill effects there are.
370
+ *
371
+ * This is equal to the number of pill effects, since all pill effects are contiguous (unlike
372
+ * collectibles).
373
+ *
374
+ * This function can only be called if at least one callback has been executed. This is because not
375
+ * all pill effects will necessarily be present when a mod first loads (due to mod load order).
376
+ */
377
+ export function getLastPillEffect(): PillEffect {
378
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
379
+ errorIfNoCallbacksFired("pill");
380
+
381
+ const numPillEffects = getNumPillEffects();
382
+ return asPillEffect(numPillEffects);
383
+ }
384
+
385
+ /**
386
+ * Helper function to get an array with every modded pill effect.
387
+ *
388
+ * Returns an empty array if there are no modded pill effects.
389
+ *
390
+ * This function can only be called if at least one callback has been executed. This is because not
391
+ * all pill effects will necessarily be present when a mod first loads (due to mod load order).
392
+ */
393
+ export function getModdedPillEffects(): PillEffect[] {
394
+ const firstModdedPillEffect = getFirstModdedPillEffect();
395
+ if (firstModdedPillEffect === undefined) {
396
+ return [];
397
+ }
398
+
399
+ const lastPillEffect = getLastPillEffect();
400
+ return irange(firstModdedPillEffect, lastPillEffect);
401
+ }
402
+
403
+ /**
404
+ * Will change depending on how many modded pill effects there are.
405
+ *
406
+ * Equal to `itemConfig.GetPillEffects().Size`. (We do not have to subtract one, because the first
407
+ * pill effect has an ID of 0 and there is no `PillEffect.NULL`.)
408
+ *
409
+ * This function can only be called if at least one callback has been executed. This is because not
410
+ * all pill effects will necessarily be present when a mod first loads (due to mod load order).
411
+ */
412
+ export function getNumPillEffects(): int {
413
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
414
+ errorIfNoCallbacksFired("pill");
415
+
416
+ return itemConfig.GetPillEffects().Size;
417
+ }
418
+
419
+ /**
420
+ * This function can only be called if at least one callback has been executed. This is because not
421
+ * all pill effects will necessarily be present when a mod first loads (due to mod load order).
422
+ */
423
+ export function getNumModdedPillEffects(): int {
424
+ errorIfFeaturesNotInitialized(FEATURE_NAME);
425
+ errorIfNoCallbacksFired("pill");
426
+
427
+ const numPillEffects = getNumPillEffects();
428
+ return numPillEffects - NUM_VANILLA_PILL_EFFECTS;
429
+ }
@@ -399,15 +399,7 @@ export function getRandomArrayIndex<T>(
399
399
  return getRandomInt(0, array.length - 1, seedOrRNG, exceptions);
400
400
  }
401
401
 
402
- /**
403
- * Initializes an array with all elements containing the specified default value.
404
- *
405
- * For example:
406
- *
407
- * ```ts
408
- * const playerTransformations = initArray(false, PlayerForm.NUM_PLAYER_FORMS - 1);
409
- * ```
410
- */
402
+ /** Initializes an array with all elements containing the specified default value. */
411
403
  export function initArray<T>(defaultValue: T, size: int): T[] {
412
404
  const array: T[] = [];
413
405
  repeat(size, () => {
@@ -1,11 +1,6 @@
1
1
  import { Card, ItemConfigCardType } from "isaac-typescript-definitions";
2
2
  import { itemConfig } from "../core/cachedClasses";
3
- import {
4
- FIRST_CARD,
5
- FIRST_MODDED_CARD,
6
- LAST_CARD,
7
- MAX_VANILLA_CARD,
8
- } from "../core/constantsFirstLast";
3
+ import { FIRST_CARD, LAST_VANILLA_CARD } from "../core/constantsFirstLast";
9
4
  import {
10
5
  CARD_DESCRIPTIONS,
11
6
  DEFAULT_CARD_DESCRIPTION,
@@ -28,14 +23,14 @@ const CARD_TYPE_TO_CARDS_MAP = new Map<ItemConfigCardType, Set<Card>>();
28
23
  */
29
24
  const CARD_SET = new Set<Card>();
30
25
 
31
- function initCardObjects() {
26
+ function lazyInitCardMapsSets() {
32
27
  // The card type to cards map should be valid for every card type, so we initialize it with empty
33
28
  // sets.
34
29
  for (const cardType of getEnumValues(ItemConfigCardType)) {
35
30
  CARD_TYPE_TO_CARDS_MAP.set(cardType, new Set<Card>());
36
31
  }
37
32
 
38
- for (const card of getAllCards()) {
33
+ for (const card of getVanillaCards()) {
39
34
  const cardType = getCardType(card);
40
35
  const cardTypeSet = CARD_TYPE_TO_CARDS_MAP.get(cardType);
41
36
  if (cardTypeSet === undefined) {
@@ -57,11 +52,6 @@ function initCardObjects() {
57
52
  addSetsToSet(CARD_SET, cards);
58
53
  }
59
54
 
60
- /** Helper function to get an array with every valid card sub-type. This includes modded cards. */
61
- export function getAllCards(): Card[] {
62
- return irange(FIRST_CARD, LAST_CARD);
63
- }
64
-
65
55
  /**
66
56
  * Helper function to get a card description from a Card enum value.
67
57
  *
@@ -131,7 +121,7 @@ export function getCardType(card: Card): ItemConfigCardType {
131
121
  */
132
122
  export function getCardsOfType(...cardTypes: ItemConfigCardType[]): Set<Card> {
133
123
  if (CARD_TYPE_TO_CARDS_MAP.size === 0) {
134
- initCardObjects();
124
+ lazyInitCardMapsSets();
135
125
  }
136
126
 
137
127
  const matchingCards = new Set<Card>();
@@ -149,19 +139,6 @@ export function getCardsOfType(...cardTypes: ItemConfigCardType[]): Set<Card> {
149
139
  return matchingCards;
150
140
  }
151
141
 
152
- /**
153
- * Helper function to get an array with every modded card sub-type.
154
- *
155
- * Returns an empty array if there are no modded cards.
156
- */
157
- export function getModdedCards(): Card[] {
158
- if (MAX_VANILLA_CARD === LAST_CARD) {
159
- return [];
160
- }
161
-
162
- return irange(FIRST_MODDED_CARD, LAST_CARD);
163
- }
164
-
165
142
  /**
166
143
  * Has an equal chance of returning any card (e.g. Fool, Reverse Fool, Wild Card, etc.).
167
144
  *
@@ -216,7 +193,7 @@ export function getRandomRune(
216
193
 
217
194
  /** Helper function to get an array with every valid vanilla card sub-type. */
218
195
  export function getVanillaCards(): Card[] {
219
- return irange(FIRST_CARD, MAX_VANILLA_CARD);
196
+ return irange(FIRST_CARD, LAST_VANILLA_CARD);
220
197
  }
221
198
 
222
199
  /**
@@ -1,6 +1,5 @@
1
1
  import { CacheFlag, CollectibleType } from "isaac-typescript-definitions";
2
2
  import { itemConfig } from "../core/cachedClasses";
3
- import { DEFAULT_PLAYER_STAT_MAP } from "../maps/defaultPlayerStatMap";
4
3
  import { getCollectibleArray } from "./collectibleSet";
5
4
  import { getEnumValues } from "./enums";
6
5
  import { hasFlag } from "./flag";
@@ -12,7 +11,11 @@ const CACHE_FLAG_TO_COLLECTIBLES_MAP = new Map<
12
11
  Set<CollectibleType>
13
12
  >();
14
13
 
15
- function initCacheFlagMap() {
14
+ function lazyInitCacheFlagMap() {
15
+ if (CACHE_FLAG_TO_COLLECTIBLES_MAP.size > 0) {
16
+ return;
17
+ }
18
+
16
19
  for (const cacheFlag of getEnumValues(CacheFlag)) {
17
20
  const collectiblesSet = new Set<CollectibleType>();
18
21
 
@@ -26,6 +29,7 @@ function initCacheFlagMap() {
26
29
  }
27
30
  }
28
31
 
32
+ /** Helper function to check in the item config if a given collectible has a given cache flag. */
29
33
  export function collectibleHasCacheFlag(
30
34
  collectibleType: CollectibleType,
31
35
  cacheFlag: CacheFlag,
@@ -41,14 +45,14 @@ export function collectibleHasCacheFlag(
41
45
  /**
42
46
  * Returns a set containing every collectible type with the given cache flag, including modded
43
47
  * collectibles.
48
+ *
49
+ * This function can only be called if at least one callback has been executed. This is because not
50
+ * all collectibles will necessarily be present when a mod first loads (due to mod load order).
44
51
  */
45
52
  export function getCollectiblesForCacheFlag(
46
53
  cacheFlag: CacheFlag,
47
54
  ): Set<CollectibleType> {
48
- // Lazy initialize the map.
49
- if (CACHE_FLAG_TO_COLLECTIBLES_MAP.size === 0) {
50
- initCacheFlagMap();
51
- }
55
+ lazyInitCacheFlagMap();
52
56
 
53
57
  const collectiblesSet = CACHE_FLAG_TO_COLLECTIBLES_MAP.get(cacheFlag);
54
58
  if (collectiblesSet === undefined) {
@@ -58,16 +62,6 @@ export function getCollectiblesForCacheFlag(
58
62
  return copySet(collectiblesSet);
59
63
  }
60
64
 
61
- /**
62
- * Returns the starting stat that Isaac (the default character) starts with. For example, if you
63
- * pass this function `CacheFlag.DAMAGE`, it will return 3.5.
64
- *
65
- * Note that the default fire delay is represented in the tear stat, not the `MaxFireDelay` value.
66
- */
67
- export function getDefaultPlayerStat(cacheFlag: CacheFlag): number | undefined {
68
- return DEFAULT_PLAYER_STAT_MAP.get(cacheFlag);
69
- }
70
-
71
65
  /**
72
66
  * Returns an array containing every collectible type that the player has that matches the provided
73
67
  * CacheFlag.
@@ -82,6 +76,9 @@ export function getDefaultPlayerStat(cacheFlag: CacheFlag): number | undefined {
82
76
  * CollectibleType.DEAD_DOVE,
83
77
  * ]
84
78
  * ```
79
+ *
80
+ * This function can only be called if at least one callback has been executed. This is because not
81
+ * all collectibles will necessarily be present when a mod first loads (due to mod load order).
85
82
  */
86
83
  export function getPlayerCollectiblesForCacheFlag(
87
84
  player: EntityPlayer,