Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"ts-pattern": "catalog:",
"type-fest": "^4.41.0",
"use-long-press": "^3.3.0",
"web-haptics": "^0.0.6"
"web-haptics": "^0.0.6",
"zod": "^4.3.6"
},
"devDependencies": {
"@cloudflare/vite-plugin": "^1.36.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const ImportFromNETRecordsListItem: FC<{
return (
<>
{open && (
<Dialog open={open} onClose={handleClose}>
<Dialog open={open} onClose={handleClose} onKeyDown={(event) => event.stopPropagation()}>
<ImportFromNETRecordsDialogContent modifyEntries={modifyEntries} onClose={handleClose} />
</Dialog>
)}
Expand Down Expand Up @@ -142,9 +142,15 @@ const ImportFromNETRecordsDialogContent: FC<{
const handleImport = async () => {
setBusy(true)
try {
await importFromNETRecords(appVersion, modifyEntries, mappedAutoImport || 'replace', (state, progress) => {
setProgress({ state, progress })
})
await importFromNETRecords(
appVersion,
modifyEntries,
mappedAutoImport || 'replace',
(state, progress) => {
setProgress({ state, progress })
},
{ region, username, password },
)
onClose()
} catch {
setProgress((progress) => ({
Expand Down Expand Up @@ -356,4 +362,4 @@ const ImportFromNETRecordsDialogContent: FC<{
</DialogActions>
</>
)
}
}
18 changes: 14 additions & 4 deletions apps/web/src/components/rating/io/import/importFromNETRecords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export const importFromNETRecords = async (
modifyEntries: ListActions<PlayEntry>,
mode: 'merge' | 'replace',
onProgress?: (state: FetchNetRecordProgressState, progress: number) => void,
authParams?: AuthParams,
) => {
if (importInFlight) {
console.warn('[importFromNETRecords] Import already in progress, skipping duplicate call')
Expand All @@ -156,15 +157,24 @@ export const importFromNETRecords = async (
icon: <CircularProgress size="1rem" thickness={5} />,
})
try {
const stored = localStorage.getItem('import-net-records')
if (!stored) {
const storedAuthParams = (() => {
const stored = localStorage.getItem('import-net-records')
if (!stored) return null
const parsed = JSON.parse(stored) as {
region: 'jp' | 'intl'
username: string
password: string
}
return parsed
})()
const params = authParams ?? storedAuthParams
if (!params) {
Comment on lines +160 to +171
toast.error(t('rating-calculator:io.import.net-records.no-credentials'), {
id: toastId,
})
throw new Error('No credentials stored.')
}
const parsed = JSON.parse(stored)
const { region, username, password } = parsed
const { region, username, password } = params
const data = await fetchNetRecords({ region, username, password }, (state, progress) => {
onProgress?.(state, progress)
toast.loading(
Expand Down
15 changes: 14 additions & 1 deletion packages/maimai-domain/src/__tests__/import-normalizers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ describe('Rating Import normalizers', () => {
expect(result.entries[0]!.comboFlag).toBe('ap')
})

it('keeps MaimaiNET SSS+ achievements above the rating cap', () => {
const result = normalizeMaimaiNetRecords(catalog, [
{
sheet: { songId: 'Song A', type: 'dx', difficulty: 'master' },
achievement: { rate: 1008427, dxScore: { achieved: 1, total: 2 }, flags: ['allPerfect'] },
},
])

expect(result.entries).toHaveLength(1)
expect(result.entries[0]!.achievementRate).toBe(100.8427)
expect(result.entries[0]!.comboFlag).toBe('ap')
})

it('normalizes MaimaiNET visible titles when song id differs from title', () => {
const titleCatalog = buildSongCatalog(
{
Expand Down Expand Up @@ -258,7 +271,7 @@ describe('Rating Import normalizers', () => {
const maimaiNet = normalizeMaimaiNetRecords(catalog, [
{
sheet: { songId: 'Song A', type: 'dx', difficulty: 'master' },
achievement: { rate: 1006000, dxScore: { achieved: 1, total: 2 }, flags: [] },
achievement: { rate: 1011000, dxScore: { achieved: 1, total: 2 }, flags: [] },
},
])
const divingFish = normalizeDivingFishRows(catalog, [
Expand Down
2 changes: 1 addition & 1 deletion packages/maimai-domain/src/import-normalizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ function normalizeAchievement(value: number, scale: number): number | null {
if (!Number.isFinite(value)) return null

const rate = value / scale
if (rate < 0 || rate > 100.5) return null
if (rate < 0 || rate > 101) return null
return rate
}

Expand Down
Loading
Loading