isaacscript-common 8.8.2 → 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 (77) 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/customStage/exports.d.ts +11 -1
  5. package/dist/features/customStage/exports.d.ts.map +1 -1
  6. package/dist/features/customStage/exports.lua +10 -4
  7. package/dist/features/customStage/versusScreen.d.ts.map +1 -1
  8. package/dist/features/customStage/versusScreen.lua +3 -3
  9. package/dist/features/extraConsoleCommands/listCommands.lua +14 -14
  10. package/dist/features/firstLast.d.ts +9 -9
  11. package/dist/features/firstLast.d.ts.map +1 -1
  12. package/dist/features/firstLast.lua +26 -26
  13. package/dist/features/preventCollectibleRotation.lua +2 -2
  14. package/dist/functions/cards.d.ts +27 -36
  15. package/dist/functions/cards.d.ts.map +1 -1
  16. package/dist/functions/cards.lua +70 -79
  17. package/dist/functions/collectibles.d.ts +1 -6
  18. package/dist/functions/collectibles.d.ts.map +1 -1
  19. package/dist/functions/collectibles.lua +1 -6
  20. package/dist/functions/gridEntities.d.ts +1 -13
  21. package/dist/functions/gridEntities.d.ts.map +1 -1
  22. package/dist/functions/gridEntities.lua +45 -66
  23. package/dist/functions/gridEntitiesSpecific.d.ts +49 -4
  24. package/dist/functions/gridEntitiesSpecific.d.ts.map +1 -1
  25. package/dist/functions/gridEntitiesSpecific.lua +81 -3
  26. package/dist/functions/pickupsSpecific.d.ts +9 -9
  27. package/dist/functions/pickupsSpecific.d.ts.map +1 -1
  28. package/dist/functions/pickupsSpecific.lua +16 -16
  29. package/dist/functions/pills.d.ts +1 -6
  30. package/dist/functions/pills.d.ts.map +1 -1
  31. package/dist/functions/pills.lua +1 -6
  32. package/dist/functions/pocketItems.lua +4 -4
  33. package/dist/functions/rockAlt.lua +2 -2
  34. package/dist/functions/trinkets.d.ts +1 -6
  35. package/dist/functions/trinkets.d.ts.map +1 -1
  36. package/dist/functions/trinkets.lua +1 -6
  37. package/dist/functions/types.d.ts +3 -3
  38. package/dist/functions/types.d.ts.map +1 -1
  39. package/dist/functions/types.lua +2 -2
  40. package/dist/index.d.ts +111 -85
  41. package/dist/maps/cardMap.d.ts +2 -2
  42. package/dist/maps/cardMap.d.ts.map +1 -1
  43. package/dist/maps/cardMap.lua +203 -203
  44. package/dist/objects/cardDescriptions.d.ts +2 -2
  45. package/dist/objects/cardDescriptions.d.ts.map +1 -1
  46. package/dist/objects/cardDescriptions.lua +99 -99
  47. package/dist/objects/cardNames.d.ts +2 -2
  48. package/dist/objects/cardNames.d.ts.map +1 -1
  49. package/dist/objects/cardNames.lua +99 -99
  50. package/dist/objects/cardTypeToItemConfigCardType.d.ts +6 -0
  51. package/dist/objects/cardTypeToItemConfigCardType.d.ts.map +1 -0
  52. package/dist/objects/cardTypeToItemConfigCardType.lua +106 -0
  53. package/package.json +2 -2
  54. package/src/core/constantsFirstLast.ts +4 -4
  55. package/src/features/customStage/exports.ts +15 -7
  56. package/src/features/customStage/versusScreen.ts +3 -3
  57. package/src/features/extraConsoleCommands/listCommands.ts +16 -16
  58. package/src/features/firstLast.ts +26 -26
  59. package/src/features/preventCollectibleRotation.ts +2 -2
  60. package/src/functions/cards.ts +102 -88
  61. package/src/functions/collectibles.ts +1 -6
  62. package/src/functions/gridEntities.ts +0 -29
  63. package/src/functions/gridEntitiesSpecific.ts +119 -3
  64. package/src/functions/pickupsSpecific.ts +16 -13
  65. package/src/functions/pills.ts +1 -6
  66. package/src/functions/pocketItems.ts +4 -4
  67. package/src/functions/rockAlt.ts +2 -2
  68. package/src/functions/trinkets.ts +1 -6
  69. package/src/functions/types.ts +3 -3
  70. package/src/maps/cardMap.ts +204 -204
  71. package/src/objects/cardDescriptions.ts +100 -100
  72. package/src/objects/cardNames.ts +100 -100
  73. package/src/objects/cardTypeToItemConfigCardType.ts +106 -0
  74. package/dist/objects/cardTypes.d.ts +0 -6
  75. package/dist/objects/cardTypes.d.ts.map +0 -1
  76. package/dist/objects/cardTypes.lua +0 -106
  77. package/src/objects/cardTypes.ts +0 -104
@@ -1,18 +1,38 @@
1
1
  import {
2
+ CrawlSpaceVariant,
2
3
  DoorVariant,
3
4
  GridEntityType,
4
5
  PitVariant,
5
6
  PoopGridEntityVariant,
6
7
  PressurePlateVariant,
7
8
  RockVariant,
9
+ TrapdoorVariant,
8
10
  } from "isaac-typescript-definitions";
9
11
  import {
10
12
  getGridEntities,
13
+ getMatchingGridEntities,
11
14
  removeGridEntities,
12
15
  spawnGridEntityWithVariant,
13
16
  } from "./gridEntities";
14
17
  import { asNumber } from "./types";
15
18
 
19
+ /**
20
+ * Helper function to get all of the grid entities of type `GridEntityType.CRAWL_SPACE` (18) in the
21
+ * room.
22
+ *
23
+ * @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
24
+ * variant. Default is -1, which matches every variant.
25
+ */
26
+ export function getCrawlSpaces(
27
+ crawlSpaceVariant: CrawlSpaceVariant = -1,
28
+ ): GridEntity[] {
29
+ if (asNumber(crawlSpaceVariant) === -1) {
30
+ return getGridEntities(GridEntityType.CRAWL_SPACE);
31
+ }
32
+
33
+ return getMatchingGridEntities(GridEntityType.CRAWL_SPACE, crawlSpaceVariant);
34
+ }
35
+
16
36
  // The `getDoors` function is not located here because doors are collected via the `Room.GetDoor`
17
37
  // method instead, which is faster.
18
38
 
@@ -153,6 +173,38 @@ export function getTNT(variant = -1): GridEntityTNT[] {
153
173
  return tntArray;
154
174
  }
155
175
 
176
+ /**
177
+ * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` (17) in the
178
+ * room. Specify a specific trapdoor variant to select only trapdoors of that variant.
179
+ */
180
+ export function getTrapdoors(trapdoorVariant?: TrapdoorVariant): GridEntity[] {
181
+ if (trapdoorVariant === undefined) {
182
+ return getGridEntities(GridEntityType.TRAPDOOR);
183
+ }
184
+
185
+ return getMatchingGridEntities(GridEntityType.TRAPDOOR, trapdoorVariant);
186
+ }
187
+
188
+ /**
189
+ * Helper function to remove all of the `GridEntityType.CRAWL_SPACE` (18) in the room.
190
+ *
191
+ * @param crawlSpaceVariant Optional. If specified, will only remove the crawl spaces that match
192
+ * this variant. Default is -1, which matches every variant.
193
+ * @param updateRoom Optional. Whether or not to update the room after the crawl spaces are removed.
194
+ * Default is false. For more information, see the description of the
195
+ * `removeGridEntities` helper function.
196
+ * @param cap Optional. If specified, will only remove the given amount of crawl spaces.
197
+ * @returns The crawl spaces that were removed.
198
+ */
199
+ export function removeAllCrawlSpaces(
200
+ crawlSpaceVariant: CrawlSpaceVariant = -1,
201
+ updateRoom = false,
202
+ cap?: int,
203
+ ): GridEntity[] {
204
+ const crawlSpaces = getCrawlSpaces(crawlSpaceVariant);
205
+ return removeGridEntities(crawlSpaces, updateRoom, cap);
206
+ }
207
+
156
208
  // The `removeAllDoors` function is not located here because doors are removed via the
157
209
  // `Room.RemoveDoor` method instead.
158
210
 
@@ -281,14 +333,56 @@ export function removeAllTNT(
281
333
  return removeGridEntities(tnt, updateRoom, cap);
282
334
  }
283
335
 
284
- /** Helper function to spawn a `GridEntityType.DOOR` (16). */
336
+ /**
337
+ * Helper function to remove all of the `GridEntityType.TRAPDOOR` (17) in the room.
338
+ *
339
+ * @param trapdoorVariant Optional. If specified, will only remove the trapdoors that match this
340
+ * variant. Default is -1, which matches every variant.
341
+ * @param updateRoom Optional. Whether or not to update the room after the trapdoors are removed.
342
+ * Default is false. For more information, see the description of the
343
+ * `removeGridEntities` helper function.
344
+ * @param cap Optional. If specified, will only remove the given amount of trapdoors.
345
+ * @returns The trapdoors that were removed.
346
+ */
347
+ export function removeAllTrapdoors(
348
+ trapdoorVariant: TrapdoorVariant = -1,
349
+ updateRoom = false,
350
+ cap?: int,
351
+ ): GridEntity[] {
352
+ const trapdoors = getTrapdoors(trapdoorVariant);
353
+ return removeGridEntities(trapdoors, updateRoom, cap);
354
+ }
355
+
356
+ /** Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18). */
357
+ export function spawnCrawlSpace(
358
+ gridIndexOrPosition: int | Vector,
359
+ ): GridEntity | undefined {
360
+ return spawnCrawlSpaceWithVariant(
361
+ CrawlSpaceVariant.NORMAL,
362
+ gridIndexOrPosition,
363
+ );
364
+ }
365
+
366
+ /** Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18) with a specific variant. */
367
+ export function spawnCrawlSpaceWithVariant(
368
+ crawlSpaceVariant: CrawlSpaceVariant,
369
+ gridIndexOrPosition: int | Vector,
370
+ ): GridEntity | undefined {
371
+ return spawnGridEntityWithVariant(
372
+ GridEntityType.CRAWL_SPACE,
373
+ crawlSpaceVariant,
374
+ gridIndexOrPosition,
375
+ );
376
+ }
377
+
378
+ /** Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant. */
285
379
  export function spawnDoor(
286
380
  gridIndexOrPosition: int | Vector,
287
381
  ): GridEntityDoor | undefined {
288
382
  return spawnDoorWithVariant(DoorVariant.UNSPECIFIED, gridIndexOrPosition);
289
383
  }
290
384
 
291
- /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
385
+ /** Helper function to spawn a `GridEntityType.DOOR` (16). */
292
386
  export function spawnDoorWithVariant(
293
387
  doorVariant: DoorVariant,
294
388
  gridIndexOrPosition: int | Vector,
@@ -310,7 +404,7 @@ export function spawnDoorWithVariant(
310
404
  return door;
311
405
  }
312
406
 
313
- /** Helper function to spawn a `GridEntityType.PIT` (7). */
407
+ /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
314
408
  export function spawnPit(
315
409
  gridIndexOrPosition: int | Vector,
316
410
  ): GridEntityPit | undefined {
@@ -489,3 +583,25 @@ export function spawnTNTWithVariant(
489
583
 
490
584
  return tnt;
491
585
  }
586
+
587
+ /** Helper function to spawn a `GridEntityType.TRAPDOOR` (17). */
588
+ export function spawnTrapdoor(
589
+ gridIndexOrPosition: int | Vector,
590
+ ): GridEntity | undefined {
591
+ return spawnCrawlSpaceWithVariant(
592
+ CrawlSpaceVariant.NORMAL,
593
+ gridIndexOrPosition,
594
+ );
595
+ }
596
+
597
+ /** Helper function to spawn a `GridEntityType.TRAPDOOR` (17) with a specific variant. */
598
+ export function spawnTrapdoorWithVariant(
599
+ trapdoorVariant: TrapdoorVariant,
600
+ gridIndexOrPosition: int | Vector,
601
+ ): GridEntity | undefined {
602
+ return spawnGridEntityWithVariant(
603
+ GridEntityType.TRAPDOOR,
604
+ trapdoorVariant,
605
+ gridIndexOrPosition,
606
+ );
607
+ }
@@ -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). */
@@ -128,12 +128,7 @@ export function getPillEffectClass(
128
128
  /**
129
129
  * Helper function to get a pill effect name from a PillEffect enum value.
130
130
  *
131
- * For example:
132
- *
133
- * ```ts
134
- * const pillEffect = PillEffect.BAD_GAS;
135
- * const pillEffectName = getPillEffectName(pillEffect); // trinketName is "Bad Gas"
136
- * ```
131
+ * For example, `getPillEffectName(PillEffect.BAD_GAS)` would return "Bad Gas".
137
132
  */
138
133
  export function getPillEffectName(pillEffect: PillEffect): string {
139
134
  // `ItemConfigPillEffect.Name` is bugged with vanilla pill effects on patch v1.7.6, so we use a
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ActiveSlot,
3
- Card,
3
+ CardType,
4
4
  CollectibleType,
5
5
  PillColor,
6
6
  PlayerType,
@@ -64,14 +64,14 @@ export function getPocketItems(player: EntityPlayer): PocketItemDescription[] {
64
64
  let pocketItemIdentified = false;
65
65
  let pocketItem2Identified = false;
66
66
  for (const slot of pocketItemSlots) {
67
- const card = player.GetCard(slot);
67
+ const cardType = player.GetCard(slot);
68
68
  const pillColor = player.GetPill(slot);
69
69
 
70
- if (card !== Card.NULL) {
70
+ if (cardType !== CardType.NULL) {
71
71
  pocketItems.push({
72
72
  slot,
73
73
  type: PocketItemType.CARD,
74
- subType: card,
74
+ subType: cardType,
75
75
  });
76
76
  } else if (pillColor !== PillColor.NULL) {
77
77
  pocketItems.push({
@@ -1,5 +1,5 @@
1
1
  import {
2
- Card,
2
+ CardType,
3
3
  CoinSubType,
4
4
  CollectibleType,
5
5
  EffectVariant,
@@ -278,7 +278,7 @@ function spawnRockAltRewardSkull(position: Vector, rng: RNG): boolean {
278
278
 
279
279
  totalChance += ROCK_ALT_CHANCES.BASIC_DROP;
280
280
  if (chance < totalChance) {
281
- spawnCardWithSeed(Card.NULL, position, rng);
281
+ spawnCardWithSeed(CardType.NULL, position, rng);
282
282
  return true;
283
283
  }
284
284
 
@@ -118,12 +118,7 @@ export function getTrinketGfxFilename(trinketType: TrinketType): string {
118
118
  * Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
119
119
  * not valid.
120
120
  *
121
- * For example:
122
- *
123
- * ```ts
124
- * const trinketType = TrinketType.SWALLOWED_PENNY;
125
- * const trinketName = getTrinketName(trinketType); // trinketName is "Swallowed Penny"
126
- * ```
121
+ * For example, `getTrinketName(TrinketType.SWALLOWED_PENNY)` would return "Swallowed Penny".
127
122
  */
128
123
  export function getTrinketName(trinketType: TrinketType): string {
129
124
  // "ItemConfigItem.Name" is bugged with vanilla items on patch v1.7.6, so we use a hard-coded map
@@ -1,5 +1,5 @@
1
1
  import {
2
- Card,
2
+ CardType,
3
3
  CollectibleType,
4
4
  LevelStage,
5
5
  NpcState,
@@ -10,12 +10,12 @@ import {
10
10
  } from "isaac-typescript-definitions";
11
11
 
12
12
  /**
13
- * Helper function to safely cast a `number` to a `Card`. (This is better than using the `as`
13
+ * Helper function to safely cast a `number` to a `CardType`. (This is better than using the `as`
14
14
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
15
15
  *
16
16
  * This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
17
17
  */
18
- export function asCard(num: number): Card {
18
+ export function asCardType(num: number): CardType {
19
19
  return num;
20
20
  }
21
21