mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-12-05 11:40:31 -06:00
Each version (prop, Qubell, clan, festo) is now a module under versions/ with its own route table and model date range. All jubeat versions call the same method names, so versions/index.ts registers one route per method and picks the version from the model date. - handlers/player.ts: one jubeat ID and name per card, in the existing festo `profile` document - handlers/scores.ts: one score store for every version; prop, Qubell and clan only see normal-mode charts of songs up to their own - handlers/version_data.ts: per-version fields, course and league results, keyed by version id (7 prop, 8 Qubell, 9 clan, 10 festo) - V2.1.0 Qubell saves move to the shared profile and scores on first login; the old documents are kept and marked `migrated` - festo moves to versions/festo with the same requests and responses; records without a ghost now get an empty one instead of a broken node - builds older than prop are refused instead of answered as Qubell Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
2.2 KiB
TypeScript
47 lines
2.2 KiB
TypeScript
import { VersionCourse, VersionData, VersionLeague } from "../models/version_data";
|
|
|
|
const META = ["_id", "__refid", "createdAt", "updatedAt", "collection", "version"];
|
|
const strip = (doc: any) => {
|
|
const out: Record<string, any> = {};
|
|
for (const key of Object.keys(doc || {})) if (!META.includes(key)) out[key] = doc[key];
|
|
return out;
|
|
};
|
|
|
|
/** A player's fields for one version (`{}` until the version saves something). */
|
|
export async function loadVersionData(refid: string, version: number): Promise<Record<string, any>> {
|
|
return strip(await DB.FindOne<VersionData>(refid, { collection: "version_data", version }));
|
|
}
|
|
|
|
export async function saveVersionData(refid: string, version: number, fields: Record<string, any>) {
|
|
await DB.Upsert<VersionData>(refid, { collection: "version_data", version }, { $set: strip(fields) });
|
|
}
|
|
|
|
export function versionCourses(refid: string, version: number) {
|
|
return DB.Find<VersionCourse>(refid, { collection: "version_course", version });
|
|
}
|
|
|
|
export function findVersionCourse(refid: string, version: number, courseId: number) {
|
|
return DB.FindOne<VersionCourse>(refid, { collection: "version_course", version, courseId });
|
|
}
|
|
|
|
export async function saveVersionCourse(refid: string, version: number, courseId: number, rating: number, scores: number[]) {
|
|
await DB.Upsert<VersionCourse>(refid, { collection: "version_course", version, courseId }, { $set: { rating, scores } });
|
|
}
|
|
|
|
export function findLeague(refid: string, version: number, leagueId: number) {
|
|
return DB.FindOne<VersionLeague>(refid, { collection: "version_league", version, leagueId });
|
|
}
|
|
|
|
/** Every player's result in one league, for promotions. */
|
|
export function leagueResults(version: number, leagueId: number) {
|
|
return DB.Find<VersionLeague>(null, { collection: "version_league", version, leagueId });
|
|
}
|
|
|
|
export function playerLeagues(refid: string, version: number) {
|
|
return DB.Find<VersionLeague>(refid, { collection: "version_league", version });
|
|
}
|
|
|
|
export async function saveLeague(refid: string, version: number, leagueId: number, score: number[], clear: number[]) {
|
|
await DB.Upsert<VersionLeague>(refid, { collection: "version_league", version, leagueId }, { $set: { score, clear } });
|
|
}
|