isaacscript-common 2.3.2 → 3.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 (269) hide show
  1. package/cachedClasses.lua +24 -0
  2. package/callbacks/customRevive.lua +2 -0
  3. package/callbacks/itemPickup.lua +2 -0
  4. package/callbacks/postBombInitLate.lua +2 -0
  5. package/callbacks/postBoneSwing.lua +2 -0
  6. package/callbacks/postCollectibleInitFirst.lua +2 -0
  7. package/callbacks/postCursedTeleport.lua +2 -0
  8. package/callbacks/postCustomDoorEnter.lua +44 -0
  9. package/callbacks/postDoorRender.lua +2 -0
  10. package/callbacks/postDoorUpdate.lua +2 -0
  11. package/callbacks/postEffectInitLate.lua +2 -0
  12. package/callbacks/postEffectStateChanged.lua +2 -0
  13. package/callbacks/postEsauJr.lua +2 -0
  14. package/callbacks/postFamiliarInitLate.lua +2 -0
  15. package/callbacks/postFamiliarStateChanged.lua +2 -0
  16. package/callbacks/postFlip.lua +2 -0
  17. package/callbacks/postGreedModeWave.lua +2 -0
  18. package/callbacks/postGridEntity.lua +2 -0
  19. package/callbacks/postGridEntityCollision.lua +2 -0
  20. package/callbacks/postGridEntityRender.lua +2 -0
  21. package/callbacks/postHolyMantleRemoved.lua +2 -0
  22. package/callbacks/postKnifeInitLate.lua +2 -0
  23. package/callbacks/postLaserInitLate.lua +2 -0
  24. package/callbacks/postNPCInitLate.lua +2 -0
  25. package/callbacks/postNPCStateChanged.lua +2 -0
  26. package/callbacks/postNewRoomEarly.lua +2 -0
  27. package/callbacks/postPickupCollect.lua +2 -0
  28. package/callbacks/postPickupInitLate.lua +2 -0
  29. package/callbacks/postPickupStateChanged.lua +2 -0
  30. package/callbacks/postPitRender.lua +2 -0
  31. package/callbacks/postPitUpdate.lua +2 -0
  32. package/callbacks/postPlayerChangeHealth.lua +2 -0
  33. package/callbacks/postPlayerChangeType.lua +2 -0
  34. package/callbacks/postPlayerFatalDamage.lua +2 -0
  35. package/callbacks/postPlayerInitLate.lua +2 -0
  36. package/callbacks/postPlayerReordered.lua +2 -0
  37. package/callbacks/postPoopRender.lua +2 -0
  38. package/callbacks/postPoopUpdate.lua +2 -0
  39. package/callbacks/postPressurePlateRender.lua +2 -0
  40. package/callbacks/postPressurePlateUpdate.lua +2 -0
  41. package/callbacks/postProjectileInitLate.lua +2 -0
  42. package/callbacks/postPurchase.lua +2 -0
  43. package/callbacks/postRockRender.lua +2 -0
  44. package/callbacks/postRockUpdate.lua +2 -0
  45. package/callbacks/postRoomClearChanged.lua +2 -0
  46. package/callbacks/postSacrifice.lua +2 -0
  47. package/callbacks/postSlotInitUpdate.lua +2 -0
  48. package/callbacks/postSlotRender.lua +2 -0
  49. package/callbacks/postSpikesRender.lua +2 -0
  50. package/callbacks/postSpikesUpdate.lua +2 -0
  51. package/callbacks/postTNTRender.lua +2 -0
  52. package/callbacks/postTNTUpdate.lua +2 -0
  53. package/callbacks/postTearInitLate.lua +2 -0
  54. package/callbacks/postTearInitVeryLate.lua +2 -0
  55. package/callbacks/postTransformation.lua +2 -0
  56. package/callbacks/postTrinketBreak.lua +2 -0
  57. package/callbacks/preBerserkDeath.lua +2 -0
  58. package/callbacks/preNewLevel.lua +2 -0
  59. package/callbacks/reorderedCallbacks.lua +16 -0
  60. package/callbacks/subscriptions/postBombInitLate.lua +6 -0
  61. package/callbacks/subscriptions/postBoneSwing.lua +6 -0
  62. package/callbacks/subscriptions/postCollectibleInitFirst.lua +6 -0
  63. package/callbacks/subscriptions/postCursedTeleport.lua +6 -0
  64. package/callbacks/subscriptions/postCustomDoorEnter.lua +6 -0
  65. package/callbacks/subscriptions/postCustomRevive.lua +6 -0
  66. package/callbacks/subscriptions/postDoorRender.lua +6 -0
  67. package/callbacks/subscriptions/postDoorUpdate.lua +6 -0
  68. package/callbacks/subscriptions/postEffectInitLate.lua +6 -0
  69. package/callbacks/subscriptions/postEffectStateChanged.lua +6 -0
  70. package/callbacks/subscriptions/postEsauJr.lua +6 -0
  71. package/callbacks/subscriptions/postFamiliarInitLate.lua +6 -0
  72. package/callbacks/subscriptions/postFamiliarStateChanged.lua +6 -0
  73. package/callbacks/subscriptions/postFirstEsauJr.lua +6 -0
  74. package/callbacks/subscriptions/postFirstFlip.lua +6 -0
  75. package/callbacks/subscriptions/postFlip.lua +6 -0
  76. package/callbacks/subscriptions/postGameStartedReordered.lua +6 -0
  77. package/callbacks/subscriptions/postGreedModeWave.lua +6 -0
  78. package/callbacks/subscriptions/postGridEntityBroken.lua +6 -0
  79. package/callbacks/subscriptions/postGridEntityCollision.lua +6 -0
  80. package/callbacks/subscriptions/postGridEntityInit.lua +6 -0
  81. package/callbacks/subscriptions/postGridEntityRemove.lua +6 -0
  82. package/callbacks/subscriptions/postGridEntityRender.lua +6 -0
  83. package/callbacks/subscriptions/postGridEntityStateChanged.lua +6 -0
  84. package/callbacks/subscriptions/postGridEntityUpdate.lua +6 -0
  85. package/callbacks/subscriptions/postHolyMantleRemoved.lua +6 -0
  86. package/callbacks/subscriptions/postItemDischarged.lua +6 -0
  87. package/callbacks/subscriptions/postItemPickup.lua +6 -0
  88. package/callbacks/subscriptions/postKnifeInitLate.lua +6 -0
  89. package/callbacks/subscriptions/postLaserInitLate.lua +6 -0
  90. package/callbacks/subscriptions/postNPCInitLate.lua +6 -0
  91. package/callbacks/subscriptions/postNPCStateChanged.lua +6 -0
  92. package/callbacks/subscriptions/postNewLevelReordered.lua +6 -0
  93. package/callbacks/subscriptions/postNewRoomEarly.lua +6 -0
  94. package/callbacks/subscriptions/postNewRoomReordered.lua +6 -0
  95. package/callbacks/subscriptions/postPEffectUpdateReordered.lua +6 -0
  96. package/callbacks/subscriptions/postPickupCollect.lua +6 -0
  97. package/callbacks/subscriptions/postPickupInitLate.lua +6 -0
  98. package/callbacks/subscriptions/postPickupStateChanged.lua +6 -0
  99. package/callbacks/subscriptions/postPitRender.lua +6 -0
  100. package/callbacks/subscriptions/postPitUpdate.lua +6 -0
  101. package/callbacks/subscriptions/postPlayerChangeHealth.lua +6 -0
  102. package/callbacks/subscriptions/postPlayerChangeType.lua +6 -0
  103. package/callbacks/subscriptions/postPlayerFatalDamage.lua +6 -0
  104. package/callbacks/subscriptions/postPlayerInitLate.lua +6 -0
  105. package/callbacks/subscriptions/postPlayerInitReordered.lua +6 -0
  106. package/callbacks/subscriptions/postPlayerRenderReordered.lua +6 -0
  107. package/callbacks/subscriptions/postPlayerUpdateReordered.lua +6 -0
  108. package/callbacks/subscriptions/postPoopRender.lua +6 -0
  109. package/callbacks/subscriptions/postPoopUpdate.lua +6 -0
  110. package/callbacks/subscriptions/postPressurePlateRender.lua +6 -0
  111. package/callbacks/subscriptions/postPressurePlateUpdate.lua +6 -0
  112. package/callbacks/subscriptions/postProjectileInitLate.lua +6 -0
  113. package/callbacks/subscriptions/postPurchase.lua +6 -0
  114. package/callbacks/subscriptions/postRockRender.lua +6 -0
  115. package/callbacks/subscriptions/postRockUpdate.lua +6 -0
  116. package/callbacks/subscriptions/postRoomClearChanged.lua +6 -0
  117. package/callbacks/subscriptions/postSacrifice.lua +6 -0
  118. package/callbacks/subscriptions/postSlotAnimationChanged.lua +6 -0
  119. package/callbacks/subscriptions/postSlotDestroyed.lua +6 -0
  120. package/callbacks/subscriptions/postSlotInit.lua +6 -0
  121. package/callbacks/subscriptions/postSlotRender.lua +6 -0
  122. package/callbacks/subscriptions/postSlotUpdate.lua +6 -0
  123. package/callbacks/subscriptions/postSpikesRender.lua +6 -0
  124. package/callbacks/subscriptions/postSpikesUpdate.lua +6 -0
  125. package/callbacks/subscriptions/postTNTRender.lua +6 -0
  126. package/callbacks/subscriptions/postTNTUpdate.lua +6 -0
  127. package/callbacks/subscriptions/postTearInitLate.lua +6 -0
  128. package/callbacks/subscriptions/postTearInitVeryLate.lua +6 -0
  129. package/callbacks/subscriptions/postTransformation.lua +6 -0
  130. package/callbacks/subscriptions/postTrinketBreak.lua +6 -0
  131. package/callbacks/subscriptions/preBerserkDeath.lua +6 -0
  132. package/callbacks/subscriptions/preCustomRevive.lua +6 -0
  133. package/callbacks/subscriptions/preItemPickup.lua +6 -0
  134. package/callbacks/subscriptions/preNewLevel.lua +6 -0
  135. package/classes/DefaultMap.d.ts +70 -39
  136. package/classes/DefaultMap.lua +94 -43
  137. package/classes/ModUpgraded.d.ts +3 -3
  138. package/classes/ModUpgraded.lua +5 -0
  139. package/constants.lua +41 -0
  140. package/constantsFirstLast.lua +63 -0
  141. package/enums/HealthType.lua +3 -0
  142. package/enums/ModCallbackCustom.d.ts +1 -1
  143. package/enums/ModCallbackCustom.lua +6 -0
  144. package/enums/private/CopyableIsaacAPIClassType.lua +1 -0
  145. package/enums/private/SerializationBrand.lua +5 -0
  146. package/features/characterHealthConversion.lua +6 -0
  147. package/features/characterStats.lua +17 -0
  148. package/features/debugDisplay/exports.lua +90 -0
  149. package/features/deployJSONRoom.lua +56 -0
  150. package/features/disableInputs.lua +45 -0
  151. package/features/disableSound.lua +14 -0
  152. package/features/extraConsoleCommands/commandsDisplay.lua +90 -0
  153. package/features/extraConsoleCommands/init.lua +16 -0
  154. package/features/extraConsoleCommands/listCommands.lua +172 -0
  155. package/features/fadeInRemover.lua +10 -0
  156. package/features/fastReset.lua +10 -0
  157. package/features/forgottenSwitch.lua +4 -0
  158. package/features/getCollectibleItemPoolType.lua +5 -0
  159. package/features/playerInventory.lua +18 -0
  160. package/features/ponyDetection.lua +4 -0
  161. package/features/preventCollectibleRotation.lua +9 -0
  162. package/features/runInNFrames.lua +50 -0
  163. package/features/saveDataManager/constants.lua +1 -0
  164. package/features/saveDataManager/exports.lua +115 -0
  165. package/features/saveDataManager/main.lua +6 -0
  166. package/features/saveDataManager/maps.lua +3 -0
  167. package/features/saveDataManager/merge.lua +20 -0
  168. package/features/sirenHelpers.lua +13 -0
  169. package/features/taintedLazarusPlayers.lua +11 -0
  170. package/featuresInitialized.lua +6 -0
  171. package/functions/array.lua +85 -0
  172. package/functions/benchmark.lua +6 -0
  173. package/functions/boss.lua +35 -0
  174. package/functions/cacheFlag.lua +4 -0
  175. package/functions/cards.lua +60 -0
  176. package/functions/challenges.lua +1 -0
  177. package/functions/character.lua +23 -0
  178. package/functions/charge.lua +39 -0
  179. package/functions/chargeBar.lua +4 -0
  180. package/functions/collectibleCacheFlag.lua +15 -0
  181. package/functions/collectibleSet.lua +3 -0
  182. package/functions/collectibleTag.lua +9 -0
  183. package/functions/collectibles.lua +131 -0
  184. package/functions/color.lua +18 -0
  185. package/functions/debug.lua +18 -0
  186. package/functions/deepCopy.lua +25 -0
  187. package/functions/doors.lua +53 -0
  188. package/functions/entity.lua +88 -0
  189. package/functions/entitySpecific.lua +182 -0
  190. package/functions/entityTypes.d.ts +1 -1
  191. package/functions/entityTypes.lua +1 -0
  192. package/functions/enums.lua +62 -0
  193. package/functions/familiars.lua +52 -0
  194. package/functions/flag.lua +77 -0
  195. package/functions/flying.lua +10 -0
  196. package/functions/globals.lua +6 -0
  197. package/functions/gridEntity.lua +105 -0
  198. package/functions/gridEntitySpecific.lua +8 -0
  199. package/functions/input.lua +11 -0
  200. package/functions/isaacAPIClass.lua +12 -0
  201. package/functions/jsonHelpers.lua +11 -0
  202. package/functions/jsonRoom.lua +5 -0
  203. package/functions/kColor.lua +9 -0
  204. package/functions/language.lua +5 -0
  205. package/functions/log.lua +28 -0
  206. package/functions/map.lua +18 -0
  207. package/functions/math.lua +26 -0
  208. package/functions/npc.lua +24 -0
  209. package/functions/pickupVariants.d.ts +11 -11
  210. package/functions/pickupVariants.lua +11 -0
  211. package/functions/pickups.lua +67 -0
  212. package/functions/pills.lua +45 -0
  213. package/functions/player.lua +166 -0
  214. package/functions/playerDataStructures.lua +65 -0
  215. package/functions/playerHealth.lua +10 -0
  216. package/functions/playerIndex.lua +47 -0
  217. package/functions/pocketItems.lua +18 -0
  218. package/functions/positionVelocity.lua +46 -0
  219. package/functions/random.lua +32 -0
  220. package/functions/revive.lua +15 -0
  221. package/functions/rng.lua +19 -0
  222. package/functions/roomData.lua +68 -0
  223. package/functions/roomGrid.lua +21 -0
  224. package/functions/roomShape.lua +22 -0
  225. package/functions/rooms.lua +100 -0
  226. package/functions/run.lua +5 -0
  227. package/functions/seeds.lua +4 -0
  228. package/functions/serialization.lua +4 -0
  229. package/functions/set.lua +22 -0
  230. package/functions/spawnCollectible.lua +24 -0
  231. package/functions/sprite.lua +25 -0
  232. package/functions/stage.lua +16 -0
  233. package/functions/string.lua +6 -0
  234. package/functions/table.lua +19 -0
  235. package/functions/tears.lua +12 -0
  236. package/functions/transformations.lua +18 -0
  237. package/functions/trinketCacheFlag.lua +3 -0
  238. package/functions/trinketGive.lua +24 -0
  239. package/functions/trinkets.lua +52 -0
  240. package/functions/tstlClass.lua +9 -0
  241. package/functions/ui.lua +16 -0
  242. package/functions/utils.d.ts +1 -0
  243. package/functions/utils.lua +88 -0
  244. package/functions/vector.lua +9 -0
  245. package/lualib_bundle.lua +21 -34
  246. package/maps/cardMap.lua +1 -0
  247. package/maps/characterMap.lua +1 -0
  248. package/maps/defaultPlayerStatMap.lua +1 -0
  249. package/maps/gridEntityXMLMap.lua +2 -0
  250. package/maps/pillEffectMap.lua +1 -0
  251. package/maps/roomShapeToTopLeftWallGridIndexMap.lua +2 -0
  252. package/maps/roomTypeMap.lua +1 -0
  253. package/objects/LRoomShapeToRectangles.lua +2 -0
  254. package/objects/colors.lua +4 -0
  255. package/objects/roomShapeBounds.lua +2 -0
  256. package/objects/roomShapeLayoutSizes.lua +4 -0
  257. package/objects/roomShapeToBottomRightPosition.lua +2 -0
  258. package/objects/roomShapeToDoorSlotsToGridIndexDelta.lua +2 -0
  259. package/objects/roomShapeToTopLeftPosition.lua +2 -0
  260. package/objects/roomShapeVolumes.lua +3 -0
  261. package/package.json +2 -2
  262. package/patchErrorFunctions.lua +8 -0
  263. package/sets/bossSets.lua +23 -0
  264. package/sets/charactersWithNoRedHeartsSet.lua +2 -0
  265. package/sets/charactersWithNoSoulHeartsSet.lua +2 -0
  266. package/sets/lostStyleCharactersSet.lua +2 -0
  267. package/types/PickingUpItem.lua +7 -0
  268. package/upgradeMod.d.ts +4 -4
  269. package/upgradeMod.lua +18 -0
@@ -63,6 +63,10 @@ local BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS = __TS__New(Set, {
63
63
  EntityType.TURDLET
64
64
  })
65
65
  DEFAULT_BOSS_MULTI_SEGMENTS = 4
66
+ --- Helper function to get all of the non-dead bosses in the room.
67
+ --
68
+ -- This function will not include bosses on an internal blacklist, such as Death's scythes or Big
69
+ -- Horn holes.
66
70
  function ____exports.getAliveBosses(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
67
71
  if ignoreFriendly == nil then
68
72
  ignoreFriendly = false
@@ -79,9 +83,20 @@ function ____exports.getAliveBosses(self, matchingEntityType, matchingVariant, m
79
83
  function(____, aliveNPC) return aliveNPC:IsBoss() end
80
84
  )
81
85
  end
86
+ --- Helper function to get the set of every boss in the game.
87
+ --
88
+ -- The set contains strings with the entity type and variant, separated by a period.
89
+ --
90
+ -- Also see the `getBossSet` and `getCombinedBossSet` functions.
82
91
  function ____exports.getAllBossesSet(self)
83
92
  return copySet(nil, ALL_BOSSES_SET)
84
93
  end
94
+ --- Helper function to get the set of vanilla bosses for a particular stage and stage type
95
+ -- combination.
96
+ --
97
+ -- The set contains strings with the entity type and variant, separated by a period.
98
+ --
99
+ -- Also see the `getAllBossesSet` and `getCombinedBossSet` functions.
85
100
  function ____exports.getBossSet(self, stage, stageType)
86
101
  local stageTypeMap = STAGE_TO_STAGE_TYPE_TO_BOSS_SET_MAP:get(stage)
87
102
  if stageTypeMap == nil then
@@ -93,6 +108,7 @@ function ____exports.getBossSet(self, stage, stageType)
93
108
  end
94
109
  return copySet(nil, bossSet)
95
110
  end
111
+ --- Helper function to get all of the bosses in the room.
96
112
  function ____exports.getBosses(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
97
113
  if ignoreFriendly == nil then
98
114
  ignoreFriendly = false
@@ -109,6 +125,13 @@ function ____exports.getBosses(self, matchingEntityType, matchingVariant, matchi
109
125
  function(____, npc) return npc:IsBoss() end
110
126
  )
111
127
  end
128
+ --- Helper function to get the set of vanilla bosses for a particular stage across all of the stage
129
+ -- types. For example, specifying a stage of 2 will return a set with all of the bosses for
130
+ -- Basement, Cellar, Burning Basement, Downpour, and Dross.
131
+ --
132
+ -- The set contains strings with the entity type and variant, separated by a period.
133
+ --
134
+ -- Also see the `getAllBossesSet` and `getBossSet` functions.
112
135
  function ____exports.getCombinedBossSet(self, stage)
113
136
  local bossSet = STAGE_TO_COMBINED_BOSS_SET_MAP:get(stage)
114
137
  if bossSet == nil then
@@ -116,9 +139,18 @@ function ____exports.getCombinedBossSet(self, stage)
116
139
  end
117
140
  return copySet(nil, bossSet)
118
141
  end
142
+ --- Helper function to check if the provided NPC is a Sin miniboss, such as Sloth or Lust.
119
143
  function ____exports.isSin(self, npc)
120
144
  return SIN_ENTITY_TYPES_SET:has(npc.Type)
121
145
  end
146
+ --- Helper function to spawn a boss.
147
+ --
148
+ -- Use this function instead of `spawnNPC` since it handles automatically spawning multiple segments
149
+ -- for multi-segment bosses.
150
+ --
151
+ -- By default, this will spawn Chub (and his variants) with 3 segments, Lokii with 2 copies,
152
+ -- Gurglings/Turdlings with 2 copies, and other multi-segment bosses with 4 segments. You can
153
+ -- customize this via the "numSegments" argument.
122
154
  function ____exports.spawnBoss(self, entityType, variant, subType, position, velocity, spawner, seed, numSegments)
123
155
  if velocity == nil then
124
156
  velocity = VectorZero
@@ -161,6 +193,9 @@ function ____exports.spawnBoss(self, entityType, variant, subType, position, vel
161
193
  end
162
194
  return npc
163
195
  end
196
+ --- Helper function to spawn a boss with a specific seed.
197
+ --
198
+ -- For more information, see the documentation for the `spawnBoss` function.
164
199
  function ____exports.spawnBossWithSeed(self, entityType, variant, subType, position, seed, velocity, spawner, numSegments)
165
200
  if velocity == nil then
166
201
  velocity = VectorZero
@@ -1,6 +1,10 @@
1
1
  local ____exports = {}
2
2
  local ____defaultPlayerStatMap = require("maps.defaultPlayerStatMap")
3
3
  local DEFAULT_PLAYER_STAT_MAP = ____defaultPlayerStatMap.DEFAULT_PLAYER_STAT_MAP
4
+ --- Returns the starting stat that Isaac (the default character) starts with. For example, if you
5
+ -- pass this function `CacheFlag.DAMAGE`, it will return 3.5.
6
+ --
7
+ -- Note that the default fire delay is represented in the tear stat, not the `MaxFireDelay` value.
4
8
  function ____exports.getDefaultPlayerStat(self, cacheFlag)
5
9
  return DEFAULT_PLAYER_STAT_MAP:get(cacheFlag)
6
10
  end
@@ -57,6 +57,7 @@ function initCardObjects(self)
57
57
  )
58
58
  addSetsToSet(nil, CARD_SET, cards)
59
59
  end
60
+ --- Helper function to get an array with every valid card sub-type. This includes modded cards.
60
61
  function ____exports.getAllCards(self)
61
62
  return irange(nil, FIRST_CARD, LAST_CARD)
62
63
  end
@@ -64,6 +65,10 @@ function ____exports.getCardType(self, card)
64
65
  local cardType = CARD_TYPES[card]
65
66
  return cardType == nil and DEFAULT_CARD_TYPE or cardType
66
67
  end
68
+ --- Helper function to get a set of cards matching the type. Also see the `CardType` enum.
69
+ --
70
+ -- This function is variadic, meaning that you can you can specify N card types to get a set
71
+ -- containing cards that match any of the specified types.
67
72
  function ____exports.getCardsOfType(self, ...)
68
73
  local cardTypes = {...}
69
74
  if CARD_TYPE_TO_CARDS_MAP.size == 0 then
@@ -83,6 +88,14 @@ function ____exports.getCardsOfType(self, ...)
83
88
  end
84
89
  CARD_TYPE_TO_CARDS_MAP = __TS__New(Map)
85
90
  CARD_SET = __TS__New(Set)
91
+ --- Helper function to get a card description from a Card enum value.
92
+ --
93
+ -- For example:
94
+ --
95
+ -- ```ts
96
+ -- const card = Card.FOOL;
97
+ -- const cardDescription = getCardDescription(card); // cardDescription is "Where journey begins"
98
+ -- ```
86
99
  function ____exports.getCardDescription(self, card)
87
100
  local cardDescription = CARD_DESCRIPTIONS[card]
88
101
  if cardDescription ~= nil then
@@ -94,6 +107,14 @@ function ____exports.getCardDescription(self, card)
94
107
  end
95
108
  return DEFAULT_CARD_DESCRIPTION
96
109
  end
110
+ --- Helper function to get a card name from a Card.
111
+ --
112
+ -- For example:
113
+ --
114
+ -- ```ts
115
+ -- const card = Card.FOOL;
116
+ -- const cardName = getCardName(card); // cardName is "0 - The Fool"
117
+ -- ```
97
118
  function ____exports.getCardName(self, card)
98
119
  local cardName = CARD_NAMES[card]
99
120
  if cardName ~= nil and cardName ~= DEFAULT_CARD_NAME then
@@ -105,12 +126,26 @@ function ____exports.getCardName(self, card)
105
126
  end
106
127
  return DEFAULT_CARD_NAME
107
128
  end
129
+ --- Helper function to get an array with every modded card sub-type.
130
+ --
131
+ -- Returns an empty array if there are no modded cards.
108
132
  function ____exports.getModdedCards(self)
109
133
  if MAX_VANILLA_CARD == LAST_CARD then
110
134
  return {}
111
135
  end
112
136
  return irange(nil, FIRST_MODDED_CARD, LAST_CARD)
113
137
  end
138
+ --- Has an equal chance of returning any card (e.g. Fool, Reverse Fool, Wild Card, etc.).
139
+ --
140
+ -- This will not return:
141
+ -- - any runes
142
+ -- - any objects like Dice Shard
143
+ -- - any modded cards (since there is not a way to distinguish between modded cards and modded
144
+ -- runes/objects)
145
+ --
146
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
147
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
148
+ -- @param exceptions Optional. An array of cards to not select.
114
149
  function ____exports.getRandomCard(self, seedOrRNG, exceptions)
115
150
  if seedOrRNG == nil then
116
151
  seedOrRNG = getRandomSeed(nil)
@@ -120,6 +155,11 @@ function ____exports.getRandomCard(self, seedOrRNG, exceptions)
120
155
  end
121
156
  return getRandomSetElement(nil, CARD_SET, seedOrRNG, exceptions)
122
157
  end
158
+ ---
159
+ -- @param cardType The card type that represents the pool of cards to select from.
160
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
161
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
162
+ -- @param exceptions Optional. An array of cards to not select.
123
163
  function ____exports.getRandomCardOfType(self, cardType, seedOrRNG, exceptions)
124
164
  if seedOrRNG == nil then
125
165
  seedOrRNG = getRandomSeed(nil)
@@ -130,6 +170,12 @@ function ____exports.getRandomCardOfType(self, cardType, seedOrRNG, exceptions)
130
170
  local cardSet = ____exports.getCardsOfType(nil, cardType)
131
171
  return getRandomSetElement(nil, cardSet, seedOrRNG, exceptions)
132
172
  end
173
+ --- Has an equal chance of returning any rune (e.g. Rune of Hagalaz, Blank Rune, Black Rune, Soul of
174
+ -- Isaac, etc.). This will never return a Rune Shard.
175
+ --
176
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
177
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
178
+ -- @param exceptions Optional. An array of runes to not select.
133
179
  function ____exports.getRandomRune(self, seedOrRNG, exceptions)
134
180
  if seedOrRNG == nil then
135
181
  seedOrRNG = getRandomSeed(nil)
@@ -141,33 +187,47 @@ function ____exports.getRandomRune(self, seedOrRNG, exceptions)
141
187
  runesSet:delete(Card.RUNE_SHARD)
142
188
  return getRandomSetElement(nil, runesSet, seedOrRNG, exceptions)
143
189
  end
190
+ --- Helper function to get an array with every valid vanilla card sub-type.
144
191
  function ____exports.getVanillaCards(self)
145
192
  return irange(nil, FIRST_CARD, MAX_VANILLA_CARD)
146
193
  end
194
+ --- Returns true for cards that have the following card type:
195
+ -- - CardType.TAROT
196
+ -- - CardType.SUIT
197
+ -- - CardType.SPECIAL
198
+ -- - CardType.TAROT_REVERSE
147
199
  function ____exports.isCard(self, card)
148
200
  return CARD_SET:has(card)
149
201
  end
202
+ --- Returns whether or not the given card matches the specified card type.
150
203
  function ____exports.isCardType(self, card, cardType)
151
204
  return cardType == ____exports.getCardType(nil, card)
152
205
  end
206
+ --- Returns true for cards that have `CardType.MODDED`.
153
207
  function ____exports.isModdedCard(self, card)
154
208
  return ____exports.isCardType(nil, card, ItemConfigCardType.MODDED)
155
209
  end
210
+ --- Returns true for cards that have `CardType.SPECIAL_OBJECT`.
156
211
  function ____exports.isPocketItemObject(self, card)
157
212
  return ____exports.isCardType(nil, card, ItemConfigCardType.SPECIAL_OBJECT)
158
213
  end
214
+ --- Returns true for cards that have `CardType.TAROT_REVERSE`.
159
215
  function ____exports.isReverseTarotCard(self, card)
160
216
  return ____exports.isCardType(nil, card, ItemConfigCardType.TAROT_REVERSE)
161
217
  end
218
+ --- Returns true for cards that have `CardType.RUNE`.
162
219
  function ____exports.isRune(self, card)
163
220
  return ____exports.isCardType(nil, card, ItemConfigCardType.RUNE)
164
221
  end
222
+ --- Returns true for cards that have `CardType.SPECIAL`.
165
223
  function ____exports.isSpecialCard(self, card)
166
224
  return ____exports.isCardType(nil, card, ItemConfigCardType.SPECIAL)
167
225
  end
226
+ --- Returns true for cards that have `CardType.SUIT`.
168
227
  function ____exports.isSuitCard(self, card)
169
228
  return ____exports.isCardType(nil, card, ItemConfigCardType.SUIT)
170
229
  end
230
+ --- Returns true for cards that have `CardType.TAROT`.
171
231
  function ____exports.isTarotCard(self, card)
172
232
  return ____exports.isCardType(nil, card, ItemConfigCardType.TAROT)
173
233
  end
@@ -2,6 +2,7 @@ local ____exports = {}
2
2
  local ____challengeNames = require("objects.challengeNames")
3
3
  local CHALLENGE_NAMES = ____challengeNames.CHALLENGE_NAMES
4
4
  local DEFAULT_CHALLENGE_NAME = ____challengeNames.DEFAULT_CHALLENGE_NAME
5
+ --- Get the proper name for a `Challenge` enum. This will only work for vanilla challenges.
5
6
  function ____exports.getChallengeName(self, challenge)
6
7
  local challengeName = CHALLENGE_NAMES[challenge]
7
8
  return challengeName == nil and DEFAULT_CHALLENGE_NAME or challengeName
@@ -21,21 +21,40 @@ local LOST_STYLE_CHARACTERS_SET = ____lostStyleCharactersSet.LOST_STYLE_CHARACTE
21
21
  function ____exports.isVanillaCharacter(self, character)
22
22
  return character <= LAST_VANILLA_CHARACTER
23
23
  end
24
+ --- Helper function to determine if the given character can have red heart containers. Returns true
25
+ -- for characters like Isaac, Magdalene, or Cain. Returns true for Keeper and Tainted Keeper, even
26
+ -- though coin containers are not technically the same as red heart containers. Returns false for
27
+ -- characters like Blue Baby. Returns false for The Lost and Tainted Lost.
24
28
  function ____exports.characterCanHaveRedHearts(self, character)
25
29
  return not CHARACTERS_WITH_NO_RED_HEARTS_SET:has(character)
26
30
  end
31
+ --- Helper function to determine if the given character can have soul hearts. Returns true for
32
+ -- characters like Isaac, Magdalene, or Cain. Returns false for characters like Bethany. Returns
33
+ -- false for The Lost and Tainted Lost.
27
34
  function ____exports.characterCanHaveSoulHearts(self, character)
28
35
  return not CHARACTERS_WITH_NO_SOUL_HEARTS_SET:has(character)
29
36
  end
37
+ --- Helper function for determining whether the given character can take free Devil Deals. (e.g. The
38
+ -- Lost, Tainted Lost, etc.)
30
39
  function ____exports.characterCanTakeFreeDevilDeals(self, character)
31
40
  return CHARACTERS_WITH_FREE_DEVIL_DEALS_SET:has(character)
32
41
  end
42
+ --- Normally, characters get a red heart container upon reaching a new floor with an eternal heart,
43
+ -- but some characters grant a black heart instead. Returns true for Dark Judas and Tainted Judas.
44
+ -- Otherwise, returns false.
33
45
  function ____exports.characterGetsBlackHeartFromEternalHeart(self, character)
34
46
  return CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART_SET:has(character)
35
47
  end
48
+ --- Helper function to determine if the specified character starts with an active item.
49
+ --
50
+ -- For the purposes of this function, the save file is considered to be fully unlocked (e.g. Isaac
51
+ -- is considered to starts with the D6, but this is not the case on a brand new save file).
36
52
  function ____exports.characterStartsWithActiveItem(self, character)
37
53
  return CHARACTERS_THAT_START_WITH_AN_ACTIVE_ITEM_SET:has(character)
38
54
  end
55
+ --- - Most characters have a 56 frame death animation (i.e. the "Death" animation).
56
+ -- - The Lost and Tainted Lost have a 38 frame death animation (i.e. the "LostDeath" animation).
57
+ -- - Tainted Forgotten have a 20 frame death animation (i.e. the "ForgottenDeath" animation).
39
58
  function ____exports.getCharacterDeathAnimationName(self, character)
40
59
  if LOST_STYLE_CHARACTERS_SET:has(character) then
41
60
  return "LostDeath"
@@ -45,6 +64,9 @@ function ____exports.getCharacterDeathAnimationName(self, character)
45
64
  end
46
65
  return "Death"
47
66
  end
67
+ --- Returns the maximum heart containers that the provided character can have. Normally, this is 12,
68
+ -- but with Keeper it is 3, and with Tainted Keeper it is 2. This does not account for Birthright or
69
+ -- Mother's Kiss; use the `getPlayerMaxHeartContainers` helper function for that.
48
70
  function ____exports.getCharacterMaxHeartContainers(self, character)
49
71
  if character == PlayerType.KEEPER then
50
72
  return 3
@@ -60,6 +82,7 @@ function ____exports.getCharacterMaxHeartContainers(self, character)
60
82
  end
61
83
  return 12
62
84
  end
85
+ --- Helper function to get the name of a character. Returns "unknown" for modded characters.
63
86
  function ____exports.getCharacterName(self, character)
64
87
  if ____exports.isVanillaCharacter(nil, character) then
65
88
  return "unknown"
@@ -13,6 +13,19 @@ local ____collectibles = require("functions.collectibles")
13
13
  local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
14
14
  local ____playerIndex = require("functions.playerIndex")
15
15
  local getPlayers = ____playerIndex.getPlayers
16
+ --- Helper function to add a charge to one of a player's active items, emulating what happens when a
17
+ -- room is cleared.
18
+ --
19
+ -- This function will take the following things into account:
20
+ -- - L rooms and 2x2 rooms granting a double charge
21
+ -- - The Battery
22
+ -- - AAA Battery
23
+ --
24
+ -- @param player The player to grant the charges to.
25
+ -- @param activeSlot The active item slot to grant the charges to.
26
+ -- @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
27
+ -- 1x1 room for the purposes of calculating how much charge to
28
+ -- grant. Default is false.
16
29
  function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, ignoreBigRoomDoubleCharge)
17
30
  if ignoreBigRoomDoubleCharge == nil then
18
31
  ignoreBigRoomDoubleCharge = false
@@ -75,6 +88,9 @@ function getNumChargesWithAAAModifier(self, player, activeSlot, chargesToAdd)
75
88
  end
76
89
  return chargesToAdd
77
90
  end
91
+ --- Helper function to get the combined normal charge and the battery charge for the player's active
92
+ -- item. This is useful because you have to add these two values together when setting the active
93
+ -- charge.
78
94
  function ____exports.getTotalCharge(self, player, activeSlot)
79
95
  local activeCharge = player:GetActiveCharge(activeSlot)
80
96
  local batteryCharge = player:GetBatteryCharge(activeSlot)
@@ -98,6 +114,18 @@ function shouldPlayFullRechargeSound(self, player, activeSlot)
98
114
  end
99
115
  return not player:NeedsCharge(activeSlot) or activeCharge == maxCharges and batteryCharge == 0
100
116
  end
117
+ --- Helper function to add a charge to a player's active item, emulating what happens when a room is
118
+ -- cleared.
119
+ --
120
+ -- This function will take the following things into account:
121
+ -- - L rooms and 2x2 rooms granting a double charge
122
+ -- - The Battery
123
+ -- - AAA Battery
124
+ --
125
+ -- @param player The player to grant the charges to.
126
+ -- @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
127
+ -- 1x1 room for the purposes of calculating how much charge to
128
+ -- grant. Default is false.
101
129
  function ____exports.addRoomClearCharge(self, player, ignoreBigRoomDoubleCharge)
102
130
  if ignoreBigRoomDoubleCharge == nil then
103
131
  ignoreBigRoomDoubleCharge = false
@@ -106,6 +134,17 @@ function ____exports.addRoomClearCharge(self, player, ignoreBigRoomDoubleCharge)
106
134
  ____exports.addRoomClearChargeToSlot(nil, player, activeSlot, ignoreBigRoomDoubleCharge)
107
135
  end
108
136
  end
137
+ --- Helper function to add a charge to every player's active item, emulating what happens when a room
138
+ -- is cleared.
139
+ --
140
+ -- This function will take the following things into account:
141
+ -- - L rooms and 2x2 rooms granting a double charge
142
+ -- - The Battery
143
+ -- - AAA Battery
144
+ --
145
+ -- @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
146
+ -- 1x1 room for the purposes of calculating how much charge to
147
+ -- grant. Default is false.
109
148
  function ____exports.addRoomClearCharges(self, ignoreBigRoomDoubleCharge)
110
149
  if ignoreBigRoomDoubleCharge == nil then
111
150
  ignoreBigRoomDoubleCharge = false
@@ -8,6 +8,8 @@ function getChargeBarClamp(self, charges, maxCharges)
8
8
  return Vector(0, meterClip)
9
9
  end
10
10
  local CHARGE_BAR_ANM2 = "gfx/ui/ui_chargebar.anm2"
11
+ --- Constructor for a `ChargeBarSprites` object. For more information, see the `renderChargeBar`
12
+ -- helper function.
11
13
  function ____exports.newChargeBarSprites(self, maxCharges)
12
14
  local back = Sprite()
13
15
  back:Load(CHARGE_BAR_ANM2, true)
@@ -32,6 +34,8 @@ function ____exports.newChargeBarSprites(self, maxCharges)
32
34
  maxCharges = maxCharges
33
35
  }
34
36
  end
37
+ --- Helper function to render a charge bar on the screen. First, call the `newChargeBarSprites`
38
+ -- function to initialize the sprites, and then call this function on every render frame.
35
39
  function ____exports.renderChargeBar(self, sprites, position, normalCharges, batteryCharges)
36
40
  sprites.back:Render(position, VectorZero, VectorZero)
37
41
  local normalChargesClamp = getChargeBarClamp(nil, normalCharges, sprites.maxCharges)
@@ -37,6 +37,8 @@ local function initCacheFlagMap(self)
37
37
  CACHE_FLAG_TO_COLLECTIBLES_MAP:set(cacheFlag, collectiblesSet)
38
38
  end
39
39
  end
40
+ --- Returns a set containing every collectible type with the given cache flag, including modded
41
+ -- collectibles.
40
42
  function ____exports.getCollectiblesForCacheFlag(self, cacheFlag)
41
43
  if CACHE_FLAG_TO_COLLECTIBLES_MAP.size == 0 then
42
44
  initCacheFlagMap(nil)
@@ -47,6 +49,19 @@ function ____exports.getCollectiblesForCacheFlag(self, cacheFlag)
47
49
  end
48
50
  return copySet(nil, collectiblesSet)
49
51
  end
52
+ --- Returns an array containing every collectible type that the player has that matches the provided
53
+ -- CacheFlag.
54
+ --
55
+ -- For example, if the cache flag is `CacheFlag.FLYING`, and the player has one Lord of the Pit and
56
+ -- two Dead Doves, then this function would return:
57
+ --
58
+ -- ```ts
59
+ -- [
60
+ -- CollectibleType.LORD_OF_THE_PIT,
61
+ -- CollectibleType.DEAD_DOVE,
62
+ -- CollectibleType.DEAD_DOVE,
63
+ -- ]
64
+ -- ```
50
65
  function ____exports.getPlayerCollectiblesForCacheFlag(self, player, cacheFlag)
51
66
  local collectiblesForCacheFlag = ____exports.getCollectiblesForCacheFlag(nil, cacheFlag)
52
67
  local playerCollectibles = {}
@@ -30,18 +30,21 @@ local function initCollectibleSets(self)
30
30
  ::__continue3::
31
31
  end
32
32
  end
33
+ --- Returns a set containing every valid collectible type in the game, including modded collectibles.
33
34
  function ____exports.getCollectibleSet(self)
34
35
  if ALL_COLLECTIBLES_SET.size == 0 then
35
36
  initCollectibleSets(nil)
36
37
  end
37
38
  return copySet(nil, ALL_COLLECTIBLES_SET)
38
39
  end
40
+ --- Returns a set containing every modded collectible type in the game.
39
41
  function ____exports.getModdedCollectibleSet(self)
40
42
  if ALL_COLLECTIBLES_SET.size == 0 then
41
43
  initCollectibleSets(nil)
42
44
  end
43
45
  return copySet(nil, MODDED_COLLECTIBLES_SET)
44
46
  end
47
+ --- Returns a set containing every valid vanilla collectible type in the game.
45
48
  function ____exports.getVanillaCollectibleSet(self)
46
49
  if ALL_COLLECTIBLES_SET.size == 0 then
47
50
  initCollectibleSets(nil)
@@ -50,6 +50,14 @@ local function initTagMap(self)
50
50
  end
51
51
  end
52
52
  end
53
+ --- Helper function to get all of the collectible types in the game that have a certain tag.
54
+ --
55
+ -- For example, to get all of the collectible types that count as offensive for the purposes of
56
+ -- Tainted Lost:
57
+ --
58
+ -- ```ts
59
+ -- const offensiveCollectibleTypes = getCollectibleTypesWithTag(ItemConfigTag.OFFENSIVE);
60
+ -- ```
53
61
  function ____exports.getCollectibleTypesWithTag(self, itemConfigTag)
54
62
  if TAG_TO_COLLECTIBLE_TYPES_MAP.size == 0 then
55
63
  initTagMap(nil)
@@ -60,6 +68,7 @@ function ____exports.getCollectibleTypesWithTag(self, itemConfigTag)
60
68
  end
61
69
  return copySet(nil, collectibleTypes)
62
70
  end
71
+ --- Returns the number of items that a player has towards a particular transformation.
63
72
  function ____exports.getPlayerNumCollectiblesWithTag(self, player, itemConfigTag)
64
73
  local collectibleTypesSet = ____exports.getCollectibleTypesWithTag(nil, itemConfigTag)
65
74
  return getPlayerCollectibleCount(