Skip to content

Commit

Permalink
feat: support exScore, fast, slow, maxCombo as optional metrics for DDR
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyoo committed Aug 27, 2024
1 parent 2a07244 commit 023f93e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions common/src/config/game-support/ddr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ClassValue, zodNonNegativeInt } from "../config-utils";
import { p } from "prudence";
import { z } from "zod";
import type { INTERNAL_GAME_CONFIG, INTERNAL_GAME_PT_CONFIG } from "../../types/internals";
import {FAST_SLOW_MAXCOMBO} from "./_common";

export const DDR_FLARE_CATEGORIES = z.enum(["CLASSIC", "WHITE", "GOLD", "NONE"]);

Expand Down Expand Up @@ -122,6 +123,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 All @@ -132,13 +146,21 @@ export const DDR_SP_CONF = {
description: "Flare Skill as it's implemented in DDR World.",
formatter: FmtScoreNoCommas,
},
exScore: {
description: "The EXScore.",
formatter: FmtScoreNoCommas,
},
},

sessionRatingAlgs: {
flareSkill: {
description: "Average of your 10 best Flare Points this session",
formatter: FmtScoreNoCommas,
},
exScore: {
description: "Average of your 10 best EXScores this session",
formatter: FmtScoreNoCommas,
},
},

profileRatingAlgs: {
Expand Down
26 changes: 26 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;

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 Expand Up @@ -336,9 +358,13 @@ export const DDR_IMPL: GPTServerImplementation<"ddr:DP" | "ddr:SP"> = {

return DDRFlare.calculate(chart.levelNum, flareLevel);
},
exScore: (scoreData) => {
return scoreData.optional.exScore ?? 0;
},
},
scoreValidators: DDR_SCORE_VALIDATORS,
sessionCalcs: {
flareSkill: SessionAvgBest10For("flareSkill"),
exScore: SessionAvgBest10For("exScore"),
},
};

0 comments on commit 023f93e

Please sign in to comment.