isaacscript-common 1.2.9 → 1.2.13

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.
@@ -132,8 +132,9 @@ export declare function getPlayerIndexVanilla(playerToFind: EntityPlayer): int |
132
132
  */
133
133
  export declare function getPlayerMaxHeartContainers(player: EntityPlayer): int;
134
134
  /**
135
- * Helper function to get the name of the player. Use this instead of the `EntityPlayer.GetName`
136
- * method if you want the name to include the "Tainted" prefix.
135
+ * Helper function to get the proper name of the player. Use this instead of the
136
+ * `EntityPlayer.GetName` method because it accounts for Blue Baby, Lazarus II, and Tainted
137
+ * characters.
137
138
  */
138
139
  export declare function getPlayerName(player: EntityPlayer): string;
139
140
  /**
@@ -216,6 +217,8 @@ export declare function canTakeFreeDevilDeals(player: EntityPlayer): boolean;
216
217
  export declare function isTainted(player: EntityPlayer): boolean;
217
218
  /** Helper function for detecting when a player is Tainted Lazarus or Dead Tainted Lazarus. */
218
219
  export declare function isTaintedLazarus(player: EntityPlayer): boolean;
220
+ export declare function isModdedCharacter(player: EntityPlayer): boolean;
221
+ export declare function isVanillaCharacter(player: EntityPlayer): boolean;
219
222
  export declare function removeCollectibleCostume(player: EntityPlayer, collectibleType: CollectibleType | int): void;
220
223
  /**
221
224
  * Helper function to remove the Dead Eye multiplier from a player.
@@ -9,7 +9,7 @@ local __TS__Iterator = ____lualib.__TS__Iterator
9
9
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
10
10
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
11
11
  local ____exports = {}
12
- local EXCLUDED_CHARACTERS
12
+ local getAdjustedPlayerName, isTaintedModded, EXCLUDED_CHARACTERS
13
13
  local ____constants = require("constants")
14
14
  local CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = ____constants.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART
15
15
  local CHARACTERS_WITH_FREE_DEVIL_DEALS = ____constants.CHARACTERS_WITH_FREE_DEVIL_DEALS
@@ -17,6 +17,7 @@ local CHARACTERS_WITH_NO_RED_HEARTS = ____constants.CHARACTERS_WITH_NO_RED_HEART
17
17
  local CHARACTERS_WITH_NO_SOUL_HEARTS = ____constants.CHARACTERS_WITH_NO_SOUL_HEARTS
18
18
  local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
19
19
  local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
20
+ local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
20
21
  local ____HealthType = require("types.HealthType")
21
22
  local HealthType = ____HealthType.HealthType
22
23
  local ____array = require("functions.array")
@@ -30,6 +31,7 @@ local ____collectibleSet = require("functions.collectibleSet")
30
31
  local getCollectibleSet = ____collectibleSet.getCollectibleSet
31
32
  local ____util = require("functions.util")
32
33
  local ensureAllCases = ____util.ensureAllCases
34
+ local stringContains = ____util.stringContains
33
35
  local trimPrefix = ____util.trimPrefix
34
36
  function ____exports.getCharacterMaxHeartContainers(self, character)
35
37
  if character == PlayerType.PLAYER_KEEPER then
@@ -67,6 +69,53 @@ function ____exports.getPlayerMaxHeartContainers(self, player)
67
69
  end
68
70
  return maxHeartContainers
69
71
  end
72
+ function getAdjustedPlayerName(self, player)
73
+ local character = player:GetPlayerType()
74
+ repeat
75
+ local ____switch71 = character
76
+ local ____cond71 = ____switch71 == PlayerType.PLAYER_BLUEBABY or ____switch71 == PlayerType.PLAYER_BLUEBABY_B
77
+ if ____cond71 then
78
+ do
79
+ return "Blue Baby"
80
+ end
81
+ end
82
+ ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2
83
+ if ____cond71 then
84
+ do
85
+ return "Lazarus II"
86
+ end
87
+ end
88
+ ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_BLACKJUDAS
89
+ if ____cond71 then
90
+ do
91
+ return "Dark Judas"
92
+ end
93
+ end
94
+ ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_JACOB
95
+ if ____cond71 then
96
+ do
97
+ return "Jacob & Esau"
98
+ end
99
+ end
100
+ ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2_B
101
+ if ____cond71 then
102
+ do
103
+ return "Dead Tainted Lazarus"
104
+ end
105
+ end
106
+ ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_JACOB2_B
107
+ if ____cond71 then
108
+ do
109
+ return "Dead Tainted Jacob"
110
+ end
111
+ end
112
+ do
113
+ do
114
+ return player:GetName()
115
+ end
116
+ end
117
+ until true
118
+ end
70
119
  function ____exports.getPlayers(self, performExclusions)
71
120
  if performExclusions == nil then
72
121
  performExclusions = false
@@ -79,18 +128,18 @@ function ____exports.getPlayers(self, performExclusions)
79
128
  do
80
129
  local player = Isaac.GetPlayer(i)
81
130
  if player == nil then
82
- goto __continue72
131
+ goto __continue81
83
132
  end
84
133
  if ____exports.isChildPlayer(nil, player) then
85
- goto __continue72
134
+ goto __continue81
86
135
  end
87
136
  local character = player:GetPlayerType()
88
137
  if performExclusions and EXCLUDED_CHARACTERS:has(character) then
89
- goto __continue72
138
+ goto __continue81
90
139
  end
91
140
  __TS__ArrayPush(players, player)
92
141
  end
93
- ::__continue72::
142
+ ::__continue81::
94
143
  i = i + 1
95
144
  end
96
145
  end
@@ -101,7 +150,26 @@ function ____exports.isChildPlayer(self, player)
101
150
  end
102
151
  function ____exports.isTainted(self, player)
103
152
  local character = player:GetPlayerType()
104
- return character >= PlayerType.PLAYER_ISAAC_B
153
+ local ____isVanillaCharacter_result_0
154
+ if ____exports.isVanillaCharacter(nil, player) then
155
+ ____isVanillaCharacter_result_0 = character >= PlayerType.PLAYER_ISAAC_B
156
+ else
157
+ ____isVanillaCharacter_result_0 = isTaintedModded(nil, player)
158
+ end
159
+ return ____isVanillaCharacter_result_0
160
+ end
161
+ function isTaintedModded(self, player)
162
+ local character = player:GetPlayerType()
163
+ local name = player:GetName()
164
+ local taintedCharacter = Isaac.GetPlayerTypeByName(name, true)
165
+ return character == taintedCharacter
166
+ end
167
+ function ____exports.isModdedCharacter(self, player)
168
+ local character = player:GetPlayerType()
169
+ return character > MAX_VANILLA_CHARACTER
170
+ end
171
+ function ____exports.isVanillaCharacter(self, player)
172
+ return not ____exports.isModdedCharacter(nil, player)
105
173
  end
106
174
  EXCLUDED_CHARACTERS = __TS__New(Set, {PlayerType.PLAYER_ESAU, PlayerType.PLAYER_THESOUL_B})
107
175
  function ____exports.addCollectibleCostume(self, player, collectibleType)
@@ -313,12 +381,12 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
313
381
  return nil
314
382
  end
315
383
  function ____exports.getPlayerName(self, player)
316
- local name = player:GetName()
384
+ local adjustedName = getAdjustedPlayerName(nil, player)
317
385
  if not ____exports.isTainted(nil, player) then
318
- return name
386
+ return adjustedName
319
387
  end
320
- local baseName = trimPrefix(nil, name, "The ")
321
- return "Tainted " .. baseName
388
+ local baseName = trimPrefix(nil, adjustedName, "The ")
389
+ return stringContains(nil, baseName, "Tainted") and baseName or "Tainted " .. baseName
322
390
  end
323
391
  function ____exports.getPlayerNumHitsRemaining(self, player)
324
392
  local hearts = player:GetHearts()
@@ -476,9 +544,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
476
544
  itemPool:RemoveCollectible(collectibleType)
477
545
  end
478
546
  repeat
479
- local ____switch112 = activeSlot
480
- local ____cond112 = ____switch112 == ActiveSlot.SLOT_PRIMARY
481
- if ____cond112 then
547
+ local ____switch124 = activeSlot
548
+ local ____cond124 = ____switch124 == ActiveSlot.SLOT_PRIMARY
549
+ if ____cond124 then
482
550
  do
483
551
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
484
552
  player:RemoveCollectible(primaryCollectibleType)
@@ -487,8 +555,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
487
555
  break
488
556
  end
489
557
  end
490
- ____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_SECONDARY
491
- if ____cond112 then
558
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_SECONDARY
559
+ if ____cond124 then
492
560
  do
493
561
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
494
562
  player:RemoveCollectible(primaryCollectibleType)
@@ -503,16 +571,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
503
571
  break
504
572
  end
505
573
  end
506
- ____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_POCKET
507
- if ____cond112 then
574
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_POCKET
575
+ if ____cond124 then
508
576
  do
509
577
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
510
578
  player:SetActiveCharge(charge, activeSlot)
511
579
  break
512
580
  end
513
581
  end
514
- ____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_POCKET2
515
- if ____cond112 then
582
+ ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_POCKET2
583
+ if ____cond124 then
516
584
  do
517
585
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
518
586
  break
@@ -5,10 +5,7 @@
5
5
  * This function is variadic, meaning that you can specify N sets to add to the first set.
6
6
  */
7
7
  export declare function addSetsToSet<T>(mainSet: Set<T>, ...setsToAdd: Array<Set<T>>): void;
8
- /**
9
- * Using a Set constructor to copy a Set does not seem to work properly, so use this helper function
10
- * instead.
11
- */
8
+ /** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
12
9
  export declare function copySet<T>(oldSet: Set<T>): Set<T>;
13
10
  /**
14
11
  * Helper function to create a new set that is the composition of two or more sets.
@@ -80,6 +80,7 @@ export declare function onSetSeed(): boolean;
80
80
  * message (which `Isaac.ConsoleOutput()` does not do by default).
81
81
  */
82
82
  export declare function printConsole(msg: string): void;
83
+ export declare function stringContains(string: string, searchString: string): boolean;
83
84
  /**
84
85
  * In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
85
86
  * `clear` method does not exist. Use this helper function as a drop-in replacement for this.
@@ -67,6 +67,9 @@ end
67
67
  function ____exports.printConsole(self, msg)
68
68
  Isaac.ConsoleOutput(msg .. "\n")
69
69
  end
70
+ function ____exports.stringContains(self, ____string, searchString)
71
+ return (string.find(____string, searchString, nil, true) or 0) - 1 ~= -1
72
+ end
70
73
  function ____exports.tableClear(self, ____table)
71
74
  for key in pairs(____table) do
72
75
  ____table[key] = nil
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.9",
3
+ "version": "1.2.13",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",