mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-26 04:22:38 +00:00
[F] Fix maimai music unlock
This commit is contained in:
parent
e0c7998448
commit
f4cc9c7734
@ -1,15 +1,14 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler.impl
|
||||
|
||||
import ext.JSON
|
||||
import icu.samnyan.aqua.net.games.Maimai2
|
||||
import icu.samnyan.aqua.sega.general.dao.CardRepository
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserItem
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.data.domain.PageRequest
|
||||
import org.springframework.stereotype.Component
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@ -17,37 +16,40 @@ import org.springframework.stereotype.Component
|
||||
@Component("Maimai2GetUserItemHandler")
|
||||
class GetUserItemHandler(
|
||||
val repos: Mai2Repos,
|
||||
val maimai2: Maimai2
|
||||
val maimai2: Maimai2,
|
||||
val cardRepo: CardRepository,
|
||||
) : BaseHandler {
|
||||
val musicUnlock = (5..8).associateWith { kind ->
|
||||
JSON.encodeToString(maimai2.musicMapping.mapKeys { UserItem().apply {
|
||||
itemKind = kind
|
||||
itemId = it.key
|
||||
stock = 1
|
||||
} }) }
|
||||
maimai2.musicMapping.map { mapOf(
|
||||
"itemKind" to kind,
|
||||
"itemId" to it.key,
|
||||
"stock" to 1,
|
||||
"isValid" to true,
|
||||
).toMap() } }
|
||||
|
||||
override fun handle(request: Map<String, Any>): Any {
|
||||
val userId = request["userId"] as Long
|
||||
val nextIndexVal = request["nextIndex"] as Long
|
||||
val maxCount = request["maxCount"] as Int
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
val nextIndexVal = (request["nextIndex"] as Number).toLong()
|
||||
val maxCount = (request["maxCount"] as Number).toInt()
|
||||
|
||||
val kind = (nextIndexVal / MULT).toInt()
|
||||
val nextIndex = (nextIndexVal % MULT).toInt()
|
||||
val pageNum = nextIndex / maxCount
|
||||
|
||||
// All Music unlock TODO: Check user settings
|
||||
if (kind in 5..8) {
|
||||
logger.info("Response: ${maimai2.musicMapping.size} items - Music unlock")
|
||||
return mapOf(
|
||||
"userId" to userId,
|
||||
"nextIndex" to 0,
|
||||
"itemKind" to kind,
|
||||
"userItemList" to musicUnlock.getValue(kind)
|
||||
)
|
||||
// Aqua Net game unlock feature
|
||||
cardRepo.findByExtId(userId).getOrNull()?.aquaUser?.gameOptions?.let { opt ->
|
||||
// All Music unlock
|
||||
if (kind in 5..8 && opt.unlockMusic) {
|
||||
logger.info("Response: ${maimai2.musicMapping.size} items - Music unlock")
|
||||
return mapOf(
|
||||
"userId" to userId,
|
||||
"nextIndex" to 0,
|
||||
"itemKind" to kind,
|
||||
"userItemList" to musicUnlock.getValue(kind)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
val dbPage = repos.userItem.findByUser_Card_ExtIdAndItemKind(userId, kind, PageRequest.of(pageNum, maxCount))
|
||||
|
||||
val currentIndex = kind * MULT + maxCount * pageNum + dbPage.numberOfElements
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user