Skip to content

Commit

Permalink
Add clean song name as accepted song answer (#2259)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism authored Jan 18, 2025
1 parent b405951 commit 5b31340
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/structures/game_round.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ export default class GameRound extends Round {

constructor(song: QueriedSong, baseExp: number, guildID: string) {
super(song, guildID);
this.acceptedSongAnswers = [song.songName, ...this.songAliases];
this.acceptedSongAnswers = [
song.songName,
song.cleanSongName,
...this.songAliases,
];
if (song.hangulSongName) {
this.acceptedSongAnswers.push(song.hangulSongName);
}
Expand Down
4 changes: 4 additions & 0 deletions src/structures/queried_song.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { AvailableGenders } from "../enums/option_types/gender";

export default class QueriedSong extends BaseArtistInfo {
songName: string;
cleanSongName: string;
hangulSongName: string | null;
youtubeLink: string;
originalLink: string | null;
Expand All @@ -17,6 +18,7 @@ export default class QueriedSong extends BaseArtistInfo {

constructor({
songName,
cleanSongName,
hangulSongName,
artistName,
hangulArtistName,
Expand All @@ -32,6 +34,7 @@ export default class QueriedSong extends BaseArtistInfo {
selectionWeight,
}: {
songName: string;
cleanSongName: string;
hangulSongName: string | null;
artistName: string;
hangulArtistName: string | null;
Expand All @@ -48,6 +51,7 @@ export default class QueriedSong extends BaseArtistInfo {
}) {
super({ artistName, hangulArtistName, artistID });
this.songName = songName;
this.cleanSongName = cleanSongName;
this.artistName = artistName;
this.hangulSongName = hangulSongName === "" ? null : hangulSongName;
this.hangulArtistName =
Expand Down
2 changes: 2 additions & 0 deletions src/structures/song_selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class SongSelector {

public static QueriedSongFields = [
"available_songs.song_name_en as songName",
"available_songs.clean_song_name_alpha_numeric as cleanSongName",
"available_songs.song_name_ko as hangulSongName",
"available_songs.artist_name_en as artistName",
"available_songs.artist_name_ko as hangulArtistName",
Expand All @@ -66,6 +67,7 @@ export default class SongSelector {

public static ExpectedQueriedSongFields = [
"expected_available_songs.song_name_en as songName",
"available_songs.clean_song_name_alpha_numeric as cleanSongName",
"expected_available_songs.song_name_ko as hangulSongName",
"expected_available_songs.artist_name_en as artistName",
"expected_available_songs.artist_name_ko as hangulArtistName",
Expand Down
1 change: 1 addition & 0 deletions src/test/unit_tests/ci/exp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ describe("exp command", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "x",
cleanSongName: "x",
hangulSongName: "x",
artistName: "x",
hangulArtistName: "x",
Expand Down
25 changes: 25 additions & 0 deletions src/test/unit_tests/ci/game_round.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "Song1",
cleanSongName: "Song1",
hangulSongName: "노래1",
artistName: "Jisoo",
hangulArtistName: "지수",
Expand Down Expand Up @@ -68,6 +69,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "Poggers Song",
cleanSongName: "Poggers Song",
hangulSongName: "리그마 포트나이트",
artistName: "IU + Blackpink",
hangulArtistName: "아이유 + 블랙핑크",
Expand Down Expand Up @@ -102,6 +104,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "Good Girls in the Dark",
cleanSongName: "Good Girls in the Dark",
hangulSongName: "상사병에 걸린 소녀들",
artistName: "Yena (Choi Yena)",
hangulArtistName: "최예나 (나)",
Expand Down Expand Up @@ -134,6 +137,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "Lovesick Girls",
cleanSongName: "Lovesick Girls",
hangulSongName: "상사병에 걸린 소녀들",
artistName: " Blackpink + IU ",
hangulArtistName:
Expand Down Expand Up @@ -169,6 +173,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "Sev en !",
cleanSongName: "Sev en",
hangulSongName: "금 !요",
artistName: "Jung kook",
hangulArtistName: "정 국",
Expand Down Expand Up @@ -224,6 +229,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "?!",
cleanSongName: "?!",
hangulSongName: "@#",
artistName: "a",
hangulArtistName: "a",
Expand Down Expand Up @@ -265,6 +271,8 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "A really epic song",
cleanSongName:
"A really epic song that's cleaned",
hangulSongName: "정말 서사시 노래",
artistName: "A really epic person",
hangulArtistName: "정말 서사시인",
Expand All @@ -290,6 +298,13 @@ describe("game round", () => {
),
);

assert.ok(
gameRound.checkGuess(
"A really epic song that's cleaned",
GuessModeType.SONG_NAME,
),
);

assert.ok(
gameRound.checkGuess(
"An epic song",
Expand Down Expand Up @@ -325,6 +340,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "A really epic song",
cleanSongName: "A really epic song",
hangulSongName: "정말 서사시 노래",
artistName: "Person2",
hangulArtistName: "2인칭",
Expand Down Expand Up @@ -377,6 +393,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "Perfect Night",
cleanSongName: "Perfect Night",
hangulSongName: "Perfect Night",
artistName: "Le Sserafim",
hangulArtistName: "르세라핌",
Expand Down Expand Up @@ -435,6 +452,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "1",
cleanSongName: "2",
hangulSongName: "3",
artistName: "5",
hangulArtistName: "6",
Expand Down Expand Up @@ -497,6 +515,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "very cool song",
cleanSongName: "very cool song",
hangulSongName: "매우 시원한 노래",
artistName: "artist",
hangulArtistName: "예술가",
Expand Down Expand Up @@ -788,6 +807,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "very cool song",
cleanSongName: "very cool song",
hangulSongName: "매우 시원한 노래",
artistName: "artist",
hangulArtistName: "예술가",
Expand Down Expand Up @@ -841,6 +861,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "dalla dalla",
cleanSongName: "dalla dalla",
hangulSongName: "매우 시원한 노래",
artistName: "artist",
hangulArtistName: "예술가",
Expand Down Expand Up @@ -969,6 +990,8 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName: "long song name to prevent rng collision",
cleanSongName:
"long song name to prevent rng collision",
hangulSongName: "충돌을 피하기 위해 긴 노래 이름",
artistName: "long artist name to prevent rng collision",
hangulArtistName: "충돌 방지를 위해 긴 아티스트 이름",
Expand Down Expand Up @@ -1009,6 +1032,7 @@ describe("game round", () => {
describe("songs have the same english and korean names, or missing korean name", () => {
it("should generate the same hint", () => {
const songName = "long song name to prevent rng collision";
const cleanSongName = songName;
const artistName = "long artist name to prevent rng collision";
for (const [koSongName, koArtistName] of [
[songName, artistName],
Expand All @@ -1019,6 +1043,7 @@ describe("game round", () => {
gameRound = new GameRound(
new QueriedSong({
songName,
cleanSongName,
hangulSongName: koSongName!,
artistName,
hangulArtistName: koArtistName!,
Expand Down

0 comments on commit 5b31340

Please sign in to comment.