-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add myt maimai dx import support #1143
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9158a2e
feat: add myt maimai dx import support
albshin b2b4e9d
chore: fix myt integration showing up, tests
albshin 340b9a4
chore: formatting
albshin 030b0a7
fix: linting
albshin 568e40e
chore: more formatting
albshin 259e573
chore: maybe running lint-fix will fix it
albshin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 213 additions & 0 deletions
213
server/src/lib/score-import/import-types/api/myt-maimaidx/converter.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
import ConvertAPIMytMaimaiDx from "./converter"; | ||
import CreateLogCtx from "lib/logger/logger"; | ||
import { ParseDateFromString } from "lib/score-import/framework/common/score-utils"; | ||
import { | ||
MaimaiComboStatus, | ||
MaimaiLevel, | ||
MaimaiScoreRank, | ||
MaimaiSyncStatus, | ||
} from "proto/generated/maimai/common_pb"; | ||
import t from "tap"; | ||
import { dmf } from "test-utils/misc"; | ||
import ResetDBState from "test-utils/resets"; | ||
import { TestingMaimaiDXChartConverter, TestingMaimaiDXSongConverter } from "test-utils/test-data"; | ||
import type { MytMaimaiDxScore } from "./types"; | ||
|
||
const logger = CreateLogCtx(__filename); | ||
|
||
const parsedScore: MytMaimaiDxScore = { | ||
playlogApiId: "6071c489-6ab9-4674-a443-f88b603fa596", | ||
info: { | ||
musicId: 11294, | ||
level: MaimaiLevel.MAIMAI_LEVEL_EXPERT, | ||
achievement: 990562, | ||
deluxscore: 1825, | ||
scoreRank: MaimaiScoreRank.MAIMAI_SCORE_RANK_SS, | ||
comboStatus: MaimaiComboStatus.MAIMAI_COMBO_STATUS_NONE, | ||
syncStatus: MaimaiSyncStatus.MAIMAI_SYNC_STATUS_NONE, | ||
isClear: true, | ||
isAchieveNewRecord: true, | ||
isDeluxscoreNewRecord: true, | ||
track: 1, | ||
userPlayDate: "2022-11-03T04:21:05.000+09:00", | ||
}, | ||
judge: { | ||
judgeCriticalPerfect: 10, | ||
judgePerfect: 656, | ||
judgeGreat: 19, | ||
judgeGood: 1, | ||
judgeMiss: 8, | ||
maxCombo: 279, | ||
fastCount: 5, | ||
lateCount: 8, | ||
}, | ||
}; | ||
|
||
t.test("#ConvertAPIMytMaimaiDx", (t) => { | ||
t.beforeEach(ResetDBState); | ||
|
||
function convert(modifier: any = {}) { | ||
return ConvertAPIMytMaimaiDx(dmf(parsedScore, modifier), {}, "api/myt-maimaidx", logger); | ||
} | ||
|
||
t.test("Should return a dryScore on valid input.", async (t) => { | ||
const res = await convert(); | ||
|
||
t.strictSame(res, { | ||
song: TestingMaimaiDXSongConverter, | ||
chart: TestingMaimaiDXChartConverter, | ||
dryScore: { | ||
service: "MYT", | ||
game: "maimaidx", | ||
scoreMeta: {}, | ||
timeAchieved: ParseDateFromString("2022-11-03T04:21:05.000+09:00"), | ||
comment: null, | ||
importType: "api/myt-maimaidx", | ||
scoreData: { | ||
percent: 99.0562, | ||
lamp: "CLEAR", | ||
judgements: { | ||
pcrit: 10, | ||
perfect: 656, | ||
great: 19, | ||
good: 1, | ||
miss: 8, | ||
}, | ||
optional: { | ||
fast: 5, | ||
slow: 8, | ||
maxCombo: 279, | ||
}, | ||
}, | ||
}, | ||
}); | ||
t.end(); | ||
}); | ||
|
||
t.test("Should reject Utage charts", (t) => { | ||
t.rejects( | ||
() => | ||
convert({ | ||
info: { | ||
musicId: 8032, | ||
level: MaimaiLevel.MAIMAI_LEVEL_UTAGE, | ||
}, | ||
}), | ||
{ | ||
message: /Utage charts are not supported/u, | ||
} | ||
); | ||
t.end(); | ||
}); | ||
|
||
t.test("Should reject unspecified difficulty", (t) => { | ||
t.rejects( | ||
() => | ||
convert({ | ||
info: { | ||
level: MaimaiLevel.MAIMAI_LEVEL_UNSPECIFIED, | ||
}, | ||
}), | ||
{ | ||
message: /Can't process a score with unspecified difficulty/u, | ||
} | ||
); | ||
t.end(); | ||
}); | ||
|
||
t.test("lamp", async (t) => { | ||
t.hasStrict( | ||
await convert({ | ||
info: { | ||
comboStatus: MaimaiComboStatus.MAIMAI_COMBO_STATUS_ALL_PERFECT_PLUS, | ||
isClear: true, | ||
}, | ||
}), | ||
{ | ||
dryScore: { scoreData: { lamp: "ALL PERFECT+" } }, | ||
} | ||
); | ||
t.hasStrict( | ||
await convert({ | ||
info: { | ||
comboStatus: MaimaiComboStatus.MAIMAI_COMBO_STATUS_ALL_PERFECT, | ||
isClear: true, | ||
}, | ||
}), | ||
{ | ||
dryScore: { scoreData: { lamp: "ALL PERFECT" } }, | ||
} | ||
); | ||
t.hasStrict( | ||
await convert({ | ||
info: { | ||
comboStatus: MaimaiComboStatus.MAIMAI_COMBO_STATUS_FULL_COMBO_PLUS, | ||
isClear: true, | ||
}, | ||
}), | ||
{ | ||
dryScore: { scoreData: { lamp: "FULL COMBO+" } }, | ||
} | ||
); | ||
t.hasStrict( | ||
await convert({ | ||
info: { | ||
comboStatus: MaimaiComboStatus.MAIMAI_COMBO_STATUS_FULL_COMBO, | ||
isClear: true, | ||
}, | ||
}), | ||
{ | ||
dryScore: { scoreData: { lamp: "FULL COMBO" } }, | ||
} | ||
); | ||
t.hasStrict( | ||
await convert({ | ||
info: { | ||
comboStatus: MaimaiComboStatus.MAIMAI_COMBO_STATUS_NONE, | ||
isClear: true, | ||
}, | ||
}), | ||
{ | ||
dryScore: { scoreData: { lamp: "CLEAR" } }, | ||
} | ||
); | ||
t.hasStrict( | ||
await convert({ | ||
info: { | ||
comboStatus: MaimaiComboStatus.MAIMAI_COMBO_STATUS_NONE, | ||
isClear: false, | ||
}, | ||
}), | ||
{ | ||
dryScore: { scoreData: { lamp: "FAILED" } }, | ||
} | ||
); | ||
t.hasStrict( | ||
await convert({ | ||
info: { | ||
comboStatus: MaimaiComboStatus.MAIMAI_COMBO_STATUS_FULL_COMBO, | ||
isClear: false, | ||
}, | ||
}), | ||
{ | ||
dryScore: { scoreData: { lamp: "FAILED" } }, | ||
} | ||
); | ||
t.end(); | ||
}); | ||
|
||
t.test("Should throw on missing chart", (t) => { | ||
t.rejects( | ||
() => | ||
convert({ | ||
info: { musicId: 999999, level: MaimaiLevel.MAIMAI_LEVEL_MASTER }, | ||
}), | ||
{ | ||
message: /Can't find chart with id 999999 and difficulty DX Master/u, | ||
} | ||
); | ||
t.end(); | ||
}); | ||
|
||
t.end(); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh