Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New match type: ddrSongHash #1213

Merged
merged 6 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/src/config/game-support/ddr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ export const DDR_SP_CONF = {
chartData: z.strictObject({
inGameID: zodNonNegativeInt,
stepCount: zodNonNegativeInt.optional(),
ddrSongHash: z.string().optional(), // optional because konaste-only songs have no hashes
}),

preferences: z.strictObject({}),
scoreMeta: z.strictObject({}),

supportedMatchTypes: ["inGameID", "songTitle", "tachiSongID"],
supportedMatchTypes: ["inGameID", "songTitle", "tachiSongID", "ddrSongHash"],
} as const satisfies INTERNAL_GAME_PT_CONFIG;

export const DDR_DP_CONF = {
Expand Down
3 changes: 2 additions & 1 deletion common/src/lib/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,8 @@ const PR_BATCH_MANUAL_SCORE = (game: Game, playtype: Playtype): PrudenceSchema =
"inGameID",
"inGameStrID",
"uscChartHash",
"popnChartHash"
"popnChartHash",
"ddrSongHash"
),
identifier: "string",
comment: optNull(p.isBoundedString(3, 240)),
Expand Down
1 change: 1 addition & 0 deletions common/src/types/batch-manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type MatchTypesNoDifficulty = "bmsChartHash" | "itgChartHash" | "popnChartHash"

// These MatchTypes need `difficulty` set in the batch manual.
type MatchTypesWithDifficulty =
| "ddrSongHash"
| "inGameID"
| "inGameStrID"
| "sdvxInGameID"
Expand Down
28 changes: 28 additions & 0 deletions seeds/scripts/test/match-type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,34 @@ const MATCH_TYPE_CHECKS: Record<
},
},
uscChartHash: { type: "CHARTS", fn: (c) => c.data.hashSHA1 },
ddrSongHash: {
type: "CHARTS",
fn: (c) => {
// if there's no ddrSongHash then it must be a konaste song
// so just use the inGameID
if (c.data.ddrSongHash === undefined) {
return `${c.data.inGameID}-${c.difficulty}`;
}

// edge case for the song "B4U (The Acolyte mix)"
//
// for some reason konmai decided to change its inGameID in DDR A3
// so now there's an a20plus version and an a3 version
// (see songIDs 37225 and 37310)
//
// unfortunately, they decided to keep the same ddrSongHash across both!
// so we manually distinguish it here.
const B4UAcolyteSongHash = "01lbO69qQiP691ll6DIiqPbIdd9O806o";
if (c.data.ddrSongHash === B4UAcolyteSongHash) {
if (c.versions[0] === "a20plus") {
return `${c.data.ddrSongHash}-${c.difficulty}-a20plus`;
}
}
// perhaps we could just merge the two "songs" together in the seeds to avoid all this?
tranq88 marked this conversation as resolved.
Show resolved Hide resolved

return `${c.data.ddrSongHash}-${c.difficulty}`;
},
},
};

let exitCode = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,46 @@ export async function ResolveMatchTypeToTachiData(
return { song, chart };
}

case "ddrSongHash": {
const difficulty = AssertStrAsDifficulty(data.difficulty, game, playtype);

let chart: ChartDocument | null;

if (context.version) {
chart = await db.anyCharts.ddr.findOne({
"data.ddrSongHash": data.identifier,
playtype,
difficulty,
versions: context.version,
});
tranq88 marked this conversation as resolved.
Show resolved Hide resolved
} else {
chart = await db.anyCharts.ddr.findOne({
"data.ddrSongHash": data.identifier,
playtype,
difficulty,
isPrimary: true,
});
}

if (!chart) {
throw new SongOrChartNotFoundFailure(
`Cannot find chart for ddrSongHash ${data.identifier} (${playtype}).`,
importType,
data,
context
);
}

const song = await db.anySongs.ddr.findOne({ id: chart.songID });

if (!song) {
logger.severe(`Song-Chart desync on ${chart.songID}.`);
throw new InternalFailure(`Failed to get song for a chart that exists.`);
}

return { song, chart };
}

default: {
const { matchType } = data;

Expand Down
Loading