isaacscript-common 6.6.2 → 6.6.5
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/postCustomDoorEnter.d.ts +1 -1
- package/dist/callbacks/postCustomDoorEnter.lua +1 -1
- package/dist/enums/private/SerializationBrand.d.ts +0 -4
- package/dist/enums/private/SerializationBrand.d.ts.map +1 -1
- package/dist/features/customStage/shadows.d.ts.map +1 -1
- package/dist/features/customStage/shadows.lua +0 -2
- package/dist/features/saveDataManager/merge.lua +4 -3
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/array.lua +1 -1
- package/dist/functions/deepCopy.d.ts +8 -5
- package/dist/functions/deepCopy.d.ts.map +1 -1
- package/dist/functions/deepCopy.lua +142 -38
- package/dist/functions/deepCopyTests.d.ts +6 -1
- package/dist/functions/deepCopyTests.d.ts.map +1 -1
- package/dist/functions/deepCopyTests.lua +19 -16
- package/dist/functions/log.d.ts +1 -1
- package/dist/functions/log.d.ts.map +1 -1
- package/dist/functions/log.lua +8 -4
- package/dist/functions/mergeTests.d.ts +7 -1
- package/dist/functions/mergeTests.d.ts.map +1 -1
- package/dist/functions/mergeTests.lua +86 -7
- package/dist/functions/playerIndex.d.ts +4 -0
- package/dist/functions/playerIndex.d.ts.map +1 -1
- package/dist/functions/playerIndex.lua +4 -0
- package/dist/functions/table.d.ts +1 -1
- package/dist/functions/table.lua +1 -1
- package/package.json +2 -2
- package/src/callbacks/postCursedTeleport.ts +1 -1
- package/src/callbacks/postCustomDoorEnter.ts +1 -1
- package/src/callbacks/postPlayerCollectible.ts +1 -1
- package/src/callbacks/postSacrifice.ts +1 -1
- package/src/enums/private/SerializationBrand.ts +0 -4
- package/src/features/customStage/shadows.ts +0 -6
- package/src/features/extraConsoleCommands/listCommands.ts +3 -3
- package/src/features/persistentEntities.ts +1 -1
- package/src/features/saveDataManager/merge.ts +3 -3
- package/src/functions/array.ts +5 -2
- package/src/functions/bitwise.ts +2 -2
- package/src/functions/deepCopy.ts +98 -19
- package/src/functions/deepCopyTests.ts +75 -19
- package/src/functions/log.ts +16 -7
- package/src/functions/mergeTests.ts +152 -4
- package/src/functions/playerIndex.ts +4 -0
- package/src/functions/table.ts +1 -1
- package/src/functions/trinketGive.ts +3 -3
- package/src/functions/tstlClass.ts +1 -1
- package/src/functions/ui.ts +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DefaultMap } from "../classes/DefaultMap";
|
|
1
2
|
import { SerializationType } from "../enums/SerializationType";
|
|
2
3
|
import { merge } from "../features/saveDataManager/merge";
|
|
3
4
|
import { deepCopy } from "./deepCopy";
|
|
@@ -6,13 +7,22 @@ import { isRNG, newRNG } from "./rng";
|
|
|
6
7
|
import { isSerializedIsaacAPIClass } from "./serialization";
|
|
7
8
|
import { copyVector, isVector } from "./vector";
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Run the suite of tests that prove that the "merge" helper function works properly. (This function
|
|
12
|
+
* is not exported but is used internally in the save data manager.)
|
|
13
|
+
*
|
|
14
|
+
* This function is only useful if you are troubleshooting the save data manager.
|
|
15
|
+
*/
|
|
16
|
+
export function runMergeTests(): void {
|
|
10
17
|
oldTableHasUpdatedValue();
|
|
11
18
|
newTableHasSameValue();
|
|
12
19
|
oldTableHasUpdatedValueFromNull();
|
|
13
20
|
oldTableHasSerializedIsaacAPIClass();
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
oldTableHasFilledChildTable();
|
|
23
|
+
oldTableHasFilledMap();
|
|
24
|
+
oldTableHasFilledDefaultMap();
|
|
25
|
+
|
|
16
26
|
oldTableHasVector();
|
|
17
27
|
oldTableHasVectorSerialized();
|
|
18
28
|
oldTableHasRNG();
|
|
@@ -90,7 +100,7 @@ function oldTableHasSerializedIsaacAPIClass() {
|
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
|
|
93
|
-
function
|
|
103
|
+
function oldTableHasFilledChildTable() {
|
|
94
104
|
interface Foo {
|
|
95
105
|
bar: string;
|
|
96
106
|
}
|
|
@@ -107,7 +117,7 @@ function oldTableHasFilledInterface() {
|
|
|
107
117
|
foo,
|
|
108
118
|
} as unknown as LuaTable<AnyNotNil, unknown>;
|
|
109
119
|
|
|
110
|
-
merge(oldTable, newTable, "
|
|
120
|
+
merge(oldTable, newTable, "oldTableHasFilledChildTable");
|
|
111
121
|
|
|
112
122
|
const oldTableValue = oldTable.get(key) as Foo | undefined;
|
|
113
123
|
if (oldTableValue === undefined) {
|
|
@@ -119,6 +129,142 @@ function oldTableHasFilledInterface() {
|
|
|
119
129
|
}
|
|
120
130
|
}
|
|
121
131
|
|
|
132
|
+
function oldTableHasFilledMap() {
|
|
133
|
+
const v = {
|
|
134
|
+
run: {
|
|
135
|
+
myMap: new Map<string, string>(),
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const saveData = {
|
|
140
|
+
run: {
|
|
141
|
+
myMap: new Map<string, string>([
|
|
142
|
+
["foo1", "bar1"],
|
|
143
|
+
["foo2", "bar2"],
|
|
144
|
+
["foo3", "bar3"],
|
|
145
|
+
]),
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
const serializedSaveData = deepCopy(saveData, SerializationType.SERIALIZE);
|
|
149
|
+
|
|
150
|
+
merge(
|
|
151
|
+
v as unknown as LuaTable,
|
|
152
|
+
serializedSaveData as LuaTable,
|
|
153
|
+
"oldTableHasFilledMap",
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const expectedSize = 3;
|
|
157
|
+
if (v.run.myMap.size !== expectedSize) {
|
|
158
|
+
error(
|
|
159
|
+
`The size of the merged map was equal to ${v.run.myMap.size}, but it should be equal to: ${expectedSize}`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
{
|
|
164
|
+
const key = "foo1";
|
|
165
|
+
const expectedValue = "bar1";
|
|
166
|
+
|
|
167
|
+
const value = v.run.myMap.get(key);
|
|
168
|
+
if (value !== expectedValue) {
|
|
169
|
+
error(
|
|
170
|
+
`The old table's map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
{
|
|
176
|
+
const key = "foo2";
|
|
177
|
+
const expectedValue = "bar2";
|
|
178
|
+
|
|
179
|
+
const value = v.run.myMap.get(key);
|
|
180
|
+
if (value !== expectedValue) {
|
|
181
|
+
error(
|
|
182
|
+
`The old table's map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
{
|
|
188
|
+
const key = "foo3";
|
|
189
|
+
const expectedValue = "bar3";
|
|
190
|
+
|
|
191
|
+
const value = v.run.myMap.get(key);
|
|
192
|
+
if (value !== expectedValue) {
|
|
193
|
+
error(
|
|
194
|
+
`The old table's map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function oldTableHasFilledDefaultMap() {
|
|
201
|
+
const v = {
|
|
202
|
+
run: {
|
|
203
|
+
myDefaultMap: new DefaultMap<string, string>("default"),
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const saveData = {
|
|
208
|
+
run: {
|
|
209
|
+
myDefaultMap: new DefaultMap<string, string>("default", [
|
|
210
|
+
["foo1", "bar1"],
|
|
211
|
+
["foo2", "bar2"],
|
|
212
|
+
["foo3", "bar3"],
|
|
213
|
+
]),
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
const serializedSaveData = deepCopy(saveData, SerializationType.SERIALIZE);
|
|
217
|
+
|
|
218
|
+
merge(
|
|
219
|
+
v as unknown as LuaTable,
|
|
220
|
+
serializedSaveData as LuaTable,
|
|
221
|
+
"oldTableHasFilledDefaultMap",
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
const expectedSize = 3;
|
|
225
|
+
if (v.run.myDefaultMap.size !== expectedSize) {
|
|
226
|
+
error(
|
|
227
|
+
`The size of the merged default map was equal to ${v.run.myDefaultMap.size}, but it should be equal to: ${expectedSize}`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
{
|
|
232
|
+
const key = "foo1";
|
|
233
|
+
const expectedValue = "bar1";
|
|
234
|
+
|
|
235
|
+
const value = v.run.myDefaultMap.get(key);
|
|
236
|
+
if (value !== expectedValue) {
|
|
237
|
+
error(
|
|
238
|
+
`The old table's default map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
{
|
|
244
|
+
const key = "foo2";
|
|
245
|
+
const expectedValue = "bar2";
|
|
246
|
+
|
|
247
|
+
const value = v.run.myDefaultMap.get(key);
|
|
248
|
+
if (value !== expectedValue) {
|
|
249
|
+
error(
|
|
250
|
+
`The old table's default map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
{
|
|
256
|
+
const key = "foo3";
|
|
257
|
+
const expectedValue = "bar3";
|
|
258
|
+
|
|
259
|
+
const value = v.run.myDefaultMap.get(key);
|
|
260
|
+
if (value !== expectedValue) {
|
|
261
|
+
error(
|
|
262
|
+
`The old table's default map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
122
268
|
function oldTableHasVector() {
|
|
123
269
|
log("Starting test: oldTableHasVector");
|
|
124
270
|
|
|
@@ -183,6 +329,7 @@ function oldTableHasVectorSerialized() {
|
|
|
183
329
|
const newTableSerialized = deepCopy(
|
|
184
330
|
newTable,
|
|
185
331
|
SerializationType.SERIALIZE,
|
|
332
|
+
"oldTableHasVectorSerialized",
|
|
186
333
|
) as LuaTable<AnyNotNil, unknown>;
|
|
187
334
|
|
|
188
335
|
merge(oldTable, newTableSerialized, "oldTableHasVectorSerialized");
|
|
@@ -266,6 +413,7 @@ function oldTableHasRNGSerialized() {
|
|
|
266
413
|
const newTableSerialized = deepCopy(
|
|
267
414
|
newTable,
|
|
268
415
|
SerializationType.SERIALIZE,
|
|
416
|
+
"oldTableHasRNGSerialized",
|
|
269
417
|
) as LuaTable<AnyNotNil, unknown>;
|
|
270
418
|
|
|
271
419
|
merge(oldTable, newTableSerialized, "oldTableHasRNGSerialized");
|
|
@@ -63,6 +63,10 @@ export function getPlayerFromIndex(
|
|
|
63
63
|
* though they are technically different characters, they share the same inventory and InitSeed.) If
|
|
64
64
|
* this is not desired, pass true for the `differentiateForgottenAndSoul` argument, and the RNG of
|
|
65
65
|
* Spoon Bender (3) will be used for The Soul.
|
|
66
|
+
*
|
|
67
|
+
* Also note that this index doesn't work in the `POST_PLAYER_INIT` function for players 2 through
|
|
68
|
+
* 4. With that said, in almost all cases, you should be lazy-initializing your data structures in
|
|
69
|
+
* other callbacks, so this should not be an issue.
|
|
66
70
|
*/
|
|
67
71
|
export function getPlayerIndex(
|
|
68
72
|
player: EntityPlayer,
|
package/src/functions/table.ts
CHANGED
|
@@ -134,7 +134,7 @@ export function getStringsFromTable(
|
|
|
134
134
|
* This function will sort the table entries based on the value of the key.
|
|
135
135
|
*
|
|
136
136
|
* This function will only work on tables that have number keys or string keys. It will throw a
|
|
137
|
-
*
|
|
137
|
+
* run-time error if it encounters a key of another type.
|
|
138
138
|
*
|
|
139
139
|
* @param luaTable The table to iterate over.
|
|
140
140
|
* @param func The function to run for each iteration.
|
|
@@ -98,7 +98,7 @@ export function temporarilyRemoveTrinket(
|
|
|
98
98
|
let numTrinkets = 0;
|
|
99
99
|
while (player.HasTrinket(trinketType)) {
|
|
100
100
|
player.TryRemoveTrinket(trinketType);
|
|
101
|
-
numTrinkets
|
|
101
|
+
numTrinkets++;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
let numSmeltedTrinkets = numTrinkets;
|
|
@@ -106,13 +106,13 @@ export function temporarilyRemoveTrinket(
|
|
|
106
106
|
trinketType1 === trinketType ||
|
|
107
107
|
trinketType1 === getGoldenTrinketType(trinketType);
|
|
108
108
|
if (trinketWasInSlot1) {
|
|
109
|
-
numSmeltedTrinkets
|
|
109
|
+
numSmeltedTrinkets--;
|
|
110
110
|
}
|
|
111
111
|
const trinketWasInSlot2 =
|
|
112
112
|
trinketType2 === trinketType ||
|
|
113
113
|
trinketType2 === getGoldenTrinketType(trinketType);
|
|
114
114
|
if (trinketWasInSlot2) {
|
|
115
|
-
numSmeltedTrinkets
|
|
115
|
+
numSmeltedTrinkets--;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
return {
|
package/src/functions/ui.ts
CHANGED
|
@@ -27,10 +27,10 @@ export function getHUDOffsetVector(): Vector {
|
|
|
27
27
|
const x = hudOffset * 2;
|
|
28
28
|
let y = hudOffset;
|
|
29
29
|
if (y >= 4) {
|
|
30
|
-
y
|
|
30
|
+
y++;
|
|
31
31
|
}
|
|
32
32
|
if (y >= 9) {
|
|
33
|
-
y
|
|
33
|
+
y++;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return Vector(x, y);
|
|
@@ -69,7 +69,7 @@ export function getHeartsUIWidth(): int {
|
|
|
69
69
|
|
|
70
70
|
let heartRowLength = getHeartRowLength(player);
|
|
71
71
|
if (hasHolyMantleEffect) {
|
|
72
|
-
heartRowLength
|
|
72
|
+
heartRowLength++;
|
|
73
73
|
}
|
|
74
74
|
if (curses === LevelCurse.UNKNOWN) {
|
|
75
75
|
heartRowLength = 1;
|