mirror of https://github.com/hykilpikonna/AquaDX
[F] Fix score display
parent
cb6bf00236
commit
42d94b43b1
|
@ -73,8 +73,4 @@
|
|||
|
||||
.desc
|
||||
opacity: 0.6
|
||||
|
||||
input[type="text"]
|
||||
flex: 1
|
||||
width: 100%
|
||||
</style>
|
||||
|
|
|
@ -2,24 +2,14 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { slide } from "svelte/transition";
|
||||
import { DATA_HOST } from "../libs/config";
|
||||
import { t } from "../libs/i18n";
|
||||
import { type GameName, getMult, parseComposition, roundFloor } from "../libs/scoring";
|
||||
import { type GameName, type ParsedComposition, roundFloor } from "../libs/scoring";
|
||||
import { coverNotFound } from "../libs/ui";
|
||||
import type { MusicMeta } from "../libs/generalTypes";
|
||||
import { tooltip } from "../libs/ui";
|
||||
import useLocalStorage from "../libs/hooks/useLocalStorage.svelte";
|
||||
|
||||
export let g: string
|
||||
export let meta: MusicMeta
|
||||
export let game: GameName
|
||||
|
||||
// // mapData: [id, difficulty, score, rank]
|
||||
// let mapData = g.split(":").map(Number)
|
||||
// // mult: [score cutoff, rank multiplier, rank text]
|
||||
// let mult = getMult(mapData[3], game)
|
||||
// let mapRank: number | undefined = meta?.notes?.[mapData[1] === 10 ? 0 : mapData[1]]?.lv
|
||||
const p = parseComposition(g, meta, game)
|
||||
export let p: ParsedComposition
|
||||
const rounding = useLocalStorage("rounding", true)
|
||||
</script>
|
||||
|
||||
|
@ -29,7 +19,7 @@
|
|||
<img src={p.img} alt="" on:error={coverNotFound} />
|
||||
<div class="info">
|
||||
<div class="first-line">
|
||||
<div class="song-title">{meta?.name ?? t("UserHome.UnknownSong")}</div>
|
||||
<div class="song-title">{p.name ?? t("UserHome.UnknownSong")}</div>
|
||||
<span class={`lv level-${p.diffId === 10 ? 3 : p.diffId}`}>
|
||||
{ p.difficulty ?? '-' }
|
||||
</span>
|
||||
|
@ -42,7 +32,7 @@
|
|||
</span>
|
||||
</span>
|
||||
{#if p.ratingChange !== undefined}
|
||||
<span class="dx-change">{ p.ratingChange.toFixed(1) }</span>
|
||||
<span class="dx-change">{ p.ratingChange }</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,22 +2,26 @@
|
|||
|
||||
<script lang="ts">
|
||||
import RatingCompSong from "./RatingCompSong.svelte";
|
||||
import { type GameName } from "../libs/scoring";
|
||||
import { parseComposition, type GameName } from "../libs/scoring";
|
||||
import { type MusicMeta } from "../libs/generalTypes";
|
||||
|
||||
export let title: string;
|
||||
export let comp: string | undefined;
|
||||
export let allMusics: Record<string, MusicMeta>;
|
||||
export let game: GameName;
|
||||
|
||||
const split = comp?.split(",")?.filter(it => it.split(":")[0] !== '0')
|
||||
?.map(it => parseComposition(it, allMusics[it.split(":")[0]], game))
|
||||
if (split) console.log("Split", split)
|
||||
</script>
|
||||
|
||||
{#if comp}
|
||||
{#if split}
|
||||
<div>
|
||||
<h2>{title}</h2>
|
||||
<div class="rating-composition">
|
||||
{#each comp.split(",").filter(it => it.split(":")[0] !== '0') as map}
|
||||
{#each split as p}
|
||||
<div>
|
||||
<RatingCompSong g={map} meta={allMusics[map.split(":")[0]]} game={game}/>
|
||||
<RatingCompSong {p} {game}/>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
|
|
@ -102,7 +102,8 @@ export function chusanRating(lv: number, score: number) {
|
|||
return 0; // C
|
||||
}
|
||||
|
||||
interface ParsedComposition {
|
||||
export interface ParsedComposition {
|
||||
name?: string
|
||||
musicId: number
|
||||
diffId: number // ID of the difficulty
|
||||
score: number
|
||||
|
@ -111,7 +112,7 @@ interface ParsedComposition {
|
|||
rank: string // e.g. 'SSS+'
|
||||
difficulty?: number // Actual difficulty of the map
|
||||
img: string
|
||||
ratingChange?: number // Rating change after playing this map
|
||||
ratingChange?: string // Rating change after playing this map
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,17 +128,18 @@ export function parseComposition(item: string, meta: MusicMeta, game: GameName):
|
|||
const [ cutoff, mult ] = [ +tup[0], +tup[1] ]
|
||||
const rank = tup[2] as string
|
||||
|
||||
let diff = meta?.notes?.[mapData[1] === 10 ? 0 : mapData[1]]?.lv
|
||||
let diff = meta?.notes?.[diffId === 10 ? 0 : diffId]?.lv
|
||||
|
||||
function calcDxChange() {
|
||||
if (!diff) return
|
||||
if (game === 'mai2')
|
||||
return Math.floor(diff * +mult * (Math.min(100.5, mapData[3] / 10000) / 100))
|
||||
return Math.floor(diff * mult * (Math.min(100.5, score / 10000) / 100)).toFixed(0)
|
||||
if (game === 'chu3')
|
||||
return chusanRating(diff, score) / 100
|
||||
return (chusanRating(diff, score) / 100).toFixed(1)
|
||||
}
|
||||
|
||||
return {
|
||||
name: meta?.name,
|
||||
musicId,
|
||||
diffId,
|
||||
score,
|
||||
|
|
Loading…
Reference in New Issue