isaacscript-common 1.2.103 → 1.2.106

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 (40) hide show
  1. package/dist/constants.d.ts +0 -2
  2. package/dist/constants.lua +0 -2
  3. package/dist/features/saveDataManager/exports.d.ts +1 -1
  4. package/dist/features/saveDataManager/load.d.ts +1 -1
  5. package/dist/features/saveDataManager/main.lua +1 -1
  6. package/dist/features/saveDataManager/maps.d.ts +1 -1
  7. package/dist/features/saveDataManager/merge.lua +1 -1
  8. package/dist/features/saveDataManager/save.d.ts +1 -1
  9. package/dist/functions/array.d.ts +7 -5
  10. package/dist/functions/array.lua +11 -9
  11. package/dist/functions/cards.d.ts +41 -11
  12. package/dist/functions/cards.lua +103 -25
  13. package/dist/functions/collectibleCacheFlag.lua +2 -2
  14. package/dist/functions/deepCopy.lua +1 -1
  15. package/dist/functions/deepCopyTests.lua +1 -1
  16. package/dist/functions/entity.d.ts +11 -0
  17. package/dist/functions/entity.lua +25 -0
  18. package/dist/functions/log.lua +10 -10
  19. package/dist/functions/pickups.d.ts +0 -7
  20. package/dist/functions/pickups.lua +0 -14
  21. package/dist/functions/pills.d.ts +1 -0
  22. package/dist/functions/pills.lua +4 -0
  23. package/dist/functions/player.lua +47 -39
  24. package/dist/functions/rooms.d.ts +8 -4
  25. package/dist/functions/rooms.lua +16 -21
  26. package/dist/functions/set.d.ts +15 -0
  27. package/dist/functions/set.lua +20 -0
  28. package/dist/functions/sprite.d.ts +4 -2
  29. package/dist/functions/transformations.lua +13 -12
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.lua +1 -1
  32. package/dist/maps/cardTypeMap.d.ts +4 -0
  33. package/dist/maps/cardTypeMap.lua +108 -0
  34. package/dist/types/CardType.d.ts +38 -0
  35. package/dist/types/CardType.lua +18 -0
  36. package/dist/types/private/SaveData.d.ts +18 -0
  37. package/dist/types/private/SaveData.lua +8 -0
  38. package/dist/types/private/SerializationBrand.d.ts +15 -0
  39. package/dist/types/private/SerializationBrand.lua +24 -0
  40. package/package.json +1 -1
@@ -17,7 +17,6 @@ local CHARACTERS_WITH_FREE_DEVIL_DEALS = ____constants.CHARACTERS_WITH_FREE_DEVI
17
17
  local CHARACTERS_WITH_NO_RED_HEARTS = ____constants.CHARACTERS_WITH_NO_RED_HEARTS
18
18
  local CHARACTERS_WITH_NO_SOUL_HEARTS = ____constants.CHARACTERS_WITH_NO_SOUL_HEARTS
19
19
  local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
20
- local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
21
20
  local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
22
21
  local ____HealthType = require("types.HealthType")
23
22
  local HealthType = ____HealthType.HealthType
@@ -56,6 +55,12 @@ function ____exports.getCharacterMaxHeartContainers(self, character)
56
55
  if character == PlayerType.PLAYER_KEEPER then
57
56
  return 3
58
57
  end
58
+ if character == PlayerType.PLAYER_THEFORGOTTEN then
59
+ return 6
60
+ end
61
+ if character == PlayerType.PLAYER_THESOUL then
62
+ return 6
63
+ end
59
64
  if character == PlayerType.PLAYER_KEEPER_B then
60
65
  return 2
61
66
  end
@@ -91,15 +96,15 @@ end
91
96
  function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSoul)
92
97
  local character = player:GetPlayerType()
93
98
  repeat
94
- local ____switch66 = character
95
- local ____cond66 = ____switch66 == PlayerType.PLAYER_THESOUL
96
- if ____cond66 then
99
+ local ____switch68 = character
100
+ local ____cond68 = ____switch68 == PlayerType.PLAYER_THESOUL
101
+ if ____cond68 then
97
102
  do
98
103
  return differentiateForgottenAndSoul and CollectibleType.COLLECTIBLE_SPOON_BENDER or DEFAULT_COLLECTIBLE_TYPE
99
104
  end
100
105
  end
101
- ____cond66 = ____cond66 or ____switch66 == PlayerType.PLAYER_LAZARUS2_B
102
- if ____cond66 then
106
+ ____cond68 = ____cond68 or ____switch68 == PlayerType.PLAYER_LAZARUS2_B
107
+ if ____cond68 then
103
108
  do
104
109
  return CollectibleType.COLLECTIBLE_INNER_EYE
105
110
  end
@@ -113,53 +118,56 @@ function getPlayerIndexCollectibleType(self, player, differentiateForgottenAndSo
113
118
  end
114
119
  function ____exports.getPlayerMaxHeartContainers(self, player)
115
120
  local character = player:GetPlayerType()
116
- local maxHeartContainers = ____exports.getCharacterMaxHeartContainers(nil, character)
121
+ local characterMaxHeartContainers = ____exports.getCharacterMaxHeartContainers(nil, character)
117
122
  if character == PlayerType.PLAYER_MAGDALENE and player:HasCollectible(CollectibleType.COLLECTIBLE_BIRTHRIGHT) then
118
- maxHeartContainers = maxHeartContainers + 6
123
+ local extraMaxHeartContainersFromBirthright = 6
124
+ return characterMaxHeartContainers + extraMaxHeartContainersFromBirthright
119
125
  end
120
- local numMothersKisses = player:GetTrinketMultiplier(TrinketType.TRINKET_MOTHERS_KISS)
121
- maxHeartContainers = maxHeartContainers + numMothersKisses
122
- if maxHeartContainers > MAX_PLAYER_HEART_CONTAINERS then
123
- maxHeartContainers = MAX_PLAYER_HEART_CONTAINERS
126
+ if ____exports.isKeeper(nil, player) then
127
+ local numMothersKisses = player:GetTrinketMultiplier(TrinketType.TRINKET_MOTHERS_KISS)
128
+ local hasGreedsGullet = player:HasCollectible(CollectibleType.COLLECTIBLE_GREEDS_GULLET)
129
+ local coins = player:GetNumCoins()
130
+ local greedsGulletCoinContainers = hasGreedsGullet and math.floor(coins / 25) or 0
131
+ return characterMaxHeartContainers + numMothersKisses + greedsGulletCoinContainers
124
132
  end
125
- return maxHeartContainers
133
+ return characterMaxHeartContainers
126
134
  end
127
135
  function getAdjustedPlayerName(self, player)
128
136
  local character = player:GetPlayerType()
129
137
  repeat
130
- local ____switch79 = character
131
- local ____cond79 = ____switch79 == PlayerType.PLAYER_BLUEBABY or ____switch79 == PlayerType.PLAYER_BLUEBABY_B
132
- if ____cond79 then
138
+ local ____switch81 = character
139
+ local ____cond81 = ____switch81 == PlayerType.PLAYER_BLUEBABY or ____switch81 == PlayerType.PLAYER_BLUEBABY_B
140
+ if ____cond81 then
133
141
  do
134
142
  return "Blue Baby"
135
143
  end
136
144
  end
137
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_LAZARUS2
138
- if ____cond79 then
145
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_LAZARUS2
146
+ if ____cond81 then
139
147
  do
140
148
  return "Lazarus II"
141
149
  end
142
150
  end
143
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_BLACKJUDAS
144
- if ____cond79 then
151
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_BLACKJUDAS
152
+ if ____cond81 then
145
153
  do
146
154
  return "Dark Judas"
147
155
  end
148
156
  end
149
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_JACOB
150
- if ____cond79 then
157
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_JACOB
158
+ if ____cond81 then
151
159
  do
152
160
  return "Jacob & Esau"
153
161
  end
154
162
  end
155
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_LAZARUS2_B
156
- if ____cond79 then
163
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_LAZARUS2_B
164
+ if ____cond81 then
157
165
  do
158
166
  return "Dead Tainted Lazarus"
159
167
  end
160
168
  end
161
- ____cond79 = ____cond79 or ____switch79 == PlayerType.PLAYER_JACOB2_B
162
- if ____cond79 then
169
+ ____cond81 = ____cond81 or ____switch81 == PlayerType.PLAYER_JACOB2_B
170
+ if ____cond81 then
163
171
  do
164
172
  return "Dead Tainted Jacob"
165
173
  end
@@ -207,6 +215,10 @@ end
207
215
  function ____exports.isChildPlayer(self, player)
208
216
  return player.Parent ~= nil
209
217
  end
218
+ function ____exports.isKeeper(self, player)
219
+ local character = player:GetPlayerType()
220
+ return character == PlayerType.PLAYER_KEEPER or character == PlayerType.PLAYER_KEEPER_B
221
+ end
210
222
  function ____exports.isTainted(self, player)
211
223
  local character = player:GetPlayerType()
212
224
  local ____isVanillaCharacter_result_1
@@ -532,10 +544,6 @@ function ____exports.isJacobOrEsau(self, player)
532
544
  local character = player:GetPlayerType()
533
545
  return character == PlayerType.PLAYER_JACOB or character == PlayerType.PLAYER_ESAU
534
546
  end
535
- function ____exports.isKeeper(self, player)
536
- local character = player:GetPlayerType()
537
- return character == PlayerType.PLAYER_KEEPER or character == PlayerType.PLAYER_KEEPER_B
538
- end
539
547
  function ____exports.isLost(self, player)
540
548
  local character = player:GetPlayerType()
541
549
  return character == PlayerType.PLAYER_THELOST or character == PlayerType.PLAYER_THELOST_B
@@ -589,9 +597,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
589
597
  itemPool:RemoveCollectible(collectibleType)
590
598
  end
591
599
  repeat
592
- local ____switch125 = activeSlot
593
- local ____cond125 = ____switch125 == ActiveSlot.SLOT_PRIMARY
594
- if ____cond125 then
600
+ local ____switch127 = activeSlot
601
+ local ____cond127 = ____switch127 == ActiveSlot.SLOT_PRIMARY
602
+ if ____cond127 then
595
603
  do
596
604
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
597
605
  player:RemoveCollectible(primaryCollectibleType)
@@ -600,8 +608,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
600
608
  break
601
609
  end
602
610
  end
603
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_SECONDARY
604
- if ____cond125 then
611
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_SECONDARY
612
+ if ____cond127 then
605
613
  do
606
614
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
607
615
  player:RemoveCollectible(primaryCollectibleType)
@@ -616,16 +624,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
616
624
  break
617
625
  end
618
626
  end
619
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_POCKET
620
- if ____cond125 then
627
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_POCKET
628
+ if ____cond127 then
621
629
  do
622
630
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
623
631
  player:SetActiveCharge(charge, activeSlot)
624
632
  break
625
633
  end
626
634
  end
627
- ____cond125 = ____cond125 or ____switch125 == ActiveSlot.SLOT_POCKET2
628
- if ____cond125 then
635
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_POCKET2
636
+ if ____cond127 then
629
637
  do
630
638
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
631
639
  break
@@ -14,7 +14,10 @@ export declare function getAllRoomGridIndexes(): int[];
14
14
  * tricky to properly detect.
15
15
  */
16
16
  export declare function getCurrentDimension(): Dimension;
17
- /** Alias for the `Level.GetCurrentRoomDesc()` method. */
17
+ /**
18
+ * Alias for the `Level.GetCurrentRoomDesc()` method. Use this to make it more clear what type of
19
+ * `RoomDescriptor` object that you are retrieving.
20
+ */
18
21
  export declare function getCurrentRoomDescriptorReadOnly(): RoomDescriptorReadOnly;
19
22
  /**
20
23
  * Helper function to get the room data for the provided room.
@@ -25,9 +28,10 @@ export declare function getRoomData(roomGridIndex?: int): RoomConfig | undefined
25
28
  /**
26
29
  * Helper function for getting the type of the room with the given grid index.
27
30
  *
31
+ * @param roomGridIndex Optional. Equal to the current room index by default.
28
32
  * @returns The room data type. Returns -1 if the type was not found.
29
33
  */
30
- export declare function getRoomType(roomGridIndex: int): RoomType;
34
+ export declare function getRoomType(roomGridIndex?: int): RoomType;
31
35
  /**
32
36
  * Helper function to get the descriptor for a room.
33
37
  *
@@ -174,9 +178,9 @@ export declare function inMegaSatanRoom(): boolean;
174
178
  */
175
179
  export declare function inMinibossRoomOf(minibossID: MinibossID): boolean;
176
180
  /**
177
- * Helper function for checking if the room room is a secret shop from the Member Card collectible.
181
+ * Helper function for checking if the room is a secret shop (from the Member Card collectible).
178
182
  *
179
- * Secret shops are simply copies of normal shops but with the backdrop of a secret room. In other
183
+ * Secret shops are simply copies of normal shops, but with the backdrop of a secret room. In other
180
184
  * words, they will have the same room type, room variant, and room sub-type of a normal shop. Thus,
181
185
  * the only way to detect them is by using the grid index.
182
186
  */
@@ -1,17 +1,14 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
4
- local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
5
- local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
- local __TS__ArrayPush = ____lualib.__TS__ArrayPush
7
4
  local Set = ____lualib.Set
8
5
  local __TS__New = ____lualib.__TS__New
6
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
7
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
9
8
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
10
9
  local Map = ____lualib.Map
11
10
  local ____exports = {}
12
11
  local ____constants = require("constants")
13
- local GENESIS_ROOM_SUBTYPE = ____constants.GENESIS_ROOM_SUBTYPE
14
- local GENESIS_ROOM_VARIANT = ____constants.GENESIS_ROOM_VARIANT
15
12
  local MAX_ROOM_INDEX = ____constants.MAX_ROOM_INDEX
16
13
  local NUM_DIMENSIONS = ____constants.NUM_DIMENSIONS
17
14
  local ____doors = require("functions.doors")
@@ -43,11 +40,20 @@ function ____exports.getRoomDescriptor(self, roomGridIndex)
43
40
  local game = Game()
44
41
  local level = game:GetLevel()
45
42
  if roomGridIndex == nil then
46
- local currentRoomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
47
- roomGridIndex = currentRoomDescriptor.SafeGridIndex
43
+ roomGridIndex = ____exports.getRoomGridIndex(nil)
48
44
  end
49
45
  return level:GetRoomByIdx(roomGridIndex)
50
46
  end
47
+ function ____exports.getRoomGridIndex(self)
48
+ local game = Game()
49
+ local level = game:GetLevel()
50
+ local currentRoomIndex = level:GetCurrentRoomIndex()
51
+ if currentRoomIndex < 0 then
52
+ return currentRoomIndex
53
+ end
54
+ local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
55
+ return roomDescriptor.SafeGridIndex
56
+ end
51
57
  function ____exports.getRoomStageID(self, roomGridIndex)
52
58
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
53
59
  return roomData == nil and -1 or roomData.StageID
@@ -133,22 +139,12 @@ function ____exports.getRoomType(self, roomGridIndex)
133
139
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
134
140
  return roomData == nil and -1 or roomData.Type
135
141
  end
136
- function ____exports.getRoomGridIndex(self)
137
- local game = Game()
138
- local level = game:GetLevel()
139
- local currentRoomIndex = level:GetCurrentRoomIndex()
140
- if currentRoomIndex < 0 then
141
- return currentRoomIndex
142
- end
143
- local roomDescriptor = ____exports.getCurrentRoomDescriptorReadOnly(nil)
144
- return roomDescriptor.SafeGridIndex
145
- end
146
142
  function ____exports.getRoomGridIndexesForType(self, ...)
147
- local roomTypes = {...}
143
+ local roomTypesSet = __TS__New(Set, {...})
148
144
  local rooms = ____exports.getRooms(nil)
149
145
  local matchingRooms = __TS__ArrayFilter(
150
146
  rooms,
151
- function(____, roomDescriptor) return roomDescriptor.Data ~= nil and __TS__ArrayIncludes(roomTypes, roomDescriptor.Data.Type) end
147
+ function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypesSet:has(roomDescriptor.Data.Type) end
152
148
  )
153
149
  return __TS__ArrayMap(
154
150
  matchingRooms,
@@ -239,9 +235,8 @@ function ____exports.inGenesisRoom(self)
239
235
  local game = Game()
240
236
  local room = game:GetRoom()
241
237
  local roomType = room:GetType()
242
- local roomVariant = ____exports.getRoomVariant(nil)
243
238
  local roomSubType = ____exports.getRoomSubType(nil)
244
- return roomType == RoomType.ROOM_ISAACS and roomVariant == GENESIS_ROOM_VARIANT and roomSubType == GENESIS_ROOM_SUBTYPE
239
+ return roomType == RoomType.ROOM_ISAACS and roomSubType == 99
245
240
  end
246
241
  function ____exports.inMegaSatanRoom(self)
247
242
  local roomGridIndex = ____exports.getRoomGridIndex(nil)
@@ -20,3 +20,18 @@ export declare function combineSets<T>(...sets: Array<Set<T> | ReadonlySet<T>>):
20
20
  * This function is variadic, meaning that you can specify N sets to remove from the first set.
21
21
  */
22
22
  export declare function deleteSetsFromSet<T>(mainSet: Set<T>, ...setsToRemove: Array<Set<T> | ReadonlySet<T>>): void;
23
+ /**
24
+ * Helper function to get a random element from the provided set.
25
+ *
26
+ * @param set The set to get an element from.
27
+ * @param seed Optional. The seed used to select the random element. `Random()` by default.
28
+ * @param exceptions Optional. An array of elements to skip over if selected.
29
+ */
30
+ export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, seed?: number, exceptions?: T[] | readonly T[]): T;
31
+ /**
32
+ * Helper function to get a sorted array based on the contents of a set.
33
+ *
34
+ * Normally, set values are returned in a random order, so use this function when the ordering of
35
+ * the contents is important.
36
+ */
37
+ export declare function getSortedSetValues<T>(set: Set<T> | ReadonlySet<T>): T[];
@@ -3,7 +3,17 @@ local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__Iterator = ____lualib.__TS__Iterator
5
5
  local __TS__New = ____lualib.__TS__New
6
+ local __TS__Spread = ____lualib.__TS__Spread
7
+ local __TS__ArraySort = ____lualib.__TS__ArraySort
6
8
  local ____exports = {}
9
+ local ____array = require("functions.array")
10
+ local getRandomArrayElement = ____array.getRandomArrayElement
11
+ function ____exports.getSortedSetValues(self, set)
12
+ local values = set:values()
13
+ local array = {__TS__Spread(values)}
14
+ __TS__ArraySort(array)
15
+ return array
16
+ end
7
17
  function ____exports.addSetsToSet(self, mainSet, ...)
8
18
  local setsToAdd = {...}
9
19
  for ____, set in ipairs(setsToAdd) do
@@ -37,4 +47,14 @@ function ____exports.deleteSetsFromSet(self, mainSet, ...)
37
47
  end
38
48
  end
39
49
  end
50
+ function ____exports.getRandomSetElement(self, set, seed, exceptions)
51
+ if seed == nil then
52
+ seed = Random()
53
+ end
54
+ if exceptions == nil then
55
+ exceptions = {}
56
+ end
57
+ local array = ____exports.getSortedSetValues(nil, set)
58
+ return getRandomArrayElement(nil, array, seed, exceptions)
59
+ end
40
60
  return ____exports
@@ -1,7 +1,9 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /**
3
- * Helper function to clear a specific layer from a sprite. This function is variadic, so pass as
4
- * many layer IDs as you want to clear. If no specific layers are passed, it will clear every layer.
3
+ * Helper function to clear a specific layer from a sprite.
4
+ *
5
+ * This function is variadic, so pass as many layer IDs as you want to clear. If no specific layers
6
+ * are passed, it will clear every layer.
5
7
  *
6
8
  * Since there is no official API method to "clear" a sprite, we can work around it by setting the
7
9
  * spritesheet to a non-existent or completely transparent file. If the path to the spritesheet does
@@ -7,6 +7,8 @@ local __TS__Iterator = ____lualib.__TS__Iterator
7
7
  local ____exports = {}
8
8
  local ____transformationNameMap = require("maps.transformationNameMap")
9
9
  local TRANSFORMATION_NAME_MAP = ____transformationNameMap.TRANSFORMATION_NAME_MAP
10
+ local ____DefaultMap = require("types.DefaultMap")
11
+ local DefaultMap = ____DefaultMap.DefaultMap
10
12
  local ____collectibles = require("functions.collectibles")
11
13
  local collectibleHasTag = ____collectibles.collectibleHasTag
12
14
  local getMaxCollectibleType = ____collectibles.getMaxCollectibleType
@@ -31,8 +33,11 @@ local TRANSFORMATION_TO_TAG_MAP = __TS__New(Map, {
31
33
  local TRANSFORMATIONS_NOT_BASED_ON_ITEMS = __TS__New(Set, {PlayerForm.PLAYERFORM_ADULTHOOD, PlayerForm.PLAYERFORM_STOMPY, PlayerForm.PLAYERFORM_FLIGHT})
32
34
  local TRANSFORMATIONS_THAT_GRANT_FLYING = __TS__New(Set, {PlayerForm.PLAYERFORM_GUPPY, PlayerForm.PLAYERFORM_LORD_OF_THE_FLIES, PlayerForm.PLAYERFORM_ANGEL, PlayerForm.PLAYERFORM_EVIL_ANGEL})
33
35
  local TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP = __TS__New(Map)
34
- local COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP = __TS__New(Map)
35
- local function initMaps(self)
36
+ local COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP = __TS__New(
37
+ DefaultMap,
38
+ function() return __TS__New(Set) end
39
+ )
40
+ local function initTransformationMaps(self)
36
41
  local maxCollectibleType = getMaxCollectibleType(nil)
37
42
  for ____, playerForm in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:keys()) do
38
43
  TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:set(
@@ -46,27 +51,23 @@ local function initMaps(self)
46
51
  local tag = ____value[2]
47
52
  do
48
53
  if not collectibleHasTag(nil, collectibleType, tag) then
49
- goto __continue6
54
+ goto __continue7
50
55
  end
51
56
  local collectibleTypesSet = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
52
57
  if collectibleTypesSet == nil then
53
58
  error("Failed to get the collectible types for transformation: " .. tostring(playerForm))
54
59
  end
55
60
  collectibleTypesSet:add(collectibleType)
56
- local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:get(collectibleType)
57
- if transformations == nil then
58
- transformations = __TS__New(Set)
59
- COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:set(collectibleType, transformations)
60
- end
61
+ local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:getAndSetDefault(collectibleType)
61
62
  transformations:add(playerForm)
62
63
  end
63
- ::__continue6::
64
+ ::__continue7::
64
65
  end
65
66
  end
66
67
  end
67
68
  function ____exports.getCollectibleTypesForTransformation(self, playerForm)
68
69
  if TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP.size == 0 then
69
- initMaps(nil)
70
+ initTransformationMaps(nil)
70
71
  end
71
72
  local collectibleTypes = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
72
73
  return collectibleTypes == nil and __TS__New(Set) or copySet(nil, collectibleTypes)
@@ -76,7 +77,7 @@ function ____exports.getPlayerNumTransformationCollectibles(self, player, player
76
77
  error(("The transformation of " .. tostring(playerForm)) .. " cannot be tracked by this function.")
77
78
  end
78
79
  if TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP.size == 0 then
79
- initMaps(nil)
80
+ initTransformationMaps(nil)
80
81
  end
81
82
  local itemsForTransformation = TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:get(playerForm)
82
83
  if itemsForTransformation == nil then
@@ -95,7 +96,7 @@ function ____exports.getTransformationName(self, playerForm)
95
96
  end
96
97
  function ____exports.getTransformationsForCollectibleType(self, collectibleType)
97
98
  if COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP.size == 0 then
98
- initMaps(nil)
99
+ initTransformationMaps(nil)
99
100
  end
100
101
  local transformations = COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP:get(collectibleType)
101
102
  return transformations == nil and __TS__New(Set) or copySet(nil, transformations)
package/dist/index.d.ts CHANGED
@@ -77,9 +77,9 @@ export * from "./maps/roomShapeToTopLeftWallGridIndexMap";
77
77
  export * from "./maps/transformationNameMap";
78
78
  export * from "./maps/trinketDescriptionMap";
79
79
  export * from "./maps/trinketNameMap";
80
- export * from "./sets/cards";
81
80
  export * from "./types/AnyEntity";
82
81
  export * from "./types/CallbackParametersCustom";
82
+ export * from "./types/CardType";
83
83
  export * from "./types/DefaultMap";
84
84
  export * from "./types/HealthType";
85
85
  export * from "./types/JSONDoor";
package/dist/index.lua CHANGED
@@ -627,7 +627,7 @@ do
627
627
  end
628
628
  end
629
629
  do
630
- local ____export = require("sets.cards")
630
+ local ____export = require("types.CardType")
631
631
  for ____exportKey, ____exportValue in pairs(____export) do
632
632
  if ____exportKey ~= "default" then
633
633
  ____exports[____exportKey] = ____exportValue
@@ -0,0 +1,4 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ import { CardType } from "../types/CardType";
3
+ export declare const CARD_TYPE_MAP: ReadonlyMap<Card, CardType>;
4
+ export declare const DEFAULT_CARD_TYPE = CardType.MODDED;
@@ -0,0 +1,108 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Map = ____lualib.Map
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local ____CardType = require("types.CardType")
7
+ local CardType = ____CardType.CardType
8
+ ____exports.CARD_TYPE_MAP = __TS__New(Map, {
9
+ {Card.CARD_FOOL, CardType.TAROT},
10
+ {Card.CARD_MAGICIAN, CardType.TAROT},
11
+ {Card.CARD_HIGH_PRIESTESS, CardType.TAROT},
12
+ {Card.CARD_EMPRESS, CardType.TAROT},
13
+ {Card.CARD_EMPEROR, CardType.TAROT},
14
+ {Card.CARD_HIEROPHANT, CardType.TAROT},
15
+ {Card.CARD_LOVERS, CardType.TAROT},
16
+ {Card.CARD_CHARIOT, CardType.TAROT},
17
+ {Card.CARD_JUSTICE, CardType.TAROT},
18
+ {Card.CARD_HERMIT, CardType.TAROT},
19
+ {Card.CARD_WHEEL_OF_FORTUNE, CardType.TAROT},
20
+ {Card.CARD_STRENGTH, CardType.TAROT},
21
+ {Card.CARD_HANGED_MAN, CardType.TAROT},
22
+ {Card.CARD_DEATH, CardType.TAROT},
23
+ {Card.CARD_TEMPERANCE, CardType.TAROT},
24
+ {Card.CARD_DEVIL, CardType.TAROT},
25
+ {Card.CARD_TOWER, CardType.TAROT},
26
+ {Card.CARD_STARS, CardType.TAROT},
27
+ {Card.CARD_MOON, CardType.TAROT},
28
+ {Card.CARD_SUN, CardType.TAROT},
29
+ {Card.CARD_JUDGEMENT, CardType.TAROT},
30
+ {Card.CARD_WORLD, CardType.TAROT},
31
+ {Card.CARD_CLUBS_2, CardType.SUIT},
32
+ {Card.CARD_DIAMONDS_2, CardType.SUIT},
33
+ {Card.CARD_SPADES_2, CardType.SUIT},
34
+ {Card.CARD_HEARTS_2, CardType.SUIT},
35
+ {Card.CARD_ACE_OF_CLUBS, CardType.SUIT},
36
+ {Card.CARD_ACE_OF_DIAMONDS, CardType.SUIT},
37
+ {Card.CARD_ACE_OF_SPADES, CardType.SUIT},
38
+ {Card.CARD_ACE_OF_HEARTS, CardType.SUIT},
39
+ {Card.CARD_JOKER, CardType.SUIT},
40
+ {Card.RUNE_HAGALAZ, CardType.RUNE},
41
+ {Card.RUNE_JERA, CardType.RUNE},
42
+ {Card.RUNE_EHWAZ, CardType.RUNE},
43
+ {Card.RUNE_DAGAZ, CardType.RUNE},
44
+ {Card.RUNE_ANSUZ, CardType.RUNE},
45
+ {Card.RUNE_PERTHRO, CardType.RUNE},
46
+ {Card.RUNE_BERKANO, CardType.RUNE},
47
+ {Card.RUNE_ALGIZ, CardType.RUNE},
48
+ {Card.RUNE_BLANK, CardType.RUNE},
49
+ {Card.RUNE_BLACK, CardType.RUNE},
50
+ {Card.CARD_CHAOS, CardType.SPECIAL},
51
+ {Card.CARD_CREDIT, CardType.SPECIAL},
52
+ {Card.CARD_RULES, CardType.SPECIAL},
53
+ {Card.CARD_HUMANITY, CardType.SPECIAL},
54
+ {Card.CARD_SUICIDE_KING, CardType.SPECIAL},
55
+ {Card.CARD_GET_OUT_OF_JAIL, CardType.SPECIAL},
56
+ {Card.CARD_QUESTIONMARK, CardType.SPECIAL},
57
+ {Card.CARD_DICE_SHARD, CardType.OBJECT},
58
+ {Card.CARD_EMERGENCY_CONTACT, CardType.OBJECT},
59
+ {Card.CARD_HOLY, CardType.SPECIAL},
60
+ {Card.CARD_HUGE_GROWTH, CardType.SPECIAL},
61
+ {Card.CARD_ANCIENT_RECALL, CardType.SPECIAL},
62
+ {Card.CARD_ERA_WALK, CardType.SPECIAL},
63
+ {Card.RUNE_SHARD, CardType.RUNE},
64
+ {Card.CARD_REVERSE_FOOL, CardType.TAROT_REVERSE},
65
+ {Card.CARD_REVERSE_MAGICIAN, CardType.TAROT_REVERSE},
66
+ {Card.CARD_REVERSE_HIGH_PRIESTESS, CardType.TAROT_REVERSE},
67
+ {Card.CARD_REVERSE_EMPRESS, CardType.TAROT_REVERSE},
68
+ {Card.CARD_REVERSE_EMPEROR, CardType.TAROT_REVERSE},
69
+ {Card.CARD_REVERSE_HIEROPHANT, CardType.TAROT_REVERSE},
70
+ {Card.CARD_REVERSE_LOVERS, CardType.TAROT_REVERSE},
71
+ {Card.CARD_REVERSE_CHARIOT, CardType.TAROT_REVERSE},
72
+ {Card.CARD_REVERSE_JUSTICE, CardType.TAROT_REVERSE},
73
+ {Card.CARD_REVERSE_HERMIT, CardType.TAROT_REVERSE},
74
+ {Card.CARD_REVERSE_WHEEL_OF_FORTUNE, CardType.TAROT_REVERSE},
75
+ {Card.CARD_REVERSE_STRENGTH, CardType.TAROT_REVERSE},
76
+ {Card.CARD_REVERSE_HANGED_MAN, CardType.TAROT_REVERSE},
77
+ {Card.CARD_REVERSE_DEATH, CardType.TAROT_REVERSE},
78
+ {Card.CARD_REVERSE_TEMPERANCE, CardType.TAROT_REVERSE},
79
+ {Card.CARD_REVERSE_DEVIL, CardType.TAROT_REVERSE},
80
+ {Card.CARD_REVERSE_TOWER, CardType.TAROT_REVERSE},
81
+ {Card.CARD_REVERSE_STARS, CardType.TAROT_REVERSE},
82
+ {Card.CARD_REVERSE_MOON, CardType.TAROT_REVERSE},
83
+ {Card.CARD_REVERSE_SUN, CardType.TAROT_REVERSE},
84
+ {Card.CARD_REVERSE_JUDGEMENT, CardType.TAROT_REVERSE},
85
+ {Card.CARD_REVERSE_WORLD, CardType.TAROT_REVERSE},
86
+ {Card.CARD_CRACKED_KEY, CardType.OBJECT},
87
+ {Card.CARD_QUEEN_OF_HEARTS, CardType.SUIT},
88
+ {Card.CARD_WILD, CardType.SPECIAL},
89
+ {Card.CARD_SOUL_ISAAC, CardType.RUNE},
90
+ {Card.CARD_SOUL_MAGDALENE, CardType.RUNE},
91
+ {Card.CARD_SOUL_CAIN, CardType.RUNE},
92
+ {Card.CARD_SOUL_JUDAS, CardType.RUNE},
93
+ {Card.CARD_SOUL_BLUEBABY, CardType.RUNE},
94
+ {Card.CARD_SOUL_EVE, CardType.RUNE},
95
+ {Card.CARD_SOUL_SAMSON, CardType.RUNE},
96
+ {Card.CARD_SOUL_AZAZEL, CardType.RUNE},
97
+ {Card.CARD_SOUL_LAZARUS, CardType.RUNE},
98
+ {Card.CARD_SOUL_EDEN, CardType.RUNE},
99
+ {Card.CARD_SOUL_LOST, CardType.RUNE},
100
+ {Card.CARD_SOUL_LILITH, CardType.RUNE},
101
+ {Card.CARD_SOUL_KEEPER, CardType.RUNE},
102
+ {Card.CARD_SOUL_APOLLYON, CardType.RUNE},
103
+ {Card.CARD_SOUL_FORGOTTEN, CardType.RUNE},
104
+ {Card.CARD_SOUL_BETHANY, CardType.RUNE},
105
+ {Card.CARD_SOUL_JACOB, CardType.RUNE}
106
+ })
107
+ ____exports.DEFAULT_CARD_TYPE = CardType.MODDED
108
+ return ____exports
@@ -0,0 +1,38 @@
1
+ /** Matches the "type" attribute in the "pocketitems.xml" file. */
2
+ export declare enum CardType {
3
+ /** A normal card with a brown back, like "0 - The Fool". */
4
+ TAROT = 0,
5
+ /** A playing card with a red back, like 2 of Clubs. This includes the Queen of Hearts. */
6
+ SUIT = 1,
7
+ /**
8
+ * A left-facing rune like Hagalaz, a right-facing rune like Ansuz, a Black Rune, a Blank Rune, a
9
+ * a Rune Shard, or a "soul" rune like Soul of Isaac.
10
+ */
11
+ RUNE = 2,
12
+ /**
13
+ * A card that does not fall into any of the other categories, like a Chaos Card (42).
14
+ *
15
+ * Most of these have unique backs.
16
+ *
17
+ * 4 cards share the Magic the Gathering back:
18
+ * - Chaos Card (42)
19
+ * - Huge Growth (52)
20
+ * - Ancient Recall (53)
21
+ * - Era Walk (54)
22
+ *
23
+ * 3 cards have a red playing card back:
24
+ * - Rules Card (44)
25
+ * - Suicide King (46)
26
+ * - ? Card (48)
27
+ */
28
+ SPECIAL = 3,
29
+ /** A Dice Shard, an Emergency Contact, or a Cracked Key. */
30
+ OBJECT = 4,
31
+ /** A reverse tarot card with a reddish-brown back, like "0 - The Fool?". */
32
+ TAROT_REVERSE = 5,
33
+ /**
34
+ * This is not a real CardType. Due to limitations in the API, getting the real type of modded
35
+ * cards is not possible, so this value is returned instead.
36
+ */
37
+ MODDED = 6
38
+ }
@@ -0,0 +1,18 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ ____exports.CardType = CardType or ({})
4
+ ____exports.CardType.TAROT = 0
5
+ ____exports.CardType[____exports.CardType.TAROT] = "TAROT"
6
+ ____exports.CardType.SUIT = 1
7
+ ____exports.CardType[____exports.CardType.SUIT] = "SUIT"
8
+ ____exports.CardType.RUNE = 2
9
+ ____exports.CardType[____exports.CardType.RUNE] = "RUNE"
10
+ ____exports.CardType.SPECIAL = 3
11
+ ____exports.CardType[____exports.CardType.SPECIAL] = "SPECIAL"
12
+ ____exports.CardType.OBJECT = 4
13
+ ____exports.CardType[____exports.CardType.OBJECT] = "OBJECT"
14
+ ____exports.CardType.TAROT_REVERSE = 5
15
+ ____exports.CardType[____exports.CardType.TAROT_REVERSE] = "TAROT_REVERSE"
16
+ ____exports.CardType.MODDED = 6
17
+ ____exports.CardType[____exports.CardType.MODDED] = "MODDED"
18
+ return ____exports
@@ -0,0 +1,18 @@
1
+ export interface SaveData {
2
+ persistent?: Record<string, unknown>;
3
+ run?: Record<string, unknown>;
4
+ level?: Record<string, unknown>;
5
+ room?: Record<string, unknown>;
6
+ dontSave?: boolean;
7
+ }
8
+ export interface SaveDataWithoutRoom {
9
+ persistent?: Record<string, unknown>;
10
+ run?: Record<string, unknown>;
11
+ level?: Record<string, unknown>;
12
+ }
13
+ export declare enum SaveDataKeys {
14
+ Persistent = "persistent",
15
+ Run = "run",
16
+ Level = "level",
17
+ Room = "room"
18
+ }
@@ -0,0 +1,8 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ ____exports.SaveDataKeys = SaveDataKeys or ({})
4
+ ____exports.SaveDataKeys.Persistent = "persistent"
5
+ ____exports.SaveDataKeys.Run = "run"
6
+ ____exports.SaveDataKeys.Level = "level"
7
+ ____exports.SaveDataKeys.Room = "room"
8
+ return ____exports