diff --git a/src/structures/game_round.ts b/src/structures/game_round.ts index 4dec8bc5b..306cdd582 100644 --- a/src/structures/game_round.ts +++ b/src/structures/game_round.ts @@ -185,7 +185,12 @@ export default class GameRound extends Round { ); } - this.acceptedArtistAnswers = [...artistNames, ...this.artistAliases]; + this.acceptedArtistAnswers = [ + ...artistNames.flatMap((x) => + this.extractBracketedComponentsFromName(x), + ), + ...this.artistAliases, + ]; this.baseExp = baseExp; this.hintUsed = false; @@ -682,4 +687,15 @@ export default class GameRound extends Round { similar: GameRound.similarityCheck(guess, cleanedArtistAliases), }; } + + private extractBracketedComponentsFromName(name: string): Array { + const match = name.match(/([^\s]+) \(([^)]+)\)/); + + if (match) { + const output = [match[1], match[2]]; + return output; + } else { + return [name]; + } + } } diff --git a/src/test/ci/game_round.test.ts b/src/test/ci/game_round.test.ts index e0fb09862..ccc143dc3 100644 --- a/src/test/ci/game_round.test.ts +++ b/src/test/ci/game_round.test.ts @@ -82,6 +82,39 @@ describe("game round", () => { }); }); + describe("artist name has a bracket (indicating alternative name)", () => { + it("should add the alternative name as an accepted artist name", () => { + gameRound = new GameRound( + { + songName: "Good Girls in the Dark", + originalSongName: "Good Girls in the Dark", + hangulSongName: "상사병에 걸린 소녀들", + originalHangulSongName: "상사병에 걸린 소녀들", + artistName: "Yena (Choi Yena)", + hangulArtistName: "최예나 (나)", + youtubeLink: "abcde", + publishDate: new Date(), + members: "female", + artistID: 3, + isSolo: "y", + rank: 0, + views: 123456789, + tags: "", + vtype: "main", + selectionWeight: 1, + }, + 5, + ); + + assert.deepStrictEqual(gameRound.acceptedArtistAnswers, [ + "Yena", + "Choi Yena", + "최예나", + "나", + ]); + }); + }); + describe("artist name has trailing or leading spaces", () => { it("should remove them", () => { gameRound = new GameRound(