Skip to content

Commit

Permalink
feat: add myt maimai dx import support (#1143)
Browse files Browse the repository at this point in the history
* feat: add myt maimai dx import support

* chore: fix myt integration showing up, tests

* chore: formatting

* fix: linting

* chore: more formatting

* chore: maybe running lint-fix will fix it
  • Loading branch information
albshin authored Aug 9, 2024
1 parent d0403c2 commit 17a95f1
Show file tree
Hide file tree
Showing 33 changed files with 2,434 additions and 4 deletions.
1 change: 1 addition & 0 deletions bot/src/slashCommands/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const choices: Array<[string, string]> = (
["CG MUSECA", "api/cg-prod-museca"],
["CG Pop'n", "api/cg-prod-popn"],
["MYT CHUNITHM", "api/myt-chunithm"],
["MYT MAIMAI DX", "api/myt-maimaidx"],
["MYT ONGEKI", "api/myt-ongeki"],
["MYT WACCA", "api/myt-wacca"],
] as Array<[string, string]>
Expand Down
13 changes: 12 additions & 1 deletion client/src/app/pages/dashboard/import/ImportPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ function ImportInfoDisplayer({ game }: { game: Game }) {
desc="Use your data from maimai DX NET."
moreInfo="If you are playing on an official maimai DX server, you can import play data from it here."
key="maimai DX NET Importer"
/>
/>,
<ImportTypeInfoCard key="api/myt-maimaidx" importType="api/myt-maimaidx" />
);
} else if (game === "museca") {
Content.unshift(
Expand Down Expand Up @@ -621,6 +622,16 @@ function ImportTypeInfoCard({
key="myt-chunithm"
/>
);
case "api/myt-maimaidx":
return (
<ImportInfoCard
name="MYT Integration"
href="myt-maimaidx"
desc="Pull your MaiMai DX scores from the MYT Network."
moreInfo="Note: All networks are reduced to their first three letters for anonymity reasons."
key="myt-maimaidx"
/>
);
case "api/myt-ongeki":
return (
<ImportInfoCard
Expand Down
3 changes: 3 additions & 0 deletions client/src/app/routes/ImportRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ export default function ImportRoutes() {
<Route exact path="/import/myt-chunithm">
<MytIntegrationPage game="chunithm" />
</Route>
<Route exact path="/import/myt-maimaidx">
<MytIntegrationPage game="maimaidx" />
</Route>
<Route exact path="/import/myt-ongeki">
<MytIntegrationPage game="ongeki" />
</Route>
Expand Down
3 changes: 1 addition & 2 deletions client/src/components/imports/MYTIntegrationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import Icon from "components/util/Icon";
import ImportStateRenderer from "./ImportStateRenderer";

interface Props {
// Other games will be added in the future.
game: "chunithm" | "ongeki" | "wacca";
game: "chunithm" | "maimaidx" | "ongeki" | "wacca";
}

export default function MytIntegrationPage({ game }: Props) {
Expand Down
1 change: 1 addition & 0 deletions common/src/constants/import-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const API_IMPORT_TYPES: Record<APIImportTypes, true> = {
"api/flo-sdvx": true,
"api/min-sdvx": true,
"api/myt-chunithm": true,
"api/myt-maimaidx": true,
"api/myt-ongeki": true,
"api/myt-wacca": true,
"api/cg-dev-museca": true,
Expand Down
1 change: 1 addition & 0 deletions common/src/types/import-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type APIImportTypes =
| "api/flo-sdvx"
| "api/min-sdvx"
| "api/myt-chunithm"
| "api/myt-maimaidx"
| "api/myt-ongeki"
| "api/myt-wacca"

Expand Down
2 changes: 2 additions & 0 deletions server/example/conf.json5
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
"api/cg-gan-sdvx",
"api/cg-gan-popn",
"api/cg-gan-museca",
"api/myt-chunithm",
"api/myt-maimaidx",
"api/myt-ongeki",
"api/myt-wacca",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const parsedScore: MytChunithmScore = {
},
};

t.test("#ConvertAPIMytOngeki", (t) => {
t.test("#ConvertAPIMytChunithm", (t) => {
t.beforeEach(ResetDBState);

function convert(modifier: any = {}) {
Expand Down
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();
});
Loading

0 comments on commit 17a95f1

Please sign in to comment.