feat: add osu! version and release stream retrieval, along with skins count functionality

This commit is contained in:
2025-07-03 14:23:11 +02:00
parent a677755451
commit 2896a68757
8 changed files with 295 additions and 31 deletions

View File

@@ -50,3 +50,31 @@ export const formatTimeReadable = (initialSeconds: number) => {
return result.trim();
};
export const releaseStreamToReadable = (releaseStream: string) => {
if (releaseStream.toLowerCase() === 'cuttingedge') return 'Cutting Edge';
return 'Stable';
};
export const compareBuildNumbers = (current: string, target: string): number => {
const parse = (version: string): [number, number] => {
const cleaned = version.split(/[^0-9.]/)[0];
const [baseStr, hotfixStr] = cleaned.split('.');
const base = parseInt(baseStr, 10);
const hotfix = hotfixStr ? parseInt(hotfixStr, 10) : 0;
return [base, hotfix];
};
const [currentBase, currentHotfix] = parse(current);
const [targetBase, targetHotfix] = parse(target);
if (targetBase > currentBase) {
return targetBase - currentBase + targetHotfix;
} else if (targetBase === currentBase) {
return targetHotfix - currentHotfix;
} else {
return -1;
}
};