isaacscript-common 1.2.102 → 1.2.105

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 (39) 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/rooms.d.ts +7 -2
  24. package/dist/functions/rooms.lua +22 -23
  25. package/dist/functions/set.d.ts +15 -0
  26. package/dist/functions/set.lua +20 -0
  27. package/dist/functions/sprite.d.ts +4 -2
  28. package/dist/functions/transformations.lua +13 -12
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.lua +1 -1
  31. package/dist/maps/cardTypeMap.d.ts +4 -0
  32. package/dist/maps/cardTypeMap.lua +108 -0
  33. package/dist/types/CardType.d.ts +38 -0
  34. package/dist/types/CardType.lua +18 -0
  35. package/dist/types/private/SaveData.d.ts +18 -0
  36. package/dist/types/private/SaveData.lua +8 -0
  37. package/dist/types/private/SerializationBrand.d.ts +15 -0
  38. package/dist/types/private/SerializationBrand.lua +24 -0
  39. package/package.json +1 -1
@@ -63,8 +63,6 @@ export declare const FINAL_STAGE: number;
63
63
  * second TMTRAINER item subtracts one from that, and so on.
64
64
  */
65
65
  export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: number;
66
- export declare const GENESIS_ROOM_VARIANT = -1;
67
- export declare const GENESIS_ROOM_SUBTYPE = -1;
68
66
  export declare const GOLDEN_TRINKET_SHIFT: number;
69
67
  export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
70
68
  export declare const GAME_FRAMES_PER_SECOND = 30;
@@ -79,8 +79,6 @@ ____exports.FAMILIARS_THAT_SHOOT_PLAYER_TEARS = __TS__New(Set, {
79
79
  })
80
80
  ____exports.FINAL_STAGE = LevelStage.NUM_STAGES - 1
81
81
  ____exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = (1 << 32) - 1
82
- ____exports.GENESIS_ROOM_VARIANT = -1
83
- ____exports.GENESIS_ROOM_SUBTYPE = -1
84
82
  ____exports.GOLDEN_TRINKET_SHIFT = 1 << 15
85
83
  ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67
86
84
  ____exports.GAME_FRAMES_PER_SECOND = 30
@@ -1,4 +1,4 @@
1
- import { SaveData } from "../../types/SaveData";
1
+ import { SaveData } from "../../types/private/SaveData";
2
2
  /**
3
3
  * This is the entry point to the save data manager, a system which provides two major features:
4
4
  *
@@ -1,4 +1,4 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
- import { SaveData } from "../../types/SaveData";
3
+ import { SaveData } from "../../types/private/SaveData";
4
4
  export declare function loadFromDisk(mod: Mod, oldSaveData: LuaTable<string, SaveData>): void;
@@ -12,7 +12,7 @@ local ____table = require("functions.table")
12
12
  local clearTable = ____table.clearTable
13
13
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
14
14
  local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
15
- local ____SaveData = require("types.SaveData")
15
+ local ____SaveData = require("types.private.SaveData")
16
16
  local SaveDataKeys = ____SaveData.SaveDataKeys
17
17
  local ____load = require("features.saveDataManager.load")
18
18
  local loadFromDisk = ____load.loadFromDisk
@@ -1,5 +1,5 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
- import { SaveData } from "../../types/SaveData";
2
+ import { SaveData } from "../../types/private/SaveData";
3
3
  export declare const saveDataMap: LuaTable<string, SaveData>;
4
4
  export declare const saveDataDefaultsMap: LuaTable<string, SaveData>;
5
5
  export declare const saveDataConditionalFuncMap: Map<string, () => boolean>;
@@ -17,7 +17,7 @@ local ____log = require("functions.log")
17
17
  local log = ____log.log
18
18
  local ____table = require("functions.table")
19
19
  local clearTable = ____table.clearTable
20
- local ____SerializationBrand = require("types.SerializationBrand")
20
+ local ____SerializationBrand = require("types.private.SerializationBrand")
21
21
  local isSerializationBrand = ____SerializationBrand.isSerializationBrand
22
22
  local SerializationBrand = ____SerializationBrand.SerializationBrand
23
23
  local ____debug = require("features.saveDataManager.debug")
@@ -1,4 +1,4 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
- import { SaveData } from "../../types/SaveData";
3
+ import { SaveData } from "../../types/private/SaveData";
4
4
  export declare function saveToDisk(mod: Mod, saveDataMap: LuaTable<string, SaveData>, saveDataConditionalFuncMap: Map<string, () => boolean>): void;
@@ -7,10 +7,12 @@
7
7
  export declare function arrayEquals<T>(array1: T[] | readonly T[], array2: T[] | readonly T[]): boolean;
8
8
  /**
9
9
  * Helper function to combine two or more arrays. Returns a new array that is the composition of all
10
- * of the specified arrays. This function is variadic, meaning that you can specify N arguments to
11
- * combine N arrays. Note that this will only perform a shallow copy of the array elements.
10
+ * of the specified arrays.
11
+ *
12
+ * This function is variadic, meaning that you can specify N arguments to combine N arrays. Note
13
+ * that this will only perform a shallow copy of the array elements.
12
14
  */
13
- export declare function combineArray<T>(...arrays: Array<T[] | readonly T[]>): T[];
15
+ export declare function combineArrays<T>(...arrays: Array<T[] | readonly T[]>): T[];
14
16
  /**
15
17
  * Helper function to perform a shallow copy.
16
18
  *
@@ -53,14 +55,14 @@ export declare function arrayToString<T>(array: T[]): string;
53
55
  *
54
56
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
55
57
  */
56
- export declare function arrayRemove<T>(originalArray: T[] | readonly T[], ...elements: T[]): T[];
58
+ export declare function arrayRemove<T>(originalArray: T[] | readonly T[], ...elementsToRemove: T[]): T[];
57
59
  /**
58
60
  * Removes the specified element(s) from the array. If the specified element(s) are not found in the
59
61
  * array, this function will do nothing. Returns whether or not one or more elements were removed.
60
62
  *
61
63
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
62
64
  */
63
- export declare function arrayRemoveInPlace<T>(array: T[], ...elements: T[] | readonly T[]): boolean;
65
+ export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: T[]): boolean;
64
66
  /**
65
67
  * Helper function to get a random element from the provided array.
66
68
  *
@@ -6,6 +6,8 @@ local __TS__ArraySplice = ____lualib.__TS__ArraySplice
6
6
  local __TS__ArraySome = ____lualib.__TS__ArraySome
7
7
  local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
8
8
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
9
+ local Set = ____lualib.Set
10
+ local __TS__New = ____lualib.__TS__New
9
11
  local __TS__ArrayIndexOf = ____lualib.__TS__ArrayIndexOf
10
12
  local ____exports = {}
11
13
  local ____random = require("functions.random")
@@ -49,7 +51,7 @@ function ____exports.arrayEquals(self, array1, array2)
49
51
  end
50
52
  )
51
53
  end
52
- function ____exports.combineArray(self, ...)
54
+ function ____exports.combineArrays(self, ...)
53
55
  local arrays = {...}
54
56
  local elements = {}
55
57
  for ____, array in ipairs(arrays) do
@@ -124,20 +126,20 @@ function ____exports.arrayToString(self, array)
124
126
  return ("[" .. commaSeparatedStrings) .. "]"
125
127
  end
126
128
  function ____exports.arrayRemove(self, originalArray, ...)
127
- local elements = {...}
128
- local array = ____exports.copyArray(nil, originalArray)
129
- for ____, element in ipairs(elements) do
130
- local index = __TS__ArrayIndexOf(array, element)
131
- if index > -1 then
132
- __TS__ArraySplice(array, index, 1)
129
+ local elementsToRemove = {...}
130
+ local elementsToRemoveSet = __TS__New(Set, elementsToRemove)
131
+ local array = {}
132
+ for ____, element in ipairs(originalArray) do
133
+ if not elementsToRemoveSet:has(element) then
134
+ __TS__ArrayPush(array, element)
133
135
  end
134
136
  end
135
137
  return array
136
138
  end
137
139
  function ____exports.arrayRemoveInPlace(self, array, ...)
138
- local elements = {...}
140
+ local elementsToRemove = {...}
139
141
  local removedOneOrMoreElements = false
140
- for ____, element in ipairs(elements) do
142
+ for ____, element in ipairs(elementsToRemove) do
141
143
  local index = __TS__ArrayIndexOf(array, element)
142
144
  if index > -1 then
143
145
  removedOneOrMoreElements = true
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ import { CardType } from "../types/CardType";
2
3
  /**
3
4
  * Helper function to get a card description from a Card enum value.
4
5
  *
@@ -20,13 +21,32 @@ export declare function getCardDescription(card: Card | int): string;
20
21
  */
21
22
  export declare function getCardName(card: Card | int): string;
22
23
  /**
23
- * Has an equal chance of returning any card (e.g. Fool, Reverse Fool, Wild Card, etc.). This will
24
- * not return any runes or objects like Dice Shard.
24
+ * Helper function to get a set of cards matching the type. Also see the [[`CardType`]] enum.
25
+ *
26
+ * This function is variadic, meaning that you can you can specify N card types to get a set
27
+ * containing cards that match any of the specified types.
28
+ */
29
+ export declare function getCardsOfType(...cardTypes: CardType[]): Set<Card>;
30
+ export declare function getCardType(card: Card | int): CardType;
31
+ export declare function getMaxCards(): int;
32
+ /**
33
+ * Has an equal chance of returning any card (e.g. Fool, Reverse Fool, Wild Card, etc.).
34
+ *
35
+ * This will not return:
36
+ * - any runes
37
+ * - any objects like Dice Shard
38
+ * - any modded cards.
25
39
  *
26
40
  * @param seed Optional. The seed with which to select the random card. `Random()` by default.
27
41
  * @param exceptions Optional. An array of cards to not select.
28
42
  */
29
43
  export declare function getRandomCard(seed?: number, exceptions?: Card[]): Card;
44
+ /**
45
+ * @param cardType The card type that represents the pool of cards to select from.
46
+ * @param seed Optional. The seed with which to select the random card. `Random()` by default.
47
+ * @param exceptions Optional. An array of cards to not select.
48
+ */
49
+ export declare function getRandomCardOfType(cardType: CardType, seed?: number, exceptions?: Card[]): Card;
30
50
  /**
31
51
  * Has an equal chance of returning any rune (e.g. Rune of Hagalaz, Blank Rune, Black Rune, Soul of
32
52
  * Isaac, etc.). This will never return a Rune Shard.
@@ -36,16 +56,26 @@ export declare function getRandomCard(seed?: number, exceptions?: Card[]): Card;
36
56
  */
37
57
  export declare function getRandomRune(seed?: number, exceptions?: Card[]): Card;
38
58
  /**
39
- * Returns true for entries in the Card enum that are not a rune and not an object (e.g. Fool,
40
- * Reverse Fool, Wild Card, etc.).
59
+ * Returns true for cards that have the following card type:
60
+ * - CardType.TAROT
61
+ * - CardType.SUIT
62
+ * - CardType.SPECIAL
63
+ * - CardType.TAROT_REVERSE
41
64
  */
42
65
  export declare function isCard(card: Card): boolean;
43
- /**
44
- * Returns true for entries in the Card enum that are an object (like Dice Shard).
45
- */
66
+ /** Returns whether or not the given card matches the specified card type. */
67
+ export declare function isCardType(card: Card, cardType: CardType): boolean;
68
+ /** Returns true for cards that have `CardType.MODDED`. */
69
+ export declare function isModdedCard(card: Card): boolean;
70
+ /** Returns true for cards that have `CardType.OBJECT`. */
46
71
  export declare function isPocketItemObject(card: Card): boolean;
47
- /**
48
- * Returns true for entries in the Card enum that are a rune (e.g. Rune of Hagalaz, Blank Rune,
49
- * Black Rune, Rune Shard, Soul of Isaac, etc.).
50
- */
72
+ /** Returns true for cards that have `CardType.TAROT`. */
73
+ export declare function isTarotCard(card: Card): boolean;
74
+ /** Returns true for cards that have `CardType.TAROT_REVERSE`. */
75
+ export declare function isReverseTarotCard(card: Card): boolean;
76
+ /** Returns true for cards that have `CardType.RUNE`. */
51
77
  export declare function isRune(card: Card): boolean;
78
+ /** Returns true for cards that have `CardType.SPECIAL`. */
79
+ export declare function isSpecialCard(card: Card): boolean;
80
+ /** Returns true for cards that have `CardType.SUIT`. */
81
+ export declare function isSuitCard(card: Card): boolean;
@@ -1,20 +1,79 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
- local __TS__ArrayPush = ____lualib.__TS__ArrayPush
3
+ local Map = ____lualib.Map
4
+ local __TS__New = ____lualib.__TS__New
5
+ local Set = ____lualib.Set
6
+ local __TS__Iterator = ____lualib.__TS__Iterator
4
7
  local ____exports = {}
8
+ local initCardObjects, CARD_TYPE_TO_CARDS_MAP, CARD_SET
5
9
  local ____cardDescriptionMap = require("maps.cardDescriptionMap")
6
10
  local CARD_DESCRIPTION_MAP = ____cardDescriptionMap.CARD_DESCRIPTION_MAP
7
11
  local ____cardNameMap = require("maps.cardNameMap")
8
12
  local CARD_NAME_MAP = ____cardNameMap.CARD_NAME_MAP
9
- local ____cards = require("sets.cards")
10
- local CARDS = ____cards.CARDS
11
- local CARD_SET = ____cards.CARD_SET
12
- local POCKET_ITEM_OBJECT_SET = ____cards.POCKET_ITEM_OBJECT_SET
13
- local RUNES = ____cards.RUNES
14
- local RUNE_SET = ____cards.RUNE_SET
15
- local ____array = require("functions.array")
16
- local arrayRemove = ____array.arrayRemove
17
- local getRandomArrayElement = ____array.getRandomArrayElement
13
+ local ____cardTypeMap = require("maps.cardTypeMap")
14
+ local CARD_TYPE_MAP = ____cardTypeMap.CARD_TYPE_MAP
15
+ local DEFAULT_CARD_TYPE = ____cardTypeMap.DEFAULT_CARD_TYPE
16
+ local ____CardType = require("types.CardType")
17
+ local CardType = ____CardType.CardType
18
+ local ____math = require("functions.math")
19
+ local range = ____math.range
20
+ local ____set = require("functions.set")
21
+ local addSetsToSet = ____set.addSetsToSet
22
+ local getRandomSetElement = ____set.getRandomSetElement
23
+ local ____utils = require("functions.utils")
24
+ local getEnumValues = ____utils.getEnumValues
25
+ function initCardObjects(self)
26
+ local maxCards = ____exports.getMaxCards(nil)
27
+ for ____, cardType in ipairs(getEnumValues(nil, CardType)) do
28
+ CARD_TYPE_TO_CARDS_MAP:set(
29
+ cardType,
30
+ __TS__New(Set)
31
+ )
32
+ end
33
+ for ____, card in ipairs(range(nil, 1, maxCards)) do
34
+ local cardType = ____exports.getCardType(nil, card)
35
+ local cardTypeSet = CARD_TYPE_TO_CARDS_MAP:get(cardType)
36
+ if cardTypeSet == nil then
37
+ error("Failed to get the card set for card type: " .. tostring(cardType))
38
+ end
39
+ cardTypeSet:add(card)
40
+ end
41
+ local cards = ____exports.getCardsOfType(
42
+ nil,
43
+ CardType.TAROT,
44
+ CardType.SUIT,
45
+ CardType.SPECIAL,
46
+ CardType.TAROT_REVERSE
47
+ )
48
+ addSetsToSet(nil, CARD_SET, cards)
49
+ end
50
+ function ____exports.getCardsOfType(self, ...)
51
+ local cardTypes = {...}
52
+ if CARD_TYPE_TO_CARDS_MAP.size == 0 then
53
+ initCardObjects(nil)
54
+ end
55
+ local matchingCards = __TS__New(Set)
56
+ for ____, cardType in ipairs(cardTypes) do
57
+ local cardSet = CARD_TYPE_TO_CARDS_MAP:get(cardType)
58
+ if cardSet == nil then
59
+ error("Failed to get the cards for type: " .. tostring(cardType))
60
+ end
61
+ for ____, card in __TS__Iterator(cardSet:values()) do
62
+ matchingCards:add(card)
63
+ end
64
+ end
65
+ return matchingCards
66
+ end
67
+ function ____exports.getCardType(self, card)
68
+ local cardType = CARD_TYPE_MAP:get(card)
69
+ return cardType == nil and DEFAULT_CARD_TYPE or cardType
70
+ end
71
+ function ____exports.getMaxCards(self)
72
+ local itemConfig = Isaac.GetItemConfig()
73
+ return itemConfig:GetCards().Size - 1
74
+ end
75
+ CARD_TYPE_TO_CARDS_MAP = __TS__New(Map)
76
+ CARD_SET = __TS__New(Set)
18
77
  function ____exports.getCardDescription(self, card)
19
78
  local itemConfig = Isaac.GetItemConfig()
20
79
  local defaultDescription = "Unknown"
@@ -54,12 +113,17 @@ function ____exports.getRandomCard(self, seed, exceptions)
54
113
  if exceptions == nil then
55
114
  exceptions = {}
56
115
  end
57
- local cardsWithoutExceptions = arrayRemove(
58
- nil,
59
- CARDS,
60
- table.unpack(exceptions)
61
- )
62
- return getRandomArrayElement(nil, cardsWithoutExceptions, seed)
116
+ return getRandomSetElement(nil, CARD_SET, seed, exceptions)
117
+ end
118
+ function ____exports.getRandomCardOfType(self, cardType, seed, exceptions)
119
+ if seed == nil then
120
+ seed = Random()
121
+ end
122
+ if exceptions == nil then
123
+ exceptions = {}
124
+ end
125
+ local cardSet = ____exports.getCardsOfType(nil, cardType)
126
+ return getRandomSetElement(nil, cardSet, seed, exceptions)
63
127
  end
64
128
  function ____exports.getRandomRune(self, seed, exceptions)
65
129
  if seed == nil then
@@ -68,21 +132,35 @@ function ____exports.getRandomRune(self, seed, exceptions)
68
132
  if exceptions == nil then
69
133
  exceptions = {}
70
134
  end
71
- __TS__ArrayPush(exceptions, Card.RUNE_SHARD)
72
- local runesWithoutExceptions = arrayRemove(
73
- nil,
74
- RUNES,
75
- table.unpack(exceptions)
76
- )
77
- return getRandomArrayElement(nil, runesWithoutExceptions, seed)
135
+ local runesSet = ____exports.getCardsOfType(nil, CardType.RUNE)
136
+ runesSet:delete(Card.RUNE_SHARD)
137
+ return getRandomSetElement(nil, runesSet, seed, exceptions)
78
138
  end
79
139
  function ____exports.isCard(self, card)
80
140
  return CARD_SET:has(card)
81
141
  end
142
+ function ____exports.isCardType(self, card, cardType)
143
+ return cardType == ____exports.getCardType(nil, card)
144
+ end
145
+ function ____exports.isModdedCard(self, card)
146
+ return ____exports.isCardType(nil, card, CardType.MODDED)
147
+ end
82
148
  function ____exports.isPocketItemObject(self, card)
83
- return POCKET_ITEM_OBJECT_SET:has(card)
149
+ return ____exports.isCardType(nil, card, CardType.OBJECT)
150
+ end
151
+ function ____exports.isTarotCard(self, card)
152
+ return ____exports.isCardType(nil, card, CardType.TAROT)
153
+ end
154
+ function ____exports.isReverseTarotCard(self, card)
155
+ return ____exports.isCardType(nil, card, CardType.TAROT_REVERSE)
84
156
  end
85
157
  function ____exports.isRune(self, card)
86
- return RUNE_SET:has(card)
158
+ return ____exports.isCardType(nil, card, CardType.RUNE)
159
+ end
160
+ function ____exports.isSpecialCard(self, card)
161
+ return ____exports.isCardType(nil, card, CardType.SPECIAL)
162
+ end
163
+ function ____exports.isSuitCard(self, card)
164
+ return ____exports.isCardType(nil, card, CardType.SUIT)
87
165
  end
88
166
  return ____exports
@@ -4,7 +4,6 @@ local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local Set = ____lualib.Set
6
6
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
7
- local __TS__Iterator = ____lualib.__TS__Iterator
8
7
  local ____exports = {}
9
8
  local ____collectibles = require("functions.collectibles")
10
9
  local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
@@ -13,6 +12,7 @@ local ____math = require("functions.math")
13
12
  local range = ____math.range
14
13
  local ____set = require("functions.set")
15
14
  local copySet = ____set.copySet
15
+ local getSortedSetValues = ____set.getSortedSetValues
16
16
  local ____utils = require("functions.utils")
17
17
  local getEnumValues = ____utils.getEnumValues
18
18
  local ____repeat = ____utils["repeat"]
@@ -42,7 +42,7 @@ end
42
42
  function ____exports.getPlayerCollectiblesForCacheFlag(self, player, cacheFlag)
43
43
  local collectiblesForCacheFlag = ____exports.getCollectiblesForCacheFlag(nil, cacheFlag)
44
44
  local playerCollectibles = {}
45
- for ____, collectibleType in __TS__Iterator(collectiblesForCacheFlag:values()) do
45
+ for ____, collectibleType in ipairs(getSortedSetValues(nil, collectiblesForCacheFlag)) do
46
46
  local numCollectibles = player:GetCollectibleNum(collectibleType)
47
47
  ____repeat(
48
48
  nil,
@@ -11,7 +11,7 @@ local ____debug = require("features.saveDataManager.debug")
11
11
  local SAVE_DATA_MANAGER_DEBUG = ____debug.SAVE_DATA_MANAGER_DEBUG
12
12
  local ____DefaultMap = require("types.DefaultMap")
13
13
  local DefaultMap = ____DefaultMap.DefaultMap
14
- local ____SerializationBrand = require("types.SerializationBrand")
14
+ local ____SerializationBrand = require("types.private.SerializationBrand")
15
15
  local isSerializationBrand = ____SerializationBrand.isSerializationBrand
16
16
  local SerializationBrand = ____SerializationBrand.SerializationBrand
17
17
  local ____log = require("functions.log")
@@ -8,7 +8,7 @@ local ____exports = {}
8
8
  local copiedObjectIsTable, copiedObjectHasKeyAndValueString, copiedTableHasKeyAndValueNumber, copiedTableDoesNotCoerceTypes, copiedObjectHasNoReferencesForPrimitivesForward, copiedObjectHasNoReferencesForPrimitivesBackward, copiedObjectHasNoReferencesForArray, copiedObjectHasChildObject, copiedMapIsMap, copiedMapHasValue, copiedSetIsSet, copiedSetHasValue, copiedMapHasChildMap, copiedDefaultMapHasChildDefaultMap, copiedDefaultMapHasBrand
9
9
  local ____DefaultMap = require("types.DefaultMap")
10
10
  local DefaultMap = ____DefaultMap.DefaultMap
11
- local ____SerializationBrand = require("types.SerializationBrand")
11
+ local ____SerializationBrand = require("types.private.SerializationBrand")
12
12
  local SerializationBrand = ____SerializationBrand.SerializationBrand
13
13
  local ____array = require("functions.array")
14
14
  local arrayEquals = ____array.arrayEquals
@@ -1,6 +1,17 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { AnyEntity } from "../types/AnyEntity";
3
3
  export declare function anyEntityCloserThan(entities: Entity[], position: Vector, distance: int): boolean;
4
+ /**
5
+ * Helper function to count the number of entities in room. Use this over the vanilla
6
+ * `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
7
+ * enemies.
8
+ *
9
+ * @param entityType -1 by default.
10
+ * @param variant -1 by default.
11
+ * @param subType -1 by default.
12
+ * @param ignoreFriendly False by default.
13
+ */
14
+ export declare function countEntities(entityType?: EntityType | int, variant?: number, subType?: number, ignoreFriendly?: boolean): number;
4
15
  /**
5
16
  * Given an array of entities, this helper function returns the closest one to a provided reference
6
17
  * entity.
@@ -19,6 +19,31 @@ function ____exports.anyEntityCloserThan(self, entities, position, distance)
19
19
  function(____, entity) return position:Distance(entity.Position) <= distance end
20
20
  )
21
21
  end
22
+ function ____exports.countEntities(self, entityType, variant, subType, ignoreFriendly)
23
+ if entityType == nil then
24
+ entityType = -1
25
+ end
26
+ if variant == nil then
27
+ variant = -1
28
+ end
29
+ if subType == nil then
30
+ subType = -1
31
+ end
32
+ if ignoreFriendly == nil then
33
+ ignoreFriendly = false
34
+ end
35
+ if not ignoreFriendly then
36
+ return Isaac.CountEntities(nil, entityType, variant, subType)
37
+ end
38
+ local entities = Isaac.FindByType(
39
+ entityType,
40
+ variant,
41
+ subType,
42
+ false,
43
+ ignoreFriendly
44
+ )
45
+ return #entities
46
+ end
22
47
  function ____exports.getClosestEntityTo(self, referenceEntity, entities)
23
48
  local closestEntity = nil
24
49
  local closestDistance = math.huge
@@ -15,10 +15,11 @@ local hasFlag = ____flag.hasFlag
15
15
  local ____player = require("functions.player")
16
16
  local getEffectsList = ____player.getEffectsList
17
17
  local ____rooms = require("functions.rooms")
18
+ local getRoomData = ____rooms.getRoomData
18
19
  local getRoomGridIndex = ____rooms.getRoomGridIndex
19
20
  local getRoomListIndex = ____rooms.getRoomListIndex
20
- local getRoomSubType = ____rooms.getRoomSubType
21
- local getRoomVariant = ____rooms.getRoomVariant
21
+ local ____set = require("functions.set")
22
+ local getSortedSetValues = ____set.getSortedSetValues
22
23
  local ____trinkets = require("functions.trinkets")
23
24
  local getTrinketName = ____trinkets.getTrinketName
24
25
  function ____exports.getDebugPrependString(self, msg, numParentFunctions)
@@ -130,14 +131,14 @@ function ____exports.logMap(map)
130
131
  ____exports.log("The size of the map was: " .. tostring(map.size))
131
132
  end
132
133
  function ____exports.logRoom()
133
- local game = Game()
134
- local room = game:GetRoom()
135
- local roomType = room:GetType()
136
- local roomVariant = getRoomVariant(nil)
137
- local roomSubType = getRoomSubType(nil)
138
134
  local roomGridIndex = getRoomGridIndex(nil)
139
135
  local roomListIndex = getRoomListIndex(nil)
140
- ____exports.log((((("Current room type/variant/sub-type: " .. tostring(roomType)) .. ".") .. tostring(roomVariant)) .. ".") .. tostring(roomSubType))
136
+ local roomData = getRoomData(nil)
137
+ if roomData == nil then
138
+ ____exports.log("Current room data is undefined.")
139
+ else
140
+ ____exports.log((((("Current room type/variant/sub-type: " .. tostring(roomData.Type)) .. ".") .. tostring(roomData.Variant)) .. ".") .. tostring(roomData.Subtype))
141
+ end
141
142
  ____exports.log("Current room grid index: " .. tostring(roomGridIndex))
142
143
  ____exports.log("Current room list index: " .. tostring(roomListIndex))
143
144
  end
@@ -190,8 +191,7 @@ function ____exports.logTemporaryEffects(player)
190
191
  end
191
192
  function ____exports.logSet(set)
192
193
  ____exports.log("Printing out a TSTL Set:")
193
- local setValues = {__TS__Spread(set:values())}
194
- __TS__ArraySort(setValues)
194
+ local setValues = getSortedSetValues(nil, set)
195
195
  for ____, value in ipairs(setValues) do
196
196
  ____exports.log(" Value: " .. tostring(value))
197
197
  end
@@ -11,13 +11,6 @@
11
11
  * ```
12
12
  */
13
13
  export declare function getPickups(matchingVariant?: PickupVariant | int, matchingSubType?: number): EntityPickup[];
14
- /**
15
- * Has as an equal chance of returning any value in the `HeartSubType` enum. Useful for spawning a random type of heart.
16
- *
17
- * @param seed Optional. The seed with which to select the random sub-type. `Random()` by default.
18
- * @param exceptions Optional. An array of sub-types to not select.
19
- */
20
- export declare function getRandomHeartSubType(seed?: number, exceptions?: HeartSubType[]): HeartSubType;
21
14
  export declare function isChest(pickup: EntityPickup): boolean;
22
15
  /**
23
16
  * Helper function to remove all of the pickups in the room.
@@ -4,13 +4,9 @@ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
4
  local ____exports = {}
5
5
  local ____constants = require("constants")
6
6
  local CHEST_PICKUP_VARIANTS = ____constants.CHEST_PICKUP_VARIANTS
7
- local ____array = require("functions.array")
8
- local getRandomArrayElement = ____array.getRandomArrayElement
9
7
  local ____entity = require("functions.entity")
10
8
  local getEntities = ____entity.getEntities
11
9
  local removeEntities = ____entity.removeEntities
12
- local ____utils = require("functions.utils")
13
- local getEnumValues = ____utils.getEnumValues
14
10
  function ____exports.getPickups(self, matchingVariant, matchingSubType)
15
11
  if matchingVariant == nil then
16
12
  matchingVariant = -1
@@ -28,16 +24,6 @@ function ____exports.getPickups(self, matchingVariant, matchingSubType)
28
24
  end
29
25
  return pickups
30
26
  end
31
- function ____exports.getRandomHeartSubType(self, seed, exceptions)
32
- if seed == nil then
33
- seed = Random()
34
- end
35
- if exceptions == nil then
36
- exceptions = {}
37
- end
38
- local heartSubTypes = getEnumValues(nil, HeartSubType)
39
- return getRandomArrayElement(nil, heartSubTypes, seed, exceptions)
40
- end
41
27
  function ____exports.isChest(self, pickup)
42
28
  return CHEST_PICKUP_VARIANTS:has(pickup.Variant)
43
29
  end
@@ -1,6 +1,7 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { PillEffectClass } from "../types/PillEffectClass";
3
3
  import { PillEffectType } from "../types/PillEffectType";
4
+ export declare function getMaxPillEffects(): int;
4
5
  /**
5
6
  * Helper function to get a pill effect class from a PillEffect enum value. In this context, the
6
7
  * class is equal to the numerical prefix in the "class" tag in the "pocketitems.xml" file. Use the
@@ -10,6 +10,10 @@ local ____PillEffectClass = require("types.PillEffectClass")
10
10
  local DEFAULT_PILL_EFFECT_CLASS = ____PillEffectClass.DEFAULT_PILL_EFFECT_CLASS
11
11
  local ____PillEffectType = require("types.PillEffectType")
12
12
  local DEFAULT_PILL_EFFECT_TYPE = ____PillEffectType.DEFAULT_PILL_EFFECT_TYPE
13
+ function ____exports.getMaxPillEffects(self)
14
+ local itemConfig = Isaac.GetItemConfig()
15
+ return itemConfig:GetPillEffects().Size - 1
16
+ end
13
17
  function ____exports.getPillEffectClass(self, pillEffect)
14
18
  local pillEffectClass = PILL_EFFECT_CLASS_MAP:get(pillEffect)
15
19
  return pillEffectClass == nil and DEFAULT_PILL_EFFECT_CLASS or pillEffectClass
@@ -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
  *
@@ -167,6 +171,7 @@ export declare function inDimension(dimension: Dimension): boolean;
167
171
  /** Helper function to determine if the current room shape is one of the four L room shapes. */
168
172
  export declare function inLRoom(): boolean;
169
173
  export declare function inGenesisRoom(): boolean;
174
+ export declare function inMegaSatanRoom(): boolean;
170
175
  /**
171
176
  * Helper function to check if the current room is a miniboss room for a particular miniboss. This
172
177
  * will only work for minibosses that have dedicated boss rooms in the "00.special rooms.stb" file.
@@ -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,12 @@ 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
240
+ end
241
+ function ____exports.inMegaSatanRoom(self)
242
+ local roomGridIndex = ____exports.getRoomGridIndex(nil)
243
+ return roomGridIndex == GridRooms.ROOM_MEGA_SATAN_IDX
245
244
  end
246
245
  function ____exports.inMinibossRoomOf(self, minibossID)
247
246
  local game = Game()
@@ -311,12 +310,12 @@ function ____exports.setRoomCleared(self)
311
310
  for ____, door in ipairs(getDoors(nil)) do
312
311
  do
313
312
  if isHiddenSecretRoomDoor(nil, door) then
314
- goto __continue58
313
+ goto __continue59
315
314
  end
316
315
  openDoorFast(nil, door)
317
316
  door.ExtraVisible = false
318
317
  end
319
- ::__continue58::
318
+ ::__continue59::
320
319
  end
321
320
  sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
322
321
  game:ShakeScreen(0)
@@ -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
@@ -0,0 +1,15 @@
1
+ /// <reference types="typescript-to-lua/language-extensions" />
2
+ export declare enum SerializationBrand {
3
+ DEFAULT_MAP = "__TSTL_DEFAULT_MAP",
4
+ /**
5
+ * This is set to the value that represents the default value (instead of an empty string like the
6
+ * other brands are).
7
+ */
8
+ DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE",
9
+ MAP = "__TSTL_MAP",
10
+ SET = "__TSTL_SET",
11
+ CLASS = "__TSTL_CLASS",
12
+ OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS",
13
+ VECTOR = "__VECTOR"
14
+ }
15
+ export declare function isSerializationBrand(key: AnyNotNil): boolean;
@@ -0,0 +1,24 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local ____utils = require("functions.utils")
7
+ local getEnumValues = ____utils.getEnumValues
8
+ ____exports.SerializationBrand = SerializationBrand or ({})
9
+ ____exports.SerializationBrand.DEFAULT_MAP = "__TSTL_DEFAULT_MAP"
10
+ ____exports.SerializationBrand.DEFAULT_MAP_VALUE = "__TSTL_DEFAULT_MAP_VALUE"
11
+ ____exports.SerializationBrand.MAP = "__TSTL_MAP"
12
+ ____exports.SerializationBrand.SET = "__TSTL_SET"
13
+ ____exports.SerializationBrand.CLASS = "__TSTL_CLASS"
14
+ ____exports.SerializationBrand.OBJECT_WITH_NUMBER_KEYS = "__TSTL_OBJECT_WITH_NUMBER_KEYS"
15
+ ____exports.SerializationBrand.VECTOR = "__VECTOR"
16
+ local SERIALIZATION_BRANDS = getEnumValues(nil, ____exports.SerializationBrand)
17
+ local SERIALIZATION_BRAND_SET = __TS__New(Set, SERIALIZATION_BRANDS)
18
+ function ____exports.isSerializationBrand(self, key)
19
+ if type(key) ~= "string" then
20
+ return false
21
+ end
22
+ return SERIALIZATION_BRAND_SET:has(key)
23
+ end
24
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.102",
3
+ "version": "1.2.105",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",