Skip to content

Commit 81988b7

Browse files
committed
ParserValidator now checks default sound assets for bgms and sfxs
1 parent 91eb3e3 commit 81988b7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/features/game/parser/ParserValidator.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ItemId } from '../commons/CommonTypes';
22
import { GameItemType } from '../location/GameMapTypes';
33
import { GameSoundType } from '../sound/GameSoundTypes';
44
import Parser from './Parser';
5+
import SoundAssets from '../assets/SoundAssets';
56

67
export enum GameEntityType {
78
locations = 'locations',
@@ -203,22 +204,24 @@ export default class ParserValidator {
203204
break;
204205

205206
case GameEntityType.bgms:
206-
const numberOfBgm = Parser.checkpoint.map
207-
.getSoundAssets()
208-
.filter(
207+
const numberOfBgm = [
208+
...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets
209+
...Object.values(SoundAssets) // Default sound assets
210+
].filter(
209211
sound => sound.soundType === GameSoundType.BGM && sound.key === itemId
210212
).length;
211213
if (numberOfBgm === 0) {
212-
console.error(`Cannot find bgm key "${itemId}"`);
214+
throw new Error(`Cannot find bgm key "${itemId}"`);
213215
} else if (numberOfBgm > 1) {
214-
console.error(`More than 1 bgm key "${itemId}"`);
216+
throw new Error(`More than 1 bgm key "${itemId}"`);
215217
}
216218
break;
217219

218220
case GameEntityType.sfxs:
219-
const numberOfSfx = Parser.checkpoint.map
220-
.getSoundAssets()
221-
.filter(
221+
const numberOfSfx = [
222+
...Parser.checkpoint.map.getSoundAssets(), // Imported sound assets
223+
...Object.values(SoundAssets) // Default sound assets
224+
].filter(
222225
sound => sound.soundType === GameSoundType.SFX && sound.key === itemId
223226
).length;
224227
if (numberOfSfx === 0) {

0 commit comments

Comments
 (0)