isaacscript-common 3.4.2 → 3.5.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.
@@ -37,6 +37,33 @@ export declare function anyPlayerIs(...matchingCharacters: PlayerType[]): boolea
37
37
  * - the player has Stompy (transformation 13)
38
38
  */
39
39
  export declare function canPlayerCrushRocks(player: EntityPlayer): boolean;
40
+ /**
41
+ * Returns whether or not all of the player's soul-heart-type hearts are black hearts.
42
+ *
43
+ * Note that this function does not consider red heart containers.
44
+ *
45
+ * For example:
46
+ *
47
+ * - If the player has one black heart, this function would return true.
48
+ * - If the player has one soul heart and two black hearts, this function would return false.
49
+ * - If the player has no black hearts, this function will return false.
50
+ * - If the player has one red heart container and three black hearts, this function would return
51
+ * true.
52
+ */
53
+ export declare function doesPlayerHaveAllBlackHearts(player: EntityPlayer): boolean;
54
+ /**
55
+ * Returns whether or not all of the player's soul-heart-type hearts are soul hearts.
56
+ *
57
+ * Note that this function does not consider red heart containers.
58
+ *
59
+ * For example:
60
+ *
61
+ * - If the player has two soul hearts and one black heart, this function would return false.
62
+ * - If the player has no soul hearts, this function will return false.
63
+ * - If the player has one red heart container and three soul hearts, this function would return
64
+ * true.
65
+ */
66
+ export declare function doesPlayerHaveAllSoulHearts(player: EntityPlayer): boolean;
40
67
  /**
41
68
  * Helper function to find the active slot that the player has the corresponding collectible type
42
69
  * in. Returns undefined if the player does not have the collectible in any active slot.
@@ -58,6 +58,16 @@ function ____exports.getCharacters(self)
58
58
  function(____, player) return player:GetPlayerType() end
59
59
  )
60
60
  end
61
+ --- Returns the number of black hearts that the player has, excluding any soul hearts. For example,
62
+ -- if the player has one full black heart, one full soul heart, and one half black heart, this
63
+ -- function returns 3.
64
+ --
65
+ -- This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
66
+ function ____exports.getPlayerBlackHearts(self, player)
67
+ local blackHeartsBitmask = player:GetBlackHearts()
68
+ local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
69
+ return blackHeartBits * 2
70
+ end
61
71
  --- Returns the maximum heart containers that the provided player can have. Normally, this is 12, but
62
72
  -- it can change depending on the character (e.g. Keeper) and other things (e.g. Mother's Kiss).
63
73
  -- This function does not account for Broken Hearts; use the `getPlayerAvailableHeartSlots` helper
@@ -78,6 +88,17 @@ function ____exports.getPlayerMaxHeartContainers(self, player)
78
88
  end
79
89
  return characterMaxHeartContainers
80
90
  end
91
+ --- Returns the number of soul hearts that the player has, excluding any black hearts. For example,
92
+ -- if the player has one full black heart, one full soul heart, and one half black heart, this
93
+ -- function returns 2.
94
+ --
95
+ -- This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
96
+ -- number of soul hearts and black hearts.
97
+ function ____exports.getPlayerSoulHearts(self, player)
98
+ local soulHearts = player:GetSoulHearts()
99
+ local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
100
+ return soulHearts - blackHearts
101
+ end
81
102
  --- Helper function to check if a player is a specific character (i.e. `PlayerType`).
82
103
  --
83
104
  -- This function is variadic, meaning that you can supply as many characters as you want to check
@@ -235,6 +256,37 @@ function ____exports.canPlayerCrushRocks(self, player)
235
256
  local effects = player:GetEffects()
236
257
  return player:HasCollectible(CollectibleType.LEO) or player:HasCollectible(CollectibleType.THUNDER_THIGHS) or effects:HasCollectibleEffect(CollectibleType.MEGA_MUSH) or player:HasPlayerForm(PlayerForm.STOMPY)
237
258
  end
259
+ --- Returns whether or not all of the player's soul-heart-type hearts are black hearts.
260
+ --
261
+ -- Note that this function does not consider red heart containers.
262
+ --
263
+ -- For example:
264
+ --
265
+ -- - If the player has one black heart, this function would return true.
266
+ -- - If the player has one soul heart and two black hearts, this function would return false.
267
+ -- - If the player has no black hearts, this function will return false.
268
+ -- - If the player has one red heart container and three black hearts, this function would return
269
+ -- true.
270
+ function ____exports.doesPlayerHaveAllBlackHearts(self, player)
271
+ local soulHearts = ____exports.getPlayerSoulHearts(nil, player)
272
+ local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
273
+ return blackHearts > 0 and soulHearts == 0
274
+ end
275
+ --- Returns whether or not all of the player's soul-heart-type hearts are soul hearts.
276
+ --
277
+ -- Note that this function does not consider red heart containers.
278
+ --
279
+ -- For example:
280
+ --
281
+ -- - If the player has two soul hearts and one black heart, this function would return false.
282
+ -- - If the player has no soul hearts, this function will return false.
283
+ -- - If the player has one red heart container and three soul hearts, this function would return
284
+ -- true.
285
+ function ____exports.doesPlayerHaveAllSoulHearts(self, player)
286
+ local soulHearts = ____exports.getPlayerSoulHearts(nil, player)
287
+ local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
288
+ return soulHearts > 0 and blackHearts == 0
289
+ end
238
290
  --- Helper function to find the active slot that the player has the corresponding collectible type
239
291
  -- in. Returns undefined if the player does not have the collectible in any active slot.
240
292
  function ____exports.getActiveItemSlot(self, player, collectibleType)
@@ -333,16 +385,6 @@ function ____exports.getPlayerAvailableHeartSlots(self, player)
333
385
  local totalOccupiedHeartSlots = totalHeartContainers + brokenHearts
334
386
  return maxHeartContainers - totalOccupiedHeartSlots
335
387
  end
336
- --- Returns the number of black hearts that the player has, excluding any soul hearts. For example,
337
- -- if the player has one full black heart, one full soul heart, and one half black heart, this
338
- -- function returns 3.
339
- --
340
- -- This is different from the `EntityPlayer.GetBlackHearts` method, since that returns a bitmask.
341
- function ____exports.getPlayerBlackHearts(self, player)
342
- local blackHeartsBitmask = player:GetBlackHearts()
343
- local blackHeartBits = countSetBits(nil, blackHeartsBitmask)
344
- return blackHeartBits * 2
345
- end
346
388
  --- Iterates over all players and checks if any are close enough to the specified position.
347
389
  --
348
390
  -- @returns The first player found when iterating upwards from index 0.
@@ -478,17 +520,6 @@ function ____exports.getPlayerNumHitsRemaining(self, player)
478
520
  local rottenHearts = player:GetRottenHearts()
479
521
  return hearts + soulHearts + boneHearts + eternalHearts - rottenHearts
480
522
  end
481
- --- Returns the number of soul hearts that the player has, excluding any black hearts. For example,
482
- -- if the player has one full black heart, one full soul heart, and one half black heart, this
483
- -- function returns 2.
484
- --
485
- -- This is different from the `EntityPlayer.GetSoulHearts` method, since that returns the combined
486
- -- number of soul hearts and black hearts.
487
- function ____exports.getPlayerSoulHearts(self, player)
488
- local soulHearts = player:GetSoulHearts()
489
- local blackHearts = ____exports.getPlayerBlackHearts(nil, player)
490
- return soulHearts - blackHearts
491
- end
492
523
  --- Helper function to get all of the players that are a certain character.
493
524
  --
494
525
  -- This function is variadic, meaning that you can supply as many characters as you want to check
@@ -719,9 +750,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
719
750
  itemPool:RemoveCollectible(collectibleType)
720
751
  end
721
752
  repeat
722
- local ____switch122 = activeSlot
723
- local ____cond122 = ____switch122 == ActiveSlot.PRIMARY
724
- if ____cond122 then
753
+ local ____switch124 = activeSlot
754
+ local ____cond124 = ____switch124 == ActiveSlot.PRIMARY
755
+ if ____cond124 then
725
756
  do
726
757
  if primaryCollectibleType ~= CollectibleType.NULL then
727
758
  player:RemoveCollectible(primaryCollectibleType)
@@ -730,8 +761,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
730
761
  break
731
762
  end
732
763
  end
733
- ____cond122 = ____cond122 or ____switch122 == ActiveSlot.SECONDARY
734
- if ____cond122 then
764
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SECONDARY
765
+ if ____cond124 then
735
766
  do
736
767
  if primaryCollectibleType ~= CollectibleType.NULL then
737
768
  player:RemoveCollectible(primaryCollectibleType)
@@ -746,16 +777,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
746
777
  break
747
778
  end
748
779
  end
749
- ____cond122 = ____cond122 or ____switch122 == ActiveSlot.POCKET
750
- if ____cond122 then
780
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.POCKET
781
+ if ____cond124 then
751
782
  do
752
783
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
753
784
  player:SetActiveCharge(charge, activeSlot)
754
785
  break
755
786
  end
756
787
  end
757
- ____cond122 = ____cond122 or ____switch122 == ActiveSlot.POCKET_SINGLE_USE
758
- if ____cond122 then
788
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.POCKET_SINGLE_USE
789
+ if ____cond124 then
759
790
  do
760
791
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
761
792
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "3.4.2",
3
+ "version": "3.5.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",