diff --git a/src/main/java/icu/samnyan/aqua/sega/maimai2/Maimai2Apis.kt b/src/main/java/icu/samnyan/aqua/sega/maimai2/Maimai2Apis.kt index 83e4051b..b55d7c0d 100644 --- a/src/main/java/icu/samnyan/aqua/sega/maimai2/Maimai2Apis.kt +++ b/src/main/java/icu/samnyan/aqua/sega/maimai2/Maimai2Apis.kt @@ -6,6 +6,8 @@ import ext.* import icu.samnyan.aqua.sega.general.PagedHandler import icu.samnyan.aqua.sega.maimai2.model.response.data.UserRivalMusic import icu.samnyan.aqua.sega.maimai2.model.response.data.UserRivalMusicDetail +import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserKaleidx +import java.time.LocalDate import java.util.* fun Maimai2ServletController.initApis() { @@ -187,13 +189,34 @@ fun Maimai2ServletController.initApis() { "GetGameNgMusicId" static { mapOf("length" to 0, "musicIdList" to empty) } "GetGameTournamentInfo" static { mapOf("length" to 0, "gameTournamentInfoList" to empty) } + // + val phases = mapOf(1 to 1, 2 to 7, 3 to 14, 4 to 21) + // Find the minimum phase id that started prior to today. + fun findPhase(baseDate: LocalDate): Int { + val today = LocalDate.now() + return phases.entries.find { baseDate.plusDays(it.value.toLong()) >= today }?.key ?: 5 + } + // Kaleidoscope, added on 1.50 - "GetGameKaleidxScope" static { mapOf("gameKaleidxScopeList" to ls( - mapOf("gateId" to 1, "phaseId" to 1), + "GetGameKaleidxScope" { mapOf("gameKaleidxScopeList" to ls( + mapOf("gateId" to 1, "phaseId" to findPhase(LocalDate.of(2025, 1, 18))), + mapOf("gateId" to 2, "phaseId" to findPhase(LocalDate.of(2025, 2, 20))), + mapOf("gateId" to 3, "phaseId" to 2), + mapOf("gateId" to 4, "phaseId" to 2), + mapOf("gateId" to 5, "phaseId" to 2), + mapOf("gateId" to 6, "phaseId" to 2), )) } "GetUserKaleidxScope".unpaged { - db.userKaleidx.findByUser_Card_ExtId(uid) + val u = db.userData.findByCardExtId(uid)() ?: (404 - "User not found") + db.userKaleidx.findByUser(u) .mapApply { isKeyFound = true } + .ifEmpty { ls( + // I'll add this here so people don't need to unlock it + Mai2UserKaleidx().apply { + user = u + gateId = 1 + } + ) } } // Added on 1.50 "GetUserNewItemList" { mapOf("userId" to uid, "userItemList" to empty) } diff --git a/src/main/java/icu/samnyan/aqua/sega/maimai2/model/userdata/UserEntities.kt b/src/main/java/icu/samnyan/aqua/sega/maimai2/model/userdata/UserEntities.kt index ca49b63c..569b9007 100644 --- a/src/main/java/icu/samnyan/aqua/sega/maimai2/model/userdata/UserEntities.kt +++ b/src/main/java/icu/samnyan/aqua/sega/maimai2/model/userdata/UserEntities.kt @@ -581,9 +581,9 @@ class Mai2UserUdemae : Mai2UserEntity() { @Table(name = "maimai2_user_kaleidx") @Data @Entity class Mai2UserKaleidx : Mai2UserEntity() { - var gateId = 0 - var isGateFound = false - var isKeyFound = false + var gateId = 1 + var isGateFound = true + var isKeyFound = true var isClear = false var totalRestLife = 0 var totalAchievement = 0