mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-12-04 19:20:29 -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>
66 lines
2.5 KiB
TypeScript
66 lines
2.5 KiB
TypeScript
// prop's global "info" node (shopinfo.regist, gametop.get_info, and inside every profile),
|
|
// and the songs picked for the weekly league and the daily FC challenge.
|
|
// Layout from bemaniutils' bemani/backend/jubeat/prop.py (__get_global_info).
|
|
|
|
import { PROP_COURSES } from "../../data/prop_courses";
|
|
|
|
const fill = (n: number, v: number): number[] => new Array(n).fill(v);
|
|
const s32a = (v: number[]) => K.ARRAY("s32", v);
|
|
|
|
export const WEEK = 604800;
|
|
const DAY = 86400;
|
|
const nowSec = () => Math.floor(Date.now() / 1000);
|
|
|
|
// Deterministic PRNG so every cabinet agrees on the weekly league / daily FC challenge songs.
|
|
const mulberry32 = (seed: number) => () => {
|
|
seed |= 0; seed = (seed + 0x6d2b79f5) | 0;
|
|
let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);
|
|
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
};
|
|
|
|
// Songs known to exist in prop: everything its course list uses.
|
|
const SONG_POOL: number[] = Array.from(new Set(
|
|
PROP_COURSES.reduce((a, c) => a.concat(c.music.map(m => m[0])), [] as number[]))).sort((a, b) => a - b);
|
|
|
|
const pickSongs = (seed: number, n: number): number[] => {
|
|
const rnd = mulberry32(seed), pool = SONG_POOL.slice(), out: number[] = [];
|
|
while (out.length < n && pool.length) out.push(pool.splice(Math.floor(rnd() * pool.length), 1)[0]);
|
|
return out;
|
|
};
|
|
|
|
/** League ids are week numbers since the epoch. */
|
|
export const currentLeagueId = () => Math.floor(nowSec() / WEEK);
|
|
export const leagueSongs = (leagueId: number) => pickSongs(leagueId * 7919 + 1, 3);
|
|
|
|
export const currentDayId = () => Math.floor(nowSec() / DAY);
|
|
export const fcChallenge = (dayId: number) => {
|
|
const s = pickSongs(dayId * 104729 + 2, 2);
|
|
return { today: s[0], whim: s[1] };
|
|
};
|
|
|
|
const EVENTS = [5, 6, 9, 14, 15, 16, 17, 18, 19];
|
|
|
|
export const info = () => ({
|
|
event_info: {
|
|
event: EVENTS.map(e => K.ATTR({ type: String(e) }, { state: K.ITEM("u8", 0) })),
|
|
},
|
|
share_music: {},
|
|
bonus_music: {},
|
|
only_now_music: {},
|
|
fc_challenge: { today: { music_id: K.ITEM("s32", fcChallenge(currentDayId()).today) } },
|
|
white_music_list: s32a(fill(32, -1)),
|
|
open_music_list: s32a(fill(32, -1)),
|
|
cabinet_survey: { id: K.ITEM("s32", -1), status: K.ITEM("s32", 0) },
|
|
kaitou_bisco: { remaining_days: K.ITEM("s32", 0) },
|
|
league: { status: K.ITEM("u8", 1) },
|
|
bistro: { bistro_id: K.ITEM("u16", 0) },
|
|
jbox: {
|
|
point: K.ITEM("s32", 0),
|
|
emblem: {
|
|
normal: { index: K.ITEM("s16", 2) },
|
|
premium: { index: K.ITEM("s16", 1) },
|
|
},
|
|
},
|
|
});
|