isaacscript-common 51.3.0 → 51.4.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.
@@ -5628,6 +5628,9 @@ export declare function getFloorDisplayFlags(minimapAPI?: boolean): Map<int, Bit
5628
5628
  /**
5629
5629
  * Helper function to get the corresponding golden trinket type from a normal trinket type.
5630
5630
  *
5631
+ * If the provided trinket type is already a golden trinket type, then the trinket type will be
5632
+ * returned unmodified.
5633
+ *
5631
5634
  * For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
5632
5635
  * corresponds to the golden trinket sub-type for Swallowed Penny.
5633
5636
  */
@@ -6145,6 +6148,14 @@ export declare function getNormalPillColorFromHorse(pillColor: PillColor): PillC
6145
6148
  /** Helper function to get an array with every non-gold and non-horse pill color. */
6146
6149
  export declare function getNormalPillColors(): PillColor[];
6147
6150
 
6151
+ /**
6152
+ * Helper function to get the corresponding normal trinket type from a golden trinket type.
6153
+ *
6154
+ * If the provided trinket type is already a normal trinket type, then the trinket type will be
6155
+ * returned unmodified.
6156
+ */
6157
+ export declare function getNormalTrinketType(trinketType: TrinketType): TrinketType;
6158
+
6148
6159
  /**
6149
6160
  * Helper function to get all of the NPCs in the room.
6150
6161
  *
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 51.3.0
3
+ isaacscript-common 51.4.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -29740,6 +29740,7 @@ return ____exports
29740
29740
  end,
29741
29741
  ["src.functions.trinkets"] = function(...)
29742
29742
  local ____exports = {}
29743
+ local GOLDEN_TRINKET_ADJUSTMENT
29743
29744
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
29744
29745
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
29745
29746
  local ____cachedClasses = require("src.core.cachedClasses")
@@ -29768,15 +29769,18 @@ local ____sprites = require("src.functions.sprites")
29768
29769
  local clearSprite = ____sprites.clearSprite
29769
29770
  local ____types = require("src.functions.types")
29770
29771
  local asNumber = ____types.asNumber
29772
+ function ____exports.isGoldenTrinketType(self, trinketType)
29773
+ return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
29774
+ end
29771
29775
  function ____exports.isVanillaTrinketType(self, trinketType)
29772
29776
  return trinketType <= LAST_VANILLA_TRINKET_TYPE
29773
29777
  end
29774
- local GOLDEN_TRINKET_ADJUSTMENT = 32768
29778
+ GOLDEN_TRINKET_ADJUSTMENT = 32768
29775
29779
  local NUM_MYSTERIOUS_PAPER_EFFECTS = getEnumLength(nil, MysteriousPaperEffect)
29776
29780
  local TRINKET_ANM2_PATH = "gfx/005.350_trinket.anm2"
29777
29781
  local TRINKET_SPRITE_LAYER = 0
29778
29782
  function ____exports.getGoldenTrinketType(self, trinketType)
29779
- return asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
29783
+ return ____exports.isGoldenTrinketType(nil, trinketType) and trinketType or asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
29780
29784
  end
29781
29785
  function ____exports.getMysteriousPaperEffectForFrame(self, player, frameCount)
29782
29786
  if frameCount == nil then
@@ -29787,6 +29791,9 @@ function ____exports.getMysteriousPaperEffectForFrame(self, player, frameCount)
29787
29791
  end
29788
29792
  return frameCount % NUM_MYSTERIOUS_PAPER_EFFECTS
29789
29793
  end
29794
+ function ____exports.getNormalTrinketType(self, trinketType)
29795
+ return ____exports.isGoldenTrinketType(nil, trinketType) and asNumber(nil, trinketType) - GOLDEN_TRINKET_ADJUSTMENT or trinketType
29796
+ end
29790
29797
  function ____exports.getTrinketDescription(self, trinketType)
29791
29798
  local trinketDescription = TRINKET_DESCRIPTION_MAP:get(trinketType)
29792
29799
  if trinketDescription ~= nil then
@@ -29816,9 +29823,6 @@ function ____exports.getTrinketName(self, trinketType)
29816
29823
  end
29817
29824
  return DEFAULT_TRINKET_NAME
29818
29825
  end
29819
- function ____exports.isGoldenTrinketType(self, trinketType)
29820
- return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
29821
- end
29822
29826
  function ____exports.isModdedTrinketType(self, trinketType)
29823
29827
  return not ____exports.isVanillaTrinketType(nil, trinketType)
29824
29828
  end
@@ -4,6 +4,9 @@ import { MysteriousPaperEffect } from "../enums/MysteriousPaperEffect";
4
4
  /**
5
5
  * Helper function to get the corresponding golden trinket type from a normal trinket type.
6
6
  *
7
+ * If the provided trinket type is already a golden trinket type, then the trinket type will be
8
+ * returned unmodified.
9
+ *
7
10
  * For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
8
11
  * corresponds to the golden trinket sub-type for Swallowed Penny.
9
12
  */
@@ -29,6 +32,13 @@ export declare function getGoldenTrinketType(trinketType: TrinketType): TrinketT
29
32
  * Default is the current frame.
30
33
  */
31
34
  export declare function getMysteriousPaperEffectForFrame(player: EntityPlayer, frameCount?: int): MysteriousPaperEffect | undefined;
35
+ /**
36
+ * Helper function to get the corresponding normal trinket type from a golden trinket type.
37
+ *
38
+ * If the provided trinket type is already a normal trinket type, then the trinket type will be
39
+ * returned unmodified.
40
+ */
41
+ export declare function getNormalTrinketType(trinketType: TrinketType): TrinketType;
32
42
  /**
33
43
  * Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
34
44
  * trinket type was not valid.
@@ -1 +1 @@
1
- {"version":3,"file":"trinkets.d.ts","sourceRoot":"","sources":["../../../src/functions/trinkets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AA8BvE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAE1E;AAED;;;;;;;;;;;;;;;;;;;GAm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,gCAAgC,CAC9C,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,GAAG,GACf,qBAAqB,GAAG,SAAS,CAUnC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAI1E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CActE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAOtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAc/D;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAErE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAYjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAiBN;AAED,6FAA6F;AAC7F,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACnB,OAAO,CAOT"}
@@ -1,4 +1,5 @@
1
1
  local ____exports = {}
2
+ local GOLDEN_TRINKET_ADJUSTMENT
2
3
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
4
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
4
5
  local ____cachedClasses = require("src.core.cachedClasses")
@@ -27,24 +28,25 @@ local ____sprites = require("src.functions.sprites")
27
28
  local clearSprite = ____sprites.clearSprite
28
29
  local ____types = require("src.functions.types")
29
30
  local asNumber = ____types.asNumber
31
+ function ____exports.isGoldenTrinketType(self, trinketType)
32
+ return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
33
+ end
30
34
  function ____exports.isVanillaTrinketType(self, trinketType)
31
35
  return trinketType <= LAST_VANILLA_TRINKET_TYPE
32
36
  end
33
- --- Add this to a `TrinketType` to get the corresponding golden trinket type.
34
- --
35
- -- Corresponds to the vanilla `PillColor.TRINKET_GOLDEN_FLAG` value.
36
- --
37
- -- 1 << 15
38
- local GOLDEN_TRINKET_ADJUSTMENT = 32768
37
+ GOLDEN_TRINKET_ADJUSTMENT = 32768
39
38
  local NUM_MYSTERIOUS_PAPER_EFFECTS = getEnumLength(nil, MysteriousPaperEffect)
40
39
  local TRINKET_ANM2_PATH = "gfx/005.350_trinket.anm2"
41
40
  local TRINKET_SPRITE_LAYER = 0
42
41
  --- Helper function to get the corresponding golden trinket type from a normal trinket type.
43
42
  --
43
+ -- If the provided trinket type is already a golden trinket type, then the trinket type will be
44
+ -- returned unmodified.
45
+ --
44
46
  -- For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
45
47
  -- corresponds to the golden trinket sub-type for Swallowed Penny.
46
48
  function ____exports.getGoldenTrinketType(self, trinketType)
47
- return asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
49
+ return ____exports.isGoldenTrinketType(nil, trinketType) and trinketType or asNumber(nil, trinketType) + GOLDEN_TRINKET_ADJUSTMENT
48
50
  end
49
51
  --- Helper function to get the current effect that the Mysterious Paper trinket is providing to the
50
52
  -- player. Returns undefined if the player does not have the Mysterious Paper trinket.
@@ -73,6 +75,13 @@ function ____exports.getMysteriousPaperEffectForFrame(self, player, frameCount)
73
75
  end
74
76
  return frameCount % NUM_MYSTERIOUS_PAPER_EFFECTS
75
77
  end
78
+ --- Helper function to get the corresponding normal trinket type from a golden trinket type.
79
+ --
80
+ -- If the provided trinket type is already a normal trinket type, then the trinket type will be
81
+ -- returned unmodified.
82
+ function ____exports.getNormalTrinketType(self, trinketType)
83
+ return ____exports.isGoldenTrinketType(nil, trinketType) and asNumber(nil, trinketType) - GOLDEN_TRINKET_ADJUSTMENT or trinketType
84
+ end
76
85
  --- Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
77
86
  -- trinket type was not valid.
78
87
  --
@@ -118,9 +127,6 @@ function ____exports.getTrinketName(self, trinketType)
118
127
  end
119
128
  return DEFAULT_TRINKET_NAME
120
129
  end
121
- function ____exports.isGoldenTrinketType(self, trinketType)
122
- return asNumber(nil, trinketType) > GOLDEN_TRINKET_ADJUSTMENT
123
- end
124
130
  function ____exports.isModdedTrinketType(self, trinketType)
125
131
  return not ____exports.isVanillaTrinketType(nil, trinketType)
126
132
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "51.3.0",
3
+ "version": "51.4.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -36,11 +36,16 @@ const TRINKET_SPRITE_LAYER = 0;
36
36
  /**
37
37
  * Helper function to get the corresponding golden trinket type from a normal trinket type.
38
38
  *
39
+ * If the provided trinket type is already a golden trinket type, then the trinket type will be
40
+ * returned unmodified.
41
+ *
39
42
  * For example, passing `TrinketType.SWALLOWED_PENNY` would result in 32769, which is the value that
40
43
  * corresponds to the golden trinket sub-type for Swallowed Penny.
41
44
  */
42
45
  export function getGoldenTrinketType(trinketType: TrinketType): TrinketType {
43
- return asNumber(trinketType) + GOLDEN_TRINKET_ADJUSTMENT;
46
+ return isGoldenTrinketType(trinketType)
47
+ ? trinketType
48
+ : asNumber(trinketType) + GOLDEN_TRINKET_ADJUSTMENT;
44
49
  }
45
50
 
46
51
  /**
@@ -78,6 +83,18 @@ export function getMysteriousPaperEffectForFrame(
78
83
  return frameCount % NUM_MYSTERIOUS_PAPER_EFFECTS;
79
84
  }
80
85
 
86
+ /**
87
+ * Helper function to get the corresponding normal trinket type from a golden trinket type.
88
+ *
89
+ * If the provided trinket type is already a normal trinket type, then the trinket type will be
90
+ * returned unmodified.
91
+ */
92
+ export function getNormalTrinketType(trinketType: TrinketType): TrinketType {
93
+ return isGoldenTrinketType(trinketType)
94
+ ? asNumber(trinketType) - GOLDEN_TRINKET_ADJUSTMENT
95
+ : trinketType;
96
+ }
97
+
81
98
  /**
82
99
  * Helper function to get the in-game description for a trinket. Returns "Unknown" if the provided
83
100
  * trinket type was not valid.