Skip to content

Commit

Permalink
Merge branch 'master' into feature/banned-player-ignore-from-vc-count
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism authored Jan 21, 2024
2 parents c9d5a1a + b74e0eb commit 14a8bbc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/structures/game_round.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -682,4 +687,15 @@ export default class GameRound extends Round {
similar: GameRound.similarityCheck(guess, cleanedArtistAliases),
};
}

private extractBracketedComponentsFromName(name: string): Array<string> {
const match = name.match(/([^\s]+) \(([^)]+)\)/);

if (match) {
const output = [match[1], match[2]];
return output;
} else {
return [name];
}
}
}
33 changes: 33 additions & 0 deletions src/test/ci/game_round.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 14a8bbc

Please sign in to comment.