sonolus-pjsekai-js 1.1.12 → 1.2.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/EnginePlayData +0 -0
- package/dist/EnginePreviewData +0 -0
- package/dist/EngineWatchData +0 -0
- package/dist/index.cjs +32 -30
- package/dist/index.d.cts +5 -4
- package/dist/sus/analyze.cjs +23 -25
- package/dist/sus/convert.cjs +19 -22
- package/dist/sus/convert.d.cts +1 -1
- package/dist/sus/decode.cjs +318 -0
- package/dist/sus/decode.d.cts +1 -0
- package/dist/sus/index.cjs +18 -0
- package/dist/{usc/index.d.ts → sus/index.d.cts} +19 -19
- package/dist/sus/revert.cjs +339 -0
- package/dist/sus/revert.d.cts +1 -0
- package/dist/usc/ccIndex.cjs +18 -0
- package/dist/usc/ccIndex.d.cts +91 -0
- package/dist/usc/convert.cjs +56 -142
- package/dist/usc/convert.d.cts +2 -2
- package/dist/usc/index.cjs +0 -16
- package/dist/usc/index.d.cts +16 -42
- package/dist/usc/revert.cjs +169 -0
- package/dist/usc/revert.d.cts +8 -0
- package/package.json +39 -39
- package/dist/sus/analyze.d.ts +0 -29
- package/dist/sus/analyze.js +0 -262
- package/dist/sus/convert.d.ts +0 -5
- package/dist/sus/convert.js +0 -301
- package/dist/usc/convert.d.ts +0 -3
- package/dist/usc/convert.js +0 -542
- package/dist/usc/index.js +0 -15
package/dist/usc/convert.cjs
CHANGED
@@ -26,8 +26,8 @@ const uscToLevelData = (usc, offset = 0) => {
|
|
26
26
|
};
|
27
27
|
if (intermediate.sim) {
|
28
28
|
const beat = intermediate.data[core_1.EngineArchetypeDataName.Beat];
|
29
|
-
if (typeof beat !==
|
30
|
-
throw new Error(
|
29
|
+
if (typeof beat !== 'number')
|
30
|
+
throw new Error('Unexpected beat');
|
31
31
|
const intermediates = timeToIntermediates.get(beat);
|
32
32
|
if (intermediates) {
|
33
33
|
intermediates.push(intermediate);
|
@@ -44,7 +44,7 @@ const uscToLevelData = (usc, offset = 0) => {
|
|
44
44
|
for (const [name, value] of Object.entries(intermediate.data)) {
|
45
45
|
if (value === undefined)
|
46
46
|
continue;
|
47
|
-
if (typeof value ===
|
47
|
+
if (typeof value === 'number') {
|
48
48
|
entity.data.push({
|
49
49
|
name,
|
50
50
|
value,
|
@@ -59,12 +59,12 @@ const uscToLevelData = (usc, offset = 0) => {
|
|
59
59
|
}
|
60
60
|
};
|
61
61
|
append({
|
62
|
-
archetype:
|
62
|
+
archetype: 'Initialization',
|
63
63
|
data: {},
|
64
64
|
sim: false,
|
65
65
|
});
|
66
66
|
append({
|
67
|
-
archetype:
|
67
|
+
archetype: 'Stage',
|
68
68
|
data: {},
|
69
69
|
sim: false,
|
70
70
|
});
|
@@ -74,7 +74,7 @@ const uscToLevelData = (usc, offset = 0) => {
|
|
74
74
|
for (const intermediates of timeToIntermediates.values()) {
|
75
75
|
for (let i = 1; i < intermediates.length; i++) {
|
76
76
|
append({
|
77
|
-
archetype:
|
77
|
+
archetype: 'SimLine',
|
78
78
|
data: {
|
79
79
|
a: intermediates[i - 1],
|
80
80
|
b: intermediates[i],
|
@@ -126,18 +126,18 @@ const single = (object, append) => {
|
|
126
126
|
archetype: object.direction
|
127
127
|
? object.trace
|
128
128
|
? object.critical
|
129
|
-
?
|
130
|
-
:
|
129
|
+
? 'CriticalTraceFlickNote'
|
130
|
+
: 'NormalTraceFlickNote'
|
131
131
|
: object.critical
|
132
|
-
?
|
133
|
-
:
|
132
|
+
? 'CriticalFlickNote'
|
133
|
+
: 'NormalFlickNote'
|
134
134
|
: object.trace
|
135
135
|
? object.critical
|
136
|
-
?
|
137
|
-
:
|
136
|
+
? 'CriticalTraceNote'
|
137
|
+
: 'NormalTraceNote'
|
138
138
|
: object.critical
|
139
|
-
?
|
140
|
-
:
|
139
|
+
? 'CriticalTapNote'
|
140
|
+
: 'NormalTapNote',
|
141
141
|
data: {
|
142
142
|
[core_1.EngineArchetypeDataName.Beat]: object.beat,
|
143
143
|
lane: object.lane,
|
@@ -157,57 +157,30 @@ const slide = (object, append) => {
|
|
157
157
|
for (const [i, connection] of connections.entries()) {
|
158
158
|
if (i === 0) {
|
159
159
|
switch (connection.type) {
|
160
|
-
case
|
161
|
-
|
162
|
-
|
163
|
-
if ("judgeType" in connection) {
|
164
|
-
if (connection.judgeType === "none") {
|
165
|
-
archetype = "IgnoredSlideStartNote";
|
166
|
-
sim = false;
|
167
|
-
}
|
168
|
-
else if (connection.judgeType === "trace") {
|
169
|
-
if (connection.critical) {
|
170
|
-
archetype = "CriticalTraceSlideStartNote";
|
171
|
-
}
|
172
|
-
else {
|
173
|
-
archetype = "NormalTraceSlideStartNote";
|
174
|
-
}
|
175
|
-
}
|
176
|
-
else {
|
177
|
-
if (connection.critical) {
|
178
|
-
archetype = "CriticalSlideStartNote";
|
179
|
-
}
|
180
|
-
else {
|
181
|
-
archetype = "NormalSlideStartNote";
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
185
|
-
else {
|
186
|
-
archetype = connection.trace
|
160
|
+
case 'start': {
|
161
|
+
const ci = {
|
162
|
+
archetype: connection.trace
|
187
163
|
? connection.critical
|
188
|
-
?
|
189
|
-
:
|
164
|
+
? 'CriticalSlideTraceNote'
|
165
|
+
: 'NormalSlideTraceNote'
|
190
166
|
: connection.critical
|
191
|
-
?
|
192
|
-
:
|
193
|
-
}
|
194
|
-
const ci = {
|
195
|
-
archetype,
|
167
|
+
? 'CriticalSlideStartNote'
|
168
|
+
: 'NormalSlideStartNote',
|
196
169
|
data: {
|
197
170
|
[core_1.EngineArchetypeDataName.Beat]: connection.beat,
|
198
171
|
lane: connection.lane,
|
199
172
|
size: connection.size,
|
200
173
|
},
|
201
|
-
sim,
|
174
|
+
sim: true,
|
202
175
|
ease: connection.ease,
|
203
176
|
};
|
204
177
|
cis.push(ci);
|
205
178
|
joints.push(ci);
|
206
179
|
continue;
|
207
180
|
}
|
208
|
-
case
|
181
|
+
case 'ignore': {
|
209
182
|
const ci = {
|
210
|
-
archetype:
|
183
|
+
archetype: 'IgnoredSlideTickNote',
|
211
184
|
data: {
|
212
185
|
[core_1.EngineArchetypeDataName.Beat]: connection.beat,
|
213
186
|
lane: connection.lane,
|
@@ -221,28 +194,28 @@ const slide = (object, append) => {
|
|
221
194
|
continue;
|
222
195
|
}
|
223
196
|
default:
|
224
|
-
throw new Error(
|
197
|
+
throw new Error('Unexpected slide start');
|
225
198
|
}
|
226
199
|
}
|
227
200
|
if (i === connections.length - 1) {
|
228
201
|
switch (connection.type) {
|
229
|
-
case
|
202
|
+
case 'end': {
|
230
203
|
const ci = {
|
231
204
|
archetype: connection.direction
|
232
205
|
? connection.trace
|
233
206
|
? connection.critical
|
234
|
-
?
|
235
|
-
:
|
207
|
+
? 'CriticalTraceFlickNote'
|
208
|
+
: 'NormalTraceFlickNote'
|
236
209
|
: connection.critical
|
237
|
-
?
|
238
|
-
:
|
210
|
+
? 'CriticalSlideEndFlickNote'
|
211
|
+
: 'NormalSlideEndFlickNote'
|
239
212
|
: connection.trace
|
240
213
|
? connection.critical
|
241
|
-
?
|
242
|
-
:
|
214
|
+
? 'CriticalSlideEndTraceNote'
|
215
|
+
: 'NormalSlideEndTraceNote'
|
243
216
|
: connection.critical
|
244
|
-
?
|
245
|
-
:
|
217
|
+
? 'CriticalSlideEndNote'
|
218
|
+
: 'NormalSlideEndNote',
|
246
219
|
data: {
|
247
220
|
[core_1.EngineArchetypeDataName.Beat]: connection.beat,
|
248
221
|
lane: connection.lane,
|
@@ -256,9 +229,9 @@ const slide = (object, append) => {
|
|
256
229
|
ends.push(ci);
|
257
230
|
continue;
|
258
231
|
}
|
259
|
-
case
|
232
|
+
case 'ignore': {
|
260
233
|
const ci = {
|
261
|
-
archetype:
|
234
|
+
archetype: 'IgnoredSlideTickNote',
|
262
235
|
data: {
|
263
236
|
[core_1.EngineArchetypeDataName.Beat]: connection.beat,
|
264
237
|
lane: connection.lane,
|
@@ -272,13 +245,13 @@ const slide = (object, append) => {
|
|
272
245
|
continue;
|
273
246
|
}
|
274
247
|
default:
|
275
|
-
throw new Error(
|
248
|
+
throw new Error('Unexpected slide end');
|
276
249
|
}
|
277
250
|
}
|
278
251
|
switch (connection.type) {
|
279
|
-
case
|
252
|
+
case 'ignore': {
|
280
253
|
const ci = {
|
281
|
-
archetype:
|
254
|
+
archetype: 'IgnoredSlideTickNote',
|
282
255
|
data: {
|
283
256
|
[core_1.EngineArchetypeDataName.Beat]: connection.beat,
|
284
257
|
lane: connection.lane,
|
@@ -291,15 +264,15 @@ const slide = (object, append) => {
|
|
291
264
|
joints.push(ci);
|
292
265
|
break;
|
293
266
|
}
|
294
|
-
case
|
267
|
+
case 'tick': {
|
295
268
|
const ci = {
|
296
269
|
archetype: connection.trace
|
297
270
|
? connection.critical
|
298
|
-
?
|
299
|
-
:
|
271
|
+
? 'CriticalSlideTraceNote'
|
272
|
+
: 'NormalSlideTraceNote'
|
300
273
|
: connection.critical
|
301
|
-
?
|
302
|
-
:
|
274
|
+
? 'CriticalSlideTickNote'
|
275
|
+
: 'NormalSlideTickNote',
|
303
276
|
data: {
|
304
277
|
[core_1.EngineArchetypeDataName.Beat]: connection.beat,
|
305
278
|
lane: connection.lane,
|
@@ -312,9 +285,9 @@ const slide = (object, append) => {
|
|
312
285
|
joints.push(ci);
|
313
286
|
break;
|
314
287
|
}
|
315
|
-
case
|
288
|
+
case 'hidden': {
|
316
289
|
const ci = {
|
317
|
-
archetype:
|
290
|
+
archetype: 'HiddenSlideTickNote',
|
318
291
|
data: {
|
319
292
|
[core_1.EngineArchetypeDataName.Beat]: connection.beat,
|
320
293
|
},
|
@@ -324,11 +297,11 @@ const slide = (object, append) => {
|
|
324
297
|
attaches.push(ci);
|
325
298
|
break;
|
326
299
|
}
|
327
|
-
case
|
300
|
+
case 'attach': {
|
328
301
|
const ci = {
|
329
302
|
archetype: connection.critical
|
330
|
-
?
|
331
|
-
:
|
303
|
+
? 'CriticalAttachedSlideTickNote'
|
304
|
+
: 'NormalAttachedSlideTickNote',
|
332
305
|
data: {
|
333
306
|
[core_1.EngineArchetypeDataName.Beat]: connection.beat,
|
334
307
|
},
|
@@ -339,7 +312,7 @@ const slide = (object, append) => {
|
|
339
312
|
break;
|
340
313
|
}
|
341
314
|
default:
|
342
|
-
throw new Error(
|
315
|
+
throw new Error('Unexpected slide tick');
|
343
316
|
}
|
344
317
|
}
|
345
318
|
const connectors = [];
|
@@ -350,15 +323,15 @@ const slide = (object, append) => {
|
|
350
323
|
continue;
|
351
324
|
const head = joints[i - 1];
|
352
325
|
if (!head.ease)
|
353
|
-
throw new Error(
|
326
|
+
throw new Error('Unexpected missing ease');
|
354
327
|
connectors.push({
|
355
328
|
archetype: object.active
|
356
329
|
? object.critical
|
357
|
-
?
|
358
|
-
:
|
330
|
+
? 'CriticalActiveSlideConnector'
|
331
|
+
: 'NormalActiveSlideConnector'
|
359
332
|
: object.critical
|
360
|
-
?
|
361
|
-
:
|
333
|
+
? 'CriticalSlideConnector'
|
334
|
+
: 'NormalSlideConnector',
|
362
335
|
data: {
|
363
336
|
start,
|
364
337
|
end,
|
@@ -384,70 +357,11 @@ const slide = (object, append) => {
|
|
384
357
|
append(connector);
|
385
358
|
}
|
386
359
|
};
|
387
|
-
const guide = (object, append) => {
|
388
|
-
const critical = object.color === "yellow" ? true : false;
|
389
|
-
// midpoints를 slide의 connections 형태로 변환
|
390
|
-
const connections = object.midpoints.map((midpoint, i) => {
|
391
|
-
if (i === 0) {
|
392
|
-
return {
|
393
|
-
type: "start",
|
394
|
-
beat: midpoint.beat,
|
395
|
-
lane: midpoint.lane,
|
396
|
-
size: midpoint.size,
|
397
|
-
trace: false,
|
398
|
-
critical: false,
|
399
|
-
ease: midpoint.ease === "out"
|
400
|
-
? "out"
|
401
|
-
: midpoint.ease === "linear"
|
402
|
-
? "linear"
|
403
|
-
: midpoint.ease === "in"
|
404
|
-
? "in"
|
405
|
-
: "linear",
|
406
|
-
};
|
407
|
-
}
|
408
|
-
else if (i === object.midpoints.length - 1) {
|
409
|
-
return {
|
410
|
-
type: "end",
|
411
|
-
beat: midpoint.beat,
|
412
|
-
lane: midpoint.lane,
|
413
|
-
size: midpoint.size,
|
414
|
-
trace: false,
|
415
|
-
critical: false,
|
416
|
-
direction: undefined,
|
417
|
-
};
|
418
|
-
}
|
419
|
-
else {
|
420
|
-
return {
|
421
|
-
type: "tick",
|
422
|
-
beat: midpoint.beat,
|
423
|
-
lane: midpoint.lane,
|
424
|
-
size: midpoint.size,
|
425
|
-
trace: false,
|
426
|
-
critical: false,
|
427
|
-
ease: midpoint.ease === "out"
|
428
|
-
? "out"
|
429
|
-
: midpoint.ease === "linear"
|
430
|
-
? "linear"
|
431
|
-
: midpoint.ease === "in"
|
432
|
-
? "in"
|
433
|
-
: "linear",
|
434
|
-
};
|
435
|
-
}
|
436
|
-
});
|
437
|
-
const slideObj = {
|
438
|
-
type: "slide",
|
439
|
-
active: true,
|
440
|
-
critical,
|
441
|
-
connections,
|
442
|
-
};
|
443
|
-
slide(slideObj, append);
|
444
|
-
};
|
445
360
|
const handlers = {
|
446
361
|
bpm,
|
447
362
|
single,
|
448
363
|
timeScale,
|
449
364
|
slide,
|
450
|
-
guide,
|
451
365
|
};
|
452
366
|
const getConnections = (object) => {
|
453
367
|
if (!object.active)
|
@@ -459,7 +373,7 @@ const getConnections = (object) => {
|
|
459
373
|
const start = Math.max(Math.ceil(min / 0.5) * 0.5, Math.floor(min / 0.5 + 1) * 0.5);
|
460
374
|
for (let beat = start; beat < max; beat += 0.5) {
|
461
375
|
connections.push({
|
462
|
-
type:
|
376
|
+
type: 'hidden',
|
463
377
|
beat,
|
464
378
|
});
|
465
379
|
}
|
package/dist/usc/convert.d.cts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import { LevelData } from
|
2
|
-
import { USC } from
|
1
|
+
import { LevelData } from '@sonolus/core';
|
2
|
+
import { USC } from './index.cjs';
|
3
3
|
export declare const uscToLevelData: (usc: USC, offset?: number) => LevelData;
|
package/dist/usc/index.cjs
CHANGED
@@ -1,18 +1,2 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.USCFade = exports.USCColor = void 0;
|
4
|
-
exports.USCColor = {
|
5
|
-
neutral: 0,
|
6
|
-
red: 1,
|
7
|
-
green: 2,
|
8
|
-
blue: 3,
|
9
|
-
yellow: 4,
|
10
|
-
purple: 5,
|
11
|
-
cyan: 6,
|
12
|
-
black: 7,
|
13
|
-
};
|
14
|
-
exports.USCFade = {
|
15
|
-
in: 2,
|
16
|
-
out: 0,
|
17
|
-
none: 1,
|
18
|
-
};
|
package/dist/usc/index.d.cts
CHANGED
@@ -2,16 +2,16 @@ export type USC = {
|
|
2
2
|
offset: number;
|
3
3
|
objects: USCObject[];
|
4
4
|
};
|
5
|
-
export type USCObject = USCBpmChange | USCTimeScaleChange | USCSingleNote | USCSlideNote
|
5
|
+
export type USCObject = USCBpmChange | USCTimeScaleChange | USCSingleNote | USCSlideNote;
|
6
6
|
type BaseUSCObject = {
|
7
7
|
beat: number;
|
8
8
|
};
|
9
9
|
export type USCBpmChange = BaseUSCObject & {
|
10
|
-
type:
|
10
|
+
type: 'bpm';
|
11
11
|
bpm: number;
|
12
12
|
};
|
13
13
|
export type USCTimeScaleChange = BaseUSCObject & {
|
14
|
-
type:
|
14
|
+
type: 'timeScale';
|
15
15
|
timeScale: number;
|
16
16
|
};
|
17
17
|
type BaseUSCNote = BaseUSCObject & {
|
@@ -19,42 +19,42 @@ type BaseUSCNote = BaseUSCObject & {
|
|
19
19
|
size: number;
|
20
20
|
};
|
21
21
|
export type USCSingleNote = BaseUSCNote & {
|
22
|
-
type:
|
22
|
+
type: 'single';
|
23
23
|
trace: boolean;
|
24
24
|
critical: boolean;
|
25
|
-
direction?:
|
25
|
+
direction?: 'left' | 'up' | 'right';
|
26
26
|
};
|
27
27
|
export type USCConnectionStartNote = BaseUSCNote & {
|
28
|
-
type:
|
28
|
+
type: 'start';
|
29
29
|
trace: boolean;
|
30
30
|
critical: boolean;
|
31
|
-
ease:
|
31
|
+
ease: 'outin' | 'out' | 'linear' | 'in' | 'inout';
|
32
32
|
};
|
33
33
|
export type USCConnectionIgnoreNote = BaseUSCNote & {
|
34
|
-
type:
|
35
|
-
ease:
|
34
|
+
type: 'ignore';
|
35
|
+
ease: 'outin' | 'out' | 'linear' | 'in' | 'inout';
|
36
36
|
};
|
37
37
|
export type USCConnectionTickNote = BaseUSCNote & {
|
38
|
-
type:
|
38
|
+
type: 'tick';
|
39
39
|
trace: boolean;
|
40
40
|
critical: boolean;
|
41
|
-
ease:
|
41
|
+
ease: 'outin' | 'out' | 'linear' | 'in' | 'inout';
|
42
42
|
};
|
43
43
|
export type USCConnectionHiddenNote = BaseUSCObject & {
|
44
|
-
type:
|
44
|
+
type: 'hidden';
|
45
45
|
};
|
46
46
|
export type USCConnectionAttachNote = BaseUSCObject & {
|
47
|
-
type:
|
47
|
+
type: 'attach';
|
48
48
|
critical: boolean;
|
49
49
|
};
|
50
50
|
export type USCConnectionEndNote = BaseUSCNote & {
|
51
|
-
type:
|
51
|
+
type: 'end';
|
52
52
|
trace: boolean;
|
53
53
|
critical: boolean;
|
54
|
-
direction?:
|
54
|
+
direction?: 'left' | 'up' | 'right';
|
55
55
|
};
|
56
56
|
export type USCSlideNote = {
|
57
|
-
type:
|
57
|
+
type: 'slide';
|
58
58
|
active: boolean;
|
59
59
|
critical: boolean;
|
60
60
|
connections: [
|
@@ -63,30 +63,4 @@ export type USCSlideNote = {
|
|
63
63
|
USCConnectionEndNote | USCConnectionIgnoreNote
|
64
64
|
];
|
65
65
|
};
|
66
|
-
export declare const USCColor: {
|
67
|
-
neutral: number;
|
68
|
-
red: number;
|
69
|
-
green: number;
|
70
|
-
blue: number;
|
71
|
-
yellow: number;
|
72
|
-
purple: number;
|
73
|
-
cyan: number;
|
74
|
-
black: number;
|
75
|
-
};
|
76
|
-
export type USCColor = keyof typeof USCColor;
|
77
|
-
export type USCGuideMidpointNote = BaseUSCNote & {
|
78
|
-
ease: "out" | "linear" | "in" | "inOut" | "outIn";
|
79
|
-
};
|
80
|
-
export declare const USCFade: {
|
81
|
-
in: number;
|
82
|
-
out: number;
|
83
|
-
none: number;
|
84
|
-
};
|
85
|
-
export type USCFade = keyof typeof USCFade;
|
86
|
-
export type USCGuideNote = {
|
87
|
-
type: "guide";
|
88
|
-
color: USCColor;
|
89
|
-
fade: USCFade;
|
90
|
-
midpoints: USCGuideMidpointNote[];
|
91
|
-
};
|
92
66
|
export {};
|
@@ -0,0 +1,169 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.uscToUSC = void 0;
|
4
|
+
/**
|
5
|
+
* B 타입의 USC Easing 값을 A 타입으로 변환합니다.
|
6
|
+
* 'inout'은 'in'으로, 'outin'은 'out'으로 매핑됩니다.
|
7
|
+
* @param ease B 타입의 Easing 값
|
8
|
+
* @returns A 타입의 Easing 값
|
9
|
+
*/
|
10
|
+
/**
|
11
|
+
* B 타입의 USC 슬라이드 연결 노드를 A 타입으로 변환합니다.
|
12
|
+
* @param connection B 타입의 연결 노트
|
13
|
+
* @returns A 타입의 연결 노트
|
14
|
+
*/
|
15
|
+
const convertConnection = (connection) => {
|
16
|
+
switch (connection.type) {
|
17
|
+
case 'start':
|
18
|
+
if (connection.judgeType === 'none') {
|
19
|
+
return {
|
20
|
+
type: 'ignore',
|
21
|
+
beat: connection.beat,
|
22
|
+
lane: connection.lane,
|
23
|
+
size: connection.size,
|
24
|
+
ease: connection.ease,
|
25
|
+
};
|
26
|
+
}
|
27
|
+
return {
|
28
|
+
type: 'start',
|
29
|
+
beat: connection.beat,
|
30
|
+
lane: connection.lane,
|
31
|
+
size: connection.size,
|
32
|
+
critical: connection.critical,
|
33
|
+
trace: connection.judgeType === 'trace',
|
34
|
+
ease: connection.ease,
|
35
|
+
};
|
36
|
+
case 'tick':
|
37
|
+
// B타입 tick 노트의 critical 유무에 따라 A타입의 tick 또는 hidden으로 분기합니다.
|
38
|
+
if (connection.critical !== undefined) {
|
39
|
+
return {
|
40
|
+
type: 'tick',
|
41
|
+
beat: connection.beat,
|
42
|
+
lane: connection.lane,
|
43
|
+
size: connection.size,
|
44
|
+
critical: connection.critical,
|
45
|
+
// A타입의 tick 노트는 trace 속성을 가지지만 B타입에는 없습니다.
|
46
|
+
// 따라서 false로 기본값을 설정합니다.
|
47
|
+
trace: false,
|
48
|
+
ease: connection.ease,
|
49
|
+
};
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
return {
|
53
|
+
type: 'ignore',
|
54
|
+
beat: connection.beat,
|
55
|
+
lane: connection.lane,
|
56
|
+
size: connection.size,
|
57
|
+
ease: connection.ease,
|
58
|
+
};
|
59
|
+
}
|
60
|
+
case 'attach':
|
61
|
+
return {
|
62
|
+
type: 'attach',
|
63
|
+
beat: connection.beat,
|
64
|
+
critical: connection.critical ?? false,
|
65
|
+
};
|
66
|
+
case 'end':
|
67
|
+
if (connection.judgeType === 'none') {
|
68
|
+
return {
|
69
|
+
type: 'ignore',
|
70
|
+
beat: connection.beat,
|
71
|
+
lane: connection.lane,
|
72
|
+
size: connection.size,
|
73
|
+
// A타입의 ignore 노트는 ease 속성이 필요하지만, B의 end 노트는 없습니다.
|
74
|
+
// 따라서 'linear'를 기본값으로 사용합니다.
|
75
|
+
ease: 'linear',
|
76
|
+
};
|
77
|
+
}
|
78
|
+
return {
|
79
|
+
type: 'end',
|
80
|
+
beat: connection.beat,
|
81
|
+
lane: connection.lane,
|
82
|
+
size: connection.size,
|
83
|
+
critical: connection.critical,
|
84
|
+
trace: connection.judgeType === 'trace',
|
85
|
+
direction: connection.direction,
|
86
|
+
};
|
87
|
+
}
|
88
|
+
};
|
89
|
+
/**
|
90
|
+
* B 타입의 USC 객체를 A 타입 USC 객체로 변환합니다.
|
91
|
+
* @param uscB B 타입 USC 객체
|
92
|
+
* @returns A 타입 USC 객체
|
93
|
+
*/
|
94
|
+
const uscToUSC = (uscB) => {
|
95
|
+
const newObjects = [];
|
96
|
+
for (const object of uscB.objects) {
|
97
|
+
switch (object.type) {
|
98
|
+
case 'bpm':
|
99
|
+
newObjects.push({
|
100
|
+
type: 'bpm',
|
101
|
+
beat: object.beat,
|
102
|
+
bpm: object.bpm,
|
103
|
+
});
|
104
|
+
break;
|
105
|
+
case 'single':
|
106
|
+
newObjects.push({
|
107
|
+
type: 'single',
|
108
|
+
beat: object.beat,
|
109
|
+
lane: object.lane,
|
110
|
+
size: object.size,
|
111
|
+
critical: object.critical,
|
112
|
+
trace: object.trace,
|
113
|
+
// B타입의 'none' 방향은 A타입에 없으므로 undefined로 처리합니다.
|
114
|
+
direction: object.direction === 'none' ? undefined : object.direction,
|
115
|
+
});
|
116
|
+
break;
|
117
|
+
case 'slide':
|
118
|
+
{
|
119
|
+
const newSlide = {
|
120
|
+
type: 'slide',
|
121
|
+
// B타입의 모든 slide는 A타입의 active slide로 간주합니다.
|
122
|
+
active: true,
|
123
|
+
critical: object.critical,
|
124
|
+
connections: object.connections.map(convertConnection),
|
125
|
+
};
|
126
|
+
newObjects.push(newSlide);
|
127
|
+
}
|
128
|
+
break;
|
129
|
+
case 'timeScaleGroup':
|
130
|
+
// B타입의 timeScaleGroup을 A타입의 개별 timeScale 변경점으로 변환합니다.
|
131
|
+
for (const change of object.changes) {
|
132
|
+
newObjects.push({
|
133
|
+
type: 'timeScale',
|
134
|
+
beat: change.beat,
|
135
|
+
timeScale: change.timeScale,
|
136
|
+
});
|
137
|
+
}
|
138
|
+
break;
|
139
|
+
case 'guide':
|
140
|
+
{
|
141
|
+
// B타입의 guide를 A타입의 비활성(active: false) 슬라이드로 변환합니다.
|
142
|
+
const guideConnections = object.midpoints.map((midpoint) => ({
|
143
|
+
type: 'ignore',
|
144
|
+
beat: midpoint.beat,
|
145
|
+
lane: midpoint.lane,
|
146
|
+
size: midpoint.size,
|
147
|
+
ease: midpoint.ease,
|
148
|
+
}));
|
149
|
+
const newGuideSlide = {
|
150
|
+
type: 'slide',
|
151
|
+
active: false,
|
152
|
+
// B타입의 guide color가 'yellow'이면 critical로 판단합니다.
|
153
|
+
critical: object.color === 'yellow',
|
154
|
+
connections: guideConnections,
|
155
|
+
};
|
156
|
+
newObjects.push(newGuideSlide);
|
157
|
+
}
|
158
|
+
break;
|
159
|
+
// 'damage' 노트는 A타입에 없으므로 무시합니다.
|
160
|
+
case 'damage':
|
161
|
+
break;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
return {
|
165
|
+
offset: uscB.offset,
|
166
|
+
objects: newObjects,
|
167
|
+
};
|
168
|
+
};
|
169
|
+
exports.uscToUSC = uscToUSC;
|