isaacscript-common 76.0.0 → 76.1.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.
@@ -25,6 +25,14 @@ export declare function getCardName(cardType: CardType): string;
25
25
  * Returns undefined if the provided card type was not valid.
26
26
  */
27
27
  export declare function getItemConfigCardType(cardType: CardType): ItemConfigCardType | undefined;
28
+ /**
29
+ * Helper function to check if a player is holding a specific card in one of their pocket item
30
+ * slots.
31
+ *
32
+ * This function is variadic, meaning that you can pass as many cards as you want to check for. The
33
+ * function will return true if the player has any of the cards.
34
+ */
35
+ export declare function hasCard(player: EntityPlayer, ...cardTypes: CardType[]): boolean;
28
36
  /**
29
37
  * Returns true for card types that have the following item config card type:
30
38
  *
@@ -1 +1 @@
1
- {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/functions/cards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAW,MAAM,8BAA8B,CAAC;AAW3E;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAgB7D;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAgBtD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,QAAQ,GACjB,kBAAkB,GAAG,SAAS,CAOhC;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAOlD;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CAET;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE5D;AAED,iFAAiF;AACjF,wBA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MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAOlD;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CAET;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE5D;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE9D;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE9D;AAED,uEAAuE;AACvE,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAElD;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAEzD;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAEtD;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAEvD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE7D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAG1E"}
@@ -1,7 +1,13 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
1
5
  local ____exports = {}
2
6
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
7
  local ItemConfigCardType = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigCardType
4
8
  local UseFlag = ____isaac_2Dtypescript_2Ddefinitions.UseFlag
9
+ local ____cachedEnumValues = require("arrays.cachedEnumValues")
10
+ local POCKET_ITEM_SLOT_VALUES = ____cachedEnumValues.POCKET_ITEM_SLOT_VALUES
5
11
  local ____cachedClasses = require("core.cachedClasses")
6
12
  local itemConfig = ____cachedClasses.itemConfig
7
13
  local ____constantsFirstLast = require("core.constantsFirstLast")
@@ -64,6 +70,22 @@ function ____exports.getItemConfigCardType(self, cardType)
64
70
  end
65
71
  return itemConfigCard.CardType
66
72
  end
73
+ --- Helper function to check if a player is holding a specific card in one of their pocket item
74
+ -- slots.
75
+ --
76
+ -- This function is variadic, meaning that you can pass as many cards as you want to check for. The
77
+ -- function will return true if the player has any of the cards.
78
+ function ____exports.hasCard(self, player, ...)
79
+ local cardTypes = {...}
80
+ local cardTypesSet = __TS__New(Set, cardTypes)
81
+ return __TS__ArraySome(
82
+ POCKET_ITEM_SLOT_VALUES,
83
+ function(____, pocketItemSlot)
84
+ local cardType = player:GetCard(pocketItemSlot)
85
+ return cardTypesSet:has(cardType)
86
+ end
87
+ )
88
+ end
67
89
  --- Returns true for card types that have the following item config card type:
68
90
  --
69
91
  -- - `ItemConfigCardType.TAROT` (0)
@@ -35,8 +35,12 @@ export declare function getTearsStat(fireDelay: float): float;
35
35
  * Helper function to check if a tear hit an enemy. A tear is considered to be missed if it hit the
36
36
  * ground, a wall, or a grid entity.
37
37
  *
38
- * Under the hood, this function uses the `Entity.IsDead` method to determine this. (Tears will not
39
- * die if they hit an enemy, but they will die if they hit a wall or object.)
38
+ * Note that tears are still considered to be missed if they hit a poop or fire, so you may want to
39
+ * handle those separately using the `POST_GRID_ENTITY_COLLISION` and `POST_ENTITY_COLLISION`
40
+ * callbacks, respectively.
41
+ *
42
+ * Under the hood, this function uses the `Entity.IsDead` method. (Tears will not die if they hit an
43
+ * enemy, but they will die if they hit a wall or object.)
40
44
  */
41
45
  export declare function isMissedTear(tear: EntityTear): boolean;
42
46
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tears.d.ts","sourceRoot":"","sources":["../../src/functions/tears.ts"],"names":[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UAAU,EAChB,eAAe,CAAC,EAAE,eAAe,EACjC,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAuBT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAgB1D"}
@@ -37,8 +37,12 @@ end
37
37
  --- Helper function to check if a tear hit an enemy. A tear is considered to be missed if it hit the
38
38
  -- ground, a wall, or a grid entity.
39
39
  --
40
- -- Under the hood, this function uses the `Entity.IsDead` method to determine this. (Tears will not
41
- -- die if they hit an enemy, but they will die if they hit a wall or object.)
40
+ -- Note that tears are still considered to be missed if they hit a poop or fire, so you may want to
41
+ -- handle those separately using the `POST_GRID_ENTITY_COLLISION` and `POST_ENTITY_COLLISION`
42
+ -- callbacks, respectively.
43
+ --
44
+ -- Under the hood, this function uses the `Entity.IsDead` method. (Tears will not die if they hit an
45
+ -- enemy, but they will die if they hit a wall or object.)
42
46
  function ____exports.isMissedTear(self, tear)
43
47
  return tear:IsDead()
44
48
  end
@@ -8189,6 +8189,15 @@ export declare function hasAnyTrinket(player: EntityPlayer): boolean;
8189
8189
  */
8190
8190
  export declare function hasArmor(entity: Entity): boolean;
8191
8191
 
8192
+ /**
8193
+ * Helper function to check if a player is holding a specific card in one of their pocket item
8194
+ * slots.
8195
+ *
8196
+ * This function is variadic, meaning that you can pass as many cards as you want to check for. The
8197
+ * function will return true if the player has any of the cards.
8198
+ */
8199
+ export declare function hasCard(player: EntityPlayer, ...cardTypes: CardType[]): boolean;
8200
+
8192
8201
  /**
8193
8202
  * Helper function to check to see if a player has one or more collectibles.
8194
8203
  *
@@ -9564,8 +9573,12 @@ export declare function isMirrorRoom(roomData: RoomConfig): boolean;
9564
9573
  * Helper function to check if a tear hit an enemy. A tear is considered to be missed if it hit the
9565
9574
  * ground, a wall, or a grid entity.
9566
9575
  *
9567
- * Under the hood, this function uses the `Entity.IsDead` method to determine this. (Tears will not
9568
- * die if they hit an enemy, but they will die if they hit a wall or object.)
9576
+ * Note that tears are still considered to be missed if they hit a poop or fire, so you may want to
9577
+ * handle those separately using the `POST_GRID_ENTITY_COLLISION` and `POST_ENTITY_COLLISION`
9578
+ * callbacks, respectively.
9579
+ *
9580
+ * Under the hood, this function uses the `Entity.IsDead` method. (Tears will not die if they hit an
9581
+ * enemy, but they will die if they hit a wall or object.)
9569
9582
  */
9570
9583
  export declare function isMissedTear(tear: EntityTear): boolean;
9571
9584
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 75.2.1
3
+ isaacscript-common 76.0.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -34799,8 +34799,12 @@ end
34799
34799
  --- Helper function to check if a tear hit an enemy. A tear is considered to be missed if it hit the
34800
34800
  -- ground, a wall, or a grid entity.
34801
34801
  --
34802
- -- Under the hood, this function uses the `Entity.IsDead` method to determine this. (Tears will not
34803
- -- die if they hit an enemy, but they will die if they hit a wall or object.)
34802
+ -- Note that tears are still considered to be missed if they hit a poop or fire, so you may want to
34803
+ -- handle those separately using the `POST_GRID_ENTITY_COLLISION` and `POST_ENTITY_COLLISION`
34804
+ -- callbacks, respectively.
34805
+ --
34806
+ -- Under the hood, this function uses the `Entity.IsDead` method. (Tears will not die if they hit an
34807
+ -- enemy, but they will die if they hit a wall or object.)
34804
34808
  function ____exports.isMissedTear(self, tear)
34805
34809
  return tear:IsDead()
34806
34810
  end
@@ -43160,10 +43164,16 @@ ____exports.ITEM_CONFIG_CARD_TYPES_FOR_CARDS_SET = __TS__New(ReadonlySet, {ItemC
43160
43164
  return ____exports
43161
43165
  end,
43162
43166
  ["functions.cards"] = function(...)
43167
+ local ____lualib = require("lualib_bundle")
43168
+ local Set = ____lualib.Set
43169
+ local __TS__New = ____lualib.__TS__New
43170
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
43163
43171
  local ____exports = {}
43164
43172
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.index")
43165
43173
  local ItemConfigCardType = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigCardType
43166
43174
  local UseFlag = ____isaac_2Dtypescript_2Ddefinitions.UseFlag
43175
+ local ____cachedEnumValues = require("arrays.cachedEnumValues")
43176
+ local POCKET_ITEM_SLOT_VALUES = ____cachedEnumValues.POCKET_ITEM_SLOT_VALUES
43167
43177
  local ____cachedClasses = require("core.cachedClasses")
43168
43178
  local itemConfig = ____cachedClasses.itemConfig
43169
43179
  local ____constantsFirstLast = require("core.constantsFirstLast")
@@ -43226,6 +43236,22 @@ function ____exports.getItemConfigCardType(self, cardType)
43226
43236
  end
43227
43237
  return itemConfigCard.CardType
43228
43238
  end
43239
+ --- Helper function to check if a player is holding a specific card in one of their pocket item
43240
+ -- slots.
43241
+ --
43242
+ -- This function is variadic, meaning that you can pass as many cards as you want to check for. The
43243
+ -- function will return true if the player has any of the cards.
43244
+ function ____exports.hasCard(self, player, ...)
43245
+ local cardTypes = {...}
43246
+ local cardTypesSet = __TS__New(Set, cardTypes)
43247
+ return __TS__ArraySome(
43248
+ POCKET_ITEM_SLOT_VALUES,
43249
+ function(____, pocketItemSlot)
43250
+ local cardType = player:GetCard(pocketItemSlot)
43251
+ return cardTypesSet:has(cardType)
43252
+ end
43253
+ )
43254
+ end
43229
43255
  --- Returns true for card types that have the following item config card type:
43230
43256
  --
43231
43257
  -- - `ItemConfigCardType.TAROT` (0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "76.0.0",
3
+ "version": "76.1.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,5 +1,6 @@
1
1
  import type { CardType } from "isaac-typescript-definitions";
2
2
  import { ItemConfigCardType, UseFlag } from "isaac-typescript-definitions";
3
+ import { POCKET_ITEM_SLOT_VALUES } from "../arrays/cachedEnumValues";
3
4
  import { itemConfig } from "../core/cachedClasses";
4
5
  import { LAST_VANILLA_CARD_TYPE } from "../core/constantsFirstLast";
5
6
  import {
@@ -79,6 +80,24 @@ export function getItemConfigCardType(
79
80
  return itemConfigCard.CardType;
80
81
  }
81
82
 
83
+ /**
84
+ * Helper function to check if a player is holding a specific card in one of their pocket item
85
+ * slots.
86
+ *
87
+ * This function is variadic, meaning that you can pass as many cards as you want to check for. The
88
+ * function will return true if the player has any of the cards.
89
+ */
90
+ export function hasCard(
91
+ player: EntityPlayer,
92
+ ...cardTypes: CardType[]
93
+ ): boolean {
94
+ const cardTypesSet = new Set(cardTypes);
95
+ return POCKET_ITEM_SLOT_VALUES.some((pocketItemSlot) => {
96
+ const cardType = player.GetCard(pocketItemSlot);
97
+ return cardTypesSet.has(cardType);
98
+ });
99
+ }
100
+
82
101
  /**
83
102
  * Returns true for card types that have the following item config card type:
84
103
  *
@@ -48,8 +48,12 @@ export function getTearsStat(fireDelay: float): float {
48
48
  * Helper function to check if a tear hit an enemy. A tear is considered to be missed if it hit the
49
49
  * ground, a wall, or a grid entity.
50
50
  *
51
- * Under the hood, this function uses the `Entity.IsDead` method to determine this. (Tears will not
52
- * die if they hit an enemy, but they will die if they hit a wall or object.)
51
+ * Note that tears are still considered to be missed if they hit a poop or fire, so you may want to
52
+ * handle those separately using the `POST_GRID_ENTITY_COLLISION` and `POST_ENTITY_COLLISION`
53
+ * callbacks, respectively.
54
+ *
55
+ * Under the hood, this function uses the `Entity.IsDead` method. (Tears will not die if they hit an
56
+ * enemy, but they will die if they hit a wall or object.)
53
57
  */
54
58
  export function isMissedTear(tear: EntityTear): boolean {
55
59
  return tear.IsDead();