isaacscript-common 9.13.6 → 9.16.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 (90) hide show
  1. package/dist/features/extraConsoleCommands/listCommands.d.ts +4 -0
  2. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  3. package/dist/features/extraConsoleCommands/listCommands.lua +81 -19
  4. package/dist/functions/collectibles.lua +4 -4
  5. package/dist/functions/minimap.d.ts +22 -4
  6. package/dist/functions/minimap.d.ts.map +1 -1
  7. package/dist/functions/minimap.lua +67 -7
  8. package/dist/functions/string.d.ts +2 -0
  9. package/dist/functions/string.d.ts.map +1 -1
  10. package/dist/functions/string.lua +5 -0
  11. package/dist/functions/trinkets.d.ts.map +1 -1
  12. package/dist/functions/trinkets.lua +4 -4
  13. package/dist/index.d.ts +34 -11
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.lua +4 -4
  16. package/dist/maps/cardNameToTypeMap.d.ts +4 -0
  17. package/dist/maps/cardNameToTypeMap.d.ts.map +1 -0
  18. package/dist/maps/{cardMap.lua → cardNameToTypeMap.lua} +2 -2
  19. package/dist/maps/characterNameToTypeMap.d.ts +4 -0
  20. package/dist/maps/characterNameToTypeMap.d.ts.map +1 -0
  21. package/dist/maps/characterNameToTypeMap.lua +92 -0
  22. package/dist/maps/collectibleDescriptionMap.d.ts +6 -0
  23. package/dist/maps/collectibleDescriptionMap.d.ts.map +1 -1
  24. package/dist/maps/collectibleDescriptionMap.lua +4 -0
  25. package/dist/maps/collectibleNameToTypeMap.d.ts +3 -0
  26. package/dist/maps/collectibleNameToTypeMap.d.ts.map +1 -0
  27. package/dist/maps/collectibleNameToTypeMap.lua +21 -0
  28. package/dist/maps/collectibleTypeToNameMap.d.ts +12 -0
  29. package/dist/maps/collectibleTypeToNameMap.d.ts.map +1 -0
  30. package/dist/maps/{collectibleNameMap.lua → collectibleTypeToNameMap.lua} +7 -1
  31. package/dist/maps/{pillEffectMap.d.ts → pillNameToEffectMap.d.ts} +2 -2
  32. package/dist/maps/pillNameToEffectMap.d.ts.map +1 -0
  33. package/dist/maps/{pillEffectMap.lua → pillNameToEffectMap.lua} +1 -1
  34. package/dist/maps/roomNameToTypeMap.d.ts +4 -0
  35. package/dist/maps/roomNameToTypeMap.d.ts.map +1 -0
  36. package/dist/maps/{roomTypeMap.lua → roomNameToTypeMap.lua} +2 -2
  37. package/dist/maps/trinketDescriptionMap.d.ts +6 -0
  38. package/dist/maps/trinketDescriptionMap.d.ts.map +1 -1
  39. package/dist/maps/trinketDescriptionMap.lua +4 -0
  40. package/dist/maps/trinketNameToTypeMap.d.ts +3 -0
  41. package/dist/maps/trinketNameToTypeMap.d.ts.map +1 -0
  42. package/dist/maps/trinketNameToTypeMap.lua +21 -0
  43. package/dist/maps/trinketTypeToNameMap.d.ts +12 -0
  44. package/dist/maps/trinketTypeToNameMap.d.ts.map +1 -0
  45. package/dist/maps/{trinketNameMap.lua → trinketTypeToNameMap.lua} +7 -1
  46. package/dist/objects/characterDamageMultipliers.lua +1 -1
  47. package/dist/objects/characterNames.lua +1 -1
  48. package/dist/objects/playerNamePNGFileNames.lua +1 -1
  49. package/dist/objects/playerPortraitPNGFileNames.lua +1 -1
  50. package/dist/sets/charactersWithBlackHeartFromEternalHeartSet.lua +1 -1
  51. package/dist/sets/charactersWithNoRedHeartsSet.lua +1 -1
  52. package/package.json +2 -2
  53. package/src/features/extraConsoleCommands/listCommands.ts +91 -16
  54. package/src/functions/collectibles.ts +3 -3
  55. package/src/functions/minimap.ts +78 -7
  56. package/src/functions/string.ts +6 -0
  57. package/src/functions/trinkets.ts +5 -2
  58. package/src/index.ts +4 -4
  59. package/src/maps/{cardMap.ts → cardNameToTypeMap.ts} +2 -2
  60. package/src/maps/characterNameToTypeMap.ts +88 -0
  61. package/src/maps/collectibleDescriptionMap.ts +6 -2
  62. package/src/maps/collectibleNameToTypeMap.ts +19 -0
  63. package/src/maps/collectibleTypeToNameMap.ts +739 -0
  64. package/src/maps/pillNameToEffectMap.ts +90 -0
  65. package/src/maps/{roomTypeMap.ts → roomNameToTypeMap.ts} +2 -2
  66. package/src/maps/trinketDescriptionMap.ts +6 -2
  67. package/src/maps/trinketNameToTypeMap.ts +17 -0
  68. package/src/maps/trinketTypeToNameMap.ts +205 -0
  69. package/src/objects/characterDamageMultipliers.ts +1 -1
  70. package/src/objects/characterNames.ts +1 -1
  71. package/src/objects/playerNamePNGFileNames.ts +1 -1
  72. package/src/objects/playerPortraitPNGFileNames.ts +1 -1
  73. package/src/sets/charactersWithBlackHeartFromEternalHeartSet.ts +1 -1
  74. package/src/sets/charactersWithNoRedHeartsSet.ts +1 -1
  75. package/dist/maps/cardMap.d.ts +0 -4
  76. package/dist/maps/cardMap.d.ts.map +0 -1
  77. package/dist/maps/characterMap.d.ts +0 -4
  78. package/dist/maps/characterMap.d.ts.map +0 -1
  79. package/dist/maps/characterMap.lua +0 -90
  80. package/dist/maps/collectibleNameMap.d.ts +0 -4
  81. package/dist/maps/collectibleNameMap.d.ts.map +0 -1
  82. package/dist/maps/pillEffectMap.d.ts.map +0 -1
  83. package/dist/maps/roomTypeMap.d.ts +0 -4
  84. package/dist/maps/roomTypeMap.d.ts.map +0 -1
  85. package/dist/maps/trinketNameMap.d.ts +0 -4
  86. package/dist/maps/trinketNameMap.d.ts.map +0 -1
  87. package/src/maps/characterMap.ts +0 -87
  88. package/src/maps/collectibleNameMap.ts +0 -731
  89. package/src/maps/pillEffectMap.ts +0 -88
  90. package/src/maps/trinketNameMap.ts +0 -198
@@ -1,8 +1,48 @@
1
1
  import { DisplayFlag, DisplayFlagZero } from "isaac-typescript-definitions";
2
2
  import { game } from "../core/cachedClasses";
3
- import { getRoomDescriptor } from "./roomData";
3
+ import { addFlag } from "./flag";
4
+ import { getRoomDescriptor, getRoomGridIndex } from "./roomData";
4
5
  import { getRoomsInsideGrid } from "./rooms";
5
6
 
7
+ /**
8
+ * Helper function to add a `DisplayFlag` to a particular room's minimap display flags (e.g. whether
9
+ * or not it is visible and so on).
10
+ *
11
+ * @param roomGridIndex Set to undefined to use the current room index.
12
+ * @param displayFlag The `DisplayFlag` to set. (See the `DisplayFlag` enum.)
13
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
14
+ * make the changes immediately visible. Default is true.
15
+ */
16
+ export function addRoomDisplayFlag(
17
+ roomGridIndex: int | undefined,
18
+ displayFlag: DisplayFlag,
19
+ updateVisibility = true,
20
+ ): void {
21
+ if (MinimapAPI === undefined) {
22
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
23
+ roomDescriptor.DisplayFlags = addFlag(
24
+ roomDescriptor.DisplayFlags,
25
+ displayFlag,
26
+ );
27
+ } else {
28
+ if (roomGridIndex === undefined) {
29
+ roomGridIndex = getRoomGridIndex();
30
+ }
31
+ const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
32
+ if (roomDescriptor !== undefined) {
33
+ roomDescriptor.DisplayFlags = addFlag(
34
+ roomDescriptor.DisplayFlags,
35
+ displayFlag,
36
+ );
37
+ }
38
+ }
39
+
40
+ if (updateVisibility) {
41
+ const level = game.GetLevel();
42
+ level.UpdateVisibility();
43
+ }
44
+ }
45
+
6
46
  /**
7
47
  * Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
8
48
  *
@@ -66,7 +106,8 @@ export function setDisplayFlags(
66
106
 
67
107
  for (const [roomGridIndex, displayFlags] of displayFlagsMap.entries()) {
68
108
  if (MinimapAPI === undefined) {
69
- setRoomDisplayFlags(roomGridIndex, displayFlags);
109
+ // We pass false to the `updateVisibility` argument as a small optimization.
110
+ setRoomDisplayFlags(roomGridIndex, displayFlags, false);
70
111
  } else {
71
112
  const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
72
113
  if (roomDescriptor !== undefined) {
@@ -90,16 +131,46 @@ export function setFloorDisplayFlags(
90
131
  * Helper function to set a particular room's minimap display flags (e.g. whether or not it is
91
132
  * visible and so on).
92
133
  *
93
- * You must call the `Level.UpdateVisibility` method after using this function for the changes to
94
- * take effect.
95
- *
96
134
  * @param roomGridIndex Set to undefined to use the current room index.
97
135
  * @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
136
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
137
+ * make the changes immediately visible. Default is true.
98
138
  */
99
139
  export function setRoomDisplayFlags(
100
140
  roomGridIndex: int | undefined,
101
141
  displayFlags: BitFlags<DisplayFlag>,
142
+ updateVisibility = true,
102
143
  ): void {
103
- const roomDescriptor = getRoomDescriptor(roomGridIndex);
104
- roomDescriptor.DisplayFlags = displayFlags;
144
+ if (MinimapAPI === undefined) {
145
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
146
+ roomDescriptor.DisplayFlags = displayFlags;
147
+ } else {
148
+ if (roomGridIndex === undefined) {
149
+ roomGridIndex = getRoomGridIndex();
150
+ }
151
+ const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
152
+ if (roomDescriptor !== undefined) {
153
+ roomDescriptor.DisplayFlags = displayFlags;
154
+ }
155
+ }
156
+
157
+ if (updateVisibility) {
158
+ const level = game.GetLevel();
159
+ level.UpdateVisibility();
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Helper function to make a single room visible in a similar way to how the Compass makes a Boss
165
+ * Room visible (e.g. by adding `DisplayFlag.SHOW_ICON`).
166
+ *
167
+ * @param roomGridIndex Set to undefined to use the current room index.
168
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
169
+ * make the changes immediately visible. Default is true.
170
+ */
171
+ export function setRoomVisible(
172
+ roomGridIndex: int | undefined,
173
+ updateVisibility = true,
174
+ ): void {
175
+ addRoomDisplayFlag(roomGridIndex, DisplayFlag.SHOW_ICON, updateVisibility);
105
176
  }
@@ -55,6 +55,12 @@ export function removeCharactersBefore(
55
55
  return string.slice(index);
56
56
  }
57
57
 
58
+ /** Helper function to remove all characters from a string that are not letters or numbers. */
59
+ export function removeNonAlphanumericCharacters(str: string): string {
60
+ const [returnValue, _] = string.gsub(str, "%W", "");
61
+ return returnValue;
62
+ }
63
+
58
64
  /**
59
65
  * Helper function to remove one or more substrings from a string, if they exist. Returns the
60
66
  * modified string.
@@ -13,7 +13,10 @@ import {
13
13
  DEFAULT_TRINKET_DESCRIPTION,
14
14
  TRINKET_DESCRIPTION_MAP,
15
15
  } from "../maps/trinketDescriptionMap";
16
- import { DEFAULT_TRINKET_NAME, TRINKET_NAME_MAP } from "../maps/trinketNameMap";
16
+ import {
17
+ DEFAULT_TRINKET_NAME,
18
+ TRINKET_TYPE_TO_NAME_MAP,
19
+ } from "../maps/trinketTypeToNameMap";
17
20
  import { getEntityID } from "./entities";
18
21
  import { isTrinket } from "./pickupVariants";
19
22
  import { isCharacter } from "./players";
@@ -123,7 +126,7 @@ export function getTrinketGfxFilename(trinketType: TrinketType): string {
123
126
  export function getTrinketName(trinketType: TrinketType): string {
124
127
  // "ItemConfigItem.Name" is bugged with vanilla items on patch v1.7.6, so we use a hard-coded map
125
128
  // as a workaround.
126
- const trinketName = TRINKET_NAME_MAP.get(trinketType);
129
+ const trinketName = TRINKET_TYPE_TO_NAME_MAP.get(trinketType);
127
130
  if (trinketName !== undefined) {
128
131
  return trinketName;
129
132
  }
package/src/index.ts CHANGED
@@ -159,10 +159,10 @@ export * from "./interfaces/RoomDescription";
159
159
  export * from "./interfaces/SaveData";
160
160
  export * from "./interfaces/StatTypeType";
161
161
  export * from "./interfaces/TrinketSituation";
162
- export * from "./maps/cardMap";
163
- export * from "./maps/characterMap";
164
- export * from "./maps/pillEffectMap";
165
- export * from "./maps/roomTypeMap";
162
+ export * from "./maps/cardNameToTypeMap";
163
+ export * from "./maps/characterNameToTypeMap";
164
+ export * from "./maps/pillNameToEffectMap";
165
+ export * from "./maps/roomNameToTypeMap";
166
166
  export * from "./objects/colors";
167
167
  export * from "./types/AnyEntity";
168
168
  export * from "./types/AnyGridEntity";
@@ -2,8 +2,8 @@ import { CardType } from "isaac-typescript-definitions";
2
2
 
3
3
  // cspell:ignore hiero
4
4
 
5
- /** Maps card names to card sub-types. */
6
- export const CARD_MAP: ReadonlyMap<string, CardType> = new Map([
5
+ /** Maps card names to the values of the `CardType` enum. */
6
+ export const CARD_NAME_TO_TYPE_MAP: ReadonlyMap<string, CardType> = new Map([
7
7
  ["fool", CardType.FOOL], // 1
8
8
  ["magician", CardType.MAGICIAN], // 2
9
9
  ["mag", CardType.MAGICIAN], // 2 - Needed since we have "mag?"
@@ -0,0 +1,88 @@
1
+ import { PlayerType } from "isaac-typescript-definitions";
2
+
3
+ /** Maps character names to the values of the `PlayerType` enum. */
4
+ export const CHARACTER_NAME_TO_TYPE_MAP = new Map<string, PlayerType>([
5
+ ["isaac", PlayerType.ISAAC], // 0
6
+ ["magdalene", PlayerType.MAGDALENE], // 1
7
+ ["maggy", PlayerType.MAGDALENE], // 1
8
+ ["cain", PlayerType.CAIN], // 2
9
+ ["judas", PlayerType.JUDAS], // 3
10
+ ["blueBaby", PlayerType.BLUE_BABY], // 4
11
+ ["bb", PlayerType.BLUE_BABY], // 4
12
+ ["eve", PlayerType.EVE], // 5
13
+ ["samson", PlayerType.SAMSON], // 6
14
+ ["azazel", PlayerType.AZAZEL], // 7
15
+ ["lazarus", PlayerType.LAZARUS], // 8
16
+ // Needed so that "laz2" does not take precedence over "lazarus".
17
+ ["laz", PlayerType.LAZARUS], // 8
18
+ ["eden", PlayerType.EDEN], // 9
19
+ ["theLost", PlayerType.THE_LOST], // 10
20
+ ["lost", PlayerType.THE_LOST], // 10
21
+ ["lazarus2", PlayerType.LAZARUS_2], // 11
22
+ ["laz2", PlayerType.LAZARUS_2], // 11
23
+ ["darkJudas", PlayerType.DARK_JUDAS], // 12
24
+ ["dJudas", PlayerType.DARK_JUDAS], // 12
25
+ ["blackJudas", PlayerType.DARK_JUDAS], // 12
26
+ ["bJudas", PlayerType.DARK_JUDAS], // 12
27
+ ["lilith", PlayerType.LILITH], // 13
28
+ ["keeper", PlayerType.KEEPER], // 14
29
+ ["apollyon", PlayerType.APOLLYON], // 15
30
+ ["theForgotten", PlayerType.THE_FORGOTTEN], // 16
31
+ ["forgotten", PlayerType.THE_FORGOTTEN], // 16
32
+ ["theSoul", PlayerType.THE_SOUL], // 17
33
+ ["soul", PlayerType.THE_SOUL], // 17
34
+ ["bethany", PlayerType.BETHANY], // 18
35
+ ["jacob", PlayerType.JACOB], // 19
36
+ ["esau", PlayerType.ESAU], // 20
37
+ ["taintedIsaac", PlayerType.ISAAC_B], // 21
38
+ ["tIsaac", PlayerType.ISAAC_B], // 21
39
+ ["taintedMagdalene", PlayerType.MAGDALENE_B], // 22
40
+ ["tMagdalene", PlayerType.MAGDALENE_B], // 22
41
+ ["taintedMaggy", PlayerType.MAGDALENE_B], // 22
42
+ ["tMaggy", PlayerType.MAGDALENE_B], // 22
43
+ ["taintedCain", PlayerType.CAIN_B], // 23
44
+ ["tCain", PlayerType.CAIN_B], // 23
45
+ ["taintedJudas", PlayerType.JUDAS_B], // 24
46
+ ["tJudas", PlayerType.JUDAS_B], // 24
47
+ ["taintedBlueBaby", PlayerType.BLUE_BABY_B], // 25
48
+ ["tBlueBaby", PlayerType.BLUE_BABY_B], // 25
49
+ ["tbb", PlayerType.BLUE_BABY_B], // 25
50
+ ["taintedEve", PlayerType.EVE_B], // 26
51
+ ["tEve", PlayerType.EVE_B], // 26
52
+ ["taintedSamson", PlayerType.SAMSON_B], // 27
53
+ ["tSamson", PlayerType.SAMSON_B], // 27
54
+ ["taintedAzazel", PlayerType.AZAZEL_B], // 28
55
+ ["tAzazel", PlayerType.AZAZEL_B], // 28
56
+ ["taintedLazarus", PlayerType.LAZARUS_B], // 29
57
+ ["tLazarus", PlayerType.LAZARUS_B], // 29
58
+ ["taintedLaz", PlayerType.LAZARUS_B], // 29
59
+ ["tLaz", PlayerType.LAZARUS_B], // 29
60
+ ["taintedEden", PlayerType.EDEN_B], // 30
61
+ ["tEden", PlayerType.EDEN_B], // 30
62
+ ["taintedLost", PlayerType.THE_LOST_B], // 31
63
+ ["tLost", PlayerType.THE_LOST_B], // 31
64
+ ["taintedLilith", PlayerType.LILITH_B], // 32
65
+ ["tLilith", PlayerType.LILITH_B], // 32
66
+ ["taintedKeeper", PlayerType.KEEPER_B], // 33
67
+ ["tKeeper", PlayerType.KEEPER_B], // 33
68
+ ["taintedApollyon", PlayerType.APOLLYON_B], // 34
69
+ ["tApollyon", PlayerType.APOLLYON_B], // 34
70
+ ["taintedForgotten", PlayerType.THE_FORGOTTEN_B], // 35
71
+ ["tForgotten", PlayerType.THE_FORGOTTEN_B], // 35
72
+ ["taintedBethany", PlayerType.BETHANY_B], // 36
73
+ ["tBethany", PlayerType.BETHANY_B], // 36
74
+ ["taintedJacob", PlayerType.JACOB_B], // 37
75
+ ["tJacob", PlayerType.JACOB_B], // 37
76
+ ["taintedLazarusDead", PlayerType.LAZARUS_2_B], // 38
77
+ ["tLazarusDead", PlayerType.LAZARUS_2_B], // 38
78
+ ["taintedLazDead", PlayerType.LAZARUS_2_B], // 38
79
+ ["tLazDead", PlayerType.LAZARUS_2_B], // 38
80
+ ["deadTaintedLazarus", PlayerType.LAZARUS_2_B], // 38
81
+ ["deadTLazarus", PlayerType.LAZARUS_2_B], // 38
82
+ ["deadTaintedLaz", PlayerType.LAZARUS_2_B], // 38
83
+ ["deadTLaz", PlayerType.LAZARUS_2_B], // 38
84
+ ["taintedJacobGhost", PlayerType.JACOB_2_B], // 39
85
+ ["tJacobGhost", PlayerType.JACOB_2_B], // 39
86
+ ["taintedSoul", PlayerType.THE_SOUL_B], // 40
87
+ ["tSoul", PlayerType.THE_SOUL_B], // 40
88
+ ]);
@@ -5,8 +5,12 @@ import { CollectibleType } from "isaac-typescript-definitions";
5
5
 
6
6
  export const DEFAULT_COLLECTIBLE_DESCRIPTION = "Unknown";
7
7
 
8
- // This is a temporary map due to missing features in the vanilla API. (Otherwise, this would be
9
- // converted to a type-safe object.)
8
+ /**
9
+ * Maps collectible types to the real English descriptions from the "stringtable.sta" file.
10
+ *
11
+ * This is a temporary map due to missing features in the vanilla API. (Otherwise, this would be
12
+ * converted to a type-safe object.)
13
+ */
10
14
  export const COLLECTIBLE_DESCRIPTION_MAP: ReadonlyMap<CollectibleType, string> =
11
15
  new Map([
12
16
  [1, "Tears up"],
@@ -0,0 +1,19 @@
1
+ import { CollectibleType } from "isaac-typescript-definitions";
2
+ import { removeNonAlphanumericCharacters } from "../functions/string";
3
+ import { COLLECTIBLE_TYPE_TO_NAME_MAP } from "./collectibleTypeToNameMap";
4
+
5
+ /**
6
+ * Maps collectible names to the values of the `CollectibleType` enum.
7
+ *
8
+ * For a mapping of `CollectibleType` to name, see `COLLECTIBLE_TYPE_TO_NAME_MAP`.
9
+ */
10
+ const collectibleNameToTypeMap = new Map<string, CollectibleType>();
11
+ for (const [collectibleType, name] of COLLECTIBLE_TYPE_TO_NAME_MAP) {
12
+ const simpleString = removeNonAlphanumericCharacters(name);
13
+ collectibleNameToTypeMap.set(simpleString, collectibleType);
14
+ }
15
+
16
+ export const COLLECTIBLE_NAME_TO_TYPE_MAP: ReadonlyMap<
17
+ string,
18
+ CollectibleType
19
+ > = collectibleNameToTypeMap;