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

feat: support exScore, fast, slow, maxCombo as optional metrics for DDR #1163

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions client/src/components/tables/cells/DDRScoreCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export default function DDRScoreCell({
score,
colour,
grade,
exScore,
scoreRenderFn,
}: {
score?: integer;
grade: string;
colour: string;
showScore?: boolean;
exScore?: integer;
scoreRenderFn?: (s: number) => string;
}) {
return (
Expand All @@ -23,6 +25,12 @@ export default function DDRScoreCell({
<strong>{grade}</strong>
<br />
{score !== undefined && <>{scoreRenderFn ? scoreRenderFn(score) : score}</>}
{typeof exScore === "number" && (
<>
<br />
[EX: {exScore}]
</>
)}
</td>
);
}
17 changes: 15 additions & 2 deletions common/src/config/game-support/ddr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IIDXDans } from "./iidx";
import { FmtNum, FmtPercent, FmtScoreNoCommas } from "../../utils/util";
import { FAST_SLOW_MAXCOMBO } from "./_common";
import { FmtNum, FmtScoreNoCommas } from "../../utils/util";
import { ClassValue, zodNonNegativeInt } from "../config-utils";
import { p } from "prudence";
import { z } from "zod";
Expand Down Expand Up @@ -122,6 +122,19 @@ export const DDR_SP_CONF = {
minimumRelevantValue: "0",
description: "The Flare rank. If no Flare is provided, Flare 0 is chosen by default.",
},
exScore: {
type: "INTEGER",
formatter: FmtNum,
validate: p.isPositiveInteger,

// We want to track the best EXScore a user gets, but it is an optional
// metric.
partOfScoreID: true,

description:
"The EXScore value. Marvelous and O.K. judgements are worth 3 points, Perfect judgements are worth 2 points, Great judgements are worth 1 point, and Good and lower judgements are not worth any points.",
},
...FAST_SLOW_MAXCOMBO,
},

defaultMetric: "score",
Expand Down
22 changes: 22 additions & 0 deletions server/src/game-implementations/games/ddr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,25 @@ export const DDR_SCORE_VALIDATORS: Array<ScoreValidator<"ddr:DP" | "ddr:SP">> =
default:
}
},
(s) => {
const { MARVELOUS, PERFECT, GREAT, OK } = s.scoreData.judgements;
zkrising marked this conversation as resolved.
Show resolved Hide resolved

if (
IsNullish(MARVELOUS) ||
IsNullish(PERFECT) ||
IsNullish(GREAT) ||
IsNullish(OK) ||
IsNullish(s.scoreData.optional.exScore)
) {
return;
}

const calculatedExScore = MARVELOUS * 3 + OK * 3 + PERFECT * 2 + GREAT;

if (calculatedExScore !== s.scoreData.optional.exScore) {
return `EXScore expected to be ${calculatedExScore} instead of ${s.scoreData.optional.exScore}`;
}
},
];

export const DDR_IMPL: GPTServerImplementation<"ddr:DP" | "ddr:SP"> = {
Expand Down Expand Up @@ -260,6 +279,9 @@ export const DDR_IMPL: GPTServerImplementation<"ddr:DP" | "ddr:SP"> = {
base.scoreData.score = score.scoreData.score;
base.scoreData.grade = score.scoreData.grade;
}),
CreatePBMergeFor("largest", "optional.exScore", "Best EX Score", (base, score) => {
base.scoreData.optional.exScore = score.scoreData.optional.exScore;
}),
],
profileCalcs: {
flareSkill: async (game: Game, playtype: Playtype, userID: integer) => {
Expand Down
Loading