forked from Cookies_Github_mirror/AquaDX
Initial Commit
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
package icu.samnyan.aqua.sega.diva.controller;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.boot.AttendHandler;
|
||||
import icu.samnyan.aqua.sega.diva.handler.boot.GameInitHandler;
|
||||
import icu.samnyan.aqua.sega.diva.handler.card.*;
|
||||
import icu.samnyan.aqua.sega.diva.handler.databank.*;
|
||||
import icu.samnyan.aqua.sega.diva.handler.ingame.*;
|
||||
import icu.samnyan.aqua.sega.diva.handler.operation.PingHandler;
|
||||
import icu.samnyan.aqua.sega.diva.handler.user.*;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.boot.GameInitRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.CardProcedureRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.ChangeNameRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.ChangePasswdRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.RegistrationRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.databank.BannerDataRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.databank.PsRankingRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.*;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.PdUnlockRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.PreStartRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.SpendCreditRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.StartRequest;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/diva")
|
||||
public class DivaController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DivaController.class);
|
||||
|
||||
private final GameInitHandler gameInitHandler;
|
||||
private final AttendHandler attendHandler;
|
||||
|
||||
private final CardProcedureHandler cardProcedureHandler;
|
||||
private final ChangeNameHandler changeNameHandler;
|
||||
private final ChangePasswdHandler changePasswdHandler;
|
||||
private final InitPasswdHandler initPasswdHandler;
|
||||
private final RegistrationHandler registrationHandler;
|
||||
|
||||
/**
|
||||
* Databank
|
||||
*/
|
||||
private final BannerInfoHandler bannerInfoHandler;
|
||||
private final BannerDataHandler bannerDataHandler;
|
||||
private final CmPlyInfoHandler cmPlyInfoHandler;
|
||||
private final ContestInfoHandler contestInfoHandler;
|
||||
private final CstmzItmCtlgHandler cstmzItmCtlgHandler;
|
||||
private final CstmzItmNgMdlListHandler cstmzItmNgMdlListHandler;
|
||||
private final FestaInfoHandler festaInfoHandler;
|
||||
private final NgWordHandler ngWordHandler;
|
||||
private final NvRankingHandler nvRankingHandler;
|
||||
private final PsRankingHandler psRankingHandler;
|
||||
private final PstdHCtrlHandler pstdHCtrlHandler;
|
||||
private final PstdItemNgLstHandler pstdItemNgLstHandler;
|
||||
private final PvDefChrLstHandler pvDefChrLstHandler;
|
||||
private final PvListHandler pvListHandler;
|
||||
private final PvNgMdlLstHandler pvNgMdlLstHandler;
|
||||
private final QstInfHandler qstInfHandler;
|
||||
private final RmtWpLstHandler rmtWpLstHandler;
|
||||
private final ShopCatalogHandler shopCatalogHandler;
|
||||
|
||||
private final BuyCstmzItmHandler buyCstmzItmHandler;
|
||||
private final BuyModuleHandler buyModuleHandler;
|
||||
private final GetPvPdHandler getPvPdHandler;
|
||||
private final ShopExitHandler shopExitHandler;
|
||||
private final StageResultHandler stageResultHandler;
|
||||
private final StageStartHandler stageStartHandler;
|
||||
private final StoreSsHandler storeSsHandler;
|
||||
|
||||
private final PingHandler pingHandler;
|
||||
|
||||
private final EndHandler endHandler;
|
||||
private final PdUnlockHandler pdUnlockHandler;
|
||||
private final PreStartHandler preStartHandler;
|
||||
private final SpendCreditHandler spendCreditHandler;
|
||||
private final StartHandler startHandler;
|
||||
|
||||
private final DivaMapper mapper;
|
||||
|
||||
public DivaController(GameInitHandler gameInitHandler, AttendHandler attendHandler, CardProcedureHandler cardProcedureHandler, ChangeNameHandler changeNameHandler, ChangePasswdHandler changePasswdHandler, InitPasswdHandler initPasswdHandler, RegistrationHandler registrationHandler, BannerInfoHandler bannerInfoHandler, BannerDataHandler bannerDataHandler, CmPlyInfoHandler cmPlyInfoHandler, ContestInfoHandler contestInfoHandler, CstmzItmCtlgHandler cstmzItmCtlgHandler, CstmzItmNgMdlListHandler cstmzItmNgMdlListHandler, FestaInfoHandler festaInfoHandler, NgWordHandler ngWordHandler, NvRankingHandler nvRankingHandler, PsRankingHandler psRankingHandler, PstdHCtrlHandler pstdHCtrlHandler, PstdItemNgLstHandler pstdItemNgLstHandler, PvDefChrLstHandler pvDefChrLstHandler, PvListHandler pvListHandler, PvNgMdlLstHandler pvNgMdlLstHandler, QstInfHandler qstInfHandler, RmtWpLstHandler rmtWpLstHandler, ShopCatalogHandler shopCatalogHandler, BuyCstmzItmHandler buyCstmzItmHandler, BuyModuleHandler buyModuleHandler, GetPvPdHandler getPvPdHandler, ShopExitHandler shopExitHandler, StageResultHandler stageResultHandler, StageStartHandler stageStartHandler, StoreSsHandler storeSsHandler, PingHandler pingHandler, EndHandler endHandler, PdUnlockHandler pdUnlockHandler, PreStartHandler preStartHandler, SpendCreditHandler spendCreditHandler, StartHandler startHandler, DivaMapper mapper) {
|
||||
this.gameInitHandler = gameInitHandler;
|
||||
this.attendHandler = attendHandler;
|
||||
this.cardProcedureHandler = cardProcedureHandler;
|
||||
this.changeNameHandler = changeNameHandler;
|
||||
this.changePasswdHandler = changePasswdHandler;
|
||||
this.initPasswdHandler = initPasswdHandler;
|
||||
this.registrationHandler = registrationHandler;
|
||||
this.bannerInfoHandler = bannerInfoHandler;
|
||||
this.bannerDataHandler = bannerDataHandler;
|
||||
this.cmPlyInfoHandler = cmPlyInfoHandler;
|
||||
this.contestInfoHandler = contestInfoHandler;
|
||||
this.cstmzItmCtlgHandler = cstmzItmCtlgHandler;
|
||||
this.cstmzItmNgMdlListHandler = cstmzItmNgMdlListHandler;
|
||||
this.festaInfoHandler = festaInfoHandler;
|
||||
this.ngWordHandler = ngWordHandler;
|
||||
this.nvRankingHandler = nvRankingHandler;
|
||||
this.psRankingHandler = psRankingHandler;
|
||||
this.pstdHCtrlHandler = pstdHCtrlHandler;
|
||||
this.pstdItemNgLstHandler = pstdItemNgLstHandler;
|
||||
this.pvDefChrLstHandler = pvDefChrLstHandler;
|
||||
this.pvListHandler = pvListHandler;
|
||||
this.pvNgMdlLstHandler = pvNgMdlLstHandler;
|
||||
this.qstInfHandler = qstInfHandler;
|
||||
this.rmtWpLstHandler = rmtWpLstHandler;
|
||||
this.shopCatalogHandler = shopCatalogHandler;
|
||||
this.buyCstmzItmHandler = buyCstmzItmHandler;
|
||||
this.buyModuleHandler = buyModuleHandler;
|
||||
this.getPvPdHandler = getPvPdHandler;
|
||||
this.shopExitHandler = shopExitHandler;
|
||||
this.stageResultHandler = stageResultHandler;
|
||||
this.stageStartHandler = stageStartHandler;
|
||||
this.storeSsHandler = storeSsHandler;
|
||||
this.pingHandler = pingHandler;
|
||||
this.endHandler = endHandler;
|
||||
this.pdUnlockHandler = pdUnlockHandler;
|
||||
this.preStartHandler = preStartHandler;
|
||||
this.spendCreditHandler = spendCreditHandler;
|
||||
this.startHandler = startHandler;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
public String formRequest(HttpServletRequest request) throws IOException {
|
||||
String bodyStr = new String(request.getInputStream().readAllBytes());
|
||||
Map<String, Object> body = parse(bodyStr);
|
||||
|
||||
String command = (String) body.getOrDefault("cmd", "");
|
||||
|
||||
logger.info("{}: {}", command, body.toString());
|
||||
|
||||
switch (command) {
|
||||
|
||||
// Boot
|
||||
case "game_init":
|
||||
return gameInitHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
case "attend":
|
||||
return attendHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
|
||||
//
|
||||
case "test":
|
||||
return gameInitHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
|
||||
// Databank
|
||||
case "nv_ranking":
|
||||
return nvRankingHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "ps_ranking":
|
||||
return psRankingHandler.handle(mapper.convert(body, PsRankingRequest.class));
|
||||
case "pv_list":
|
||||
return pvListHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "ng_word":
|
||||
return ngWordHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "rmt_wp_list":
|
||||
return rmtWpLstHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "festa_info":
|
||||
return festaInfoHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "contest_info":
|
||||
return contestInfoHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "pv_def_chr_list":
|
||||
return pvDefChrLstHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "pv_ng_mdl_list":
|
||||
return pvNgMdlLstHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "cstmz_itm_ng_mdl_list":
|
||||
return cstmzItmNgMdlListHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "banner_info":
|
||||
return bannerInfoHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "banner_data":
|
||||
return bannerDataHandler.handle(mapper.convert(body, BannerDataRequest.class));
|
||||
case "cm_ply_info":
|
||||
return cmPlyInfoHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "qst_inf":
|
||||
return qstInfHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "pstd_h_ctrl":
|
||||
return pstdHCtrlHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "pstd_item_ng_lst":
|
||||
return pstdItemNgLstHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "shop_catalog":
|
||||
return shopCatalogHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "cstmz_itm_ctlg":
|
||||
return cstmzItmCtlgHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
|
||||
case "card_procedure":
|
||||
return cardProcedureHandler.handle(mapper.convert(body, CardProcedureRequest.class));
|
||||
case "registration":
|
||||
return registrationHandler.handle(mapper.convert(body, RegistrationRequest.class));
|
||||
case "init_passwd":
|
||||
return initPasswdHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
case "change_passwd":
|
||||
return changePasswdHandler.handle(mapper.convert(body, ChangePasswdRequest.class));
|
||||
case "change_name":
|
||||
return changeNameHandler.handle(mapper.convert(body, ChangeNameRequest.class));
|
||||
|
||||
case "pre_start":
|
||||
return preStartHandler.handle(mapper.convert(body, PreStartRequest.class));
|
||||
case "start":
|
||||
return startHandler.handle(mapper.convert(body, StartRequest.class));
|
||||
case "pd_unlock":
|
||||
return pdUnlockHandler.handle(mapper.convert(body, PdUnlockRequest.class));
|
||||
case "spend_credit":
|
||||
return spendCreditHandler.handle(mapper.convert(body, SpendCreditRequest.class));
|
||||
case "no_card_end":
|
||||
return gameInitHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
case "end":
|
||||
return endHandler.handle(mapper.convert(body, StageResultRequest.class));
|
||||
|
||||
case "get_pv_pd":
|
||||
return getPvPdHandler.handle(mapper.convert(body, GetPvPdRequest.class));
|
||||
case "buy_module":
|
||||
return buyModuleHandler.handle(mapper.convert(body, BuyModuleRequest.class));
|
||||
case "buy_cstmz_itm":
|
||||
return buyCstmzItmHandler.handle(mapper.convert(body, BuyCstmzItmRequest.class));
|
||||
case "shop_exit":
|
||||
return shopExitHandler.handle(mapper.convert(body, ShopExitRequest.class));
|
||||
case "stage_start":
|
||||
return stageStartHandler.handle(mapper.convert(body, StageStartRequest.class));
|
||||
case "stage_result":
|
||||
return stageResultHandler.handle(mapper.convert(body, StageResultRequest.class));
|
||||
case "store_ss":
|
||||
return gameInitHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
|
||||
default:
|
||||
return "stat=0";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public String fileRequest(@RequestParam String query, @RequestParam(required = false) MultipartFile bin) throws IOException, ServletException {
|
||||
|
||||
Map<String, Object> body = parse(query);
|
||||
|
||||
String command = (String) body.getOrDefault("cmd", "");
|
||||
|
||||
logger.info("{}: {}", command, body.toString());
|
||||
|
||||
switch (command) {
|
||||
case "ping":
|
||||
return pingHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "investigate":
|
||||
return gameInitHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "store_ss":
|
||||
return storeSsHandler.handle(mapper.convert(body, StoreSsRequest.class), bin);
|
||||
default:
|
||||
return "stat=1";
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> parse(String form) {
|
||||
String[] kvps = form.split("&");
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
for (String kvp :
|
||||
kvps) {
|
||||
String[] k = kvp.split("=");
|
||||
k[1] = URLDecoder.decode(k[1], StandardCharsets.UTF_8);
|
||||
Object value;
|
||||
if (k[1].contains(",")) {
|
||||
value = deArray(k[1]);
|
||||
} else {
|
||||
value = k[1];
|
||||
}
|
||||
body.put(k[0], value);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
private Object deArray(String input) {
|
||||
if (!input.contains(",")) return input;
|
||||
return Arrays.stream(input.split(",")).map(x -> URLDecoder.decode(x, StandardCharsets.UTF_8))
|
||||
.map(this::deArray).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package icu.samnyan.aqua.sega.diva.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@ControllerAdvice(basePackages = "icu.samnyan.aqua.sega.diva")
|
||||
public class DivaControllerAdvice {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.gamedata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.Contest;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface ContestRepository extends JpaRepository<Contest, Integer> {
|
||||
List<Contest> findTop8ByEnable(boolean enable);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.gamedata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.DivaCustomize;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface DivaCustomizeRepository extends JpaRepository<DivaCustomize, Integer> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.gamedata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.DivaModule;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface DivaModuleRepository extends JpaRepository<DivaModule, Integer> {
|
||||
Optional<DivaModule> findById(int id);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.gamedata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.Festa;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface FestaRepository extends JpaRepository<Festa, Integer> {
|
||||
List<Festa> findTop2ByEnableOrderByCreateDateDesc(boolean enable);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.gamedata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.NgWords;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface NgWordsRepository extends JpaRepository<NgWords, Integer> {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.gamedata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.PvEntry;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface PvEntryRepository extends JpaRepository<PvEntry, Integer> {
|
||||
List<PvEntry> findByDifficulty(Difficulty difficulty);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface GameSessionRepository extends JpaRepository<GameSession, Long> {
|
||||
Optional<GameSession> findByPdId(PlayerProfile profile);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayLog;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface PlayLogRepository extends JpaRepository<PlayLog, Long> {
|
||||
Page<PlayLog> findByPdId_PdIdOrderByDateTimeDesc(int pdId, Pageable page);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerContest;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public interface PlayerContestRepository extends JpaRepository<PlayerContest, Long> {
|
||||
Optional<PlayerContest> findByPdIdAndContestId(PlayerProfile pdId, int contestId);
|
||||
|
||||
List<PlayerContest> findTop4ByPdIdOrderByLastUpdateTimeDesc(PlayerProfile pdId);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerCustomize;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface PlayerCustomizeRepository extends JpaRepository<PlayerCustomize, Long> {
|
||||
List<PlayerCustomize> findByPdId(PlayerProfile profile);
|
||||
|
||||
Page<PlayerCustomize> findByPdId_PdId(int pdId, Pageable page);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerModule;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface PlayerModuleRepository extends JpaRepository<PlayerModule, Long> {
|
||||
List<PlayerModule> findByPdId(PlayerProfile profile);
|
||||
|
||||
Page<PlayerModule> findByPdId_PdId(int pdId, Pageable pageable);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface PlayerProfileRepository extends JpaRepository<PlayerProfile, Long> {
|
||||
|
||||
Optional<PlayerProfile> findByPdId(int pdId);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvCustomize;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface PlayerPvCustomizeRepository extends JpaRepository<PlayerPvCustomize, Long> {
|
||||
Optional<PlayerPvCustomize> findByPdIdAndPvId(PlayerProfile profile, int pvId);
|
||||
|
||||
Optional<PlayerPvCustomize> findByPdId_PdIdAndPvId(int pdId, int pvId);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Edition;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvRecord;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface PlayerPvRecordRepository extends JpaRepository<PlayerPvRecord, Long> {
|
||||
Optional<PlayerPvRecord> findByPdIdAndPvIdAndEditionAndDifficulty(PlayerProfile profile, int pvId, Edition edition, Difficulty difficulty);
|
||||
|
||||
@Query("SELECT COUNT(t1.id) as ranking from DivaPlayerPvRecord as t1 " +
|
||||
"where t1.maxScore >= (" +
|
||||
"SELECT maxScore from DivaPlayerPvRecord where pvId = :pvId and pdId = :pdId and edition = :edition and difficulty = :difficulty" +
|
||||
") and t1.pvId = :pvId and t1.edition = :edition and t1.difficulty = :difficulty")
|
||||
Integer rankByPvIdAndPdIdAndEditionAndDifficulty(@Param("pvId") int pvId,
|
||||
@Param("pdId") PlayerProfile pdId,
|
||||
@Param("edition") Edition edition,
|
||||
@Param("difficulty") Difficulty difficulty
|
||||
);
|
||||
|
||||
List<PlayerPvRecord> findByPdId(PlayerProfile profile);
|
||||
|
||||
Optional<PlayerPvRecord> findByIdAndPdId_PdId(long id, int pdId);
|
||||
|
||||
List<PlayerPvRecord> findByPdIdAndEdition(PlayerProfile profile, Edition edition);
|
||||
|
||||
List<PlayerPvRecord> findTop3ByPvIdAndEditionAndDifficultyOrderByMaxScore(int pvId, Edition edition, Difficulty difficulty);
|
||||
|
||||
Page<PlayerPvRecord> findByPdId_PdIdOrderByPvId(int pdId, Pageable page);
|
||||
|
||||
List<PlayerPvRecord> findByPdId_PdIdAndPvId(int pdId, int pvId);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerScreenShot;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public interface PlayerScreenShotRepository extends JpaRepository<PlayerScreenShot, Long> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package icu.samnyan.aqua.sega.diva.exception;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class ProfileNotFoundException extends RuntimeException {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package icu.samnyan.aqua.sega.diva.exception;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class PvRecordDataException extends RuntimeException {
|
||||
public PvRecordDataException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package icu.samnyan.aqua.sega.diva.exception;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class SessionNotExistException extends RuntimeException {
|
||||
|
||||
public SessionNotExistException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SessionNotExistException() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package icu.samnyan.aqua.sega.diva.exception;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class SessionNotFoundException extends RuntimeException {
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package icu.samnyan.aqua.sega.diva.filter;
|
||||
|
||||
import icu.samnyan.aqua.sega.chunithm.filter.ChuniRequestWrapper;
|
||||
import icu.samnyan.aqua.sega.util.Compression;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class DivaCompressionFilter extends OncePerRequestFilter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DivaCompressionFilter.class);
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
|
||||
String encoding = request.getHeader("pragma");
|
||||
byte[] reqSrc = request.getInputStream().readAllBytes();
|
||||
|
||||
byte[] reqResult;
|
||||
if (encoding != null && encoding.equals("DFI")) {
|
||||
reqResult = Base64.getMimeDecoder().decode(reqSrc);
|
||||
reqResult = Compression.decompress(reqResult);
|
||||
} else {
|
||||
reqResult = reqSrc;
|
||||
}
|
||||
|
||||
ChuniRequestWrapper requestWrapper = new ChuniRequestWrapper(request, reqResult);
|
||||
|
||||
filterChain.doFilter(requestWrapper, response);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
|
||||
String path = request.getServletPath();
|
||||
return !path.startsWith("/diva");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class BaseHandler {
|
||||
|
||||
protected final DivaMapper mapper;
|
||||
|
||||
public BaseHandler(DivaMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
protected String build(Map<String, Object> map) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
map.forEach((key, val) -> {
|
||||
if (val != null) {
|
||||
if (val instanceof String) {
|
||||
if (!val.equals("")) {
|
||||
sb.append(key).append("=");
|
||||
sb.append(val);
|
||||
sb.append("&");
|
||||
}
|
||||
} else {
|
||||
sb.append(key).append("=");
|
||||
// sb.append(URLEncoder.encode(String.valueOf(val), StandardCharsets.UTF_8));
|
||||
sb.append(val);
|
||||
sb.append("&");
|
||||
}
|
||||
}
|
||||
});
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.boot;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.attend.DispersalParameter;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.attend.EtcParameter;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.attend.GameBalanceParameter;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.boot.AttendResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class AttendHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AttendHandler.class);
|
||||
|
||||
public AttendHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
AttendResponse response = new AttendResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
new EtcParameter().toInternal(),
|
||||
new DispersalParameter().toInternal(),
|
||||
new GameBalanceParameter().toInternal(),
|
||||
LocalDateTime.now()
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.boot;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.boot.GameInitResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class GameInitHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GameInitHandler.class);
|
||||
|
||||
public GameInitHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
GameInitResponse response = new GameInitResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
"0,0",
|
||||
"FFFF"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.StartMode;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.CardProcedureRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.CardProcedureResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class CardProcedureHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CardProcedureHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public CardProcedureHandler(DivaMapper mapper, PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
public String handle(CardProcedureRequest request) {
|
||||
Optional<PlayerProfile> profileOptional = playerProfileService.findByPdId(request.getAime_id());
|
||||
CardProcedureResponse response;
|
||||
if (profileOptional.isEmpty()) {
|
||||
response = new CardProcedureResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.FAILED
|
||||
);
|
||||
} else {
|
||||
PlayerProfile profile = profileOptional.get();
|
||||
|
||||
Optional<GameSession> sessionOptional = gameSessionRepository.findByPdId(profile);
|
||||
if (sessionOptional.isPresent()) {
|
||||
GameSession session = sessionOptional.get();
|
||||
if (session.getLastUpdateTime().isBefore(LocalDateTime.now().minusMinutes(5))) {
|
||||
gameSessionRepository.delete(session);
|
||||
}
|
||||
response = new CardProcedureResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.FAILED
|
||||
);
|
||||
} else {
|
||||
GameSession session = new GameSession(
|
||||
ThreadLocalRandom.current().nextInt(100, 99999),
|
||||
profile,
|
||||
StartMode.CARD_PROCEDURE,
|
||||
LocalDateTime.now(),
|
||||
LocalDateTime.now(),
|
||||
-1,
|
||||
-1,
|
||||
profile.getLevel(),
|
||||
profile.getLevelExp(),
|
||||
profile.getLevel(),
|
||||
profile.getLevelExp(),
|
||||
profile.getVocaloidPoints()
|
||||
);
|
||||
|
||||
gameSessionRepository.save(session);
|
||||
response = new CardProcedureResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.SUCCESS,
|
||||
100,
|
||||
session.getAcceptId(),
|
||||
profile.getPdId(),
|
||||
profile.getPlayerName(),
|
||||
profile.getLevel(),
|
||||
profile.getLevelExp(),
|
||||
profile.getLevelTitle(),
|
||||
profile.getPlateEffectId(),
|
||||
profile.getPlateId(),
|
||||
profile.getVocaloidPoints(),
|
||||
profile.getPasswordStatus()
|
||||
);
|
||||
}
|
||||
}
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.ChangeNameRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.ChangeNameResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class ChangeNameHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChangeNameHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public ChangeNameHandler(DivaMapper mapper, PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
public String handle(ChangeNameRequest request) {
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
profile.setPlayerName(request.getPlayer_name());
|
||||
|
||||
ChangeNameResponse response = new ChangeNameResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.SUCCESS,
|
||||
profile.getPdId(),
|
||||
session.getAcceptId(),
|
||||
profile.getPlayerName()
|
||||
);
|
||||
|
||||
playerProfileService.save(profile);
|
||||
gameSessionRepository.delete(session);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.PassStat;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.ChangePasswdRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.ChangePasswdResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class ChangePasswdHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChangePasswdHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public ChangePasswdHandler(DivaMapper mapper, PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
public String handle(ChangePasswdRequest request) {
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
profile.setPasswordStatus(PassStat.SET);
|
||||
profile.setPassword(request.getNew_passwd());
|
||||
|
||||
ChangePasswdResponse response = new ChangePasswdResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.SUCCESS,
|
||||
profile.getPdId(),
|
||||
session.getAcceptId()
|
||||
);
|
||||
|
||||
playerProfileService.save(profile);
|
||||
gameSessionRepository.delete(session);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class InitPasswdHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(InitPasswdHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public InitPasswdHandler(DivaMapper mapper, PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
BaseResponse response = new BaseResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"0");
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.RegistrationRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.RegistrationResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class RegistrationHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RegistrationHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
public RegistrationHandler(DivaMapper mapper, PlayerProfileService playerProfileService) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
}
|
||||
|
||||
public String handle(RegistrationRequest request) {
|
||||
RegistrationResponse response;
|
||||
if (playerProfileService.findByPdId(request.getAime_id()).isPresent()) {
|
||||
response = new RegistrationResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.FAILED,
|
||||
-1);
|
||||
} else {
|
||||
PlayerProfile profile = playerProfileService.register(request);
|
||||
response = new RegistrationResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.SUCCESS,
|
||||
profile.getPdId());
|
||||
}
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.databank.BannerDataRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.BannerDataResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class BannerDataHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BannerDataHandler.class);
|
||||
|
||||
public BannerDataHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BannerDataRequest request) {
|
||||
BannerDataResponse response = new BannerDataResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
LocalDateTime.now(),
|
||||
"***",
|
||||
"***",
|
||||
request.getBd_id()
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.BannerInfoResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class BannerInfoHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BannerInfoHandler.class);
|
||||
|
||||
public BannerInfoHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
BannerInfoResponse response = new BannerInfoResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class CmPlyInfoHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CmPlyInfoHandler.class);
|
||||
|
||||
public CmPlyInfoHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
BaseResponse response = new BaseResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok");
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.ContestRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.Contest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.ContestInfoResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class ContestInfoHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CmPlyInfoHandler.class);
|
||||
|
||||
private final ContestRepository contestRepository;
|
||||
|
||||
public ContestInfoHandler(DivaMapper mapper, ContestRepository contestRepository) {
|
||||
super(mapper);
|
||||
this.contestRepository = contestRepository;
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
List<Contest> contestList = contestRepository.findTop8ByEnable(true);
|
||||
String ci_str = "***";
|
||||
if (!contestList.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
contestList.forEach(x -> sb.append(URIEncoder.encode(x.getString())).append(","));
|
||||
sb.append("%2A%2A%2A,".repeat(Math.max(0, 8 - contestList.size())));
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
ci_str = sb.toString();
|
||||
}
|
||||
ContestInfoResponse response = new ContestInfoResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
LocalDateTime.now(),
|
||||
ci_str
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.DivaCustomizeRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.DivaCustomize;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.CstmzItmCtlgResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class CstmzItmCtlgHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CstmzItmCtlgHandler.class);
|
||||
|
||||
private final DivaCustomizeRepository customizeRepository;
|
||||
|
||||
public CstmzItmCtlgHandler(DivaMapper mapper, DivaCustomizeRepository customizeRepository) {
|
||||
super(mapper);
|
||||
this.customizeRepository = customizeRepository;
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
List<DivaCustomize> customizeList = customizeRepository.findAll();
|
||||
|
||||
CstmzItmCtlgResponse response = new CstmzItmCtlgResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now()),
|
||||
URIEncoder.encode(customizeList.stream().map(DivaCustomize::toInternal).map(URIEncoder::encode)
|
||||
.collect(Collectors.joining(",")))
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.CstmzItmNgMdlListResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class CstmzItmNgMdlListHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CstmzItmCtlgHandler.class);
|
||||
|
||||
public CstmzItmNgMdlListHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
CstmzItmNgMdlListResponse response = new CstmzItmNgMdlListResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now()),
|
||||
"***"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.FestaRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.collection.FestaCollection;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.Festa;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.FestaInfoResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class FestaInfoHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(FestaInfoHandler.class);
|
||||
|
||||
private final FestaRepository festaRepository;
|
||||
|
||||
public FestaInfoHandler(DivaMapper mapper, FestaRepository festaRepository) {
|
||||
super(mapper);
|
||||
this.festaRepository = festaRepository;
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
List<Festa> festaList = festaRepository.findTop2ByEnableOrderByCreateDateDesc(true);
|
||||
FestaCollection collection = new FestaCollection(festaList);
|
||||
|
||||
FestaInfoResponse response = new FestaInfoResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
collection.getIds(),
|
||||
collection.getNames(),
|
||||
collection.getKinds(),
|
||||
collection.getDiffs(),
|
||||
collection.getPvIds(),
|
||||
collection.getAttr(),
|
||||
collection.getAddVps(),
|
||||
collection.getVpMultipliers(),
|
||||
collection.getStarts(),
|
||||
collection.getEnds(),
|
||||
collection.getLastUpdateTime()
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class NgWordHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NgWordHandler.class);
|
||||
|
||||
public NgWordHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
BaseResponse response = new BaseResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok");
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.NvRankingResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class NvRankingHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NvRankingHandler.class);
|
||||
|
||||
public NvRankingHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
NvRankingResponse response = new NvRankingResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerPvRecordRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Edition;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.collection.PsRankingCollection;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.databank.PsRankingRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.PsRankingResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvRecord;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PsRankingHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PsRankingHandler.class);
|
||||
|
||||
private final PlayerPvRecordRepository playerPvRecordRepository;
|
||||
|
||||
public PsRankingHandler(DivaMapper mapper, PlayerPvRecordRepository playerPvRecordRepository) {
|
||||
super(mapper);
|
||||
this.playerPvRecordRepository = playerPvRecordRepository;
|
||||
}
|
||||
|
||||
public String handle(PsRankingRequest request) {
|
||||
Edition edition = Edition.ORIGINAL;
|
||||
Difficulty difficulty = Difficulty.HARD;
|
||||
|
||||
switch (request.getRnk_ps_idx()) {
|
||||
case 0:
|
||||
difficulty = Difficulty.HARD;
|
||||
break;
|
||||
case 1:
|
||||
difficulty = Difficulty.EXTREME;
|
||||
break;
|
||||
case 2: {
|
||||
difficulty = Difficulty.EXTREME;
|
||||
edition = Edition.EXTRA;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int[] list = request.getRnk_ps_pv_id_lst();
|
||||
Map<Integer, PsRankingCollection> resultCollections = new LinkedHashMap<>();
|
||||
for (int i :
|
||||
list) {
|
||||
|
||||
List<PlayerPvRecord> records = playerPvRecordRepository.findTop3ByPvIdAndEditionAndDifficultyOrderByMaxScore(i, Edition.ORIGINAL, difficulty);
|
||||
resultCollections.put(i, new PsRankingCollection(i, edition, records));
|
||||
}
|
||||
|
||||
List<Integer> pvIds = new LinkedList<>();
|
||||
List<Integer> edition1 = new LinkedList<>();
|
||||
List<Integer> edition2 = new LinkedList<>();
|
||||
List<Integer> edition3 = new LinkedList<>();
|
||||
List<Integer> score1 = new LinkedList<>();
|
||||
List<Integer> score2 = new LinkedList<>();
|
||||
List<Integer> score3 = new LinkedList<>();
|
||||
List<String> name1 = new LinkedList<>();
|
||||
List<String> name2 = new LinkedList<>();
|
||||
List<String> name3 = new LinkedList<>();
|
||||
|
||||
resultCollections.forEach((key, obj) -> {
|
||||
pvIds.add(key);
|
||||
edition1.add(obj.getFirst().getEdition().getValue());
|
||||
edition2.add(obj.getSecond().getEdition().getValue());
|
||||
edition3.add(obj.getThird().getEdition().getValue());
|
||||
score1.add(obj.getFirst().getMaxScore());
|
||||
score2.add(obj.getSecond().getMaxScore());
|
||||
score3.add(obj.getThird().getMaxScore());
|
||||
name1.add(URIEncoder.encode(obj.getFirst().getPdId() != null ? obj.getFirst().getPdId().getPlayerName() : "xxx"));
|
||||
name2.add(URIEncoder.encode(obj.getSecond().getPdId() != null ? obj.getFirst().getPdId().getPlayerName() : "xxx"));
|
||||
name3.add(URIEncoder.encode(obj.getThird().getPdId() != null ? obj.getFirst().getPdId().getPlayerName() : "xxx"));
|
||||
});
|
||||
|
||||
PsRankingResponse response = new PsRankingResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
LocalDateTime.now(),
|
||||
LocalDateTime.now(),
|
||||
request.getRnk_ps_idx(),
|
||||
pvIds.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
edition1.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
edition2.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
edition3.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
score1.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
score2.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
score3.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
name1.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
name2.stream().map(Object::toString).collect(Collectors.joining(",")),
|
||||
name3.stream().map(Object::toString).collect(Collectors.joining(","))
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.PstdHCtrlResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PstdHCtrlHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PstdHCtrlHandler.class);
|
||||
|
||||
public PstdHCtrlHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
PstdHCtrlResponse response = new PstdHCtrlResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now()),
|
||||
"***,***"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.PstdItemNgLstResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PstdItemNgLstHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PstdItemNgLstHandler.class);
|
||||
|
||||
public PstdItemNgLstHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
PstdItemNgLstResponse response = new PstdItemNgLstResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now()),
|
||||
"***",
|
||||
"***"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.PvDefChrLstResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PvDefChrLstHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PvDefChrLstHandler.class);
|
||||
|
||||
public PvDefChrLstHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
PvDefChrLstResponse response = new PvDefChrLstResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now()),
|
||||
"***"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.PvEntryRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.PvEntry;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.PvListResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PvListHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BannerDataHandler.class);
|
||||
|
||||
private final PvEntryRepository pvEntryRepository;
|
||||
|
||||
private final DateTimeFormatter df;
|
||||
|
||||
public PvListHandler(DivaMapper mapper, PvEntryRepository pvEntryRepository) {
|
||||
super(mapper);
|
||||
this.pvEntryRepository = pvEntryRepository;
|
||||
this.df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<PvEntry> easyList = pvEntryRepository.findByDifficulty(Difficulty.EASY);
|
||||
List<PvEntry> normalList = pvEntryRepository.findByDifficulty(Difficulty.NORMAL);
|
||||
List<PvEntry> hardList = pvEntryRepository.findByDifficulty(Difficulty.HARD);
|
||||
List<PvEntry> extremeList = pvEntryRepository.findByDifficulty(Difficulty.EXTREME);
|
||||
|
||||
sb.append(URIEncoder.encode(difficultyString(easyList))).append(",");
|
||||
sb.append(URIEncoder.encode(difficultyString(normalList))).append(",");
|
||||
sb.append(URIEncoder.encode(difficultyString(hardList))).append(",");
|
||||
sb.append(URIEncoder.encode(difficultyString(extremeList))).append(",");
|
||||
sb.append("%2A%2A%2A");
|
||||
|
||||
PvListResponse response = new PvListResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
LocalDateTime.now(),
|
||||
sb.toString());
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private String entryString(PvEntry entry) {
|
||||
return "" + entry.getPvId() + "," +
|
||||
entry.getVersion() + "," +
|
||||
entry.getEdition().getValue() + "," +
|
||||
df.format(entry.getDemoStart()) + "," +
|
||||
df.format(entry.getDemoEnd()) + "," +
|
||||
df.format(entry.getPlayableStart()) + "," +
|
||||
df.format(entry.getPlayableEnd());
|
||||
}
|
||||
|
||||
private String difficultyString(List<PvEntry> list) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
list.forEach(x -> sb.append(URIEncoder.encode(entryString(x))).append(","));
|
||||
if (sb.length() > 0) sb.deleteCharAt(sb.length() - 1);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.PvNgMdlLstResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PvNgMdlLstHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PvNgMdlLstHandler.class);
|
||||
|
||||
public PvNgMdlLstHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
|
||||
PvNgMdlLstResponse response = new PvNgMdlLstResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now()),
|
||||
"***"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.QstInfResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class QstInfHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(QstInfHandler.class);
|
||||
|
||||
public QstInfHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
|
||||
QstInfResponse response = new QstInfResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now()),
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.RmtWpLstResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class RmtWpLstHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(QstInfHandler.class);
|
||||
|
||||
public RmtWpLstHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
RmtWpLstResponse response = new RmtWpLstResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now()),
|
||||
"***"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.DivaModuleRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.DivaModule;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.ShopCatalogResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class ShopCatalogHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ShopCatalogHandler.class);
|
||||
|
||||
private final DivaModuleRepository moduleRepository;
|
||||
|
||||
public ShopCatalogHandler(DivaMapper mapper, DivaModuleRepository moduleRepository) {
|
||||
super(mapper);
|
||||
this.moduleRepository = moduleRepository;
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
List<DivaModule> moduleList = moduleRepository.findAll();
|
||||
|
||||
ShopCatalogResponse response = new ShopCatalogResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
LocalDateTime.now(),
|
||||
URIEncoder.encode(moduleList.stream().map(DivaModule::toInternal).map(URIEncoder::encode)
|
||||
.collect(Collectors.joining(",")))
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.DivaCustomizeRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.DivaCustomize;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.BuyCstmzItmRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.BuyCstmzItmResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerCustomizeService;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class BuyCstmzItmHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BuyCstmzItmHandler.class);
|
||||
|
||||
private final DivaCustomizeRepository divaCustomizeRepository;
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final PlayerCustomizeService playerCustomizeService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public BuyCstmzItmHandler(DivaMapper mapper, DivaCustomizeRepository divaCustomizeRepository, PlayerProfileService playerProfileService, PlayerCustomizeService playerCustomizeService, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.divaCustomizeRepository = divaCustomizeRepository;
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.playerCustomizeService = playerCustomizeService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
public String handle(BuyCstmzItmRequest request) {
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
Optional<DivaCustomize> customizeOptional = divaCustomizeRepository.findById(request.getCstmz_itm_id());
|
||||
|
||||
BuyCstmzItmResponse response;
|
||||
if (customizeOptional.isEmpty()) {
|
||||
response = new BuyCstmzItmResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.FAILED
|
||||
);
|
||||
} else {
|
||||
if (session.getVp() < customizeOptional.get().getPrice()) {
|
||||
response = new BuyCstmzItmResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.FAILED
|
||||
);
|
||||
} else {
|
||||
playerCustomizeService.buy(profile, request.getCstmz_itm_id());
|
||||
session.setVp(session.getVp() - customizeOptional.get().getPrice());
|
||||
gameSessionRepository.save(session);
|
||||
|
||||
response = new BuyCstmzItmResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.SUCCESS,
|
||||
request.getCstmz_itm_id(),
|
||||
playerCustomizeService.getModuleHaveString(profile),
|
||||
session.getVp()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.DivaModuleRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.DivaModule;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.BuyModuleRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.BuyModuleResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerModuleService;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class BuyModuleHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BuyModuleHandler.class);
|
||||
|
||||
private final DivaModuleRepository divaModuleRepository;
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final PlayerModuleService playerModuleService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public BuyModuleHandler(DivaMapper mapper, DivaModuleRepository divaModuleRepository, PlayerProfileService playerProfileService, PlayerModuleService playerModuleService, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.divaModuleRepository = divaModuleRepository;
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.playerModuleService = playerModuleService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
public String handle(BuyModuleRequest request) {
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
Optional<DivaModule> moduleOptional = divaModuleRepository.findById(request.getMdl_id());
|
||||
|
||||
BuyModuleResponse response;
|
||||
if (moduleOptional.isEmpty()) {
|
||||
response = new BuyModuleResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.FAILED
|
||||
);
|
||||
} else {
|
||||
if (session.getVp() < moduleOptional.get().getPrice()) {
|
||||
response = new BuyModuleResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.FAILED
|
||||
);
|
||||
} else {
|
||||
playerModuleService.buy(profile, request.getMdl_id());
|
||||
session.setVp(session.getVp() - moduleOptional.get().getPrice());
|
||||
gameSessionRepository.save(session);
|
||||
|
||||
response = new BuyModuleResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.SUCCESS,
|
||||
request.getMdl_id(),
|
||||
playerModuleService.getModuleHaveString(profile),
|
||||
session.getVp()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerPvCustomizeRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerPvRecordRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Edition;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.GetPvPdRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.GetPvPdResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvCustomize;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvRecord;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class GetPvPdHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetPvPdHandler.class);
|
||||
|
||||
private final PlayerPvRecordRepository pvRecordRepository;
|
||||
private final PlayerPvCustomizeRepository pvCustomizeRepository;
|
||||
private final PlayerProfileRepository profileRepository;
|
||||
|
||||
public GetPvPdHandler(DivaMapper mapper, PlayerPvRecordRepository pvRecordRepository, PlayerPvCustomizeRepository pvCustomizeRepository, PlayerProfileRepository profileRepository) {
|
||||
super(mapper);
|
||||
this.pvRecordRepository = pvRecordRepository;
|
||||
this.pvCustomizeRepository = pvCustomizeRepository;
|
||||
this.profileRepository = profileRepository;
|
||||
}
|
||||
|
||||
public String handle(GetPvPdRequest request) {
|
||||
|
||||
PlayerProfile profile = profileRepository.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
StringBuilder pd = new StringBuilder();
|
||||
|
||||
for (int pvId :
|
||||
request.getPd_pv_id_lst()) {
|
||||
if (pvId == -1) {
|
||||
pd.append("***").append(",");
|
||||
} else {
|
||||
int diff = request.getDifficulty();
|
||||
Difficulty difficulty = Difficulty.fromValue(diff);
|
||||
Optional<PlayerPvRecord> edition0optional = pvRecordRepository.findByPdIdAndPvIdAndEditionAndDifficulty(profile, pvId, Edition.ORIGINAL, difficulty);
|
||||
PlayerPvRecord edition0 = edition0optional.orElseGet(() -> new PlayerPvRecord(pvId, Edition.ORIGINAL));
|
||||
PlayerPvRecord edition1 = pvRecordRepository.findByPdIdAndPvIdAndEditionAndDifficulty(profile, pvId, Edition.EXTRA, difficulty).orElseGet(() -> new PlayerPvRecord(pvId, Edition.EXTRA));
|
||||
PlayerPvCustomize customize = pvCustomizeRepository.findByPdIdAndPvId(profile, pvId).orElseGet(() -> new PlayerPvCustomize(profile, pvId));
|
||||
|
||||
String str = getString(edition0, customize) + "," + getString(edition1, customize);
|
||||
// logger.info(str);
|
||||
pd.append(URIEncoder.encode(str)).append(",");
|
||||
}
|
||||
}
|
||||
pd.deleteCharAt(pd.length() - 1);
|
||||
|
||||
|
||||
GetPvPdResponse response = new GetPvPdResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
pd.toString(),
|
||||
false,
|
||||
DivaDateTimeUtil.getString(LocalDateTime.now())
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
private String getString(PlayerPvRecord record, PlayerPvCustomize customize) {
|
||||
return
|
||||
"" + record.getPvId() + "," +
|
||||
record.getEdition().getValue() + "," +
|
||||
record.getResult().getValue() + "," +
|
||||
record.getMaxScore() + "," +
|
||||
record.getMaxAttain() + "," +
|
||||
record.getChallengeKind().getValue() + "," +
|
||||
customize.getModule() + "," +
|
||||
customize.getCustomize() + "," +
|
||||
customize.getCustomizeFlag() + "," +
|
||||
customize.getSkin() + "," +
|
||||
customize.getButtonSe() + "," +
|
||||
customize.getSlideSe() + "," +
|
||||
customize.getChainSlideSe() + "," +
|
||||
customize.getSliderTouchSe() + "," +
|
||||
"15," +
|
||||
"0," +
|
||||
"0," +
|
||||
"-1,-1," +
|
||||
pvRecordRepository.rankByPvIdAndPdIdAndEditionAndDifficulty(record.getPvId(), record.getPdId(), record.getEdition(), record.getDifficulty()) + "," +
|
||||
record.getRgoPurchased() + "," +
|
||||
record.getRgoPlayed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerPvCustomizeRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.ShopExitRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.ShopExitResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvCustomize;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static icu.samnyan.aqua.sega.diva.util.DivaStringUtils.arrToCsv;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class ShopExitHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ShopExitHandler.class);
|
||||
|
||||
private final PlayerProfileRepository playerProfileRepository;
|
||||
|
||||
private final PlayerPvCustomizeRepository pvCustomizeRepository;
|
||||
|
||||
public ShopExitHandler(DivaMapper mapper, PlayerProfileRepository playerProfileRepository, PlayerPvCustomizeRepository pvCustomizeRepository) {
|
||||
super(mapper);
|
||||
this.playerProfileRepository = playerProfileRepository;
|
||||
this.pvCustomizeRepository = pvCustomizeRepository;
|
||||
}
|
||||
|
||||
public String handle(ShopExitRequest request) {
|
||||
|
||||
PlayerProfile profile = playerProfileRepository.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
PlayerPvCustomize customize = pvCustomizeRepository.findByPdIdAndPvId(profile, request.getPly_pv_id()).orElseGet(() -> new PlayerPvCustomize(profile, request.getPly_pv_id()));
|
||||
|
||||
if (request.getUse_pv_mdl_eqp() == 1) {
|
||||
customize.setModule(arrToCsv(request.getMdl_eqp_pv_ary()));
|
||||
customize.setCustomize(arrToCsv(request.getC_itm_eqp_pv_ary()));
|
||||
customize.setCustomizeFlag(arrToCsv(request.getMs_itm_flg_pv_ary()));
|
||||
} else {
|
||||
customize.setModule("-1,-1,-1");
|
||||
customize.setCustomize("-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1");
|
||||
customize.setCustomizeFlag("1,1,1,1,1,1,1,1,1,1,1,1");
|
||||
}
|
||||
|
||||
profile.setCommonModule(arrToCsv(request.getMdl_eqp_cmn_ary()));
|
||||
profile.setCommonCustomizeItems(arrToCsv(request.getC_itm_eqp_cmn_ary()));
|
||||
profile.setModuleSelectItemFlag(arrToCsv(request.getMs_itm_flg_cmn_ary()));
|
||||
|
||||
playerProfileRepository.save(profile);
|
||||
pvCustomizeRepository.save(customize);
|
||||
ShopExitResponse response = new ShopExitResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
Result.SUCCESS
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayLogRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerPvRecordRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.*;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.StageResultRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.StageResultResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayLog;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvRecord;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaCalculator;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static icu.samnyan.aqua.sega.diva.model.common.Const.NULL_QUEST;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class StageResultHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StageResultHandler.class);
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
private final PlayerPvRecordRepository pvRecordRepository;
|
||||
private final PlayerProfileRepository profileRepository;
|
||||
private final PlayLogRepository playLogRepository;
|
||||
|
||||
private final DivaCalculator divaCalculator;
|
||||
|
||||
public StageResultHandler(DivaMapper mapper, GameSessionRepository gameSessionRepository, PlayerPvRecordRepository pvRecordRepository, PlayerProfileRepository profileRepository, PlayLogRepository playLogRepository, DivaCalculator divaCalculator) {
|
||||
super(mapper);
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
this.pvRecordRepository = pvRecordRepository;
|
||||
this.profileRepository = profileRepository;
|
||||
this.playLogRepository = playLogRepository;
|
||||
this.divaCalculator = divaCalculator;
|
||||
}
|
||||
|
||||
public String handle(StageResultRequest request) {
|
||||
StageResultResponse response;
|
||||
if (request.getPd_id() != -1) {
|
||||
PlayerProfile profile = profileRepository.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
// Get the last played index
|
||||
int[] pvIds = request.getStg_ply_pv_id();
|
||||
int stageIndex = session.getStageIndex();
|
||||
|
||||
// Convert to play log object
|
||||
PlayLog log = getLog(request, profile, stageIndex);
|
||||
logger.debug("Stage Result Object: {}", log.toString());
|
||||
|
||||
PlayerPvRecord record = pvRecordRepository.findByPdIdAndPvIdAndEditionAndDifficulty(profile, log.getPvId(), log.getEdition(), log.getDifficulty())
|
||||
.orElseGet(() -> new PlayerPvRecord(profile, log.getPvId(), log.getEdition(), log.getDifficulty()));
|
||||
|
||||
// Update pvRecord field
|
||||
record.setMaxScore(Math.max(record.getMaxScore(), log.getScore()));
|
||||
record.setMaxAttain(Math.max(record.getMaxAttain(), log.getAttainPoint()));
|
||||
|
||||
if (record.getResult().getValue() < log.getClearResult().getValue()) {
|
||||
record.setResult(log.getClearResult());
|
||||
}
|
||||
|
||||
String[] updateRgo = log.getRhythmGameOptions().split(",");
|
||||
String[] oldRgo = record.getRgoPlayed().split(",");
|
||||
for (int i = 0; i < updateRgo.length; i++) {
|
||||
if (updateRgo[i].equals("1")) {
|
||||
oldRgo[i] = "1";
|
||||
}
|
||||
}
|
||||
record.setRgoPlayed(StringUtils.join(oldRgo, ","));
|
||||
|
||||
session.setVp(session.getVp() + log.getVp());
|
||||
session.setLastPvId(log.getPvId());
|
||||
session.setLastUpdateTime(LocalDateTime.now());
|
||||
|
||||
LevelInfo levelInfo = divaCalculator.getLevelInfo(profile);
|
||||
session.setOldLevelNumber(session.getLevelNumber());
|
||||
session.setOldLevelExp(session.getLevelExp());
|
||||
session.setLevelNumber(levelInfo.getLevelNumber());
|
||||
session.setLevelExp(levelInfo.getLevelExp());
|
||||
|
||||
pvRecordRepository.save(record);
|
||||
playLogRepository.save(log);
|
||||
gameSessionRepository.save(session);
|
||||
// profileRepository.save(profile);
|
||||
|
||||
String cnp_sp = StringUtils.join(request.getCr_sp(), ",");
|
||||
cnp_sp = cnp_sp.substring(cnp_sp.indexOf(",") + 1) + ",-1";
|
||||
response = new StageResultResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
ChallengeKind.UNDEFINED.getValue(),
|
||||
session.getOldLevelNumber(),
|
||||
session.getOldLevelExp(),
|
||||
session.getLevelNumber(),
|
||||
session.getLevelExp(),
|
||||
profile.getLevelTitle(),
|
||||
profile.getPlateEffectId(),
|
||||
profile.getPlateId(),
|
||||
session.getVp(),
|
||||
0,
|
||||
request.getCr_cid(),
|
||||
request.getCr_tv(),
|
||||
cnp_sp,
|
||||
"xxx",
|
||||
"-1,-1,-1,-1,-1",
|
||||
"xxx",
|
||||
"xxx",
|
||||
"xxx",
|
||||
"xxx",
|
||||
"xxx",
|
||||
0,
|
||||
LocalDateTime.now(),
|
||||
-1,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
NULL_QUEST,
|
||||
NULL_QUEST,
|
||||
NULL_QUEST,
|
||||
NULL_QUEST,
|
||||
NULL_QUEST,
|
||||
"-1,-1,-1,-1,-1",
|
||||
"-1,-1,-1,-1,-1",
|
||||
"-1,-1,-1,-1,-1"
|
||||
);
|
||||
} else {
|
||||
response = new StageResultResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok"
|
||||
);
|
||||
}
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private PlayLog getLog(StageResultRequest request, PlayerProfile profile, int i) {
|
||||
return new PlayLog(
|
||||
profile,
|
||||
request.getStg_ply_pv_id()[i],
|
||||
Difficulty.fromValue(request.getStg_difficulty()[i]),
|
||||
Edition.fromValue(request.getStg_edtn()[i]),
|
||||
request.getStg_scrpt_ver()[i],
|
||||
request.getStg_score()[i],
|
||||
ChallengeKind.fromValue(request.getStg_chllng_kind()[i]),
|
||||
request.getStg_chllng_result()[i],
|
||||
ClearResult.fromValue(request.getStg_clr_kind()[i]),
|
||||
request.getStg_vcld_pts()[i],
|
||||
request.getStg_cool_cnt()[i],
|
||||
request.getStg_cool_pct()[i],
|
||||
request.getStg_fine_cnt()[i],
|
||||
request.getStg_fine_pct()[i],
|
||||
request.getStg_safe_cnt()[i],
|
||||
request.getStg_safe_pct()[i],
|
||||
request.getStg_sad_cnt()[i],
|
||||
request.getStg_sad_pct()[i],
|
||||
request.getStg_wt_wg_cnt()[i],
|
||||
request.getStg_wt_wg_pct()[i],
|
||||
request.getStg_max_cmb()[i],
|
||||
request.getStg_chance_tm()[i],
|
||||
request.getStg_sm_hl()[i],
|
||||
request.getStg_atn_pnt()[i],
|
||||
request.getStg_skin_id()[i],
|
||||
request.getStg_btn_se()[i],
|
||||
request.getStg_btn_se_vol()[i],
|
||||
request.getStg_sld_se()[i],
|
||||
request.getStg_chn_sld_se()[i],
|
||||
request.getStg_sldr_tch_se()[i],
|
||||
slice(request.getStg_mdl_id(), 3, i),
|
||||
request.getStg_cpt_rslt()[i],
|
||||
request.getStg_sld_scr()[i],
|
||||
request.getStg_vcl_chg()[i],
|
||||
slice(request.getStg_c_itm_id(), 12, i),
|
||||
slice(request.getStg_rgo(), 3, i),
|
||||
request.getStg_ss_num()[i],
|
||||
request.getTime_stamp().toLocalDateTime()
|
||||
// ZonedDateTime.parse(request.getTime_stamp()).toLocalDateTime()
|
||||
);
|
||||
}
|
||||
|
||||
public String slice(int[] arr, int length, int offset) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = length * offset; i < length * (offset + 1); i++) {
|
||||
sb.append(arr[i]).append(",");
|
||||
}
|
||||
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.StageStartRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class StageStartHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StageResultHandler.class);
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
private final PlayerProfileRepository profileRepository;
|
||||
|
||||
public StageStartHandler(DivaMapper mapper, GameSessionRepository gameSessionRepository, PlayerProfileRepository profileRepository) {
|
||||
super(mapper);
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
this.profileRepository = profileRepository;
|
||||
}
|
||||
|
||||
public String handle(StageStartRequest request) {
|
||||
if (request.getPd_id() != -1) {
|
||||
PlayerProfile profile = profileRepository.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
session.setStageIndex(session.getStageIndex() + 1);
|
||||
|
||||
gameSessionRepository.save(session);
|
||||
}
|
||||
|
||||
BaseResponse response = new BaseResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok");
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerScreenShotRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.StoreSsRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerScreenShot;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
|
||||
import static icu.samnyan.aqua.sega.diva.util.DivaStringUtils.arrToCsv;
|
||||
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class StoreSsHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StoreSsHandler.class);
|
||||
|
||||
private final PlayerProfileRepository profileRepository;
|
||||
|
||||
private final PlayerScreenShotRepository screenShotRepository;
|
||||
|
||||
public StoreSsHandler(DivaMapper mapper, PlayerProfileRepository profileRepository, PlayerScreenShotRepository screenShotRepository) {
|
||||
super(mapper);
|
||||
this.profileRepository = profileRepository;
|
||||
this.screenShotRepository = screenShotRepository;
|
||||
}
|
||||
|
||||
|
||||
public String handle(StoreSsRequest request, MultipartFile file) {
|
||||
PlayerProfile profile = profileRepository.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
|
||||
BaseResponse response;
|
||||
try {
|
||||
String filename = request.getPd_id() + "-" + LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) + ".jpg";
|
||||
Files.write(Paths.get("data/" + filename), file.getBytes());
|
||||
|
||||
PlayerScreenShot ss = new PlayerScreenShot(
|
||||
profile,
|
||||
filename,
|
||||
request.getPd_id(),
|
||||
arrToCsv(request.getSs_mdl_id()),
|
||||
arrToCsv(request.getSs_c_itm_id())
|
||||
);
|
||||
screenShotRepository.save(ss);
|
||||
|
||||
response = new BaseResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok");
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error("Screenshot save failed", e);
|
||||
|
||||
response = new BaseResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"0");
|
||||
}
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.operation;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.operation.PingResponse;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PingHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PingHandler.class);
|
||||
|
||||
public PingHandler(DivaMapper mapper) {
|
||||
super(mapper);
|
||||
}
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
|
||||
PingResponse response = new PingResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.ContestRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerContestRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.ContestBorder;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Edition;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.SortMode;
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.Contest;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.StageResultRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerContest;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static icu.samnyan.aqua.sega.diva.util.DivaStringUtils.getDummyString;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class EndHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(EndHandler.class);
|
||||
|
||||
private final ContestRepository contestRepository;
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final PlayerContestRepository playerContestRepository;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public EndHandler(DivaMapper mapper, ContestRepository contestRepository, PlayerProfileService playerProfileService, PlayerContestRepository playerContestRepository, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.contestRepository = contestRepository;
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.playerContestRepository = playerContestRepository;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
public String handle(StageResultRequest request) {
|
||||
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
|
||||
profile.setHeadphoneVolume(request.getHp_vol());
|
||||
profile.setButtonSeOn(request.isBtn_se_vol());
|
||||
profile.setButtonSeVolume(request.getBtn_se_vol2());
|
||||
profile.setSliderSeVolume(request.getSldr_se_vol2());
|
||||
profile.setVocaloidPoints(session.getVp());
|
||||
profile.setLevel(session.getLevelNumber());
|
||||
profile.setLevelExp(session.getLevelExp());
|
||||
profile.setNextPvId(request.getNxt_pv_id());
|
||||
profile.setNextDifficulty(Difficulty.fromValue(request.getNxt_dffclty()));
|
||||
profile.setNextEdition(Edition.fromValue(request.getNxt_edtn()));
|
||||
profile.setSortMode(SortMode.fromValue(request.getSort_kind()));
|
||||
|
||||
if (request.getCr_cid() != -1) {
|
||||
Contest contest = contestRepository.findById(request.getCr_cid()).orElseGet(Contest::new);
|
||||
ContestBorder currentResultRank = getContestRank(contest, request.getCr_tv());
|
||||
if (request.getCr_if() == 0) {
|
||||
// Do contest is playing
|
||||
profile.setContestNowPlayingEnable(true);
|
||||
profile.setContestNowPlayingId(request.getCr_cid());
|
||||
profile.setContestNowPlayingResultRank(currentResultRank);
|
||||
profile.setContestNowPlayingValue(request.getCr_tv());
|
||||
profile.setContestNowPlayingSpecifier(String.join(",", request.getCr_sp()));
|
||||
} else {
|
||||
PlayerContest contestRecord = playerContestRepository.findByPdIdAndContestId(profile, request.getCr_cid()).orElseGet(() -> new PlayerContest(profile, request.getCr_cid()));
|
||||
contestRecord.setStartCount(contestRecord.getStartCount() + 1);
|
||||
contestRecord.setBestValue(Math.max(contestRecord.getBestValue(), request.getCr_tv()));
|
||||
contestRecord.setResultRank(currentResultRank.getValue() > contestRecord.getResultRank().getValue() ? currentResultRank : contestRecord.getResultRank());
|
||||
contestRecord.setLastUpdateTime(LocalDateTime.now());
|
||||
|
||||
playerContestRepository.save(contestRecord);
|
||||
profile.setContestNowPlayingEnable(false);
|
||||
profile.setContestNowPlayingId(-1);
|
||||
profile.setContestNowPlayingResultRank(ContestBorder.NONE);
|
||||
profile.setContestNowPlayingValue(-1);
|
||||
profile.setContestNowPlayingSpecifier(getDummyString("-1", 60));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
playerProfileService.save(profile);
|
||||
gameSessionRepository.delete(session);
|
||||
|
||||
|
||||
BaseResponse response = new BaseResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private ContestBorder getContestRank(Contest contest, int value) {
|
||||
if (value >= contest.getGoldBorders()) return ContestBorder.GOLD;
|
||||
if (value >= contest.getSliverBorders()) return ContestBorder.SILVER;
|
||||
if (value >= contest.getBronzeBorders()) return ContestBorder.BRONZE;
|
||||
return ContestBorder.NONE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.PdUnlockRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PdUnlockHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PdUnlockHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public PdUnlockHandler(DivaMapper mapper, PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
|
||||
public String handle(PdUnlockRequest request) {
|
||||
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
gameSessionRepository.delete(session);
|
||||
|
||||
BaseResponse response = new BaseResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok"
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.PreStartResult;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.StartMode;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.PreStartRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.user.PreStartResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class PreStartHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PreStartHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
public PreStartHandler(DivaMapper mapper, PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
}
|
||||
|
||||
public String handle(PreStartRequest request) {
|
||||
Optional<PlayerProfile> profileOptional = playerProfileService.findByPdId(request.getAime_id());
|
||||
PreStartResponse response;
|
||||
boolean normalStart = false;
|
||||
if (profileOptional.isEmpty()) {
|
||||
response = new PreStartResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
PreStartResult.NEW_REGISTRATION);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
} else {
|
||||
PlayerProfile profile = profileOptional.get();
|
||||
|
||||
Optional<GameSession> sessionOptional = gameSessionRepository.findByPdId(profile);
|
||||
if (sessionOptional.isPresent()) {
|
||||
GameSession session = sessionOptional.get();
|
||||
if (!session.getLastUpdateTime().isBefore(LocalDateTime.now().minusMinutes(5)) && session.getStartMode() == StartMode.START) {
|
||||
|
||||
response = new PreStartResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
PreStartResult.ALREADY_PLAYING
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
} else {
|
||||
gameSessionRepository.delete(session);
|
||||
}
|
||||
}
|
||||
|
||||
GameSession session = new GameSession(
|
||||
ThreadLocalRandom.current().nextInt(100, 99999),
|
||||
profile,
|
||||
StartMode.PRE_START,
|
||||
LocalDateTime.now(),
|
||||
LocalDateTime.now(),
|
||||
-1,
|
||||
-1,
|
||||
profile.getLevel(),
|
||||
profile.getLevelExp(),
|
||||
profile.getLevel(),
|
||||
profile.getLevelExp(),
|
||||
profile.getVocaloidPoints()
|
||||
);
|
||||
|
||||
gameSessionRepository.save(session);
|
||||
|
||||
response = new PreStartResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
PreStartResult.SUCCESS,
|
||||
session.getAcceptId(),
|
||||
profile.getPdId(),
|
||||
profile.getPlayerName(),
|
||||
profile.getSortMode(),
|
||||
profile.getLevel(),
|
||||
profile.getLevelExp(),
|
||||
profile.getLevelTitle(),
|
||||
profile.getPlateEffectId(),
|
||||
profile.getPlateId(),
|
||||
profile.getCommonModule(),
|
||||
profile.getCommonModuleSetTime(),
|
||||
profile.getCommonSkin(),
|
||||
profile.getButtonSe(),
|
||||
profile.getSlideSe(),
|
||||
profile.getChainSlideSe(),
|
||||
profile.getSliderTouchSe(),
|
||||
profile.getVocaloidPoints(),
|
||||
profile.getPasswordStatus()
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.SpendCreditRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.user.SpendCreditResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class SpendCreditHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SpendCreditHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
public SpendCreditHandler(DivaMapper mapper, PlayerProfileService playerProfileService) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
}
|
||||
|
||||
public String handle(SpendCreditRequest request) {
|
||||
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
|
||||
SpendCreditResponse response = new SpendCreditResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
"-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x,-1,-1,x,-1,-1,x,x,-1,x",
|
||||
0,
|
||||
profile.getVocaloidPoints(),
|
||||
profile.getLevelTitle(),
|
||||
profile.getPlateEffectId(),
|
||||
profile.getPlateId()
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerContestRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerPvRecordRepository;
|
||||
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.PvRecordDataException;
|
||||
import icu.samnyan.aqua.sega.diva.exception.SessionNotFoundException;
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.StartMode;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.collection.ClearSet;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.collection.ClearTally;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.StartRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.user.StartResponse;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerContest;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvRecord;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerCustomizeService;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerModuleService;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
public class StartHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StartHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
|
||||
private final PlayerCustomizeService playerCustomizeService;
|
||||
|
||||
private final PlayerModuleService playerModuleService;
|
||||
|
||||
private final PlayerPvRecordRepository playerPvRecordRepository;
|
||||
|
||||
private final PlayerContestRepository playerContestRepository;
|
||||
|
||||
public StartHandler(DivaMapper mapper, PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository, PlayerCustomizeService playerCustomizeService, PlayerModuleService playerModuleService, PlayerPvRecordRepository playerPvRecordRepository, PlayerContestRepository playerContestRepository) {
|
||||
super(mapper);
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
this.playerCustomizeService = playerCustomizeService;
|
||||
this.playerModuleService = playerModuleService;
|
||||
this.playerPvRecordRepository = playerPvRecordRepository;
|
||||
this.playerContestRepository = playerContestRepository;
|
||||
}
|
||||
|
||||
public String handle(StartRequest request) {
|
||||
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
session.setStartMode(StartMode.START);
|
||||
gameSessionRepository.save(session);
|
||||
|
||||
String module_have = playerModuleService.getModuleHaveString(profile);
|
||||
String customize_have = playerCustomizeService.getModuleHaveString(profile);
|
||||
|
||||
Map<String, String> contestResult = getContestResult(profile);
|
||||
|
||||
StartResponse response = new StartResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
profile.getPdId(),
|
||||
Result.SUCCESS,
|
||||
session.getAcceptId(),
|
||||
session.getAcceptId(),
|
||||
profile.getPlayerName(),
|
||||
profile.getHeadphoneVolume(),
|
||||
profile.isButtonSeOn(),
|
||||
profile.getButtonSeVolume(),
|
||||
profile.getSliderSeVolume(),
|
||||
profile.getSortMode(),
|
||||
profile.getLevel(),
|
||||
profile.getLevelExp(),
|
||||
profile.getLevelTitle(),
|
||||
profile.getPlateEffectId(),
|
||||
profile.getPlateId(),
|
||||
profile.getCommonModule(),
|
||||
profile.getCommonCustomizeItems(),
|
||||
profile.getModuleSelectItemFlag(),
|
||||
LocalDateTime.now(),
|
||||
module_have,
|
||||
customize_have,
|
||||
profile.isPreferPerPvModule(),
|
||||
profile.isPreferCommonModule(),
|
||||
profile.isUsePerPvSkin(),
|
||||
profile.isUsePerPvButtonSe(),
|
||||
profile.isUsePerPvSliderSe(),
|
||||
profile.isUsePerPvChainSliderSe(),
|
||||
profile.isUsePerPvTouchSliderSe(),
|
||||
profile.getVocaloidPoints(),
|
||||
profile.getNextPvId(),
|
||||
profile.getNextDifficulty(),
|
||||
profile.getNextEdition(),
|
||||
contestResult.get("cv_cid"), // contest progress
|
||||
contestResult.get("cv_sc"),
|
||||
contestResult.get("cv_rr"),
|
||||
contestResult.get("cv_bv"),
|
||||
contestResult.get("cv_bf"),
|
||||
profile.isContestNowPlayingEnable() ? profile.getContestNowPlayingId() : -1,
|
||||
profile.getContestNowPlayingValue(),
|
||||
profile.getContestNowPlayingResultRank(),
|
||||
profile.getContestNowPlayingSpecifier(),
|
||||
profile.getMyList0(),
|
||||
profile.getMyList1(),
|
||||
profile.getMyList2(),
|
||||
null,
|
||||
null,
|
||||
// getDummyString("-1", 40),
|
||||
// getDummyString("-1", 40),
|
||||
profile.isShowClearBorder(),
|
||||
profile.isShowInterimRanking(),
|
||||
profile.isShowClearStatus(),
|
||||
countClearStatus(profile),
|
||||
profile.isShowRgoSetting(),
|
||||
null, // Currently quest not working
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private String countClearStatus(PlayerProfile profile) {
|
||||
List<PlayerPvRecord> pvRecordList = playerPvRecordRepository.findByPdId(profile);
|
||||
ClearTally clearTally = new ClearTally();
|
||||
pvRecordList.forEach(x -> {
|
||||
switch (x.getEdition()) {
|
||||
case ORIGINAL: {
|
||||
switch (x.getResult()) {
|
||||
case CHEAP:
|
||||
getDiff(x, clearTally).addClear();
|
||||
break;
|
||||
case STANDARD:
|
||||
getDiff(x, clearTally).addClear();
|
||||
break;
|
||||
case GREAT:
|
||||
getDiff(x, clearTally).addGreat();
|
||||
break;
|
||||
case EXCELLENT:
|
||||
getDiff(x, clearTally).addExcellent();
|
||||
break;
|
||||
case PERFECT:
|
||||
getDiff(x, clearTally).addPerfect();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EXTRA: {
|
||||
switch (x.getResult()) {
|
||||
case CHEAP:
|
||||
clearTally.getExtraExtreme().addClear();
|
||||
break;
|
||||
case STANDARD:
|
||||
clearTally.getExtraExtreme().addClear();
|
||||
break;
|
||||
case GREAT:
|
||||
clearTally.getExtraExtreme().addGreat();
|
||||
break;
|
||||
case EXCELLENT:
|
||||
clearTally.getExtraExtreme().addExcellent();
|
||||
break;
|
||||
case PERFECT:
|
||||
clearTally.getExtraExtreme().addPerfect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return clearTally.toInternal();
|
||||
}
|
||||
|
||||
private ClearSet getDiff(PlayerPvRecord record, ClearTally clearTally) {
|
||||
switch (record.getDifficulty()) {
|
||||
case EASY:
|
||||
return clearTally.getEasy();
|
||||
case NORMAL:
|
||||
return clearTally.getNormal();
|
||||
case HARD:
|
||||
return clearTally.getHard();
|
||||
case EXTREME:
|
||||
return clearTally.getExtreme();
|
||||
default:
|
||||
throw new PvRecordDataException("Difficulty data not exist, record id:" + record.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> getContestResult(PlayerProfile profile) {
|
||||
List<Integer> cv_cid = new LinkedList<>();
|
||||
List<Integer> cv_sc = new LinkedList<>();
|
||||
List<Integer> cv_rr = new LinkedList<>();
|
||||
List<Integer> cv_bv = new LinkedList<>();
|
||||
List<Integer> cv_bf = new LinkedList<>();
|
||||
List<PlayerContest> contestList = playerContestRepository.findTop4ByPdIdOrderByLastUpdateTimeDesc(profile);
|
||||
contestList.forEach(x -> {
|
||||
cv_cid.add(x.getContestId());
|
||||
cv_sc.add(x.getStartCount());
|
||||
cv_rr.add(x.getResultRank().getValue());
|
||||
cv_bv.add(x.getBestValue());
|
||||
cv_bf.add(-1);
|
||||
});
|
||||
for (int i = cv_cid.size(); i < 4; i++) {
|
||||
cv_cid.add(-1);
|
||||
cv_sc.add(-1);
|
||||
cv_rr.add(-1);
|
||||
cv_bv.add(-1);
|
||||
cv_bf.add(-1);
|
||||
}
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("cv_cid", cv_cid.stream().map(Object::toString).collect(Collectors.joining(",")));
|
||||
result.put("cv_sc", cv_sc.stream().map(Object::toString).collect(Collectors.joining(",")));
|
||||
result.put("cv_rr", cv_rr.stream().map(Object::toString).collect(Collectors.joining(",")));
|
||||
result.put("cv_bv", cv_bv.stream().map(Object::toString).collect(Collectors.joining(",")));
|
||||
result.put("cv_bf", cv_bf.stream().map(Object::toString).collect(Collectors.joining(",")));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package icu.samnyan.aqua.sega.diva.model;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public interface Internalizable {
|
||||
String toInternal();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum ChallengeKind {
|
||||
UNDEFINED(-1),
|
||||
CLEAR(0),
|
||||
GREAT(1),
|
||||
EXCELLENT(2),
|
||||
PERFECT(3),
|
||||
COMPLETED(4);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
ChallengeKind(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
public static ChallengeKind fromValue(int i) {
|
||||
for (ChallengeKind challengeKind :
|
||||
ChallengeKind.values()) {
|
||||
if (challengeKind.getValue() == i) return challengeKind;
|
||||
}
|
||||
return ChallengeKind.UNDEFINED;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum ClearResult implements ValueEnum {
|
||||
NO_CLEAR(-1),
|
||||
MISS_TAKE(0),
|
||||
CHEAP(1),
|
||||
STANDARD(2),
|
||||
GREAT(3),
|
||||
EXCELLENT(4),
|
||||
PERFECT(5);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
ClearResult(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
public static ClearResult fromValue(int i) {
|
||||
for (ClearResult clearResult :
|
||||
ClearResult.values()) {
|
||||
if (clearResult.getValue() == i) return clearResult;
|
||||
}
|
||||
return ClearResult.NO_CLEAR;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class Const {
|
||||
public final static String ALL_NOT_HAVE = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
||||
public final static String ALL_NOT_HAVE_TEST = "0";
|
||||
public final static String ALL_HAVE = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
|
||||
public final static String NULL_QUEST = "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1";
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum ContestBorder {
|
||||
NONE(-1),
|
||||
BRONZE(0),
|
||||
SILVER(1),
|
||||
GOLD(2);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
ContestBorder(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum ContestLeague {
|
||||
BEGINNER(0),
|
||||
INTERMEDIATE(1),
|
||||
ADVANCED(2),
|
||||
PROFESSIONAL(3);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
ContestLeague(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum ContestNormaType {
|
||||
SCORE(0),
|
||||
PERCENTAGE(1),
|
||||
COOL_PERCENTAGE(2);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
ContestNormaType(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum ContestStageLimit {
|
||||
UNLIMITED(0),
|
||||
LIMITED(1);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
ContestStageLimit(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum Difficulty {
|
||||
UNDEFINED(-1),
|
||||
EASY(0),
|
||||
NORMAL(1),
|
||||
HARD(2),
|
||||
EXTREME(3);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
Difficulty(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
public static Difficulty fromValue(int i) {
|
||||
for (Difficulty difficulty :
|
||||
Difficulty.values()) {
|
||||
if (difficulty.getValue() == i) return difficulty;
|
||||
}
|
||||
return Difficulty.UNDEFINED;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum Edition {
|
||||
ORIGINAL(0),
|
||||
EXTRA(1);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
Edition(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
public static Edition fromValue(int i) {
|
||||
for (Edition edition :
|
||||
Edition.values()) {
|
||||
if (edition.getValue() == i) return edition;
|
||||
}
|
||||
return Edition.ORIGINAL;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum FestaKind {
|
||||
PINK_FESTA(0),
|
||||
GREEN_FESTA(1);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
FestaKind(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LevelInfo {
|
||||
private int levelNumber;
|
||||
private int levelExp;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum PassStat {
|
||||
MISS(0),
|
||||
SET(1),
|
||||
RESET(2),
|
||||
REISSUE(3);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
PassStat(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum PreStartResult {
|
||||
SUCCESS(1),
|
||||
FAILED(0),
|
||||
CARD_TOO_NEW(-1),
|
||||
ALREADY_PLAYING(-2),
|
||||
NEW_REGISTRATION(-3),
|
||||
CARD_BANNED(-4);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
PreStartResult(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum Result {
|
||||
FAILED(0),
|
||||
SUCCESS(1);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
Result(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum SortMode {
|
||||
COMPLEXITY(0),
|
||||
NAME(1),
|
||||
RELEASE_DATE(2),
|
||||
MY_LIST_A(3),
|
||||
MY_LIST_B(4),
|
||||
MY_LIST_C(5);
|
||||
|
||||
|
||||
private int value;
|
||||
|
||||
SortMode(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
public static SortMode fromValue(int i) {
|
||||
for (SortMode sortMode :
|
||||
SortMode.values()) {
|
||||
if (sortMode.getValue() == i) return sortMode;
|
||||
}
|
||||
return SortMode.RELEASE_DATE;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public enum StartMode {
|
||||
PRE_START,
|
||||
START,
|
||||
CARD_PROCEDURE
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public interface ValueEnum {
|
||||
int getValue();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.attend;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.Internalizable;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DispersalParameter implements Internalizable {
|
||||
private int max_pd_items = 30;
|
||||
private int max_ps_rankings = 100;
|
||||
private int max_uploadable_screenshots = 2;
|
||||
private int ss_upload_delay = 1;
|
||||
|
||||
@Override
|
||||
public String toInternal() {
|
||||
List<Integer> list = new LinkedList<>();
|
||||
list.add(max_pd_items);
|
||||
list.add(1);
|
||||
list.add(max_ps_rankings);
|
||||
list.add(max_uploadable_screenshots);
|
||||
list.add(ss_upload_delay);
|
||||
list.add(1);
|
||||
list.addAll(Collections.nCopies(100, 0));
|
||||
return list.stream().limit(100).map(Object::toString).collect(Collectors.joining(","));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.attend;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.Internalizable;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class EtcParameter implements Internalizable {
|
||||
private Boolean module_shop_close = false;
|
||||
private Boolean card_reissue_close = true;
|
||||
private Boolean card_renewal_close = true;
|
||||
private Boolean reset_passwd_close = true;
|
||||
private Boolean change_passwd_close = false;
|
||||
private Boolean change_name_close = false;
|
||||
private Boolean encore_mode_close = true;
|
||||
private Boolean third_stg_mode_close = false;
|
||||
private Integer slow_down_threshold = 0;
|
||||
private Boolean log_write_flag = false;
|
||||
private Boolean daily_quest_close = true;
|
||||
private Boolean weekly_quest_close = true;
|
||||
private Boolean special_quest_close = true;
|
||||
private Boolean nppg_close = false;
|
||||
|
||||
@Override
|
||||
public String toInternal() {
|
||||
List<Object> list = new LinkedList<>();
|
||||
list.add(module_shop_close);
|
||||
list.add(card_reissue_close);
|
||||
list.add(card_renewal_close);
|
||||
list.add(reset_passwd_close);
|
||||
list.add(change_passwd_close);
|
||||
list.add(change_name_close);
|
||||
list.add(encore_mode_close);
|
||||
list.add(third_stg_mode_close);
|
||||
list.add(slow_down_threshold);
|
||||
list.add(log_write_flag);
|
||||
list.add(daily_quest_close);
|
||||
list.add(weekly_quest_close);
|
||||
list.add(special_quest_close);
|
||||
list.add(nppg_close);
|
||||
list.addAll(Collections.nCopies(100, 0));
|
||||
return list.stream().limit(100).map(x -> {
|
||||
if (x instanceof Boolean) {
|
||||
return (Boolean) x ? "1" : "0";
|
||||
}
|
||||
if (x instanceof Integer) {
|
||||
return String.valueOf(x);
|
||||
}
|
||||
return "0";
|
||||
}).collect(Collectors.joining(","));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.attend;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.Internalizable;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class GameBalanceParameter implements Internalizable {
|
||||
|
||||
private int name_change_price = 100;
|
||||
private GameBalanceTrialBidSet easy_trials = new GameBalanceTrialBidSet(
|
||||
new GameBalanceTrialBid(5, 10),
|
||||
new GameBalanceTrialBid(10, 25),
|
||||
new GameBalanceTrialBid(20, 50),
|
||||
new GameBalanceTrialBid(30, 90)
|
||||
);
|
||||
private GameBalanceTrialBidSet normal_trials = new GameBalanceTrialBidSet(
|
||||
new GameBalanceTrialBid(5, 10),
|
||||
new GameBalanceTrialBid(10, 25),
|
||||
new GameBalanceTrialBid(20, 50),
|
||||
new GameBalanceTrialBid(30, 90)
|
||||
);
|
||||
private GameBalanceTrialBidSet hard_trials = new GameBalanceTrialBidSet(
|
||||
new GameBalanceTrialBid(5, 10),
|
||||
new GameBalanceTrialBid(10, 25),
|
||||
new GameBalanceTrialBid(20, 50),
|
||||
new GameBalanceTrialBid(30, 90)
|
||||
);
|
||||
private GameBalanceTrialBidSet extreme_trials = new GameBalanceTrialBidSet(
|
||||
new GameBalanceTrialBid(5, 10),
|
||||
new GameBalanceTrialBid(10, 25),
|
||||
new GameBalanceTrialBid(20, 50),
|
||||
new GameBalanceTrialBid(30, 90)
|
||||
);
|
||||
private GameBalanceTrialBidSet extra_extreme_trials = new GameBalanceTrialBidSet(
|
||||
new GameBalanceTrialBid(5, 10),
|
||||
new GameBalanceTrialBid(10, 25),
|
||||
new GameBalanceTrialBid(20, 50),
|
||||
new GameBalanceTrialBid(30, 90)
|
||||
);
|
||||
|
||||
@Override
|
||||
public String toInternal() {
|
||||
Integer[] arr = new Integer[]{
|
||||
this.name_change_price,
|
||||
0, // unkn
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4, // unkn
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
3,
|
||||
4,
|
||||
5, // unkn
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
4,
|
||||
5,
|
||||
6, // unkn
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
5,
|
||||
6,
|
||||
7, // unkn
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
9,
|
||||
10,
|
||||
14 // unkn
|
||||
};
|
||||
List<Integer> list = new LinkedList<>(Arrays.asList(arr));
|
||||
list.addAll(easy_trials.getArr());
|
||||
list.addAll(normal_trials.getArr());
|
||||
list.addAll(hard_trials.getArr());
|
||||
list.addAll(extreme_trials.getArr());
|
||||
list.addAll(extra_extreme_trials.getArr());
|
||||
list.add(10);
|
||||
list.add(30);
|
||||
list.addAll(Collections.nCopies(100, 0));
|
||||
return list.stream().limit(100).map(Object::toString).collect(Collectors.joining(","));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.attend;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class GameBalanceTrialBid {
|
||||
private int pay;
|
||||
private int win;
|
||||
|
||||
public String getString() {
|
||||
return pay + "," + win;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.attend;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class GameBalanceTrialBidSet {
|
||||
private GameBalanceTrialBid clear;
|
||||
private GameBalanceTrialBid great;
|
||||
private GameBalanceTrialBid excellent;
|
||||
private GameBalanceTrialBid perfect;
|
||||
|
||||
public List<Integer> getArr() {
|
||||
Integer[] arr = new Integer[]{
|
||||
clear.getPay(),
|
||||
clear.getWin(),
|
||||
great.getPay(),
|
||||
great.getWin(),
|
||||
excellent.getPay(),
|
||||
excellent.getWin(),
|
||||
perfect.getPay(),
|
||||
perfect.getWin(),
|
||||
};
|
||||
return new LinkedList<>(Arrays.asList(arr));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.collection;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ClearSet {
|
||||
private int clear = 0;
|
||||
private int great = 0;
|
||||
private int excellent = 0;
|
||||
private int perfect = 0;
|
||||
|
||||
public void addClear() {
|
||||
this.clear += 1;
|
||||
}
|
||||
|
||||
public void addGreat() {
|
||||
this.great += 1;
|
||||
}
|
||||
|
||||
public void addExcellent() {
|
||||
this.excellent += 1;
|
||||
}
|
||||
|
||||
public void addPerfect() {
|
||||
this.perfect += 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.collection;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.Internalizable;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ClearTally implements Internalizable {
|
||||
|
||||
private ClearSet easy = new ClearSet();
|
||||
private ClearSet normal = new ClearSet();
|
||||
private ClearSet hard = new ClearSet();
|
||||
private ClearSet extreme = new ClearSet();
|
||||
private ClearSet extraExtreme = new ClearSet();
|
||||
|
||||
@Override
|
||||
public String toInternal() {
|
||||
List<Integer> list = new LinkedList<>();
|
||||
list.add(easy.getClear());
|
||||
list.add(easy.getGreat());
|
||||
list.add(easy.getExcellent());
|
||||
list.add(easy.getPerfect());
|
||||
list.add(normal.getClear());
|
||||
list.add(normal.getGreat());
|
||||
list.add(normal.getExcellent());
|
||||
list.add(normal.getPerfect());
|
||||
list.add(hard.getClear());
|
||||
list.add(hard.getGreat());
|
||||
list.add(hard.getExcellent());
|
||||
list.add(hard.getPerfect());
|
||||
list.add(extreme.getClear());
|
||||
list.add(extreme.getGreat());
|
||||
list.add(extreme.getExcellent());
|
||||
list.add(extreme.getPerfect());
|
||||
list.add(extraExtreme.getClear());
|
||||
list.add(extraExtreme.getGreat());
|
||||
list.add(extraExtreme.getExcellent());
|
||||
list.add(extraExtreme.getPerfect());
|
||||
return list.stream().map(Object::toString).collect(Collectors.joining(","));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.collection;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.Festa;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
public class FestaCollection {
|
||||
private Festa firstFesta = new Festa();
|
||||
private Festa secondFesta = new Festa();
|
||||
|
||||
public FestaCollection(Festa firstFesta, Festa secondFesta) {
|
||||
this.firstFesta = firstFesta;
|
||||
this.secondFesta = secondFesta;
|
||||
}
|
||||
|
||||
public FestaCollection(Festa firstFesta) {
|
||||
this.firstFesta = firstFesta;
|
||||
}
|
||||
|
||||
public FestaCollection(List<Festa> festas) {
|
||||
if (festas.size() >= 2) {
|
||||
this.firstFesta = festas.get(0);
|
||||
this.secondFesta = festas.get(1);
|
||||
} else if (festas.size() == 1) {
|
||||
this.firstFesta = festas.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
public String getIds() {
|
||||
return this.firstFesta.getId() + "," + this.secondFesta.getId();
|
||||
}
|
||||
|
||||
public String getNames() {
|
||||
return URIEncoder.encode(this.firstFesta.getName()) + "," + URIEncoder.encode(this.secondFesta.getName());
|
||||
}
|
||||
|
||||
public String getKinds() {
|
||||
return this.firstFesta.getKind().getValue() + "," + this.secondFesta.getKind().getValue();
|
||||
}
|
||||
|
||||
public String getDiffs() {
|
||||
return this.firstFesta.getDifficulty().getValue() + "," + this.secondFesta.getDifficulty().getValue();
|
||||
}
|
||||
|
||||
public String getPvIds() {
|
||||
return this.firstFesta.getPvList() + "," + this.secondFesta.getPvList();
|
||||
}
|
||||
|
||||
public String getAttr() {
|
||||
return this.firstFesta.getAttributes() + "," + this.secondFesta.getAttributes();
|
||||
}
|
||||
|
||||
public String getAddVps() {
|
||||
return this.firstFesta.getAddVP() + "," + this.secondFesta.getAddVP();
|
||||
}
|
||||
|
||||
public String getVpMultipliers() {
|
||||
return this.firstFesta.getVpMultiplier() + "," + this.secondFesta.getVpMultiplier();
|
||||
}
|
||||
|
||||
public String getStarts() {
|
||||
return DivaDateTimeUtil.getString(this.firstFesta.getStart()) + "," + DivaDateTimeUtil.getString(this.secondFesta.getStart());
|
||||
}
|
||||
|
||||
public String getEnds() {
|
||||
return DivaDateTimeUtil.getString(this.firstFesta.getEnd()) + "," + DivaDateTimeUtil.getString(this.secondFesta.getEnd());
|
||||
}
|
||||
|
||||
public String getLastUpdateTime() {
|
||||
return DivaDateTimeUtil.getString(this.firstFesta.getCreateDate().compareTo(this.secondFesta.getCreateDate()) < 0 ? this.firstFesta.getCreateDate() : this.secondFesta.getCreateDate());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.common.collection;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Edition;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvRecord;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
public class PsRankingCollection {
|
||||
private PlayerPvRecord first;
|
||||
private PlayerPvRecord second;
|
||||
private PlayerPvRecord third;
|
||||
|
||||
public PsRankingCollection(int pvId, Edition edition, List<PlayerPvRecord> list) {
|
||||
this.first = new PlayerPvRecord(pvId, edition);
|
||||
this.second = new PlayerPvRecord(pvId, edition);
|
||||
this.third = new PlayerPvRecord(pvId, edition);
|
||||
if (list.size() >= 1) {
|
||||
this.first = list.get(0);
|
||||
}
|
||||
if (list.size() >= 2) {
|
||||
this.second = list.get(1);
|
||||
}
|
||||
if (list.size() >= 3) {
|
||||
this.third = list.get(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.gamedata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.ContestLeague;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.ContestNormaType;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.ContestStageLimit;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "DivaContest")
|
||||
@Table(name = "diva_contest")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Contest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private int id;
|
||||
|
||||
private boolean enable;
|
||||
|
||||
private LocalDateTime startTime;
|
||||
|
||||
private LocalDateTime endTime;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ContestLeague league;
|
||||
|
||||
private int stars;
|
||||
|
||||
private int minComplexity;
|
||||
|
||||
private int maxComplexity;
|
||||
|
||||
private int stages;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ContestStageLimit stageLimit;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ContestNormaType normaType;
|
||||
|
||||
private int bronzeBorders = 0;
|
||||
|
||||
private int sliverBorders = 0;
|
||||
|
||||
private int goldBorders = 0;
|
||||
|
||||
public String getString() {
|
||||
List<Object> list = new LinkedList<>();
|
||||
list.add(this.id);
|
||||
list.add(DivaDateTimeUtil.format(this.startTime));
|
||||
list.add(DivaDateTimeUtil.format(this.endTime));
|
||||
list.add(URIEncoder.encode(this.name));
|
||||
list.add(URIEncoder.encode(this.description));
|
||||
list.add(this.league.getValue());
|
||||
list.add(this.stars);
|
||||
list.add(this.stages);
|
||||
list.add(this.stageLimit.getValue());
|
||||
list.add(this.normaType.getValue());
|
||||
list.add(this.bronzeBorders);
|
||||
list.add(this.sliverBorders);
|
||||
list.add(this.goldBorders);
|
||||
list.add(-1);
|
||||
list.add(-2);
|
||||
list.add(this.minComplexity);
|
||||
list.add(this.maxComplexity);
|
||||
list.add(-1);
|
||||
list.add(-2);
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("-2");
|
||||
list.add("7fffffffffffffffffffffffffffffff");
|
||||
return list.stream().map(Object::toString).collect(Collectors.joining(","));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.gamedata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import icu.samnyan.aqua.sega.diva.model.Internalizable;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "DivaCustomize")
|
||||
@Table(name = "diva_customize")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DivaCustomize implements Serializable, Internalizable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private int price;
|
||||
|
||||
private LocalDateTime releaseDate;
|
||||
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private int sortOrder;
|
||||
|
||||
@Override
|
||||
public String toInternal() {
|
||||
return id + ",0," +
|
||||
URIEncoder.encode(name) + "," +
|
||||
price + "," +
|
||||
DivaDateTimeUtil.format(releaseDate) + "," +
|
||||
DivaDateTimeUtil.format(endDate) + "," +
|
||||
sortOrder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.gamedata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import icu.samnyan.aqua.sega.diva.model.Internalizable;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.util.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "DivaModule")
|
||||
@Table(name = "diva_module")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DivaModule implements Serializable, Internalizable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private int price;
|
||||
|
||||
private LocalDateTime releaseDate;
|
||||
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private int sortOrder;
|
||||
|
||||
@Override
|
||||
public String toInternal() {
|
||||
return id + ",0," +
|
||||
URIEncoder.encode(name) + "," +
|
||||
price + "," +
|
||||
DivaDateTimeUtil.format(releaseDate) + "," +
|
||||
DivaDateTimeUtil.format(endDate) + "," +
|
||||
sortOrder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.gamedata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.FestaKind;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "DivaFesta")
|
||||
@Table(name = "diva_festa")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Festa implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private int id = -1;
|
||||
|
||||
private boolean enable = true;
|
||||
|
||||
private String name = "xxx";
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private FestaKind kind = FestaKind.PINK_FESTA;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Difficulty difficulty = Difficulty.UNDEFINED;
|
||||
|
||||
private String pvList = "ALL";
|
||||
|
||||
private String attributes = "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
|
||||
|
||||
private Integer addVP = 0;
|
||||
|
||||
private Integer vpMultiplier = 1;
|
||||
|
||||
private LocalDateTime start = LocalDateTime.of(2005, 1, 1, 0, 0);
|
||||
|
||||
private LocalDateTime end = LocalDateTime.of(2005, 1, 1, 0, 0);
|
||||
|
||||
private LocalDateTime createDate = LocalDateTime.of(2005, 1, 1, 0, 0);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.gamedata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "DivaNgWords")
|
||||
@Table(name = "diva_ng_words")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class NgWords implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private int id;
|
||||
|
||||
private String word;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.gamedata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty;
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Edition;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "DivaPvEntry")
|
||||
@Table(name = "diva_pv_entry")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PvEntry implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
private int pvId;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Difficulty difficulty;
|
||||
|
||||
private int version;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Edition edition;
|
||||
|
||||
private LocalDateTime demoStart;
|
||||
|
||||
private LocalDateTime demoEnd;
|
||||
|
||||
private LocalDateTime playableStart;
|
||||
|
||||
private LocalDateTime playableEnd;
|
||||
|
||||
public PvEntry(int pvId, Difficulty difficulty, int version, Edition edition, LocalDateTime demoStart, LocalDateTime demoEnd, LocalDateTime playableStart, LocalDateTime playableEnd) {
|
||||
this.pvId = pvId;
|
||||
this.difficulty = difficulty;
|
||||
this.version = version;
|
||||
this.edition = edition;
|
||||
this.demoStart = demoStart;
|
||||
this.demoEnd = demoEnd;
|
||||
this.playableStart = playableStart;
|
||||
this.playableEnd = playableEnd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* Data format from <url>https://dev.s-ul.eu/mikumiku/minime/wikis/home</url>
|
||||
*
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BaseRequest {
|
||||
private String cmd; // Command
|
||||
private String req_id; // Request Id
|
||||
private String game_id; // Game Id
|
||||
private String r_ver; // Game Version
|
||||
private String kc_serial; // KeyChip Serial
|
||||
private String b_serial; // Board Serial
|
||||
private String place_id; // Place Id
|
||||
private ZonedDateTime time_stamp;
|
||||
private String start_up_mode; // Satellite mode, as on dipsw#1, 0 is SUB and 1 is MAIN
|
||||
private String cmm_dly_mod;
|
||||
private String cmm_dly_sec;
|
||||
private String cmm_err_mod;
|
||||
private String country_code;
|
||||
private String region_code;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FormRequest {
|
||||
private String query;
|
||||
private MultipartFile bin;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.request.boot;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <url>https://dev.s-ul.eu/mikumiku/minime/wikis/Command/attend</url>
|
||||
*
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AttendRequest extends BaseRequest {
|
||||
public String atnd_lut; // Date-Time of last attend state update
|
||||
public String atnd_prm1; // Etc. Parameter, only 14 are used, but array of 100 int
|
||||
public String atnd_prm2; // Game balance parameter, only 89 are used of 100
|
||||
public String atnd_prm3; // Dispersal parameter, only 6 used of 100
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.request.boot;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class GameInitRequest extends BaseRequest {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.request.card;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CardProcedureRequest extends BaseRequest {
|
||||
private int cd_adm_cmd;
|
||||
private String a_code;
|
||||
private int aime_id;
|
||||
private String aime_a_code;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package icu.samnyan.aqua.sega.diva.model.request.card;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChangeNameRequest extends BaseRequest {
|
||||
private String a_code;
|
||||
private int aime_id;
|
||||
private String aime_a_code;
|
||||
private int pd_id;
|
||||
private int accept_idx;
|
||||
private String player_name;
|
||||
private int chg_name_price;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user