sonolus-d4dj-engine 1.1.1 → 1.1.2

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/README.md CHANGED
@@ -21,7 +21,7 @@ Todo list:
21
21
  ## Installation
22
22
 
23
23
  ```
24
- npm install sonolus-bandori-engine
24
+ npm install sonolus-d4dj-engine
25
25
  ```
26
26
 
27
27
  ## Custom Resources
@@ -1,45 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.b34djToLevelData = void 0;
4
- function b34djToLevelData(chartData, offset = 0) {
5
- let chart = Object.values(chartData);
6
- chart[2] = chart[2].map((obj) => Object.values(obj));
7
- chart[3] = chart[3].map((obj) => Object.values(obj));
8
- const timescale = chart[2];
9
- chart[2] = [];
3
+ exports.d4djToLevelData = exports.b34djToLevelData = void 0;
4
+ const index_cjs_1 = require("./index.cjs");
5
+ function b34djToLevelData(chart, offset = 0) {
6
+ let d4chart = [];
7
+ d4chart[0] = chart.MusicName;
8
+ d4chart[1] = [];
9
+ d4chart[2] = chart.BarLineList;
10
+ d4chart[3] = chart.NoteDataList.map((note) => [note.LaneId, index_cjs_1.D4DJNoteType[note.Type], note.Time, note.NextId, note.Direction, note.EffectType, note.EffectParameter]);
11
+ const timescale = chart.SoflanDataList.map((soflan) => [soflan.Time, soflan.TimeScale, soflan.LeftRight]);
10
12
  timescale.forEach((ts) => {
11
- const i = chart[2].findIndex((tsc) => (tsc[0] === ts[0]) && (tsc[1] === ts[1]));
13
+ const i = d4chart[1].findIndex((tsc) => (tsc[0] === ts[0]) && (tsc[1] === ts[1]));
12
14
  if (i === -1)
13
- chart[2].push(ts);
15
+ d4chart[1].push(ts);
14
16
  else
15
- chart[2][i][2] = 3;
17
+ d4chart[1][i][2] = 3;
16
18
  });
17
- chart = JSON.parse(JSON.stringify(chart)
18
- .replaceAll('"Tap1"', "0")
19
- .replaceAll('"Tap2"', "1")
20
- .replaceAll('"ScratchLeft"', "2")
21
- .replaceAll('"ScratchRight"', "3")
22
- .replaceAll('"StopStart"', "4")
23
- .replaceAll('"StopEnd"', "5")
24
- .replaceAll('"LongStart"', "6")
25
- .replaceAll('"LongMiddle"', "7")
26
- .replaceAll('"LongEnd"', "8")
27
- .replaceAll('"Slide"', "9"));
28
- const temp = chart[1];
29
- chart[1] = chart[2];
30
- chart[2] = temp;
31
- chart[3] = chart[3].map((note) => {
32
- const temp = note[1];
33
- note[1] = note[2];
34
- note[2] = temp;
35
- return note;
36
- });
37
- return parse(chart, offset);
19
+ return d4djToLevelData(d4chart, offset);
38
20
  }
39
21
  exports.b34djToLevelData = b34djToLevelData;
40
22
  ;
41
- function parse(chart, offset = 0) {
42
- let sus = {
23
+ function d4djToLevelData(chart, offset = 0) {
24
+ let data = {
43
25
  bgmOffset: offset,
44
26
  entities: [
45
27
  {
@@ -209,15 +191,16 @@ function parse(chart, offset = 0) {
209
191
  ],
210
192
  }));
211
193
  let notes = note(chart);
212
- sus.entities.push(...ts, ...notes, ...bl);
213
- return sus;
194
+ data.entities.push(...ts, ...notes, ...bl);
195
+ return data;
214
196
  }
197
+ exports.d4djToLevelData = d4djToLevelData;
215
198
  function note(chart) {
216
199
  let hold = [];
217
200
  let slider = [];
218
201
  let notes = {};
219
- let sol = chart[3].map((arr, i) => {
220
- const sus = {
202
+ let nots = chart[3].map((arr, i) => {
203
+ const not = {
221
204
  archetype: arr[1] === 0
222
205
  ? "DarkTapNote"
223
206
  : arr[1] === 1
@@ -262,43 +245,43 @@ function note(chart) {
262
245
  : (notes[arr[2]] = [{ name: `note${i}`, lane: arr[0] }]);
263
246
  if (arr[3] && (arr[1] === 4 || arr[1] === 6)) {
264
247
  let note = {};
265
- note.head = sus.name;
248
+ note.head = not.name;
266
249
  note.tail = `note${arr[3]}`;
267
250
  hold.push(note);
268
- sus.data.push({
251
+ not.data.push({
269
252
  name: "tail",
270
253
  ref: `note${arr[3]}`,
271
254
  });
272
255
  }
273
256
  if (arr[1] === 9) {
274
257
  if (arr[3] > 0) {
275
- slider.push({ prev: sus.name, next: `note${arr[3]}` });
276
- sus.data.push({
258
+ slider.push({ prev: not.name, next: `note${arr[3]}` });
259
+ not.data.push({
277
260
  name: "next",
278
261
  ref: `note${arr[3]}`,
279
262
  });
280
263
  }
281
- const sld = slider.find((note) => note.next === sus.name);
264
+ const sld = slider.find((note) => note.next === not.name);
282
265
  if (sld)
283
- sus.data.push({
266
+ not.data.push({
284
267
  name: "prev",
285
268
  ref: sld.prev,
286
269
  });
287
270
  }
288
271
  if (arr[1] === 5 || arr[1] === 8) {
289
- sus.data.push({
272
+ not.data.push({
290
273
  name: "head",
291
- ref: hold.find((note) => note.tail === sus.name).head,
274
+ ref: hold.find((note) => note.tail === not.name).head,
292
275
  });
293
276
  }
294
277
  if (arr[4])
295
- sus.data.push({
278
+ not.data.push({
296
279
  name: "direction",
297
280
  value: arr[4],
298
281
  });
299
- return sus;
282
+ return not;
300
283
  });
301
- hold.forEach(({ head, tail }, i) => sol.splice(parseInt(head.replace("note", "")) + 1 + i, 0, {
284
+ hold.forEach(({ head, tail }, i) => nots.splice(parseInt(head.replace("note", "")) + 1 + i, 0, {
302
285
  archetype: "HoldConnector",
303
286
  data: [
304
287
  {
@@ -314,7 +297,7 @@ function note(chart) {
314
297
  for (const beat in notes) {
315
298
  const sim = notes[beat].sort((a, b) => a.lane - b.lane);
316
299
  if (sim.length === 2) {
317
- sol.push({
300
+ nots.push({
318
301
  archetype: "SimLine",
319
302
  data: [
320
303
  {
@@ -329,7 +312,7 @@ function note(chart) {
329
312
  });
330
313
  }
331
314
  else if (sim.length === 3) {
332
- sol.push({
315
+ nots.push({
333
316
  archetype: "SimLine",
334
317
  data: [
335
318
  {
@@ -342,7 +325,7 @@ function note(chart) {
342
325
  },
343
326
  ],
344
327
  });
345
- sol.push({
328
+ nots.push({
346
329
  archetype: "SimLine",
347
330
  data: [
348
331
  {
@@ -357,5 +340,5 @@ function note(chart) {
357
340
  });
358
341
  }
359
342
  }
360
- return sol;
343
+ return nots;
361
344
  }
@@ -1,3 +1,4 @@
1
1
  import { LevelData } from '@sonolus/core';
2
2
  import { B34DJChart } from './index.cjs';
3
- export declare function b34djToLevelData(chartData: B34DJChart, offset?: number): LevelData;
3
+ export declare function b34djToLevelData(chart: B34DJChart, offset?: number): LevelData;
4
+ export declare function d4djToLevelData(chart: any, offset?: number): LevelData;
@@ -1,2 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.D4DJNoteType = exports.B34DJNoteType = void 0;
4
+ var B34DJNoteType;
5
+ (function (B34DJNoteType) {
6
+ B34DJNoteType["Tap1"] = "Tap1";
7
+ B34DJNoteType["Tap2"] = "Tap2";
8
+ B34DJNoteType["ScratchLeft"] = "ScratchLeft";
9
+ B34DJNoteType["ScratchRight"] = "ScratchRight";
10
+ B34DJNoteType["StopStart"] = "StopStart";
11
+ B34DJNoteType["StopEnd"] = "StopEnd";
12
+ B34DJNoteType["LongStart"] = "LongStart";
13
+ B34DJNoteType["LongMiddle"] = "LongMiddle";
14
+ B34DJNoteType["LongEnd"] = "LongEnd";
15
+ B34DJNoteType["Slide"] = "Slide";
16
+ })(B34DJNoteType || (exports.B34DJNoteType = B34DJNoteType = {}));
17
+ var D4DJNoteType;
18
+ (function (D4DJNoteType) {
19
+ D4DJNoteType[D4DJNoteType["Tap1"] = 0] = "Tap1";
20
+ D4DJNoteType[D4DJNoteType["Tap2"] = 1] = "Tap2";
21
+ D4DJNoteType[D4DJNoteType["ScratchLeft"] = 2] = "ScratchLeft";
22
+ D4DJNoteType[D4DJNoteType["ScratchRight"] = 3] = "ScratchRight";
23
+ D4DJNoteType[D4DJNoteType["StopStart"] = 4] = "StopStart";
24
+ D4DJNoteType[D4DJNoteType["StopEnd"] = 5] = "StopEnd";
25
+ D4DJNoteType[D4DJNoteType["LongStart"] = 6] = "LongStart";
26
+ D4DJNoteType[D4DJNoteType["LongMiddle"] = 7] = "LongMiddle";
27
+ D4DJNoteType[D4DJNoteType["LongEnd"] = 8] = "LongEnd";
28
+ D4DJNoteType[D4DJNoteType["Slide"] = 9] = "Slide";
29
+ })(D4DJNoteType || (exports.D4DJNoteType = D4DJNoteType = {}));
@@ -1,7 +1,8 @@
1
1
  export type B34DJChart = {
2
- MusicName: "music_0000001";
3
- BarLineList: number[];
2
+ MusicName: string;
4
3
  SoflanDataList: B34DJSoflanData[];
4
+ BarLineList: number[];
5
+ NoteDataList: B34DJNoteData[];
5
6
  };
6
7
  export type B34DJSoflanData = {
7
8
  Time: number;
@@ -10,10 +11,34 @@ export type B34DJSoflanData = {
10
11
  };
11
12
  export type B34DJNoteData = {
12
13
  LaneId: number;
14
+ Type: B34DJNoteType;
13
15
  Time: number;
14
- Type: "Tap1" | "Tap2" | "ScratchLeft" | "ScratchRight" | "StopStart" | "StopEnd" | "LongStart" | "LongMiddle" | "LongEnd" | "Slide";
15
- NextId: number;
16
- Direction: number;
17
- EffectType: number;
18
- EffectParameter: number;
16
+ NextId?: number;
17
+ Direction?: number;
18
+ EffectType?: number;
19
+ EffectParameter?: number;
19
20
  };
21
+ export declare enum B34DJNoteType {
22
+ Tap1 = "Tap1",
23
+ Tap2 = "Tap2",
24
+ ScratchLeft = "ScratchLeft",
25
+ ScratchRight = "ScratchRight",
26
+ StopStart = "StopStart",
27
+ StopEnd = "StopEnd",
28
+ LongStart = "LongStart",
29
+ LongMiddle = "LongMiddle",
30
+ LongEnd = "LongEnd",
31
+ Slide = "Slide"
32
+ }
33
+ export declare enum D4DJNoteType {
34
+ Tap1 = 0,
35
+ Tap2 = 1,
36
+ ScratchLeft = 2,
37
+ ScratchRight = 3,
38
+ StopStart = 4,
39
+ StopEnd = 5,
40
+ LongStart = 6,
41
+ LongMiddle = 7,
42
+ LongEnd = 8,
43
+ Slide = 9
44
+ }
package/dist/index.cjs CHANGED
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.databaseEngineItem = exports.version = exports.b34djToLevelData = void 0;
17
+ exports.databaseEngineItem = exports.version = exports.d4djToLevelData = exports.b34djToLevelData = void 0;
18
18
  var convert_cjs_1 = require("./b34dj/convert.cjs");
19
19
  Object.defineProperty(exports, "b34djToLevelData", { enumerable: true, get: function () { return convert_cjs_1.b34djToLevelData; } });
20
+ Object.defineProperty(exports, "d4djToLevelData", { enumerable: true, get: function () { return convert_cjs_1.d4djToLevelData; } });
20
21
  __exportStar(require("./b34dj/index.cjs"), exports);
21
- exports.version = '1.1.1';
22
+ exports.version = '1.1.2';
22
23
  exports.databaseEngineItem = {
23
24
  name: 'd4dj',
24
25
  version: 12,
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- export { b34djToLevelData } from './b34dj/convert.cjs';
1
+ export { b34djToLevelData, d4djToLevelData } from './b34dj/convert.cjs';
2
2
  export * from './b34dj/index.cjs';
3
- export declare const version = "1.1.1";
3
+ export declare const version = "1.1.2";
4
4
  export declare const databaseEngineItem: {
5
5
  readonly name: "d4dj";
6
6
  readonly version: 12;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonolus-d4dj-engine",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "A recreation of D4DJ Groovy Mix engine in Sonolus.",
5
5
  "type": "module",
6
6
  "author": "Gorengan Hunter",