isaacscript-common 8.9.1 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/debug.d.ts +25 -0
- package/dist/functions/debug.d.ts.map +1 -1
- package/dist/functions/debug.lua +50 -0
- package/dist/functions/familiars.d.ts.map +1 -1
- package/dist/functions/itemPool.lua +9 -11
- package/dist/functions/log.d.ts +2 -7
- package/dist/functions/log.d.ts.map +1 -1
- package/dist/functions/log.lua +9 -31
- 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 +65 -78
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +0 -8
- 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/debug.ts +49 -0
- package/src/functions/familiars.ts +1 -0
- package/src/functions/itemPool.ts +6 -7
- package/src/functions/log.ts +15 -35
- 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/index.ts +0 -1
- 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/functions/dev.d.ts +0 -20
- package/dist/functions/dev.d.ts.map +0 -1
- package/dist/functions/dev.lua +0 -34
- 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/functions/dev.ts +0 -31
- package/src/objects/cardTypes.ts +0 -104
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
// - `POST_PLAYER_COLLECTIBLE_ADDED`
|
|
3
3
|
// - `POST_PLAYER_COLLECTIBLE_REMOVED`
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ActiveSlot,
|
|
7
|
+
CollectibleType,
|
|
8
|
+
ModCallback,
|
|
9
|
+
} from "isaac-typescript-definitions";
|
|
6
10
|
import { DefaultMap } from "../classes/DefaultMap";
|
|
7
11
|
import { saveDataManager } from "../features/saveDataManager/exports";
|
|
12
|
+
import { arrayEquals } from "../functions/array";
|
|
13
|
+
import { getEnumValues } from "../functions/enums";
|
|
8
14
|
import {
|
|
9
15
|
defaultMapGetPlayer,
|
|
10
16
|
mapGetPlayer,
|
|
@@ -29,6 +35,10 @@ const v = {
|
|
|
29
35
|
PlayerIndex,
|
|
30
36
|
Map<CollectibleType, int>
|
|
31
37
|
>(() => new Map()),
|
|
38
|
+
playersActiveItemMap: new DefaultMap<
|
|
39
|
+
PlayerIndex,
|
|
40
|
+
Map<ActiveSlot, CollectibleType>
|
|
41
|
+
>(() => new Map()),
|
|
32
42
|
},
|
|
33
43
|
};
|
|
34
44
|
|
|
@@ -65,16 +75,17 @@ function postPEffectUpdate(player: EntityPlayer) {
|
|
|
65
75
|
const difference = newCollectibleCount - oldCollectibleCount;
|
|
66
76
|
|
|
67
77
|
if (difference > 0) {
|
|
68
|
-
collectibleCountChanged(player, difference
|
|
78
|
+
collectibleCountChanged(player, difference);
|
|
69
79
|
} else if (difference < 0) {
|
|
70
|
-
collectibleCountChanged(player, difference * -1
|
|
80
|
+
collectibleCountChanged(player, difference * -1);
|
|
81
|
+
} else if (difference === 0) {
|
|
82
|
+
checkActiveItemsChanged(player);
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
function collectibleCountChanged(
|
|
75
87
|
player: EntityPlayer,
|
|
76
88
|
numCollectiblesChanged: int,
|
|
77
|
-
increased: boolean,
|
|
78
89
|
) {
|
|
79
90
|
const oldCollectibleMap = defaultMapGetPlayer(
|
|
80
91
|
v.run.playersCollectibleMap,
|
|
@@ -83,19 +94,20 @@ function collectibleCountChanged(
|
|
|
83
94
|
const newCollectibleMap = getPlayerCollectibleMap(player);
|
|
84
95
|
mapSetPlayer(v.run.playersCollectibleMap, player, newCollectibleMap);
|
|
85
96
|
|
|
86
|
-
const
|
|
97
|
+
const collectibleTypeSet = new Set<CollectibleType>([
|
|
87
98
|
...oldCollectibleMap.keys(),
|
|
88
99
|
...newCollectibleMap.keys(),
|
|
89
|
-
];
|
|
90
|
-
collectibleTypes.sort();
|
|
100
|
+
]);
|
|
91
101
|
|
|
92
102
|
let numFired = 0;
|
|
93
|
-
for (const collectibleType of
|
|
103
|
+
for (const collectibleType of collectibleTypeSet.values()) {
|
|
94
104
|
const oldNum = oldCollectibleMap.get(collectibleType) ?? 0;
|
|
95
105
|
const newNum = newCollectibleMap.get(collectibleType) ?? 0;
|
|
96
|
-
const difference =
|
|
106
|
+
const difference = newNum - oldNum;
|
|
107
|
+
const increased = difference > 0;
|
|
108
|
+
const absoluteDifference = Math.abs(difference);
|
|
97
109
|
|
|
98
|
-
repeat(
|
|
110
|
+
repeat(absoluteDifference, () => {
|
|
99
111
|
if (increased) {
|
|
100
112
|
postPlayerCollectibleAddedFire(player, collectibleType);
|
|
101
113
|
} else {
|
|
@@ -109,3 +121,70 @@ function collectibleCountChanged(
|
|
|
109
121
|
}
|
|
110
122
|
}
|
|
111
123
|
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The special case is when a player swaps their active item for another active item. In this
|
|
127
|
+
* situation, their overall collectible count will not change. Thus, we explicitly check for this.
|
|
128
|
+
*/
|
|
129
|
+
function checkActiveItemsChanged(player: EntityPlayer) {
|
|
130
|
+
const activeItemMap = defaultMapGetPlayer(v.run.playersActiveItemMap, player);
|
|
131
|
+
|
|
132
|
+
const oldCollectibleTypes: CollectibleType[] = [];
|
|
133
|
+
const newCollectibleTypes: CollectibleType[] = [];
|
|
134
|
+
|
|
135
|
+
for (const activeSlot of getEnumValues(ActiveSlot)) {
|
|
136
|
+
const oldCollectibleType =
|
|
137
|
+
activeItemMap.get(activeSlot) ?? CollectibleType.NULL;
|
|
138
|
+
const newCollectibleType = player.GetActiveItem(activeSlot);
|
|
139
|
+
activeItemMap.set(activeSlot, newCollectibleType);
|
|
140
|
+
|
|
141
|
+
oldCollectibleTypes.push(oldCollectibleType);
|
|
142
|
+
newCollectibleTypes.push(newCollectibleType);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// For example, it is possible for the player to switch Schoolbag items, which will cause the
|
|
146
|
+
// collectibles in the array to be the same, but in a different order. Thus, sort both arrays
|
|
147
|
+
// before comparing them.
|
|
148
|
+
oldCollectibleTypes.sort();
|
|
149
|
+
newCollectibleTypes.sort();
|
|
150
|
+
|
|
151
|
+
if (!arrayEquals(oldCollectibleTypes, newCollectibleTypes)) {
|
|
152
|
+
const collectibleTypeSet = new Set<CollectibleType>([
|
|
153
|
+
...oldCollectibleTypes,
|
|
154
|
+
...newCollectibleTypes,
|
|
155
|
+
]);
|
|
156
|
+
activeItemsChanged(player, collectibleTypeSet);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* One or more active items have changed (with the player's total collectible count remaining the
|
|
162
|
+
* same).
|
|
163
|
+
*/
|
|
164
|
+
function activeItemsChanged(
|
|
165
|
+
player: EntityPlayer,
|
|
166
|
+
collectibleTypesSet: Set<CollectibleType>,
|
|
167
|
+
) {
|
|
168
|
+
const oldCollectibleMap = defaultMapGetPlayer(
|
|
169
|
+
v.run.playersCollectibleMap,
|
|
170
|
+
player,
|
|
171
|
+
);
|
|
172
|
+
const newCollectibleMap = getPlayerCollectibleMap(player);
|
|
173
|
+
mapSetPlayer(v.run.playersCollectibleMap, player, newCollectibleMap);
|
|
174
|
+
|
|
175
|
+
for (const collectibleType of collectibleTypesSet.values()) {
|
|
176
|
+
const oldNum = oldCollectibleMap.get(collectibleType) ?? 0;
|
|
177
|
+
const newNum = newCollectibleMap.get(collectibleType) ?? 0;
|
|
178
|
+
const difference = newNum - oldNum;
|
|
179
|
+
const increased = difference > 0;
|
|
180
|
+
const absoluteDifference = Math.abs(difference);
|
|
181
|
+
|
|
182
|
+
repeat(absoluteDifference, () => {
|
|
183
|
+
if (increased) {
|
|
184
|
+
postPlayerCollectibleAddedFire(player, collectibleType);
|
|
185
|
+
} else {
|
|
186
|
+
postPlayerCollectibleRemovedFire(player, collectibleType);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Constants related to modded items can be found in the "firstLast.ts" file.
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
CardType,
|
|
5
5
|
CollectibleType,
|
|
6
6
|
LevelStage,
|
|
7
7
|
PillColor,
|
|
@@ -48,13 +48,13 @@ export const NUM_VANILLA_TRINKET_TYPES = getEnumLength(TrinketType) - 1;
|
|
|
48
48
|
// -----
|
|
49
49
|
|
|
50
50
|
/** Equal to `Card.FOOL`. */
|
|
51
|
-
export const
|
|
51
|
+
export const FIRST_CARD_TYPE = CardType.FOOL;
|
|
52
52
|
|
|
53
53
|
/** Calculated from the `Card` enum. */
|
|
54
|
-
export const
|
|
54
|
+
export const LAST_VANILLA_CARD_TYPE = getLastEnumValue(CardType);
|
|
55
55
|
|
|
56
56
|
/** Calculated from the `Card` enum. `Card.NULL` is not included. */
|
|
57
|
-
export const
|
|
57
|
+
export const NUM_VANILLA_CARD_TYPES = getEnumLength(CardType) - 1;
|
|
58
58
|
|
|
59
59
|
// ------------
|
|
60
60
|
// Pill Effects
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
import {
|
|
25
25
|
ActiveSlot,
|
|
26
26
|
CacheFlag,
|
|
27
|
-
|
|
27
|
+
CardType,
|
|
28
28
|
Challenge,
|
|
29
29
|
CollectibleType,
|
|
30
30
|
Direction,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
import { game, sfxManager } from "../../core/cachedClasses";
|
|
44
44
|
import { MAX_LEVEL_GRID_INDEX } from "../../core/constants";
|
|
45
45
|
import {
|
|
46
|
-
|
|
46
|
+
FIRST_CARD_TYPE,
|
|
47
47
|
FIRST_CHARACTER,
|
|
48
48
|
FIRST_PILL_EFFECT,
|
|
49
49
|
FIRST_ROOM_TYPE,
|
|
@@ -88,13 +88,13 @@ import { gridCoordinatesToWorldPosition } from "../../functions/roomGrid";
|
|
|
88
88
|
import { changeRoom } from "../../functions/rooms";
|
|
89
89
|
import { onSetSeed, restart, setUnseeded } from "../../functions/run";
|
|
90
90
|
import { getGoldenTrinketType } from "../../functions/trinkets";
|
|
91
|
-
import {
|
|
91
|
+
import { asCardType } from "../../functions/types";
|
|
92
92
|
import { irange, printConsole, printEnabled } from "../../functions/utils";
|
|
93
93
|
import { CARD_MAP } from "../../maps/cardMap";
|
|
94
94
|
import { CHARACTER_MAP } from "../../maps/characterMap";
|
|
95
95
|
import { PILL_EFFECT_MAP } from "../../maps/pillEffectMap";
|
|
96
96
|
import { ROOM_TYPE_MAP } from "../../maps/roomTypeMap";
|
|
97
|
-
import {
|
|
97
|
+
import { getLastCardType, getLastPillEffect } from "../firstLast";
|
|
98
98
|
import {
|
|
99
99
|
addHeart,
|
|
100
100
|
devilAngel,
|
|
@@ -326,8 +326,8 @@ export function card(params: string): void {
|
|
|
326
326
|
return;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
let
|
|
330
|
-
const num = tonumber(params) as
|
|
329
|
+
let cardType: CardType;
|
|
330
|
+
const num = tonumber(params) as CardType | undefined;
|
|
331
331
|
if (num === undefined) {
|
|
332
332
|
const match = getMapPartialMatch(params, CARD_MAP);
|
|
333
333
|
if (match === undefined) {
|
|
@@ -335,35 +335,35 @@ export function card(params: string): void {
|
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
|
|
338
|
+
cardType = match[1];
|
|
339
339
|
} else {
|
|
340
|
-
const
|
|
341
|
-
if (num <
|
|
340
|
+
const lastCardType = getLastCardType();
|
|
341
|
+
if (num < FIRST_CARD_TYPE || num > lastCardType) {
|
|
342
342
|
printConsole(`Invalid card sub-type: ${num}`);
|
|
343
343
|
return;
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
cardType = num;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
const cardName = getCardName(
|
|
350
|
-
Isaac.ExecuteCommand(`g k${
|
|
351
|
-
printConsole(`Gave card: ${cardName} (${
|
|
349
|
+
const cardName = getCardName(cardType);
|
|
350
|
+
Isaac.ExecuteCommand(`g k${cardType}`);
|
|
351
|
+
printConsole(`Gave card: ${cardName} (${cardType})`);
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
/** Spawns every card on the ground, starting at the top-left-most tile. */
|
|
355
355
|
export function cards(): void {
|
|
356
|
-
const
|
|
356
|
+
const lastCardType = getLastCardType();
|
|
357
357
|
|
|
358
358
|
let cardType = 1;
|
|
359
359
|
for (let y = 0; y <= 6; y++) {
|
|
360
360
|
for (let x = 0; x <= 12; x++) {
|
|
361
|
-
if (
|
|
361
|
+
if (asCardType(cardType) === lastCardType) {
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
const position = gridCoordinatesToWorldPosition(x, y);
|
|
366
|
-
spawnCard(
|
|
366
|
+
spawnCard(asCardType(cardType), position);
|
|
367
367
|
cardType++;
|
|
368
368
|
}
|
|
369
369
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
CardType,
|
|
3
3
|
CollectibleType,
|
|
4
4
|
PillEffect,
|
|
5
5
|
TrinketType,
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
import { ModUpgraded } from "../classes/ModUpgraded";
|
|
8
8
|
import { itemConfig } from "../core/cachedClasses";
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
FIRST_CARD_TYPE,
|
|
11
11
|
FIRST_PILL_EFFECT,
|
|
12
12
|
FIRST_TRINKET_TYPE,
|
|
13
|
-
|
|
13
|
+
LAST_VANILLA_CARD_TYPE,
|
|
14
14
|
LAST_VANILLA_COLLECTIBLE_TYPE,
|
|
15
15
|
LAST_VANILLA_PILL_EFFECT,
|
|
16
16
|
LAST_VANILLA_TRINKET_TYPE,
|
|
17
|
-
|
|
17
|
+
NUM_VANILLA_CARD_TYPES,
|
|
18
18
|
NUM_VANILLA_COLLECTIBLE_TYPES,
|
|
19
19
|
NUM_VANILLA_PILL_EFFECTS,
|
|
20
20
|
NUM_VANILLA_TRINKET_TYPES,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
import { ModCallbackCustom } from "../enums/ModCallbackCustom";
|
|
23
23
|
import { errorIfFeaturesNotInitialized } from "../featuresInitialized";
|
|
24
24
|
import {
|
|
25
|
-
|
|
25
|
+
asCardType,
|
|
26
26
|
asCollectibleType,
|
|
27
27
|
asNumber,
|
|
28
28
|
asPillEffect,
|
|
@@ -168,7 +168,7 @@ export function getFirstModdedTrinketType(): TrinketType | undefined {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
* Will change depending on how many modded
|
|
171
|
+
* Will change depending on how many modded trinkets there are.
|
|
172
172
|
*
|
|
173
173
|
* This is equal to the number of trinket types, since all trinket types are contiguous (unlike
|
|
174
174
|
* collectibles).
|
|
@@ -206,7 +206,7 @@ export function getModdedTrinketTypes(): TrinketType[] {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
|
-
* Will change depending on how many modded
|
|
209
|
+
* Will change depending on how many modded trinkets there are.
|
|
210
210
|
*
|
|
211
211
|
* Equal to `itemConfig.GetTrinkets().Size - 1`. (We subtract one to account for
|
|
212
212
|
* `TrinketType.NULL`.)
|
|
@@ -254,9 +254,9 @@ export function getTrinketTypes(): TrinketType[] {
|
|
|
254
254
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
255
255
|
* all cards will necessarily be present when a mod first loads (due to mod load order).
|
|
256
256
|
*/
|
|
257
|
-
export function
|
|
258
|
-
const
|
|
259
|
-
return irange(
|
|
257
|
+
export function getAllCardTypes(): CardType[] {
|
|
258
|
+
const lastCardType = getLastCardType();
|
|
259
|
+
return irange(FIRST_CARD_TYPE, lastCardType);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
/**
|
|
@@ -265,13 +265,13 @@ export function getAllCards(): Card[] {
|
|
|
265
265
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
266
266
|
* all cards will necessarily be present when a mod first loads (due to mod load order).
|
|
267
267
|
*/
|
|
268
|
-
export function
|
|
268
|
+
export function getFirstModdedCardType(): CardType | undefined {
|
|
269
269
|
errorIfFeaturesNotInitialized(FEATURE_NAME);
|
|
270
270
|
errorIfNoCallbacksFired("card");
|
|
271
271
|
|
|
272
|
-
const
|
|
273
|
-
const itemConfigCard = itemConfig.GetCard(
|
|
274
|
-
return itemConfigCard === undefined ? undefined :
|
|
272
|
+
const firstModdedCardType = asCardType(asNumber(LAST_VANILLA_CARD_TYPE) + 1);
|
|
273
|
+
const itemConfigCard = itemConfig.GetCard(firstModdedCardType);
|
|
274
|
+
return itemConfigCard === undefined ? undefined : firstModdedCardType;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
/**
|
|
@@ -283,12 +283,12 @@ export function getFirstModdedCard(): Card | undefined {
|
|
|
283
283
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
284
284
|
* all cards will necessarily be present when a mod first loads (due to mod load order).
|
|
285
285
|
*/
|
|
286
|
-
export function
|
|
286
|
+
export function getLastCardType(): CardType {
|
|
287
287
|
errorIfFeaturesNotInitialized(FEATURE_NAME);
|
|
288
288
|
errorIfNoCallbacksFired("card");
|
|
289
289
|
|
|
290
|
-
const numCards =
|
|
291
|
-
return
|
|
290
|
+
const numCards = getNumCardTypes();
|
|
291
|
+
return asCardType(numCards);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
/**
|
|
@@ -299,14 +299,14 @@ export function getLastCard(): Card {
|
|
|
299
299
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
300
300
|
* all cards will necessarily be present when a mod first loads (due to mod load order).
|
|
301
301
|
*/
|
|
302
|
-
export function
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
302
|
+
export function getModdedCardTypes(): CardType[] {
|
|
303
|
+
const firstModdedCardType = getFirstModdedCardType();
|
|
304
|
+
if (firstModdedCardType === undefined) {
|
|
305
305
|
return [];
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
const
|
|
309
|
-
return irange(
|
|
308
|
+
const lastCardType = getLastCardType();
|
|
309
|
+
return irange(firstModdedCardType, lastCardType);
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
/**
|
|
@@ -317,7 +317,7 @@ export function getModdedCards(): Card[] {
|
|
|
317
317
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
318
318
|
* all cards will necessarily be present when a mod first loads (due to mod load order).
|
|
319
319
|
*/
|
|
320
|
-
export function
|
|
320
|
+
export function getNumCardTypes(): int {
|
|
321
321
|
errorIfFeaturesNotInitialized(FEATURE_NAME);
|
|
322
322
|
errorIfNoCallbacksFired("card");
|
|
323
323
|
|
|
@@ -328,12 +328,12 @@ export function getNumCards(): int {
|
|
|
328
328
|
* This function can only be called if at least one callback has been executed. This is because not
|
|
329
329
|
* all trinkets will necessarily be present when a mod first loads (due to mod load order).
|
|
330
330
|
*/
|
|
331
|
-
export function
|
|
331
|
+
export function getNumModdedCardTypes(): int {
|
|
332
332
|
errorIfFeaturesNotInitialized(FEATURE_NAME);
|
|
333
333
|
errorIfNoCallbacksFired("card");
|
|
334
334
|
|
|
335
|
-
const
|
|
336
|
-
return
|
|
335
|
+
const numCardTypes = getNumCardTypes();
|
|
336
|
+
return numCardTypes - NUM_VANILLA_CARD_TYPES;
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
// ------------
|
|
@@ -35,16 +35,12 @@ function newPlayerInventory(player: EntityPlayer) {
|
|
|
35
35
|
const inventory: CollectibleType[] = [];
|
|
36
36
|
|
|
37
37
|
for (const collectibleType of getCollectibleArray()) {
|
|
38
|
-
// We
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
repeat(numCollectibles, () => {
|
|
45
|
-
inventory.push(collectibleType);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
38
|
+
// We need to specify "true" as the second argument here to filter out things like Lilith's
|
|
39
|
+
// Incubus.
|
|
40
|
+
const numCollectibles = player.GetCollectibleNum(collectibleType, true);
|
|
41
|
+
repeat(numCollectibles, () => {
|
|
42
|
+
inventory.push(collectibleType);
|
|
43
|
+
});
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
return inventory;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// switching mechanic.
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
CardType,
|
|
6
6
|
CollectibleType,
|
|
7
7
|
ModCallback,
|
|
8
8
|
PickupVariant,
|
|
@@ -39,7 +39,7 @@ export function preventCollectibleRotationInit(mod: Mod): void {
|
|
|
39
39
|
mod.AddCallback(
|
|
40
40
|
ModCallback.POST_USE_CARD,
|
|
41
41
|
useCardSoulOfIsaac,
|
|
42
|
-
|
|
42
|
+
CardType.SOUL_ISAAC,
|
|
43
43
|
); // 5
|
|
44
44
|
|
|
45
45
|
mod.AddCallback(
|