isaacscript-common 8.9.0 → 9.0.1
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.
- package/dist/callbacks/postPlayerCollectible.d.ts.map +1 -1
- package/dist/callbacks/postPlayerCollectible.lua +78 -9
- package/dist/core/constantsFirstLast.d.ts +4 -4
- package/dist/core/constantsFirstLast.d.ts.map +1 -1
- package/dist/core/constantsFirstLast.lua +4 -4
- package/dist/features/extraConsoleCommands/listCommands.lua +14 -14
- package/dist/features/firstLast.d.ts +9 -9
- package/dist/features/firstLast.d.ts.map +1 -1
- package/dist/features/firstLast.lua +26 -26
- package/dist/features/playerInventory.d.ts.map +1 -1
- package/dist/features/playerInventory.lua +8 -10
- package/dist/features/preventCollectibleRotation.lua +2 -2
- package/dist/functions/cards.d.ts +27 -36
- package/dist/functions/cards.d.ts.map +1 -1
- package/dist/functions/cards.lua +70 -79
- package/dist/functions/collectibleCacheFlag.d.ts +4 -1
- package/dist/functions/collectibleCacheFlag.d.ts.map +1 -1
- package/dist/functions/collectibleCacheFlag.lua +5 -2
- package/dist/functions/collectibles.d.ts +1 -6
- package/dist/functions/collectibles.d.ts.map +1 -1
- package/dist/functions/collectibles.lua +1 -6
- package/dist/functions/familiars.d.ts.map +1 -1
- package/dist/functions/itemPool.lua +9 -11
- package/dist/functions/pickupsSpecific.d.ts +9 -9
- package/dist/functions/pickupsSpecific.d.ts.map +1 -1
- package/dist/functions/pickupsSpecific.lua +16 -16
- package/dist/functions/pills.d.ts +1 -6
- package/dist/functions/pills.d.ts.map +1 -1
- package/dist/functions/pills.lua +1 -6
- package/dist/functions/players.d.ts +6 -0
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/players.lua +7 -1
- package/dist/functions/pocketItems.lua +4 -4
- package/dist/functions/rockAlt.lua +2 -2
- package/dist/functions/trinkets.d.ts +1 -6
- package/dist/functions/trinkets.d.ts.map +1 -1
- package/dist/functions/trinkets.lua +1 -6
- package/dist/functions/types.d.ts +3 -3
- package/dist/functions/types.d.ts.map +1 -1
- package/dist/functions/types.lua +2 -2
- package/dist/index.d.ts +63 -78
- package/dist/maps/cardMap.d.ts +2 -2
- package/dist/maps/cardMap.d.ts.map +1 -1
- package/dist/maps/cardMap.lua +203 -203
- package/dist/objects/cardDescriptions.d.ts +2 -2
- package/dist/objects/cardDescriptions.d.ts.map +1 -1
- package/dist/objects/cardDescriptions.lua +99 -99
- package/dist/objects/cardNames.d.ts +2 -2
- package/dist/objects/cardNames.d.ts.map +1 -1
- package/dist/objects/cardNames.lua +99 -99
- package/dist/objects/cardTypeToItemConfigCardType.d.ts +6 -0
- package/dist/objects/cardTypeToItemConfigCardType.d.ts.map +1 -0
- package/dist/objects/cardTypeToItemConfigCardType.lua +106 -0
- package/package.json +2 -2
- package/src/callbacks/postPlayerCollectible.ts +89 -10
- package/src/core/constantsFirstLast.ts +4 -4
- package/src/features/extraConsoleCommands/listCommands.ts +16 -16
- package/src/features/firstLast.ts +26 -26
- package/src/features/playerInventory.ts +6 -10
- package/src/features/preventCollectibleRotation.ts +2 -2
- package/src/functions/cards.ts +102 -86
- package/src/functions/collectibleCacheFlag.ts +6 -2
- package/src/functions/collectibles.ts +1 -6
- package/src/functions/familiars.ts +1 -0
- package/src/functions/itemPool.ts +6 -7
- package/src/functions/pickupsSpecific.ts +16 -13
- package/src/functions/pills.ts +1 -6
- package/src/functions/players.ts +14 -1
- package/src/functions/pocketItems.ts +4 -4
- package/src/functions/rockAlt.ts +2 -2
- package/src/functions/trinkets.ts +1 -6
- package/src/functions/types.ts +3 -3
- package/src/maps/cardMap.ts +204 -204
- package/src/objects/cardDescriptions.ts +100 -100
- package/src/objects/cardNames.ts +100 -100
- package/src/objects/cardTypeToItemConfigCardType.ts +106 -0
- package/dist/objects/cardTypes.d.ts +0 -6
- package/dist/objects/cardTypes.d.ts.map +0 -1
- package/dist/objects/cardTypes.lua +0 -106
- package/src/objects/cardTypes.ts +0 -104
package/src/functions/cards.ts
CHANGED
|
@@ -1,40 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CardType, ItemConfigCardType } from "isaac-typescript-definitions";
|
|
2
2
|
import { itemConfig } from "../core/cachedClasses";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FIRST_CARD_TYPE,
|
|
5
|
+
LAST_VANILLA_CARD_TYPE,
|
|
6
|
+
} from "../core/constantsFirstLast";
|
|
4
7
|
import {
|
|
5
8
|
CARD_DESCRIPTIONS,
|
|
6
9
|
DEFAULT_CARD_DESCRIPTION,
|
|
7
10
|
} from "../objects/cardDescriptions";
|
|
8
11
|
import { CARD_NAMES, DEFAULT_CARD_NAME } from "../objects/cardNames";
|
|
9
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
CARD_TYPE_TO_ITEM_CONFIG_CARD_TYPE,
|
|
14
|
+
DEFAULT_CARD_TYPE,
|
|
15
|
+
} from "../objects/cardTypeToItemConfigCardType";
|
|
10
16
|
import { getEnumValues } from "./enums";
|
|
11
17
|
import { getRandomSeed } from "./rng";
|
|
12
18
|
import { addSetsToSet, getRandomSetElement } from "./set";
|
|
13
19
|
import { irange } from "./utils";
|
|
14
20
|
|
|
15
|
-
const
|
|
21
|
+
const ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP = new Map<
|
|
22
|
+
ItemConfigCardType,
|
|
23
|
+
Set<CardType>
|
|
24
|
+
>();
|
|
16
25
|
|
|
17
26
|
/**
|
|
18
|
-
* Contains all of the entries in the `
|
|
27
|
+
* Contains all of the entries in the `CardType` enum with the following types:
|
|
19
28
|
* - ItemConfigCardType.TAROT
|
|
20
29
|
* - ItemConfigCardType.SUIT
|
|
21
30
|
* - ItemConfigCardType.SPECIAL
|
|
22
31
|
* - ItemConfigCardType.TAROT_REVERSE
|
|
23
32
|
*/
|
|
24
|
-
const CARD_SET = new Set<
|
|
33
|
+
const CARD_SET = new Set<CardType>();
|
|
25
34
|
|
|
26
35
|
function lazyInitCardMapsSets() {
|
|
27
36
|
// The card type to cards map should be valid for every card type, so we initialize it with empty
|
|
28
37
|
// sets.
|
|
29
38
|
for (const cardType of getEnumValues(ItemConfigCardType)) {
|
|
30
|
-
|
|
39
|
+
ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP.set(cardType, new Set<CardType>());
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
for (const card of
|
|
34
|
-
const
|
|
35
|
-
const cardTypeSet =
|
|
42
|
+
for (const card of getVanillaCardTypes()) {
|
|
43
|
+
const itemConfigCardType = getItemConfigCardType(card);
|
|
44
|
+
const cardTypeSet =
|
|
45
|
+
ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP.get(itemConfigCardType);
|
|
36
46
|
if (cardTypeSet === undefined) {
|
|
37
|
-
error(
|
|
47
|
+
error(
|
|
48
|
+
`Failed to get the card set for item config card type: ${itemConfigCardType}`,
|
|
49
|
+
);
|
|
38
50
|
}
|
|
39
51
|
cardTypeSet.add(card);
|
|
40
52
|
}
|
|
@@ -43,7 +55,7 @@ function lazyInitCardMapsSets() {
|
|
|
43
55
|
// - ItemConfigCardType.RUNE
|
|
44
56
|
// - ItemConfigCardType.SPECIAL_OBJECT
|
|
45
57
|
// - ItemConfigCardType.MODDED
|
|
46
|
-
const cards =
|
|
58
|
+
const cards = getCardTypesOfType(
|
|
47
59
|
ItemConfigCardType.TAROT,
|
|
48
60
|
ItemConfigCardType.SUIT,
|
|
49
61
|
ItemConfigCardType.SPECIAL,
|
|
@@ -55,23 +67,19 @@ function lazyInitCardMapsSets() {
|
|
|
55
67
|
/**
|
|
56
68
|
* Helper function to get a card description from a Card enum value.
|
|
57
69
|
*
|
|
58
|
-
* For example
|
|
59
|
-
*
|
|
60
|
-
* ```ts
|
|
61
|
-
* const card = Card.FOOL;
|
|
62
|
-
* const cardDescription = getCardDescription(card); // cardDescription is "Where journey begins"
|
|
63
|
-
* ```
|
|
70
|
+
* For example, `getCardDescription(card)` returns "Where journey begins".
|
|
64
71
|
*/
|
|
65
|
-
export function getCardDescription(
|
|
72
|
+
export function getCardDescription(cardType: CardType): string {
|
|
66
73
|
// "ItemConfigCard.Description" is bugged with vanilla cards on patch v1.7.6, so we use a
|
|
67
74
|
// hard-coded map as a workaround.
|
|
68
|
-
const cardDescription = CARD_DESCRIPTIONS[
|
|
75
|
+
const cardDescription = CARD_DESCRIPTIONS[cardType];
|
|
76
|
+
// Handle modded cards.
|
|
69
77
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
70
78
|
if (cardDescription !== undefined) {
|
|
71
79
|
return cardDescription;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
|
-
const itemConfigCard = itemConfig.GetCard(
|
|
82
|
+
const itemConfigCard = itemConfig.GetCard(cardType);
|
|
75
83
|
if (itemConfigCard !== undefined) {
|
|
76
84
|
return itemConfigCard.Description;
|
|
77
85
|
}
|
|
@@ -82,23 +90,19 @@ export function getCardDescription(card: Card): string {
|
|
|
82
90
|
/**
|
|
83
91
|
* Helper function to get a card name from a Card.
|
|
84
92
|
*
|
|
85
|
-
* For example
|
|
86
|
-
*
|
|
87
|
-
* ```ts
|
|
88
|
-
* const card = Card.FOOL;
|
|
89
|
-
* const cardName = getCardName(card); // cardName is "0 - The Fool"
|
|
90
|
-
* ```
|
|
93
|
+
* For example, `getCardName(Card.FOOL)` would return "0 - The Fool".
|
|
91
94
|
*/
|
|
92
|
-
export function getCardName(
|
|
95
|
+
export function getCardName(cardType: CardType): string {
|
|
93
96
|
// "ItemConfigCard.Name" is bugged with vanilla cards on patch v1.7.6, so we use a hard-coded map
|
|
94
97
|
// as a workaround.
|
|
95
|
-
const cardName = CARD_NAMES[
|
|
98
|
+
const cardName = CARD_NAMES[cardType];
|
|
99
|
+
// Handle modded cards.
|
|
96
100
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
97
101
|
if (cardName !== undefined) {
|
|
98
102
|
return cardName;
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
const itemConfigCard = itemConfig.GetCard(
|
|
105
|
+
const itemConfigCard = itemConfig.GetCard(cardType);
|
|
102
106
|
if (itemConfigCard !== undefined) {
|
|
103
107
|
return itemConfigCard.Name;
|
|
104
108
|
}
|
|
@@ -106,37 +110,45 @@ export function getCardName(card: Card): string {
|
|
|
106
110
|
return DEFAULT_CARD_NAME;
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
export function getCardType(card: Card): ItemConfigCardType {
|
|
110
|
-
const cardType = CARD_TYPES[card];
|
|
111
|
-
// Handle modded cards.
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
113
|
-
return cardType === undefined ? DEFAULT_CARD_TYPE : cardType;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
113
|
/**
|
|
117
|
-
* Helper function to get a set of
|
|
114
|
+
* Helper function to get a set of card types matching the `ItemConfigCardType`.
|
|
118
115
|
*
|
|
119
116
|
* This function is variadic, meaning that you can you can specify N card types to get a set
|
|
120
117
|
* containing cards that match any of the specified types.
|
|
121
118
|
*/
|
|
122
|
-
export function
|
|
123
|
-
|
|
119
|
+
export function getCardTypesOfType(
|
|
120
|
+
...itemConfigCardTypes: ItemConfigCardType[]
|
|
121
|
+
): Set<CardType> {
|
|
122
|
+
if (ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP.size === 0) {
|
|
124
123
|
lazyInitCardMapsSets();
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
const
|
|
128
|
-
for (const
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
const matchingCardTypes = new Set<CardType>();
|
|
127
|
+
for (const itemConfigCardType of itemConfigCardTypes) {
|
|
128
|
+
const cardTypeSet =
|
|
129
|
+
ITEM_CONFIG_CARD_TYPE_TO_CARD_TYPE_MAP.get(itemConfigCardType);
|
|
130
|
+
if (cardTypeSet === undefined) {
|
|
131
|
+
error(
|
|
132
|
+
`Failed to get the card type set for item config type: ${itemConfigCardType}`,
|
|
133
|
+
);
|
|
132
134
|
}
|
|
133
135
|
|
|
134
|
-
for (const
|
|
135
|
-
|
|
136
|
+
for (const cardType of cardTypeSet.values()) {
|
|
137
|
+
matchingCardTypes.add(cardType);
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
|
|
139
|
-
return
|
|
141
|
+
return matchingCardTypes;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function getItemConfigCardType(cardType: CardType): ItemConfigCardType {
|
|
145
|
+
const itemConfigCardType = CARD_TYPE_TO_ITEM_CONFIG_CARD_TYPE[cardType];
|
|
146
|
+
|
|
147
|
+
// Handle modded cards.
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
149
|
+
return itemConfigCardType === undefined
|
|
150
|
+
? DEFAULT_CARD_TYPE
|
|
151
|
+
: itemConfigCardType;
|
|
140
152
|
}
|
|
141
153
|
|
|
142
154
|
/**
|
|
@@ -154,24 +166,25 @@ export function getCardsOfType(...cardTypes: ItemConfigCardType[]): Set<Card> {
|
|
|
154
166
|
*/
|
|
155
167
|
export function getRandomCard(
|
|
156
168
|
seedOrRNG: Seed | RNG = getRandomSeed(),
|
|
157
|
-
exceptions:
|
|
158
|
-
):
|
|
169
|
+
exceptions: CardType[] = [],
|
|
170
|
+
): CardType {
|
|
159
171
|
return getRandomSetElement(CARD_SET, seedOrRNG, exceptions);
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
/**
|
|
163
|
-
* @param
|
|
175
|
+
* @param itemConfigCardType The item config card type that represents the pool of cards to select
|
|
176
|
+
* from.
|
|
164
177
|
* @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
165
178
|
* `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
166
179
|
* @param exceptions Optional. An array of cards to not select.
|
|
167
180
|
*/
|
|
168
|
-
export function
|
|
169
|
-
|
|
181
|
+
export function getRandomCardTypeOfType(
|
|
182
|
+
itemConfigCardType: ItemConfigCardType,
|
|
170
183
|
seedOrRNG: Seed | RNG = getRandomSeed(),
|
|
171
|
-
exceptions:
|
|
172
|
-
):
|
|
173
|
-
const
|
|
174
|
-
return getRandomSetElement(
|
|
184
|
+
exceptions: CardType[] = [],
|
|
185
|
+
): CardType {
|
|
186
|
+
const cardTypeSet = getCardTypesOfType(itemConfigCardType);
|
|
187
|
+
return getRandomSetElement(cardTypeSet, seedOrRNG, exceptions);
|
|
175
188
|
}
|
|
176
189
|
|
|
177
190
|
/**
|
|
@@ -184,16 +197,16 @@ export function getRandomCardOfType(
|
|
|
184
197
|
*/
|
|
185
198
|
export function getRandomRune(
|
|
186
199
|
seedOrRNG: Seed | RNG = getRandomSeed(),
|
|
187
|
-
exceptions:
|
|
188
|
-
):
|
|
189
|
-
const runesSet =
|
|
190
|
-
runesSet.delete(
|
|
200
|
+
exceptions: CardType[] = [],
|
|
201
|
+
): CardType {
|
|
202
|
+
const runesSet = getCardTypesOfType(ItemConfigCardType.RUNE);
|
|
203
|
+
runesSet.delete(CardType.RUNE_SHARD);
|
|
191
204
|
return getRandomSetElement(runesSet, seedOrRNG, exceptions);
|
|
192
205
|
}
|
|
193
206
|
|
|
194
207
|
/** Helper function to get an array with every valid vanilla card sub-type. */
|
|
195
|
-
export function
|
|
196
|
-
return irange(
|
|
208
|
+
export function getVanillaCardTypes(): CardType[] {
|
|
209
|
+
return irange(FIRST_CARD_TYPE, LAST_VANILLA_CARD_TYPE);
|
|
197
210
|
}
|
|
198
211
|
|
|
199
212
|
/**
|
|
@@ -203,51 +216,54 @@ export function getVanillaCards(): Card[] {
|
|
|
203
216
|
* - CardType.SPECIAL
|
|
204
217
|
* - CardType.TAROT_REVERSE
|
|
205
218
|
*/
|
|
206
|
-
export function isCard(
|
|
207
|
-
return CARD_SET.has(
|
|
219
|
+
export function isCard(cardType: CardType): boolean {
|
|
220
|
+
return CARD_SET.has(cardType);
|
|
208
221
|
}
|
|
209
222
|
|
|
210
|
-
/** Returns whether or not the given card matches the specified card type. */
|
|
211
|
-
export function isCardType(
|
|
212
|
-
|
|
223
|
+
/** Returns whether or not the given card type matches the specified item config card type. */
|
|
224
|
+
export function isCardType(
|
|
225
|
+
cardType: CardType,
|
|
226
|
+
itemConfigCardType: ItemConfigCardType,
|
|
227
|
+
): boolean {
|
|
228
|
+
return itemConfigCardType === getItemConfigCardType(cardType);
|
|
213
229
|
}
|
|
214
230
|
|
|
215
231
|
/** Returns true for any card or rune added by a mod. */
|
|
216
|
-
export function
|
|
217
|
-
return !
|
|
232
|
+
export function isModdedCardType(cardType: CardType): boolean {
|
|
233
|
+
return !isVanillaCardType(cardType);
|
|
218
234
|
}
|
|
219
235
|
|
|
220
|
-
/** Returns true for cards that have `
|
|
221
|
-
export function isPocketItemObject(
|
|
222
|
-
return isCardType(
|
|
236
|
+
/** Returns true for cards that have `ItemConfigCardType.SPECIAL_OBJECT`. */
|
|
237
|
+
export function isPocketItemObject(cardType: CardType): boolean {
|
|
238
|
+
return isCardType(cardType, ItemConfigCardType.SPECIAL_OBJECT);
|
|
223
239
|
}
|
|
224
240
|
|
|
225
|
-
/** Returns true for cards that have `
|
|
226
|
-
export function isReverseTarotCard(
|
|
227
|
-
return isCardType(
|
|
241
|
+
/** Returns true for cards that have `ItemConfigCardType.TAROT_REVERSE`. */
|
|
242
|
+
export function isReverseTarotCard(cardType: CardType): boolean {
|
|
243
|
+
return isCardType(cardType, ItemConfigCardType.TAROT_REVERSE);
|
|
228
244
|
}
|
|
229
245
|
|
|
230
246
|
/** Returns true for cards that have `CardType.RUNE`. */
|
|
231
|
-
export function isRune(
|
|
232
|
-
return isCardType(
|
|
247
|
+
export function isRune(cardType: CardType): boolean {
|
|
248
|
+
return isCardType(cardType, ItemConfigCardType.RUNE);
|
|
233
249
|
}
|
|
234
250
|
|
|
235
251
|
/** Returns true for cards that have `CardType.SPECIAL`. */
|
|
236
|
-
export function isSpecialCard(
|
|
237
|
-
return isCardType(
|
|
252
|
+
export function isSpecialCard(cardType: CardType): boolean {
|
|
253
|
+
return isCardType(cardType, ItemConfigCardType.SPECIAL);
|
|
238
254
|
}
|
|
239
255
|
|
|
240
256
|
/** Returns true for cards that have `CardType.SUIT`. */
|
|
241
|
-
export function isSuitCard(
|
|
242
|
-
return isCardType(
|
|
257
|
+
export function isSuitCard(cardType: CardType): boolean {
|
|
258
|
+
return isCardType(cardType, ItemConfigCardType.SUIT);
|
|
243
259
|
}
|
|
244
260
|
|
|
245
261
|
/** Returns true for cards that have `CardType.TAROT`. */
|
|
246
|
-
export function isTarotCard(
|
|
247
|
-
return isCardType(
|
|
262
|
+
export function isTarotCard(cardType: CardType): boolean {
|
|
263
|
+
return isCardType(cardType, ItemConfigCardType.TAROT);
|
|
248
264
|
}
|
|
249
265
|
|
|
250
266
|
/** Returns true for any vanilla card or rune. */
|
|
251
|
-
export function
|
|
252
|
-
return
|
|
267
|
+
export function isVanillaCardType(cardType: CardType): boolean {
|
|
268
|
+
return cardType <= LAST_VANILLA_CARD_TYPE;
|
|
253
269
|
}
|
|
@@ -64,7 +64,7 @@ export function getCollectiblesForCacheFlag(
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Returns an array containing every collectible type that the player has that matches the provided
|
|
67
|
-
* CacheFlag
|
|
67
|
+
* `CacheFlag`.
|
|
68
68
|
*
|
|
69
69
|
* For example, if the cache flag is `CacheFlag.FLYING`, and the player has one Lord of the Pit and
|
|
70
70
|
* two Dead Doves, then this function would return:
|
|
@@ -77,6 +77,9 @@ export function getCollectiblesForCacheFlag(
|
|
|
77
77
|
* ]
|
|
78
78
|
* ```
|
|
79
79
|
*
|
|
80
|
+
* Note that this array will not include collectibles that the player does not really have, like
|
|
81
|
+
* Lilith's Incubus.
|
|
82
|
+
*
|
|
80
83
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
81
84
|
* all collectibles will necessarily be present when a mod first loads (due to mod load order).
|
|
82
85
|
*/
|
|
@@ -88,7 +91,8 @@ export function getPlayerCollectiblesForCacheFlag(
|
|
|
88
91
|
|
|
89
92
|
const playerCollectibles: CollectibleType[] = [];
|
|
90
93
|
for (const collectibleType of getSortedSetValues(collectiblesForCacheFlag)) {
|
|
91
|
-
|
|
94
|
+
// We specify "true" as the second argument to filter out things like Lilith's Incubus.
|
|
95
|
+
const numCollectibles = player.GetCollectibleNum(collectibleType, true);
|
|
92
96
|
repeat(numCollectibles, () => {
|
|
93
97
|
playerCollectibles.push(collectibleType);
|
|
94
98
|
});
|
|
@@ -303,12 +303,7 @@ export function getCollectibleMaxCharges(
|
|
|
303
303
|
* Helper function to get the name of a collectible. Returns "Unknown" if the provided collectible
|
|
304
304
|
* type is not valid.
|
|
305
305
|
*
|
|
306
|
-
* For example
|
|
307
|
-
*
|
|
308
|
-
* ```ts
|
|
309
|
-
* const collectibleType = CollectibleType.SAD_ONION;
|
|
310
|
-
* const collectibleName = getCollectibleName(collectibleType); // collectibleName is "Sad Onion"
|
|
311
|
-
* ```
|
|
306
|
+
* For example, `getCollectibleName(CollectibleType.SAD_ONION)` would return "Sad Onion".
|
|
312
307
|
*/
|
|
313
308
|
export function getCollectibleName(collectibleType: CollectibleType): string {
|
|
314
309
|
// "ItemConfigItem.Name" is bugged with vanilla items on patch v1.7.6, so we use a hard-coded map
|
|
@@ -82,6 +82,7 @@ export function checkFamiliarFromCollectibles(
|
|
|
82
82
|
familiarVariant: FamiliarVariant,
|
|
83
83
|
familiarSubType?: int,
|
|
84
84
|
): void {
|
|
85
|
+
// We need to include non-real collectibles, like Lilith's Incubus.
|
|
85
86
|
const numCollectibles = player.GetCollectibleNum(collectibleType);
|
|
86
87
|
const effects = player.GetEffects();
|
|
87
88
|
|
|
@@ -128,13 +128,12 @@ function removeItemsAndTrinketsThatAffectItemPools(): [
|
|
|
128
128
|
for (const player of getPlayers()) {
|
|
129
129
|
const removedItems: CollectibleType[] = [];
|
|
130
130
|
for (const itemToRemove of COLLECTIBLES_THAT_AFFECT_ITEM_POOLS) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
131
|
+
// We need to include non-real collectibles, like Lilith's Incubus.
|
|
132
|
+
const numCollectibles = player.GetCollectibleNum(itemToRemove);
|
|
133
|
+
repeat(numCollectibles, () => {
|
|
134
|
+
player.RemoveCollectible(itemToRemove);
|
|
135
|
+
removedItems.push(itemToRemove);
|
|
136
|
+
});
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
mapSetPlayer(removedItemsMap, player, removedItems);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatterySubType,
|
|
3
3
|
BombSubType,
|
|
4
|
-
|
|
4
|
+
CardType,
|
|
5
5
|
CoinSubType,
|
|
6
6
|
CollectibleType,
|
|
7
7
|
HeartSubType,
|
|
@@ -45,11 +45,11 @@ export function getBombPickups(
|
|
|
45
45
|
/**
|
|
46
46
|
* Helper function to get all of the card entities in the room.
|
|
47
47
|
*
|
|
48
|
-
* @param
|
|
49
|
-
*
|
|
48
|
+
* @param cardType Optional. If specified, will only get the cards that match the sub-type. Default
|
|
49
|
+
* is -1, which matches every sub-type.
|
|
50
50
|
*/
|
|
51
|
-
export function getCards(
|
|
52
|
-
return getPickups(PickupVariant.TAROT_CARD,
|
|
51
|
+
export function getCards(cardType: CardType = -1): EntityPickupCard[] {
|
|
52
|
+
return getPickups(PickupVariant.TAROT_CARD, cardType) as EntityPickupCard[];
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -176,15 +176,18 @@ export function removeAllBombPickups(
|
|
|
176
176
|
/**
|
|
177
177
|
* Helper function to remove all of the cards in the room.
|
|
178
178
|
*
|
|
179
|
-
* @param
|
|
180
|
-
*
|
|
179
|
+
* @param cardType Optional. If specified, will only remove cards that match this sub-type. Default
|
|
180
|
+
* is -1, which matches every sub-type.
|
|
181
181
|
* @param cap Optional. If specified, will only remove the given amount of cards.
|
|
182
182
|
* @returns The cards that were removed.
|
|
183
183
|
*/
|
|
184
|
-
export function removeAllCards(
|
|
184
|
+
export function removeAllCards(
|
|
185
|
+
cardType: CardType = -1,
|
|
186
|
+
cap?: int,
|
|
187
|
+
): EntityPickupCard[] {
|
|
185
188
|
return removeAllPickups(
|
|
186
189
|
PickupVariant.TAROT_CARD,
|
|
187
|
-
|
|
190
|
+
cardType,
|
|
188
191
|
cap,
|
|
189
192
|
) as EntityPickupCard[];
|
|
190
193
|
}
|
|
@@ -392,7 +395,7 @@ export function spawnBombPickupWithSeed(
|
|
|
392
395
|
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TAROT_CARD` (300).
|
|
393
396
|
*/
|
|
394
397
|
export function spawnCard(
|
|
395
|
-
|
|
398
|
+
cardType: CardType,
|
|
396
399
|
position: Vector,
|
|
397
400
|
velocity: Vector = VectorZero,
|
|
398
401
|
spawner: Entity | undefined = undefined,
|
|
@@ -400,7 +403,7 @@ export function spawnCard(
|
|
|
400
403
|
): EntityPickupCard {
|
|
401
404
|
return spawnPickup(
|
|
402
405
|
PickupVariant.TAROT_CARD,
|
|
403
|
-
|
|
406
|
+
cardType,
|
|
404
407
|
position,
|
|
405
408
|
velocity,
|
|
406
409
|
spawner,
|
|
@@ -413,13 +416,13 @@ export function spawnCard(
|
|
|
413
416
|
* and a specific seed.
|
|
414
417
|
*/
|
|
415
418
|
export function spawnCardWithSeed(
|
|
416
|
-
|
|
419
|
+
cardType: CardType,
|
|
417
420
|
position: Vector,
|
|
418
421
|
seedOrRNG: Seed | RNG,
|
|
419
422
|
velocity: Vector = VectorZero,
|
|
420
423
|
spawner: Entity | undefined = undefined,
|
|
421
424
|
): EntityPickupCard {
|
|
422
|
-
return spawnCard(
|
|
425
|
+
return spawnCard(cardType, position, velocity, spawner, seedOrRNG);
|
|
423
426
|
}
|
|
424
427
|
|
|
425
428
|
/** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.COIN` (20). */
|
package/src/functions/pills.ts
CHANGED
|
@@ -128,12 +128,7 @@ export function getPillEffectClass(
|
|
|
128
128
|
/**
|
|
129
129
|
* Helper function to get a pill effect name from a PillEffect enum value.
|
|
130
130
|
*
|
|
131
|
-
* For example
|
|
132
|
-
*
|
|
133
|
-
* ```ts
|
|
134
|
-
* const pillEffect = PillEffect.BAD_GAS;
|
|
135
|
-
* const pillEffectName = getPillEffectName(pillEffect); // trinketName is "Bad Gas"
|
|
136
|
-
* ```
|
|
131
|
+
* For example, `getPillEffectName(PillEffect.BAD_GAS)` would return "Bad Gas".
|
|
137
132
|
*/
|
|
138
133
|
export function getPillEffectName(pillEffect: PillEffect): string {
|
|
139
134
|
// `ItemConfigPillEffect.Name` is bugged with vanilla pill effects on patch v1.7.6, so we use a
|
package/src/functions/players.ts
CHANGED
|
@@ -223,6 +223,8 @@ export function getPlayerCloserThan(
|
|
|
223
223
|
* collectible type(s) provided.
|
|
224
224
|
*
|
|
225
225
|
* This function is variadic, meaning that you can specify N collectible types.
|
|
226
|
+
*
|
|
227
|
+
* Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
226
228
|
*/
|
|
227
229
|
export function getPlayerCollectibleCount(
|
|
228
230
|
player: EntityPlayer,
|
|
@@ -230,6 +232,8 @@ export function getPlayerCollectibleCount(
|
|
|
230
232
|
): int {
|
|
231
233
|
let numCollectibles = 0;
|
|
232
234
|
for (const collectibleType of collectibleTypes) {
|
|
235
|
+
// We need to specify "true" as the second argument here to filter out things like Lilith's
|
|
236
|
+
// Incubus.
|
|
233
237
|
numCollectibles += player.GetCollectibleNum(collectibleType, true);
|
|
234
238
|
}
|
|
235
239
|
|
|
@@ -239,6 +243,8 @@ export function getPlayerCollectibleCount(
|
|
|
239
243
|
/**
|
|
240
244
|
* Iterates over every item in the game and returns a map containing the number of each item that
|
|
241
245
|
* the player has.
|
|
246
|
+
*
|
|
247
|
+
* Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
242
248
|
*/
|
|
243
249
|
export function getPlayerCollectibleMap(
|
|
244
250
|
player: EntityPlayer,
|
|
@@ -247,6 +253,8 @@ export function getPlayerCollectibleMap(
|
|
|
247
253
|
|
|
248
254
|
const collectibleMap = new Map<CollectibleType, int>();
|
|
249
255
|
for (const collectibleType of collectibleArray) {
|
|
256
|
+
// We need to specify "true" as the second argument here to filter out things like Lilith's
|
|
257
|
+
// Incubus.
|
|
250
258
|
const collectibleNum = player.GetCollectibleNum(collectibleType, true);
|
|
251
259
|
if (collectibleNum > 0) {
|
|
252
260
|
collectibleMap.set(collectibleType, collectibleNum);
|
|
@@ -374,14 +382,19 @@ export function getPlayersWithTrinket(
|
|
|
374
382
|
/**
|
|
375
383
|
* Returns the total number of collectibles amongst all players. For example, if player 1 has 1 Sad
|
|
376
384
|
* Onion and player 2 has 2 Sad Onions, then this function would return 3.
|
|
385
|
+
*
|
|
386
|
+
* Note that this will filter out non-real collectibles like Lilith's Incubus.
|
|
377
387
|
*/
|
|
378
388
|
export function getTotalPlayerCollectibles(
|
|
379
389
|
collectibleType: CollectibleType,
|
|
380
390
|
): int {
|
|
381
391
|
const players = getPlayers();
|
|
382
392
|
const numCollectiblesArray = players.map((player) =>
|
|
383
|
-
|
|
393
|
+
// We need to specify "true" as the second argument here to filter out things like Lilith's
|
|
394
|
+
// Incubus.
|
|
395
|
+
player.GetCollectibleNum(collectibleType, true),
|
|
384
396
|
);
|
|
397
|
+
|
|
385
398
|
return sumArray(numCollectiblesArray);
|
|
386
399
|
}
|
|
387
400
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ActiveSlot,
|
|
3
|
-
|
|
3
|
+
CardType,
|
|
4
4
|
CollectibleType,
|
|
5
5
|
PillColor,
|
|
6
6
|
PlayerType,
|
|
@@ -64,14 +64,14 @@ export function getPocketItems(player: EntityPlayer): PocketItemDescription[] {
|
|
|
64
64
|
let pocketItemIdentified = false;
|
|
65
65
|
let pocketItem2Identified = false;
|
|
66
66
|
for (const slot of pocketItemSlots) {
|
|
67
|
-
const
|
|
67
|
+
const cardType = player.GetCard(slot);
|
|
68
68
|
const pillColor = player.GetPill(slot);
|
|
69
69
|
|
|
70
|
-
if (
|
|
70
|
+
if (cardType !== CardType.NULL) {
|
|
71
71
|
pocketItems.push({
|
|
72
72
|
slot,
|
|
73
73
|
type: PocketItemType.CARD,
|
|
74
|
-
subType:
|
|
74
|
+
subType: cardType,
|
|
75
75
|
});
|
|
76
76
|
} else if (pillColor !== PillColor.NULL) {
|
|
77
77
|
pocketItems.push({
|
package/src/functions/rockAlt.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
CardType,
|
|
3
3
|
CoinSubType,
|
|
4
4
|
CollectibleType,
|
|
5
5
|
EffectVariant,
|
|
@@ -278,7 +278,7 @@ function spawnRockAltRewardSkull(position: Vector, rng: RNG): boolean {
|
|
|
278
278
|
|
|
279
279
|
totalChance += ROCK_ALT_CHANCES.BASIC_DROP;
|
|
280
280
|
if (chance < totalChance) {
|
|
281
|
-
spawnCardWithSeed(
|
|
281
|
+
spawnCardWithSeed(CardType.NULL, position, rng);
|
|
282
282
|
return true;
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -118,12 +118,7 @@ export function getTrinketGfxFilename(trinketType: TrinketType): string {
|
|
|
118
118
|
* Helper function to get the name of a trinket. Returns "Unknown" if the provided trinket type is
|
|
119
119
|
* not valid.
|
|
120
120
|
*
|
|
121
|
-
* For example
|
|
122
|
-
*
|
|
123
|
-
* ```ts
|
|
124
|
-
* const trinketType = TrinketType.SWALLOWED_PENNY;
|
|
125
|
-
* const trinketName = getTrinketName(trinketType); // trinketName is "Swallowed Penny"
|
|
126
|
-
* ```
|
|
121
|
+
* For example, `getTrinketName(TrinketType.SWALLOWED_PENNY)` would return "Swallowed Penny".
|
|
127
122
|
*/
|
|
128
123
|
export function getTrinketName(trinketType: TrinketType): string {
|
|
129
124
|
// "ItemConfigItem.Name" is bugged with vanilla items on patch v1.7.6, so we use a hard-coded map
|
package/src/functions/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
CardType,
|
|
3
3
|
CollectibleType,
|
|
4
4
|
LevelStage,
|
|
5
5
|
NpcState,
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
} from "isaac-typescript-definitions";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Helper function to safely cast a `number` to a `
|
|
13
|
+
* Helper function to safely cast a `number` to a `CardType`. (This is better than using the `as`
|
|
14
14
|
* TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
|
|
15
15
|
*
|
|
16
16
|
* This is useful to satisfy the "isaacscript/strict-enums" ESLint rule.
|
|
17
17
|
*/
|
|
18
|
-
export function
|
|
18
|
+
export function asCardType(num: number): CardType {
|
|
19
19
|
return num;
|
|
20
20
|
}
|
|
21
21
|
|