Skip to content

Commit 75ba67f

Browse files
committed
fix: song null
1 parent 0e925a4 commit 75ba67f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.idea/aquadx-bot.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/types/src/Song.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,17 @@ export default class Song implements DataSong {
207207
return _.uniqBy(results, (it) => `${it.id}_${it.title}`);
208208
}
209209

210-
public static getByCondition(condition: (song: DataSong) => boolean, ver: MaiVersion = 145) {
211-
return dxdata.songs.filter(condition).map(songRaw => new this(songRaw, undefined, false, ver));
210+
public static getByCondition(condition: (song: Song) => boolean, ver: MaiVersion = 145, officialOnly = true) {
211+
let tmp = Song.getAllSongs(ver);
212+
if (officialOnly) {
213+
tmp = tmp.filter(song => song.id < 2000);
214+
}
215+
tmp = tmp.filter(condition);
216+
return tmp;
212217
}
213218

214-
public static getAllIds = () => Object.keys(ALL_MUSIC).map(Number).map(it => it % 1e4);
219+
public static allIds = _.uniq(Object.keys(ALL_MUSIC).map(Number).map(it => it % 1e4));
220+
public static getAllSongs = (ver: MaiVersion = 145) => Song.allIds.map(id => Song.fromId(id, ver)).filter(it => it);
215221

216222
public getChart(difficulty: DifficultyEnum | number | typeof LEVEL[number], dx = this.dx) {
217223
if (LEVEL.includes(difficulty as any)) {

0 commit comments

Comments
 (0)