-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathddrSongGeneration.js
137 lines (121 loc) · 4.19 KB
/
ddrSongGeneration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// This file is used to generate ALL songs, including extra manual processing steps
// Extra song metas are found in the songs/ folder
var songMetas = [
];
/** Adds a new note in at the correct location. Does NOT shift any notes around. */
function addAbility(song, abilityId, time, duration, noteType) {
var newNote = {
"time": time,
"duration": duration,
"noteType": noteType,
"abilityId": abilityId
};
var notes = song.notes;
for (var index = 0; index < notes.length; index++) {
var note = notes[index];
if (note.time > newNote.time) {
notes.splice(
index, 0,
newNote
);
return;
}
}
song.notes.push(
newNote
);
}
function deleteAt(song, index) {
var note = song.notes[index];
song.notes.splice(index, 1);
console.log(" Delete Note At: " + index + " (" + note.abilityId + ", " + note.noteType + ")");
if (index == 0) {
console.log(" Shifting notes back so note 0 is at t=0");
fixTimeOffset(song.notes);
}
}
function deleteAbilityId(song, abilityId) {
var notes = song.notes;
var numDeleted = 0;
for (var index = 0; index < notes.length; index++) {
var note = notes[index];
if (note.abilityId == abilityId) {
song.notes.splice(index, 1);
numDeleted += 1;
if (index == 0) {
console.log(" Shifting notes back so note 0 is at t=0");
fixTimeOffset(song.notes);
}
index -= 1;
}
}
console.log(" Deleted " + numDeleted + " notes of abilityId: " + abilityId);
}
async function generateSongs() {
var songs = [];
var allSongMetas = [];
allSongMetas = allSongMetas.concat(songMetas);
allSongMetas = allSongMetas.concat(snowCrowsSongMetas);
console.log("Starting Generation of " + allSongMetas.length + " Songs");
for (var songMetasIndex = 0; songMetasIndex < allSongMetas.length; songMetasIndex++) {
var songMeta = allSongMetas[songMetasIndex];
// console.log("Generating Song: " + songMeta.name);
var song = await generateSong(
songMeta.name,
songMeta.description,
songMeta.logUrl,
songMeta.buildChatCode,
songMeta.buildUrl,
false // Don't optimize at this stage. Do it after postProcess
)
// console.log(" Song Generated!");
var postProcessSteps = songMeta.postProcessSteps;
for (var postIndex = 0; postIndex < postProcessSteps.length; postIndex++) {
var process = postProcessSteps[postIndex];
var command = process.command;
console.log(" Post Process: " + command);
if (command == "AddAbility") {
addAbility(
song,
process.abilityId,
process.time,
process.duration,
process.noteType
);
} else if (command == "AddPreCastAbility") {
song = addPrecastAbility(
song,
process.abilityId,
process.time,
process.duration,
process.noteType
);
} else if (command == "AddAutoCastAbility") {
song = addAutocastAbility(
song,
process.abilityId,
process.interval,
process.offset,
process.noteType
);
} else if (command == "DeleteAt") {
var index = process.index;
deleteAt(song, index);
} else if (command == "DeleteAbilityId") {
deleteAbilityId(song, process.abilityId);
} else if (command == "OptimizeAbilityQueue") {
song.notes = optimizeAbilityQueue(
song.decodedBuildTemplate,
song.notes
);
}
}
console.log(" Completed");
songs.push(song);
}
if (songs.length == 1) {
return songs[0];
} else {
return songs;
}
}