mirror of https://github.com/hykilpikonna/AquaDX
[+] Ongeki infinite kaika
parent
43e5f93a37
commit
9745e65eed
|
@ -46,6 +46,9 @@ class AquaGameOptions(
|
|||
|
||||
@SettingField("mai2")
|
||||
var enableMusicRank: Boolean = true,
|
||||
|
||||
@SettingField("ongeki")
|
||||
var ongekiInfiniteKaika: Boolean = false,
|
||||
)
|
||||
|
||||
interface AquaGameOptionsRepo : JpaRepository<AquaGameOptions, Long>
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserItemRepository;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserItem;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetUserItemHandler")
|
||||
public class GetUserItemHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserItemHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final UserItemRepository userItemRepository;
|
||||
|
||||
@Autowired
|
||||
public GetUserItemHandler(BasicMapper mapper, UserItemRepository userItemRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userItemRepository = userItemRepository;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
Long nextIndexVal = (Long) request.get("nextIndex");
|
||||
Integer maxCount = (Integer) request.get("maxCount");
|
||||
|
||||
Long mul = 10000000000L;
|
||||
|
||||
int kind = (int) (nextIndexVal / mul);
|
||||
int nextIndex = (int) (nextIndexVal % mul);
|
||||
int pageNum = nextIndex / maxCount;
|
||||
|
||||
Page<UserItem> dbPage = userItemRepository.findByUser_Card_ExtIdAndItemKind(userId, kind, PageRequest.of(pageNum, maxCount));
|
||||
|
||||
long currentIndex = kind * mul + maxCount * pageNum + dbPage.getNumberOfElements();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("length", dbPage.getNumberOfElements());
|
||||
resultMap.put("nextIndex", dbPage.getNumberOfElements() < maxCount ? -1 : currentIndex);
|
||||
resultMap.put("itemKind", kind);
|
||||
resultMap.put("userItemList", dbPage.getContent());
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl
|
||||
|
||||
import ext.*
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserDataRepository
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserItemRepository
|
||||
import icu.samnyan.aqua.sega.ongeki.model.common.ItemType
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserItem
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper
|
||||
import org.springframework.data.domain.PageRequest
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component("OngekiGetUserItemHandler")
|
||||
class GetUserItemHandler(
|
||||
val mapper: BasicMapper,
|
||||
val userDataRepo: UserDataRepository,
|
||||
val userItemRepo: UserItemRepository
|
||||
) : BaseHandler {
|
||||
val log = logger()
|
||||
|
||||
override fun handle(request: Map<String, Any>): String {
|
||||
val uid = parsing { request["userId"]!!.long }
|
||||
val nextIndexVal = parsing { request["nextIndex"]!!.long }
|
||||
val maxCount = parsing { request["maxCount"]!!.int }
|
||||
|
||||
val mul = 10000000000L
|
||||
val kind = (nextIndexVal / mul).toInt()
|
||||
val pg = (nextIndexVal % mul).toInt() / maxCount
|
||||
|
||||
var dat = userItemRepo.findByUser_Card_ExtIdAndItemKind(uid, kind, PageRequest.of(pg, maxCount)).content
|
||||
|
||||
// Check if user have infinite kaika
|
||||
if (kind == ItemType.KaikaItem.ordinal) {
|
||||
val u = userDataRepo.findByCard_ExtId(uid)()
|
||||
u?.card?.aquaUser?.gameOptions?.let {
|
||||
if (it.ongekiInfiniteKaika) {
|
||||
dat = listOf(UserItem().apply {
|
||||
user = u
|
||||
itemKind = ItemType.KaikaItem.ordinal
|
||||
itemId = 1
|
||||
stock = 999
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val resultMap = mapOf(
|
||||
"userId" to uid,
|
||||
"length" to dat.size,
|
||||
"nextIndex" to if (dat.size < maxCount) -1 else kind * mul + maxCount * pg + dat.size,
|
||||
"itemKind" to kind,
|
||||
"userItemList" to dat
|
||||
)
|
||||
|
||||
return mapper.write(resultMap).also { log.info("Response: $it") }
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE aqua_game_options ADD ongeki_infinite_kaika BIT(1) NOT NULL DEFAULT 0;
|
Loading…
Reference in New Issue