mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-12-14 11:56:15 +08:00
Compare commits
18 Commits
drop-the-c
...
80ba8146df
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80ba8146df | ||
|
|
9bf6ba8de6 | ||
|
|
dd1f1fdb10 | ||
|
|
6b3f1db904 | ||
|
|
fff5dc974a | ||
|
|
d0bcf5181c | ||
|
|
952e849530 | ||
|
|
bfdb67ac9f | ||
|
|
465dcb7f64 | ||
|
|
db446ffad0 | ||
|
|
fcf3e865da | ||
|
|
bb76a25e72 | ||
|
|
7d1cf8c8d6 | ||
|
|
c52f890054 | ||
|
|
1ddb6803a7 | ||
|
|
b1428a9e8c | ||
|
|
3474c89172 | ||
|
|
83cf96b7c7 |
@@ -212,6 +212,8 @@ val <K, V> Map<K, V>.mut get() = toMutableMap()
|
||||
val <T> Set<T>.mut get() = toMutableSet()
|
||||
|
||||
fun <T> List<T>.unique(fn: (T) -> Any) = distinctBy(fn).ifEmpty { null }
|
||||
val <T> Collection<T>.csv get() = joinToString(",")
|
||||
val IntArray.csv get() = joinToString(",")
|
||||
|
||||
// Optionals
|
||||
operator fun <T> Optional<T>.invoke(): T? = orElse(null)
|
||||
@@ -228,6 +230,7 @@ fun Str.fromChusanUsername() = String(this.toByteArray(StandardCharsets.ISO_8859
|
||||
fun Str.truncate(len: Int) = if (this.length > len) this.take(len) + "..." else this
|
||||
val Str.some get() = ifBlank { null }
|
||||
val ByteArray.hexStr get() = toHexString()
|
||||
operator fun StringBuilder.plusAssign(other: String) { this.append(other) }
|
||||
|
||||
// Coroutine
|
||||
suspend fun <T> async(block: suspend kotlinx.coroutines.CoroutineScope.() -> T): T = withContext(Dispatchers.IO) { block() }
|
||||
@@ -256,6 +259,7 @@ operator fun <E> List<E>.component13(): E = get(12)
|
||||
|
||||
inline operator fun <reified E> List<Any?>.invoke(i: Int) = get(i) as E
|
||||
val empty = emptyList<Any>()
|
||||
val emptyMap = emptyMap<Any, Any>()
|
||||
|
||||
val <F> Pair<F, *>.l get() = component1()
|
||||
val <S> Pair<*, S>.r get() = component2()
|
||||
|
||||
@@ -8,6 +8,7 @@ import icu.samnyan.aqua.net.games.IUserData
|
||||
import icu.samnyan.aqua.net.utils.AquaNetProps
|
||||
import icu.samnyan.aqua.net.utils.SUCCESS
|
||||
import icu.samnyan.aqua.sega.chusan.model.Chu3UserDataRepo
|
||||
import icu.samnyan.aqua.sega.diva.PlayerProfileRepository
|
||||
import icu.samnyan.aqua.sega.general.dao.CardRepository
|
||||
import icu.samnyan.aqua.sega.general.model.Card
|
||||
import icu.samnyan.aqua.sega.general.service.CardService
|
||||
@@ -19,7 +20,6 @@ import org.springframework.scheduling.annotation.Scheduled
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import java.time.LocalDateTime
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
import kotlin.random.Random
|
||||
|
||||
@RestController
|
||||
@@ -204,7 +204,7 @@ class CardGameService(
|
||||
val chusan: Chu3UserDataRepo,
|
||||
val wacca: WcUserRepo,
|
||||
val ongeki: OgkUserDataRepo,
|
||||
val diva: icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository,
|
||||
val diva: PlayerProfileRepository,
|
||||
val safety: AquaNetSafetyService,
|
||||
val cardRepo: CardRepository,
|
||||
val em: EntityManager
|
||||
|
||||
199
src/main/java/icu/samnyan/aqua/sega/diva/DivaController.kt
Normal file
199
src/main/java/icu/samnyan/aqua/sega/diva/DivaController.kt
Normal file
@@ -0,0 +1,199 @@
|
||||
package icu.samnyan.aqua.sega.diva
|
||||
|
||||
import ext.JDict
|
||||
import ext.MutJDict
|
||||
import ext.emptyMap
|
||||
import ext.logger
|
||||
import icu.samnyan.aqua.sega.diva.handler.AttendHandler
|
||||
import icu.samnyan.aqua.sega.diva.handler.PingHandler
|
||||
import icu.samnyan.aqua.sega.diva.handler.card.CardProcedureHandler
|
||||
import icu.samnyan.aqua.sega.diva.handler.card.ChangeNameHandler
|
||||
import icu.samnyan.aqua.sega.diva.handler.card.ChangePasswdHandler
|
||||
import icu.samnyan.aqua.sega.diva.handler.card.RegistrationHandler
|
||||
import icu.samnyan.aqua.sega.diva.handler.databank.*
|
||||
import icu.samnyan.aqua.sega.diva.handler.ingame.*
|
||||
import icu.samnyan.aqua.sega.diva.handler.user.*
|
||||
import icu.samnyan.aqua.sega.diva.model.BaseRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.BuyCstmzItmRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.BuyModuleRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.CardProcedureRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.ChangeNameRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.ChangePasswdRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.GetPvPdRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.RegistrationRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.ShopExitRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.StageResultRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.StageStartRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.StoreSsRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.PsRankingRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.PdUnlockRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.PreStartRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.SpendCreditRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.StartRequest
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaMapper
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaTime
|
||||
import icu.samnyan.aqua.sega.diva.util.URIEncoder.encode
|
||||
import jakarta.servlet.http.HttpServletRequest
|
||||
import lombok.AllArgsConstructor
|
||||
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 java.net.URLDecoder
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
val DIVA_BAD = mapOf("stat" to "0")
|
||||
val DIVA_OK = emptyMap
|
||||
val DIVA_INIT = mapOf("db_close" to "0,0", "retry_time" to "FFFF")
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/g/diva")
|
||||
@AllArgsConstructor
|
||||
class DivaController(
|
||||
val attendHandler: AttendHandler,
|
||||
val cardProcedureHandler: CardProcedureHandler,
|
||||
val changeNameHandler: ChangeNameHandler,
|
||||
val changePasswdHandler: ChangePasswdHandler,
|
||||
val registrationHandler: RegistrationHandler,
|
||||
val contestInfoHandler: ContestInfoHandler,
|
||||
val festaInfoHandler: FestaInfoHandler,
|
||||
val nvRankingHandler: NvRankingHandler,
|
||||
val psRankingHandler: PsRankingHandler,
|
||||
val pvListHandler: PvListHandler,
|
||||
val shopCatalogHandler: ShopCatalogHandler,
|
||||
val buyCstmzItmHandler: BuyCstmzItmHandler,
|
||||
val buyModuleHandler: BuyModuleHandler,
|
||||
val getPvPdHandler: GetPvPdHandler,
|
||||
val shopExitHandler: ShopExitHandler,
|
||||
val stageResultHandler: StageResultHandler,
|
||||
val stageStartHandler: StageStartHandler,
|
||||
val storeSsHandler: StoreSsHandler,
|
||||
val pingHandler: PingHandler,
|
||||
val endHandler: EndHandler,
|
||||
val pdUnlockHandler: PdUnlockHandler,
|
||||
val preStartHandler: PreStartHandler,
|
||||
val spendCreditHandler: SpendCreditHandler,
|
||||
val startHandler: StartHandler,
|
||||
val db: DivaRepos
|
||||
) {
|
||||
val logger = logger()
|
||||
val mapper = DivaMapper()
|
||||
|
||||
fun buildResultMap(map: JDict) =
|
||||
map.filterValues { it != null && !(it is String && it == "") }
|
||||
.map { (k, v) -> "$k=$v" }.joinToString("&")
|
||||
|
||||
@PostMapping(value = ["/"], consumes = [MediaType.APPLICATION_FORM_URLENCODED_VALUE])
|
||||
fun formRequest(request: HttpServletRequest): String? {
|
||||
val bodyStr = String(request.inputStream.readAllBytes())
|
||||
val body = parse(bodyStr)
|
||||
|
||||
val command = body.getOrDefault("cmd", "") as String?
|
||||
|
||||
logger.info("{}: {}", command, body)
|
||||
val respObj = when (command) {
|
||||
"game_init" -> DIVA_INIT
|
||||
"attend" -> attendHandler.handle()
|
||||
"test" -> DIVA_INIT
|
||||
"nv_ranking" -> nvRankingHandler.handle(mapper.convert(body, BaseRequest::class.java))
|
||||
"ps_ranking" -> psRankingHandler.handle(mapper.convert(body, PsRankingRequest::class.java))
|
||||
|
||||
"pv_list" -> pvListHandler.handle(mapper.convert(body, BaseRequest::class.java))
|
||||
"ng_word" -> DIVA_OK
|
||||
"rmt_wp_list" -> mapOf("rwl_lut" to DivaTime.now, "rw_lst" to "***")
|
||||
"festa_info" -> festaInfoHandler.handle(mapper.convert(body, BaseRequest::class.java))
|
||||
"contest_info" -> contestInfoHandler.handle(mapper.convert(body, BaseRequest::class.java))
|
||||
"pv_def_chr_list" -> mapOf("pdcl_lut" to DivaTime.now, "pdc_lst" to "***")
|
||||
"pv_ng_mdl_list" -> mapOf("pnml_lut" to DivaTime.now, "pnm_lst" to "***")
|
||||
"cstmz_itm_ng_mdl_list" -> mapOf("cinml_lut" to DivaTime.now, "cinm_lst" to "***")
|
||||
|
||||
"banner_info" -> listOf("bi_lut", "bi_id", "bi_st", "bi_et", "bi_ut").associateWith { null }
|
||||
"banner_data" -> mapOf("bd_ut" to DivaTime.now, "bd_ti" to "***", "bd_hs" to "***", "bd_id" to body["bd_id"])
|
||||
|
||||
"cm_ply_info" -> emptyMap
|
||||
"qst_inf" -> mapOf("qi_lut" to DivaTime.now, "qhi_str" to null, "qrai_str" to null)
|
||||
"pstd_h_ctrl" -> mapOf("p_std_hc_lut" to DivaTime.now, "p_std_hc_str" to "***,***")
|
||||
"pstd_item_ng_lst" -> mapOf("p_std_i_n_lut" to DivaTime.now, "p_std_i_ie_n_lst" to "***", "p_std_i_se_n_lst" to "***")
|
||||
|
||||
"shop_catalog" -> shopCatalogHandler.handle(mapper.convert(body, BaseRequest::class.java))
|
||||
"cstmz_itm_ctlg" -> mapOf(
|
||||
"cstmz_itm_ctlg_lut" to DivaTime.now,
|
||||
"cstmz_itm_ctlg" to encode(db.g.customize.findAll().map { it.toInternal() }.joinToString(",") { encode(it) })
|
||||
)
|
||||
"card_procedure" -> cardProcedureHandler.handle(mapper.convert(body, CardProcedureRequest::class.java))
|
||||
|
||||
"registration" -> registrationHandler.handle(mapper.convert(body, RegistrationRequest::class.java))
|
||||
|
||||
"init_passwd" -> DIVA_BAD
|
||||
|
||||
"change_passwd" -> changePasswdHandler.handle(mapper.convert(body, ChangePasswdRequest::class.java))
|
||||
|
||||
"change_name" -> changeNameHandler.handle(mapper.convert(body, ChangeNameRequest::class.java))
|
||||
|
||||
"pre_start" -> preStartHandler.handle(mapper.convert(body, PreStartRequest::class.java))
|
||||
"start" -> startHandler.handle(mapper.convert(body, StartRequest::class.java))
|
||||
"pd_unlock" -> pdUnlockHandler.handle(mapper.convert(body, PdUnlockRequest::class.java))
|
||||
"spend_credit" -> spendCreditHandler.handle(mapper.convert(body, SpendCreditRequest::class.java))
|
||||
|
||||
"no_card_end" -> DIVA_INIT
|
||||
"end" -> endHandler.handle(mapper.convert(body, StageResultRequest::class.java))
|
||||
"get_pv_pd" -> getPvPdHandler.handle(mapper.convert(body, GetPvPdRequest::class.java))
|
||||
"buy_module" -> buyModuleHandler.handle(mapper.convert(body, BuyModuleRequest::class.java))
|
||||
|
||||
"buy_cstmz_itm" -> buyCstmzItmHandler.handle(mapper.convert(body, BuyCstmzItmRequest::class.java))
|
||||
|
||||
"shop_exit" -> shopExitHandler.handle(mapper.convert(body, ShopExitRequest::class.java))
|
||||
"stage_start" -> stageStartHandler.handle(mapper.convert(body, StageStartRequest::class.java))
|
||||
|
||||
"stage_result" -> stageResultHandler.handle(mapper.convert(body, StageResultRequest::class.java))
|
||||
|
||||
"store_ss" -> DIVA_INIT
|
||||
else -> DIVA_BAD
|
||||
}
|
||||
val resp = respObj as? String
|
||||
?: buildResultMap(mapOf("cmd" to command, "req_id" to body["req_id"], "stat" to "ok") + mapper.toMap(respObj))
|
||||
logger.info("Response: {}", resp)
|
||||
return resp
|
||||
}
|
||||
|
||||
@PostMapping(value = ["/"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
|
||||
fun fileRequest(@RequestParam query: String, @RequestParam(required = false) bin: MultipartFile): String? {
|
||||
val body = parse(query)
|
||||
val command = body.getOrDefault("cmd", "") as String?
|
||||
|
||||
logger.info("{}: {}", command, body)
|
||||
|
||||
val respObj = when (command) {
|
||||
"ping" -> pingHandler.handle(mapper.convert(body, BaseRequest::class.java))
|
||||
"investigate" -> DIVA_INIT
|
||||
"store_ss" -> storeSsHandler.handle(mapper.convert(body, StoreSsRequest::class.java), bin)
|
||||
else -> "stat=1"
|
||||
}
|
||||
val resp = respObj as? String ?: buildResultMap(mapper.toMap(respObj))
|
||||
logger.info("Response: {}", resp)
|
||||
return resp
|
||||
}
|
||||
|
||||
fun parse(form: String): MutJDict {
|
||||
val kvps = form.split('&').dropLastWhile { it.isEmpty() }
|
||||
val body: MutJDict = LinkedHashMap()
|
||||
for (kvp in kvps) {
|
||||
var (k, v) = kvp.split('=').dropLastWhile { it.isEmpty() }
|
||||
v = URLDecoder.decode(v, StandardCharsets.UTF_8)
|
||||
body[k] = if (v.contains(",")) { v.deArray() } else { v }
|
||||
}
|
||||
return body
|
||||
}
|
||||
|
||||
fun String.deArray(): Any {
|
||||
if (!contains(',')) return this
|
||||
return split(',').dropLastWhile { it.isEmpty() }
|
||||
.map { URLDecoder.decode(it, StandardCharsets.UTF_8) }
|
||||
.map { it.deArray() }
|
||||
}
|
||||
}
|
||||
164
src/main/java/icu/samnyan/aqua/sega/diva/DivaRepos.kt
Normal file
164
src/main/java/icu/samnyan/aqua/sega/diva/DivaRepos.kt
Normal file
@@ -0,0 +1,164 @@
|
||||
package icu.samnyan.aqua.sega.diva
|
||||
|
||||
import ext.invoke
|
||||
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.db.gamedata.Contest
|
||||
import icu.samnyan.aqua.sega.diva.model.db.gamedata.DivaCustomize
|
||||
import icu.samnyan.aqua.sega.diva.model.db.gamedata.DivaModule
|
||||
import icu.samnyan.aqua.sega.diva.model.db.gamedata.Festa
|
||||
import icu.samnyan.aqua.sega.diva.model.db.gamedata.Pv
|
||||
import icu.samnyan.aqua.sega.diva.model.db.gamedata.PvEntry
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.GameSession
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayLog
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerContest
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerCustomize
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerInventory
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerModule
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerProfile
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerPvCustomize
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerPvRecord
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerScreenShot
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
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.Component
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.util.*
|
||||
|
||||
@Component
|
||||
class DivaGameRepos(
|
||||
val contest: ContestRepository,
|
||||
val customize: DivaCustomizeRepository,
|
||||
val module: DivaModuleRepository,
|
||||
val pv: DivaPvRepository,
|
||||
val festa: FestaRepository,
|
||||
val pvEntry: PvEntryRepository
|
||||
)
|
||||
|
||||
@Component
|
||||
class DivaRepos(
|
||||
val g: DivaGameRepos,
|
||||
val s: DivaServices,
|
||||
val gameSession: GameSessionRepository,
|
||||
val playLog: PlayLogRepository,
|
||||
val contest: PlayerContestRepository,
|
||||
val customize: PlayerCustomizeRepository,
|
||||
val inventory: PlayerInventoryRepository,
|
||||
val module: PlayerModuleRepository,
|
||||
val profile: PlayerProfileRepository,
|
||||
val pvCustomize: PlayerPvCustomizeRepository,
|
||||
val pvRecord: PlayerPvRecordRepository,
|
||||
val screenShot: PlayerScreenShotRepository,
|
||||
) {
|
||||
fun profile(id: Long) = profile.findByPdId(id)() ?: throw ProfileNotFoundException()
|
||||
fun session(id: Long) = profile(id).let { it to (gameSession.findByPdId(it)() ?: throw SessionNotFoundException()) }
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface ContestRepository : JpaRepository<Contest, Int> {
|
||||
fun findTop8ByEnable(enable: Boolean): MutableList<Contest>
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface DivaCustomizeRepository : JpaRepository<DivaCustomize, Int>
|
||||
|
||||
@Repository
|
||||
interface DivaModuleRepository : JpaRepository<DivaModule, Int>
|
||||
|
||||
interface DivaPvRepository : JpaRepository<Pv, Int>
|
||||
|
||||
@Repository
|
||||
interface FestaRepository : JpaRepository<Festa, Int> {
|
||||
fun findTop2ByEnableOrderByCreateDateDesc(enable: Boolean): MutableList<Festa>
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface PvEntryRepository : JpaRepository<PvEntry, Int> {
|
||||
fun findByDifficulty(difficulty: Difficulty): MutableList<PvEntry>
|
||||
}
|
||||
|
||||
interface PlayerContestRepository : JpaRepository<PlayerContest, Long> {
|
||||
fun findByPdIdAndContestId(pdId: PlayerProfile, contestId: Int): Optional<PlayerContest>
|
||||
|
||||
fun findTop4ByPdIdOrderByLastUpdateTimeDesc(pdId: PlayerProfile): MutableList<PlayerContest>
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface GameSessionRepository : JpaRepository<GameSession, Long> {
|
||||
fun findByPdId(profile: PlayerProfile): Optional<GameSession>
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface PlayerCustomizeRepository : JpaRepository<PlayerCustomize, Long> {
|
||||
fun findByPdId(profile: PlayerProfile): MutableList<PlayerCustomize>
|
||||
|
||||
fun findByPdIdAndCustomizeId(currentProfile: PlayerProfile, parseInt: Int): Optional<PlayerCustomize>
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface PlayerInventoryRepository : JpaRepository<PlayerInventory, Long> {
|
||||
fun findByPdIdAndTypeAndValue(profile: PlayerProfile, type: String, value: String): Optional<PlayerInventory>
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface PlayerProfileRepository : JpaRepository<PlayerProfile, Long> {
|
||||
fun findByPdId(pdId: Long): Optional<PlayerProfile>
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface PlayerPvCustomizeRepository : JpaRepository<PlayerPvCustomize, Long> {
|
||||
fun findByPdIdAndPvId(profile: PlayerProfile, pvId: Int): Optional<PlayerPvCustomize>
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface PlayerPvRecordRepository : JpaRepository<PlayerPvRecord, Long> {
|
||||
fun findByPdIdAndPvIdAndEditionAndDifficulty(
|
||||
profile: PlayerProfile,
|
||||
pvId: Int,
|
||||
edition: Edition,
|
||||
difficulty: Difficulty
|
||||
): Optional<PlayerPvRecord>
|
||||
|
||||
fun findByPdId_PdIdAndPvIdAndEditionAndDifficulty(
|
||||
pdId: Long,
|
||||
pvId: Int,
|
||||
edition: Edition,
|
||||
difficulty: Difficulty
|
||||
): Optional<PlayerPvRecord>
|
||||
|
||||
@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")
|
||||
)
|
||||
fun rankByPvIdAndPdIdAndEditionAndDifficulty(
|
||||
@Param("pvId") pvId: Int,
|
||||
@Param("pdId") pdId: PlayerProfile,
|
||||
@Param("edition") edition: Edition,
|
||||
@Param("difficulty") difficulty: Difficulty
|
||||
): Int
|
||||
|
||||
fun findByPdId(profile: PlayerProfile): MutableList<PlayerPvRecord>
|
||||
|
||||
fun findByPdIdAndEdition(profile: PlayerProfile, edition: Edition): MutableList<PlayerPvRecord>
|
||||
|
||||
fun findTop3ByPvIdAndEditionAndDifficultyOrderByMaxScoreDesc(
|
||||
pvId: Int,
|
||||
edition: Edition,
|
||||
difficulty: Difficulty
|
||||
): MutableList<PlayerPvRecord>
|
||||
}
|
||||
|
||||
interface PlayerScreenShotRepository : JpaRepository<PlayerScreenShot, Long>
|
||||
|
||||
@Repository
|
||||
interface PlayLogRepository : JpaRepository<PlayLog, Long>
|
||||
|
||||
@Repository
|
||||
interface PlayerModuleRepository : JpaRepository<PlayerModule, Long> {
|
||||
fun findByPdId(profile: PlayerProfile): MutableList<PlayerModule>
|
||||
}
|
||||
63
src/main/java/icu/samnyan/aqua/sega/diva/DivaServices.kt
Normal file
63
src/main/java/icu/samnyan/aqua/sega/diva/DivaServices.kt
Normal file
@@ -0,0 +1,63 @@
|
||||
package icu.samnyan.aqua.sega.diva
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.RegistrationRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerCustomize
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerModule
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerProfile
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.stereotype.Service
|
||||
import java.math.BigInteger
|
||||
import java.util.*
|
||||
|
||||
|
||||
@Component
|
||||
class DivaServices(
|
||||
val profile: PlayerProfileService,
|
||||
val module: PlayerModuleService,
|
||||
val customize: PlayerCustomizeService
|
||||
)
|
||||
|
||||
@Service
|
||||
class PlayerModuleService(val repo: PlayerModuleRepository) {
|
||||
fun buy(profile: PlayerProfile, moduleId: Int) = repo.save(PlayerModule(profile, moduleId))
|
||||
|
||||
fun getModuleHaveString(profile: PlayerProfile): String {
|
||||
val moduleList = repo.findByPdId(profile)
|
||||
var module_have = BigInteger("0")
|
||||
for (module in moduleList) {
|
||||
module_have = module_have.or(BigInteger.valueOf(1).shiftLeft(module.moduleId))
|
||||
}
|
||||
println(module_have.toString(2))
|
||||
return StringUtils.leftPad(module_have.toString(16), 250, "0").uppercase(Locale.getDefault())
|
||||
}
|
||||
}
|
||||
|
||||
@Service
|
||||
class PlayerProfileService(val repo: PlayerProfileRepository) {
|
||||
fun findByPdId(pdId: Long): Optional<PlayerProfile> = repo.findByPdId(pdId)
|
||||
|
||||
fun register(request: RegistrationRequest): PlayerProfile {
|
||||
val profile = PlayerProfile()
|
||||
profile.pdId = request.aime_id
|
||||
profile.playerName = request.player_name
|
||||
|
||||
return repo.save(profile)
|
||||
}
|
||||
|
||||
fun save(profile: PlayerProfile) = repo.save(profile)
|
||||
}
|
||||
|
||||
@Service
|
||||
class PlayerCustomizeService(val repo: PlayerCustomizeRepository) {
|
||||
fun buy(profile: PlayerProfile, customizeId: Int) = repo.save(PlayerCustomize(profile, customizeId))
|
||||
|
||||
fun getModuleHaveString(profile: PlayerProfile): String {
|
||||
val customizeList = repo.findByPdId(profile)
|
||||
var customize_have = BigInteger("0")
|
||||
for (customize in customizeList) {
|
||||
customize_have = customize_have.or(BigInteger.valueOf(1).shiftLeft(customize.customizeId))
|
||||
}
|
||||
return StringUtils.leftPad(customize_have.toString(16), 250, "0")
|
||||
}
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
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 jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.AllArgsConstructor;
|
||||
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 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("/g/diva")
|
||||
@AllArgsConstructor
|
||||
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;
|
||||
|
||||
@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);
|
||||
|
||||
return switch (command) {
|
||||
|
||||
// Boot
|
||||
case "game_init" -> gameInitHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
case "attend" -> attendHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
|
||||
//
|
||||
case "test" -> gameInitHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
|
||||
// Databank
|
||||
case "nv_ranking" -> nvRankingHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "ps_ranking" -> psRankingHandler.handle(mapper.convert(body, PsRankingRequest.class));
|
||||
case "pv_list" -> pvListHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "ng_word" -> ngWordHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "rmt_wp_list" -> rmtWpLstHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "festa_info" -> festaInfoHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "contest_info" -> contestInfoHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "pv_def_chr_list" -> pvDefChrLstHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "pv_ng_mdl_list" -> pvNgMdlLstHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "cstmz_itm_ng_mdl_list" -> cstmzItmNgMdlListHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "banner_info" -> bannerInfoHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "banner_data" -> bannerDataHandler.handle(mapper.convert(body, BannerDataRequest.class));
|
||||
case "cm_ply_info" -> cmPlyInfoHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "qst_inf" -> qstInfHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "pstd_h_ctrl" -> pstdHCtrlHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "pstd_item_ng_lst" -> pstdItemNgLstHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "shop_catalog" -> shopCatalogHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "cstmz_itm_ctlg" -> cstmzItmCtlgHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "card_procedure" -> cardProcedureHandler.handle(mapper.convert(body, CardProcedureRequest.class));
|
||||
case "registration" -> registrationHandler.handle(mapper.convert(body, RegistrationRequest.class));
|
||||
case "init_passwd" -> initPasswdHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
case "change_passwd" -> changePasswdHandler.handle(mapper.convert(body, ChangePasswdRequest.class));
|
||||
case "change_name" -> changeNameHandler.handle(mapper.convert(body, ChangeNameRequest.class));
|
||||
case "pre_start" -> preStartHandler.handle(mapper.convert(body, PreStartRequest.class));
|
||||
case "start" -> startHandler.handle(mapper.convert(body, StartRequest.class));
|
||||
case "pd_unlock" -> pdUnlockHandler.handle(mapper.convert(body, PdUnlockRequest.class));
|
||||
case "spend_credit" -> spendCreditHandler.handle(mapper.convert(body, SpendCreditRequest.class));
|
||||
case "no_card_end" -> gameInitHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
case "end" -> endHandler.handle(mapper.convert(body, StageResultRequest.class));
|
||||
case "get_pv_pd" -> getPvPdHandler.handle(mapper.convert(body, GetPvPdRequest.class));
|
||||
case "buy_module" -> buyModuleHandler.handle(mapper.convert(body, BuyModuleRequest.class));
|
||||
case "buy_cstmz_itm" -> buyCstmzItmHandler.handle(mapper.convert(body, BuyCstmzItmRequest.class));
|
||||
case "shop_exit" -> shopExitHandler.handle(mapper.convert(body, ShopExitRequest.class));
|
||||
case "stage_start" -> stageStartHandler.handle(mapper.convert(body, StageStartRequest.class));
|
||||
case "stage_result" -> stageResultHandler.handle(mapper.convert(body, StageResultRequest.class));
|
||||
case "store_ss" -> gameInitHandler.handle(mapper.convert(body, GameInitRequest.class));
|
||||
default -> "stat=0";
|
||||
};
|
||||
}
|
||||
|
||||
@PostMapping(value = "/", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public String fileRequest(@RequestParam String query, @RequestParam(required = false) MultipartFile bin) {
|
||||
|
||||
Map<String, Object> body = parse(query);
|
||||
|
||||
String command = (String) body.getOrDefault("cmd", "");
|
||||
|
||||
logger.info("{}: {}", command, body);
|
||||
|
||||
return switch (command) {
|
||||
case "ping" -> pingHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "investigate" -> gameInitHandler.handle(mapper.convert(body, BaseRequest.class));
|
||||
case "store_ss" -> storeSsHandler.handle(mapper.convert(body, StoreSsRequest.class), bin);
|
||||
default -> "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());
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
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> {
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.gamedata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.Pv;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public interface DivaPvRepository extends JpaRepository<Pv, Integer> {
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
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> {
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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(long pdId, Pageable page);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface PlayerCustomizeRepository extends JpaRepository<PlayerCustomize, Long> {
|
||||
List<PlayerCustomize> findByPdId(PlayerProfile profile);
|
||||
|
||||
Page<PlayerCustomize> findByPdId_PdId(long pdId, Pageable page);
|
||||
|
||||
Optional<PlayerCustomize> findByPdIdAndCustomizeId(PlayerProfile currentProfile, int parseInt);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerInventory;
|
||||
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 PlayerInventoryRepository extends JpaRepository<PlayerInventory, Long> {
|
||||
Optional<PlayerInventory> findByPdIdAndTypeAndValue(PlayerProfile profile, String type, String value);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
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(long pdId, Pageable pageable);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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(long pdId);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
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(long pdId, int pvId);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
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);
|
||||
|
||||
Optional<PlayerPvRecord> findByPdId_PdIdAndPvIdAndEditionAndDifficulty(long pdId, 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, long pdId);
|
||||
|
||||
List<PlayerPvRecord> findByPdIdAndEdition(PlayerProfile profile, Edition edition);
|
||||
|
||||
List<PlayerPvRecord> findTop3ByPvIdAndEditionAndDifficultyOrderByMaxScoreDesc(int pvId, Edition edition, Difficulty difficulty);
|
||||
|
||||
Page<PlayerPvRecord> findByPvIdAndEditionAndDifficultyOrderByMaxScoreDesc(int pvId, Edition edition, Difficulty difficulty, Pageable page);
|
||||
|
||||
Page<PlayerPvRecord> findByPdId_PdIdOrderByPvId(long pdId, Pageable page);
|
||||
|
||||
List<PlayerPvRecord> findByPdId_PdIdAndPvId(long pdId, int pvId);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerScreenShot;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public interface PlayerScreenShotRepository extends JpaRepository<PlayerScreenShot, Long> {
|
||||
List<PlayerScreenShot> findByPdId_PdId(long pdId);
|
||||
Optional<PlayerScreenShot> findByFileName(String fileName);
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.exception;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class ProfileNotFoundException extends RuntimeException {
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.exception;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class PvRecordDataException extends RuntimeException {
|
||||
public PvRecordDataException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.exception;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class SessionNotFoundException extends RuntimeException {
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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 {
|
||||
static protected DivaMapper mapper = new DivaMapper();
|
||||
|
||||
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,77 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler
|
||||
|
||||
import ext.csv
|
||||
import icu.samnyan.aqua.sega.diva.model.BaseRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.operation.PingResponse
|
||||
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository
|
||||
import icu.samnyan.aqua.sega.general.model.PropertyEntry
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
|
||||
fun gameBalanceParameter(): String {
|
||||
val name_change_price = 100
|
||||
// Trial bids: clear.pay, clear.win, great.pay, great.win, excellent.pay, excellent.win, perfect.pay, perfect.win
|
||||
val easy_trials = listOf(5, 10, 10, 25, 20, 50, 30, 90)
|
||||
val normal_trials = listOf(5, 10, 10, 25, 20, 50, 30, 90)
|
||||
val hard_trials = listOf(5, 10, 10, 25, 20, 50, 30, 90)
|
||||
val extreme_trials = listOf(5, 10, 10, 25, 20, 50, 30, 90)
|
||||
val extra_extreme_trials = listOf(5, 10, 10, 25, 20, 50, 30, 90)
|
||||
|
||||
return (listOf(name_change_price, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 3, 4, 5, 1, 1, 1, 4, 5, 6, 1, 1, 1, 5, 6, 7, 4, 4, 4, 9, 10, 14) +
|
||||
easy_trials + normal_trials + hard_trials +
|
||||
extreme_trials + extra_extreme_trials + listOf(10, 30) + Collections.nCopies(100, 0)).take(100).csv
|
||||
}
|
||||
|
||||
fun EtcParameter(): String {
|
||||
val module_shop_close = false
|
||||
val card_reissue_close = true
|
||||
val card_renewal_close = true
|
||||
val reset_passwd_close = true
|
||||
val change_passwd_close = false
|
||||
val change_name_close = false
|
||||
val encore_mode_close = true
|
||||
val third_stg_mode_close = false
|
||||
val slow_down_threshold = 0
|
||||
val log_write_flag = false
|
||||
val daily_quest_close = true
|
||||
val weekly_quest_close = true
|
||||
val special_quest_close = true
|
||||
val nppg_close = false
|
||||
|
||||
val list = listOf(module_shop_close, card_reissue_close, card_renewal_close, reset_passwd_close,
|
||||
change_passwd_close, change_name_close, encore_mode_close, third_stg_mode_close,
|
||||
slow_down_threshold, log_write_flag, daily_quest_close, weekly_quest_close,
|
||||
special_quest_close, nppg_close) + Collections.nCopies(100, 0)
|
||||
return list.take(100).map {
|
||||
if (it is Boolean) if (it) "1" else "0"
|
||||
else if (it is Int) it.toString()
|
||||
else "0"
|
||||
}.csv
|
||||
}
|
||||
|
||||
@Component
|
||||
class AttendHandler {
|
||||
fun handle() = mapOf(
|
||||
"atnd_prm1" to EtcParameter(),
|
||||
"atnd_prm2" to mapOf(
|
||||
"max_pd_items" to 30, "" to 1, "max_ps_rankings" to 100,
|
||||
"max_screenshots" to 2, "ss_upload_delay" to 1, "" to 1
|
||||
).values.plus(Collections.nCopies(100, 0)).take(100).csv,
|
||||
"atnd_prm3" to gameBalanceParameter(),
|
||||
"atnd_lut" to LocalDateTime.now()
|
||||
)
|
||||
}
|
||||
|
||||
@Component
|
||||
class PingHandler(val rp: PropertyEntryRepository) {
|
||||
fun handle(request: BaseRequest): Any {
|
||||
val news: PropertyEntry = rp.findByPropertyKey("diva_news") ?: PropertyEntry("diva_news", "xxx")
|
||||
val warning: PropertyEntry = rp.findByPropertyKey("diva_warning") ?: PropertyEntry("diva_warning", "xxx")
|
||||
|
||||
return PingResponse(
|
||||
news.propertyValue,
|
||||
warning.propertyValue
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class CardProcedureHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CardProcedureHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final 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,
|
||||
-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,71 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
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.CardProcedureRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.CardProcedureResponse
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.GameSession
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
import java.util.concurrent.ThreadLocalRandom
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class CardProcedureHandler(val db: DivaRepos) {
|
||||
fun handle(request: CardProcedureRequest): Any {
|
||||
val profileOptional = db.profile.findByPdId(request.aime_id)
|
||||
if (profileOptional.isEmpty) {
|
||||
return CardProcedureResponse(
|
||||
Result.FAILED
|
||||
)
|
||||
} else {
|
||||
val profile = profileOptional.get()
|
||||
|
||||
val sessionOptional = db.gameSession.findByPdId(profile)
|
||||
if (sessionOptional.isPresent) {
|
||||
val session = sessionOptional.get()
|
||||
if (session.lastUpdateTime.isBefore(LocalDateTime.now().minusMinutes(5))) {
|
||||
db.gameSession.delete(session)
|
||||
}
|
||||
return CardProcedureResponse(
|
||||
Result.FAILED
|
||||
)
|
||||
} else {
|
||||
val session = GameSession(
|
||||
ThreadLocalRandom.current().nextInt(100, 99999),
|
||||
profile,
|
||||
StartMode.CARD_PROCEDURE,
|
||||
LocalDateTime.now(),
|
||||
LocalDateTime.now(),
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
profile.level,
|
||||
profile.levelExp,
|
||||
profile.level,
|
||||
profile.levelExp,
|
||||
profile.vocaloidPoints
|
||||
)
|
||||
|
||||
db.gameSession.save(session)
|
||||
return CardProcedureResponse(
|
||||
Result.SUCCESS,
|
||||
100,
|
||||
session.acceptId,
|
||||
profile.pdId,
|
||||
profile.playerName,
|
||||
profile.level,
|
||||
profile.levelExp,
|
||||
profile.levelTitle,
|
||||
profile.plateEffectId,
|
||||
profile.plateId,
|
||||
profile.vocaloidPoints,
|
||||
profile.passwordStatus
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class ChangeNameHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChangeNameHandler.class);
|
||||
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
private final 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,
|
||||
session.getAcceptId(),
|
||||
profile.getPdId(),
|
||||
profile.getPlayerName()
|
||||
);
|
||||
|
||||
playerProfileService.save(profile);
|
||||
gameSessionRepository.delete(session);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.ChangeNameRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.ChangeNameResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class ChangeNameHandler(val db: DivaRepos) {
|
||||
fun handle(request: ChangeNameRequest): Any {
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
profile.playerName = request.player_name
|
||||
db.profile.save(profile)
|
||||
db.gameSession.delete(session)
|
||||
|
||||
return ChangeNameResponse(
|
||||
Result.SUCCESS,
|
||||
session.acceptId,
|
||||
profile.pdId,
|
||||
profile.playerName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class ChangePasswdHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChangePasswdHandler.class);
|
||||
private final PlayerProfileService playerProfileService;
|
||||
private final 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,
|
||||
session.getAcceptId(),
|
||||
profile.getPdId()
|
||||
);
|
||||
|
||||
playerProfileService.save(profile);
|
||||
gameSessionRepository.delete(session);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
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.ChangePasswdRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.ChangePasswdResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class ChangePasswdHandler(val db: DivaRepos) {
|
||||
fun handle(request: ChangePasswdRequest): Any {
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
profile.passwordStatus = PassStat.SET
|
||||
profile.password = request.new_passwd
|
||||
db.profile.save(profile)
|
||||
db.gameSession.delete(session)
|
||||
|
||||
return ChangePasswdResponse(
|
||||
Result.SUCCESS,
|
||||
session.acceptId,
|
||||
profile.pdId
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class InitPasswdHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(InitPasswdHandler.class);
|
||||
private final PlayerProfileService playerProfileService;
|
||||
private final 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;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class RegistrationHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(RegistrationHandler.class);
|
||||
private final 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,27 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.PlayerProfileService
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.RegistrationRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.RegistrationResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class RegistrationHandler(val service: PlayerProfileService) {
|
||||
fun handle(request: RegistrationRequest) =
|
||||
if (service.findByPdId(request.aime_id).isPresent) {
|
||||
RegistrationResponse(
|
||||
Result.FAILED,
|
||||
-1
|
||||
)
|
||||
} else {
|
||||
val profile = service.register(request)
|
||||
RegistrationResponse(
|
||||
Result.SUCCESS,
|
||||
profile.pdId
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
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.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class ContestInfoHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CmPlyInfoHandler.class);
|
||||
private final 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,33 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.db.gamedata.Contest
|
||||
import icu.samnyan.aqua.sega.diva.model.BaseRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.ContestInfoResponse
|
||||
import icu.samnyan.aqua.sega.diva.util.URIEncoder.encode
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
import java.util.function.Consumer
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class ContestInfoHandler(val db: DivaRepos) {
|
||||
fun handle(request: BaseRequest): Any {
|
||||
val contestList = db.g.contest.findTop8ByEnable(true)
|
||||
var ci_str = "***"
|
||||
if (!contestList.isEmpty()) {
|
||||
val sb = StringBuilder()
|
||||
contestList.forEach(Consumer { x: Contest? -> sb.append(encode(x!!.string)).append(",") })
|
||||
sb.append("%2A%2A%2A,".repeat(max(0, 8 - contestList.size)))
|
||||
sb.deleteCharAt(sb.length - 1)
|
||||
ci_str = sb.toString()
|
||||
}
|
||||
return ContestInfoResponse(
|
||||
LocalDateTime.now(),
|
||||
ci_str
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
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.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class CstmzItmCtlgHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CstmzItmCtlgHandler.class);
|
||||
|
||||
private final DivaCustomizeRepository 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;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class FestaInfoHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FestaInfoHandler.class);
|
||||
private final 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,32 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.FestaRepository
|
||||
import icu.samnyan.aqua.sega.diva.model.common.collection.FestaCollection
|
||||
import icu.samnyan.aqua.sega.diva.model.BaseRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.FestaInfoResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class FestaInfoHandler(private val festaRepository: FestaRepository) {
|
||||
fun handle(request: BaseRequest): Any {
|
||||
val festaList = festaRepository.findTop2ByEnableOrderByCreateDateDesc(true)
|
||||
val collection = FestaCollection(festaList)
|
||||
|
||||
return FestaInfoResponse(
|
||||
collection.ids,
|
||||
collection.names,
|
||||
collection.kinds,
|
||||
collection.diffs,
|
||||
collection.pvIds,
|
||||
collection.attr,
|
||||
collection.addVps,
|
||||
collection.vpMultipliers,
|
||||
collection.starts,
|
||||
collection.ends,
|
||||
collection.lastUpdateTime
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
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 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 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,18 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.model.BaseRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.NvRankingResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class NvRankingHandler {
|
||||
fun handle(request: BaseRequest) = NvRankingResponse(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
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.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class PsRankingHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PsRankingHandler.class);
|
||||
private final 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.findTop3ByPvIdAndEditionAndDifficultyOrderByMaxScoreDesc(i, edition, 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.getSecond().getPdId().getPlayerName() : "xxx"));
|
||||
name3.add(URIEncoder.encode(obj.getThird().getPdId() != null ? obj.getThird().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,84 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank
|
||||
|
||||
import ext.csv
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
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.PsRankingRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.PsRankingResponse
|
||||
import icu.samnyan.aqua.sega.diva.util.URIEncoder.encode
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class PsRankingHandler(val db: DivaRepos) {
|
||||
fun handle(request: PsRankingRequest): Any {
|
||||
var edition = Edition.ORIGINAL
|
||||
var difficulty = Difficulty.HARD
|
||||
|
||||
when (request.rnk_ps_idx) {
|
||||
0 -> difficulty = Difficulty.HARD
|
||||
1 -> difficulty = Difficulty.EXTREME
|
||||
2 -> {
|
||||
difficulty = Difficulty.EXTREME
|
||||
edition = Edition.EXTRA
|
||||
}
|
||||
}
|
||||
|
||||
val list = request.rnk_ps_pv_id_lst
|
||||
val resultCollections: MutableMap<Int?, PsRankingCollection?> = LinkedHashMap<Int?, PsRankingCollection?>()
|
||||
for (i in list) {
|
||||
val records = db.pvRecord.findTop3ByPvIdAndEditionAndDifficultyOrderByMaxScoreDesc(
|
||||
i,
|
||||
edition,
|
||||
difficulty
|
||||
)
|
||||
resultCollections.put(i, PsRankingCollection(i, edition, records))
|
||||
}
|
||||
|
||||
val pvIds: MutableList<Int?> = LinkedList<Int?>()
|
||||
val edition1: MutableList<Int?> = LinkedList<Int?>()
|
||||
val edition2: MutableList<Int?> = LinkedList<Int?>()
|
||||
val edition3: MutableList<Int?> = LinkedList<Int?>()
|
||||
val score1: MutableList<Int?> = LinkedList<Int?>()
|
||||
val score2: MutableList<Int?> = LinkedList<Int?>()
|
||||
val score3: MutableList<Int?> = LinkedList<Int?>()
|
||||
val name1: MutableList<String?> = LinkedList<String?>()
|
||||
val name2: MutableList<String?> = LinkedList<String?>()
|
||||
val name3: MutableList<String?> = LinkedList<String?>()
|
||||
|
||||
resultCollections.forEach { (key: Int?, obj: PsRankingCollection?) ->
|
||||
pvIds.add(key)
|
||||
edition1.add(obj!!.first.edition.value)
|
||||
edition2.add(obj.second.edition.value)
|
||||
edition3.add(obj.third.edition.value)
|
||||
score1.add(obj.first.maxScore)
|
||||
score2.add(obj.second.maxScore)
|
||||
score3.add(obj.third.maxScore)
|
||||
name1.add(encode(obj.first.pdId?.playerName ?: "xxx"))
|
||||
name2.add(encode(obj.second.pdId?.playerName ?: "xxx"))
|
||||
name3.add(encode(obj.third.pdId?.playerName ?: "xxx"))
|
||||
}
|
||||
|
||||
return PsRankingResponse(
|
||||
LocalDateTime.now(),
|
||||
LocalDateTime.now(),
|
||||
request.rnk_ps_idx,
|
||||
pvIds.csv,
|
||||
edition1.csv,
|
||||
edition2.csv,
|
||||
edition3.csv,
|
||||
score1.csv,
|
||||
score2.csv,
|
||||
score3.csv,
|
||||
name1.csv,
|
||||
name2.csv,
|
||||
name3.csv
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
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.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class PvListHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(BannerDataHandler.class);
|
||||
private final PvEntryRepository pvEntryRepository;
|
||||
private final DateTimeFormatter 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,57 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty
|
||||
import icu.samnyan.aqua.sega.diva.model.db.gamedata.PvEntry
|
||||
import icu.samnyan.aqua.sega.diva.model.BaseRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.PvListResponse
|
||||
import icu.samnyan.aqua.sega.diva.util.URIEncoder.encode
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.function.Consumer
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class PvListHandler(val db: DivaRepos) {
|
||||
private val df: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
|
||||
|
||||
fun handle(request: BaseRequest): Any {
|
||||
val sb = StringBuilder()
|
||||
|
||||
val easyList = db.g.pvEntry.findByDifficulty(Difficulty.EASY)
|
||||
val normalList = db.g.pvEntry.findByDifficulty(Difficulty.NORMAL)
|
||||
val hardList = db.g.pvEntry.findByDifficulty(Difficulty.HARD)
|
||||
val extremeList = db.g.pvEntry.findByDifficulty(Difficulty.EXTREME)
|
||||
|
||||
sb.append(encode(difficultyString(easyList))).append(",")
|
||||
sb.append(encode(difficultyString(normalList))).append(",")
|
||||
sb.append(encode(difficultyString(hardList))).append(",")
|
||||
sb.append(encode(difficultyString(extremeList))).append(",")
|
||||
sb.append("%2A%2A%2A")
|
||||
|
||||
return PvListResponse(
|
||||
LocalDateTime.now(),
|
||||
sb.toString()
|
||||
)
|
||||
}
|
||||
|
||||
private fun entryString(entry: PvEntry): String {
|
||||
return "" + entry.pvId + "," +
|
||||
entry.version + "," +
|
||||
entry.edition.value + "," +
|
||||
df.format(entry.demoStart) + "," +
|
||||
df.format(entry.demoEnd) + "," +
|
||||
df.format(entry.playableStart) + "," +
|
||||
df.format(entry.playableEnd)
|
||||
}
|
||||
|
||||
private fun difficultyString(list: MutableList<PvEntry>): String {
|
||||
val sb = StringBuilder()
|
||||
list.forEach(Consumer { sb.append(encode(entryString(it))).append(",") })
|
||||
if (sb.isNotEmpty()) sb.deleteCharAt(sb.length - 1)
|
||||
return sb.toString()
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
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 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 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;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
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.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class ShopCatalogHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ShopCatalogHandler.class);
|
||||
private final DivaModuleRepository 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,23 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.databank
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaModuleRepository
|
||||
import icu.samnyan.aqua.sega.diva.model.BaseRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.databank.ShopCatalogResponse
|
||||
import icu.samnyan.aqua.sega.diva.util.URIEncoder.encode
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class ShopCatalogHandler(private val moduleRepository: DivaModuleRepository) {
|
||||
fun handle(request: BaseRequest): Any {
|
||||
val moduleList = moduleRepository.findAll()
|
||||
|
||||
return ShopCatalogResponse(
|
||||
LocalDateTime.now(),
|
||||
encode(moduleList.map { it.toInternal() }.joinToString(",") { encode(it) })
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
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 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,38 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame
|
||||
|
||||
import ext.invoke
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.BuyCstmzItmRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.BuyCstmzItmResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class BuyCstmzItmHandler(val db: DivaRepos) {
|
||||
fun handle(request: BuyCstmzItmRequest): Any {
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
val customize = db.g.customize.findById(request.cstmz_itm_id)() ?: return BuyCstmzItmResponse(
|
||||
Result.FAILED
|
||||
)
|
||||
|
||||
if (session.vp < customize.price) {
|
||||
return BuyCstmzItmResponse(
|
||||
Result.FAILED
|
||||
)
|
||||
}
|
||||
db.s.customize.buy(profile, request.cstmz_itm_id)
|
||||
session.vp -= customize.price
|
||||
db.gameSession.save(session)
|
||||
|
||||
return BuyCstmzItmResponse(
|
||||
Result.SUCCESS,
|
||||
request.cstmz_itm_id,
|
||||
db.s.customize.getModuleHaveString(profile),
|
||||
session.vp
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
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 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,39 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.BuyModuleRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.BuyModuleResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class BuyModuleHandler(val db: DivaRepos) {
|
||||
fun handle(request: BuyModuleRequest): Any {
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
val moduleOptional = db.g.module.findById(request.mdl_id)
|
||||
|
||||
if (moduleOptional.isEmpty) {
|
||||
return BuyModuleResponse(
|
||||
Result.FAILED
|
||||
)
|
||||
}
|
||||
if (session.vp < moduleOptional.get().price) {
|
||||
return BuyModuleResponse(
|
||||
Result.FAILED
|
||||
)
|
||||
}
|
||||
db.s.module.buy(profile, request.mdl_id)
|
||||
session.vp -= moduleOptional.get().price
|
||||
db.gameSession.save(session)
|
||||
|
||||
return BuyModuleResponse(
|
||||
Result.SUCCESS,
|
||||
request.mdl_id,
|
||||
db.s.module.getModuleHaveString(profile),
|
||||
session.vp
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerPvCustomizeRepository;
|
||||
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.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.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil;
|
||||
import icu.samnyan.aqua.sega.diva.util.URIEncoder;
|
||||
import lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class GetPvPdHandler extends BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetPvPdHandler.class);
|
||||
|
||||
private final PlayerPvRecordRepository pvRecordRepository;
|
||||
private final PlayerPvCustomizeRepository pvCustomizeRepository;
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
public String handle(GetPvPdRequest request) {
|
||||
|
||||
Optional<PlayerProfile> profileO = playerProfileService.findByPdId(request.getPd_id());
|
||||
StringBuilder pd = new StringBuilder();
|
||||
|
||||
for (int pvId :
|
||||
request.getPd_pv_id_lst()) {
|
||||
if (pvId == -1) {
|
||||
pd.append("***").append(",");
|
||||
} else {
|
||||
if (profileO.isEmpty()) {
|
||||
pd.append("***").append(",");
|
||||
} else {
|
||||
var profile = profileO.get();
|
||||
int diff = request.getDifficulty();
|
||||
Difficulty difficulty = Difficulty.fromValue(diff);
|
||||
|
||||
// Myself
|
||||
PlayerPvRecord edition0 = pvRecordRepository.findByPdIdAndPvIdAndEditionAndDifficulty(profile, pvId, Edition.ORIGINAL, difficulty)
|
||||
.orElseGet(() -> new PlayerPvRecord(pvId, Edition.ORIGINAL));
|
||||
|
||||
PlayerPvRecord edition1 = pvRecordRepository.findByPdIdAndPvIdAndEditionAndDifficulty(profile, pvId, Edition.EXTRA, difficulty)
|
||||
.orElseGet(() -> new PlayerPvRecord(pvId, Edition.EXTRA));
|
||||
|
||||
// Rival
|
||||
PlayerPvRecord rivalEdition0;
|
||||
PlayerPvRecord rivalEdition1;
|
||||
if (profile.getRivalPdId() != -1) {
|
||||
rivalEdition0 = pvRecordRepository.findByPdId_PdIdAndPvIdAndEditionAndDifficulty(profile.getRivalPdId(), pvId, Edition.ORIGINAL, difficulty)
|
||||
.orElseGet(() -> new PlayerPvRecord(pvId, Edition.ORIGINAL));
|
||||
|
||||
rivalEdition1 = pvRecordRepository.findByPdId_PdIdAndPvIdAndEditionAndDifficulty(profile.getRivalPdId(), pvId, Edition.EXTRA, difficulty)
|
||||
.orElseGet(() -> new PlayerPvRecord(pvId, Edition.EXTRA));
|
||||
} else {
|
||||
rivalEdition0 = new PlayerPvRecord(pvId, Edition.ORIGINAL);
|
||||
rivalEdition1 = new PlayerPvRecord(pvId, Edition.EXTRA);
|
||||
}
|
||||
|
||||
PlayerPvCustomize customize = pvCustomizeRepository.findByPdIdAndPvId(profile, pvId).orElseGet(() -> new PlayerPvCustomize(profile, pvId));
|
||||
|
||||
String str = getString(edition0, customize, rivalEdition0, profile.getRivalPdId()) + "," + getString(edition1, customize, rivalEdition1, profile.getRivalPdId());
|
||||
// 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, PlayerPvRecord rivalRecord, long rivalId) {
|
||||
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() + "," +
|
||||
rivalId + "," +
|
||||
rivalRecord.getMaxScore() + "," +
|
||||
rivalRecord.getMaxAttain() + "," +
|
||||
"-1,-1," +
|
||||
pvRecordRepository.rankByPvIdAndPdIdAndEditionAndDifficulty(record.getPvId(), record.getPdId(), record.getEdition(), record.getDifficulty()) + "," +
|
||||
record.getRgoPurchased() + "," +
|
||||
record.getRgoPlayed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
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.GetPvPdRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.GetPvPdResponse
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerPvCustomize
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerPvRecord
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaTime
|
||||
import icu.samnyan.aqua.sega.diva.util.URIEncoder.encode
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.function.Supplier
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class GetPvPdHandler(val db: DivaRepos) {
|
||||
fun handle(request: GetPvPdRequest): Any {
|
||||
val profileO = db.profile.findByPdId(request.pd_id)
|
||||
val pd = StringBuilder()
|
||||
|
||||
for (pvId in request.pd_pv_id_lst) {
|
||||
if (pvId == -1) {
|
||||
pd.append("***").append(",")
|
||||
} else {
|
||||
if (profileO.isEmpty) {
|
||||
pd.append("***").append(",")
|
||||
} else {
|
||||
val profile = profileO.get()
|
||||
val diff = request.difficulty
|
||||
val difficulty = Difficulty.fromValue(diff)
|
||||
|
||||
// Myself
|
||||
val edition0 = db.pvRecord.findByPdIdAndPvIdAndEditionAndDifficulty(
|
||||
profile,
|
||||
pvId,
|
||||
Edition.ORIGINAL,
|
||||
difficulty
|
||||
)
|
||||
.orElseGet(Supplier { PlayerPvRecord(pvId, Edition.ORIGINAL) })
|
||||
|
||||
val edition1 = db.pvRecord.findByPdIdAndPvIdAndEditionAndDifficulty(
|
||||
profile,
|
||||
pvId,
|
||||
Edition.EXTRA,
|
||||
difficulty
|
||||
)
|
||||
.orElseGet(Supplier { PlayerPvRecord(pvId, Edition.EXTRA) })
|
||||
|
||||
// Rival
|
||||
val rivalEdition0: PlayerPvRecord?
|
||||
val rivalEdition1: PlayerPvRecord?
|
||||
if (profile.rivalPdId != -1L) {
|
||||
rivalEdition0 = db.pvRecord.findByPdId_PdIdAndPvIdAndEditionAndDifficulty(
|
||||
profile.rivalPdId,
|
||||
pvId,
|
||||
Edition.ORIGINAL,
|
||||
difficulty
|
||||
)
|
||||
.orElseGet(Supplier { PlayerPvRecord(pvId, Edition.ORIGINAL) })
|
||||
|
||||
rivalEdition1 = db.pvRecord.findByPdId_PdIdAndPvIdAndEditionAndDifficulty(
|
||||
profile.rivalPdId,
|
||||
pvId,
|
||||
Edition.EXTRA,
|
||||
difficulty
|
||||
)
|
||||
.orElseGet(Supplier { PlayerPvRecord(pvId, Edition.EXTRA) })
|
||||
} else {
|
||||
rivalEdition0 = PlayerPvRecord(pvId, Edition.ORIGINAL)
|
||||
rivalEdition1 = PlayerPvRecord(pvId, Edition.EXTRA)
|
||||
}
|
||||
|
||||
val customize = db.pvCustomize.findByPdIdAndPvId(profile, pvId)
|
||||
.orElseGet(Supplier { PlayerPvCustomize(profile, pvId) })
|
||||
|
||||
val str = getString(
|
||||
edition0,
|
||||
customize,
|
||||
rivalEdition0,
|
||||
profile.rivalPdId
|
||||
) + "," + getString(edition1, customize, rivalEdition1, profile.rivalPdId)
|
||||
pd.append(encode(str)).append(",")
|
||||
}
|
||||
}
|
||||
}
|
||||
pd.deleteCharAt(pd.length - 1)
|
||||
|
||||
|
||||
return GetPvPdResponse(
|
||||
pd.toString(),
|
||||
false,
|
||||
DivaTime.now
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
private fun getString(
|
||||
record: PlayerPvRecord,
|
||||
customize: PlayerPvCustomize,
|
||||
rivalRecord: PlayerPvRecord,
|
||||
rivalId: Long
|
||||
): String {
|
||||
return record.pvId.toString() + "," +
|
||||
record.edition.value + "," +
|
||||
record.result.value + "," +
|
||||
record.maxScore + "," +
|
||||
record.maxAttain + "," +
|
||||
record.challengeKind.value + "," +
|
||||
customize.module + "," +
|
||||
customize.customize + "," +
|
||||
customize.customizeFlag + "," +
|
||||
customize.skin + "," +
|
||||
customize.buttonSe + "," +
|
||||
customize.slideSe + "," +
|
||||
customize.chainSlideSe + "," +
|
||||
customize.sliderTouchSe + "," +
|
||||
rivalId + "," +
|
||||
rivalRecord.maxScore + "," +
|
||||
rivalRecord.maxAttain + "," +
|
||||
"-1,-1," +
|
||||
db.pvRecord.rankByPvIdAndPdIdAndEditionAndDifficulty(
|
||||
record.pvId,
|
||||
record.pdId,
|
||||
record.edition,
|
||||
record.difficulty
|
||||
) + "," +
|
||||
record.rgoPurchased + "," +
|
||||
record.rgoPlayed
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
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.service.PlayerProfileService;
|
||||
import lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class ShopExitHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ShopExitHandler.class);
|
||||
private final PlayerProfileService playerProfileService;
|
||||
private final PlayerPvCustomizeRepository pvCustomizeRepository;
|
||||
|
||||
public String handle(ShopExitRequest request) {
|
||||
|
||||
PlayerProfile profile = playerProfileService.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()));
|
||||
|
||||
playerProfileService.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,42 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame
|
||||
|
||||
import ext.csv
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.ShopExitRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.ShopExitResponse
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerPvCustomize
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.function.Supplier
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class ShopExitHandler(val db: DivaRepos) {
|
||||
fun handle(request: ShopExitRequest): Any {
|
||||
val profile = db.profile(request.pd_id)
|
||||
val customize = db.pvCustomize.findByPdIdAndPvId(profile, request.ply_pv_id)
|
||||
.orElseGet(Supplier { PlayerPvCustomize(profile, request.ply_pv_id) })
|
||||
|
||||
if (request.use_pv_mdl_eqp == 1) {
|
||||
customize.module = request.mdl_eqp_pv_ary.csv
|
||||
customize.customize = request.c_itm_eqp_pv_ary.csv
|
||||
customize.customizeFlag = request.ms_itm_flg_pv_ary.csv
|
||||
} else {
|
||||
customize.module = "-1,-1,-1"
|
||||
customize.customize = "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"
|
||||
customize.customizeFlag = "1,1,1,1,1,1,1,1,1,1,1,1"
|
||||
}
|
||||
|
||||
profile.commonModule = request.mdl_eqp_cmn_ary.csv
|
||||
profile.commonCustomizeItems = request.c_itm_eqp_cmn_ary.csv
|
||||
profile.moduleSelectItemFlag = request.ms_itm_flg_cmn_ary.csv
|
||||
|
||||
db.profile.save(profile)
|
||||
db.pvCustomize.save(customize)
|
||||
return ShopExitResponse(
|
||||
Result.SUCCESS
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,403 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.gamedata.ContestRepository;
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.*;
|
||||
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.gamedata.Contest;
|
||||
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.*;
|
||||
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService;
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaCalculator;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import static icu.samnyan.aqua.sega.diva.model.common.Const.NULL_QUEST;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class StageResultHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StageResultHandler.class);
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
private final PlayerPvRecordRepository pvRecordRepository;
|
||||
private final PlayerProfileService playerProfileService;
|
||||
private final PlayLogRepository playLogRepository;
|
||||
private final ContestRepository contestRepository;
|
||||
private final PlayerContestRepository playerContestRepository;
|
||||
private final PlayerCustomizeRepository playerCustomizeRepository;
|
||||
private final PlayerInventoryRepository playerInventoryRepository;
|
||||
|
||||
private final DivaCalculator divaCalculator;
|
||||
|
||||
private PlayerProfile currentProfile = null;
|
||||
|
||||
public String handle(StageResultRequest request) {
|
||||
StageResultResponse response;
|
||||
if (request.getPd_id() != -1) {
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
currentProfile = profile;
|
||||
// Get the last played index
|
||||
int[] pvIds = request.getStg_ply_pv_id();
|
||||
int[] stageArr = request.getStg_ply_pv_id();
|
||||
int stageIndex = 0;
|
||||
if (stageArr[0] != -1) {
|
||||
stageIndex = 0;
|
||||
}
|
||||
if (stageArr[1] != -1) {
|
||||
stageIndex = 1;
|
||||
}
|
||||
if (stageArr[2] != -1) {
|
||||
stageIndex = 2;
|
||||
}
|
||||
if (stageArr[3] != -1) {
|
||||
stageIndex = 3;
|
||||
}
|
||||
|
||||
// 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()));
|
||||
|
||||
// Not save personal record in no fail mode
|
||||
if (request.getGame_type() != 1) {
|
||||
// Only update personal record when using rhythm game option
|
||||
if (log.getRhythmGameOptions().equals("0,0,0")) {
|
||||
// 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());
|
||||
|
||||
session.setStageResultIndex(stageIndex);
|
||||
|
||||
// Calculate reward
|
||||
// Contest reward
|
||||
String contestSpecifier = String.join(",", request.getCr_sp());
|
||||
String[] contestRewardType = {"-1", "-1", "-1"};
|
||||
String[] contestRewardValue = {"-1", "-1", "-1"};
|
||||
String[] contestRewardString1 = {"***", "***", "***"};
|
||||
String[] contestRewardString2 = {"***", "***", "***"};
|
||||
int contestEntryRewardType = -1;
|
||||
int contestEntryRewardValue = -1;
|
||||
String contestEntryRewardString1 = "***";
|
||||
String contestEntryRewardString2 = "***";
|
||||
int contestId = request.getCr_cid();
|
||||
if (contestId != -1) {
|
||||
List<ContestProgress> progress = getContestProgress(request.getCr_sp());
|
||||
contestSpecifier = getContestSpecifier(progress);
|
||||
|
||||
// Check if the contest info exist
|
||||
Optional<Contest> contestOptional = contestRepository.findById(contestId);
|
||||
if (contestOptional.isPresent()) {
|
||||
Contest contest = contestOptional.get();
|
||||
Optional<PlayerContest> playerContestOptional = playerContestRepository.findByPdIdAndContestId(profile, contestId);
|
||||
|
||||
// Contest Entry Reward
|
||||
// Check if this is first stage
|
||||
if (progress.size() == 1 && playerContestOptional.isEmpty()) {
|
||||
if (StringUtils.isNotBlank(contest.getContestEntryReward())) {
|
||||
// Check if this is first time play this contest
|
||||
String reward = contest.getContestEntryReward();
|
||||
String[] rewardValue = reward.split(":");
|
||||
|
||||
contestEntryRewardType = Integer.parseInt(rewardValue[0]);
|
||||
contestEntryRewardValue = Integer.parseInt(rewardValue[1]);
|
||||
contestEntryRewardString1 = rewardValue[2];
|
||||
contestEntryRewardString2 = rewardValue[3];
|
||||
}
|
||||
}
|
||||
|
||||
// Only if this is the first time reach this value
|
||||
int previousValue = progress.stream().limit(progress.size() - 1).mapToInt(ContestProgress::getScores).sum();
|
||||
int currentValue = progress.stream().mapToInt(ContestProgress::getScores).sum();
|
||||
|
||||
// Bronze Reward
|
||||
Map<String, String> bronze = updateReward(currentValue, previousValue, contest.getBronzeBorders(), contest.getBronzeContestReward());
|
||||
if (bronze != null) {
|
||||
contestRewardType[0] = bronze.get("type");
|
||||
contestRewardValue[0] = bronze.get("value");
|
||||
contestRewardString1[0] = bronze.get("string1");
|
||||
contestRewardString2[2] = bronze.get("string2");
|
||||
}
|
||||
|
||||
// Silver Reward
|
||||
Map<String, String> silver = updateReward(currentValue, previousValue, contest.getSliverBorders(), contest.getSliverContestReward());
|
||||
if (silver != null) {
|
||||
contestRewardType[1] = silver.get("type");
|
||||
contestRewardValue[1] = silver.get("value");
|
||||
contestRewardString1[1] = silver.get("string1");
|
||||
contestRewardString2[2] = silver.get("string2");
|
||||
}
|
||||
|
||||
// Gold Reward
|
||||
Map<String, String> gold = updateReward(currentValue, previousValue, contest.getGoldBorders(), contest.getGoldContestReward());
|
||||
if (gold != null) {
|
||||
contestRewardType[2] = gold.get("type");
|
||||
contestRewardValue[2] = gold.get("value");
|
||||
contestRewardString1[2] = gold.get("string1");
|
||||
contestRewardString2[2] = gold.get("string2");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pvRecordRepository.save(record);
|
||||
playLogRepository.save(log);
|
||||
gameSessionRepository.save(session);
|
||||
|
||||
|
||||
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(),
|
||||
contestSpecifier,
|
||||
String.join(",", contestRewardType),
|
||||
String.join(",", contestRewardValue),
|
||||
String.join(",", contestRewardString1),
|
||||
String.join(",", contestRewardString2),
|
||||
contestEntryRewardType,
|
||||
contestEntryRewardValue,
|
||||
contestEntryRewardString1,
|
||||
contestEntryRewardString2,
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"-1,-1,-1,-1,-1",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"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()
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private List<ContestProgress> getContestProgress(String[] arr) {
|
||||
List<ContestProgress> result = new LinkedList<>();
|
||||
for (int i = 0; i < arr.length; i = i + 6) {
|
||||
if (!arr[i].equals("-1")) {
|
||||
result.add(new ContestProgress(
|
||||
Integer.parseInt(arr[i]),
|
||||
Integer.parseInt(arr[i + 1]),
|
||||
Integer.parseInt(arr[i + 2]),
|
||||
Integer.parseInt(arr[i + 3]),
|
||||
Integer.parseInt(arr[i + 4]),
|
||||
Integer.parseInt(arr[i + 5])
|
||||
));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getContestSpecifier(List<ContestProgress> progresses) {
|
||||
List<String> result = new LinkedList<>();
|
||||
for (ContestProgress x : progresses) {
|
||||
result.add(String.valueOf(x.getHardness()));
|
||||
result.add(String.valueOf(x.getEdition()));
|
||||
result.add(String.valueOf(x.getStars()));
|
||||
result.add(String.valueOf(x.getScores()));
|
||||
result.add(String.valueOf(x.getVersion()));
|
||||
}
|
||||
while (result.size() < 60) {
|
||||
result.add("-1");
|
||||
}
|
||||
return String.join(",", result);
|
||||
}
|
||||
|
||||
private Map<String, String> updateReward(int currentValue, int previousValue, int borders, String reward) {
|
||||
if (currentValue > borders && previousValue < borders) {
|
||||
if (StringUtils.isNotBlank(reward)) {
|
||||
String[] rewardValue = reward.split(":");
|
||||
Map<String, String> result = new HashMap<>();
|
||||
switch (rewardValue[0]) {
|
||||
case "-1":
|
||||
return null;
|
||||
case "0": {
|
||||
result.put("type", rewardValue[0]);
|
||||
result.put("value", rewardValue[1]);
|
||||
result.put("string1", "***");
|
||||
result.put("string2", "***");
|
||||
break;
|
||||
}
|
||||
case "1": {
|
||||
if (playerInventoryRepository.findByPdIdAndTypeAndValue(currentProfile, "SKIN", rewardValue[1]).isPresent()) {
|
||||
result.put("type", "-1");
|
||||
result.put("value", "-1");
|
||||
result.put("string1", "***");
|
||||
result.put("string2", "***");
|
||||
} else {
|
||||
playerInventoryRepository.save(new PlayerInventory(null, currentProfile, rewardValue[1], "SKIN"));
|
||||
result.put("type", rewardValue[0]);
|
||||
result.put("value", rewardValue[1]);
|
||||
result.put("string1", rewardValue[2]);
|
||||
result.put("string2", rewardValue[3]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "2": {
|
||||
if (playerInventoryRepository.findByPdIdAndTypeAndValue(currentProfile, "PLATE", rewardValue[1]).isPresent()) {
|
||||
result.put("type", "-1");
|
||||
result.put("value", "-1");
|
||||
result.put("string1", "***");
|
||||
result.put("string2", "***");
|
||||
} else {
|
||||
playerInventoryRepository.save(new PlayerInventory(null, currentProfile, rewardValue[1], "PLATE"));
|
||||
result.put("type", rewardValue[0]);
|
||||
result.put("value", rewardValue[1]);
|
||||
result.put("string1", rewardValue[2]);
|
||||
result.put("string2", rewardValue[3]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "3": {
|
||||
if (playerCustomizeRepository.findByPdIdAndCustomizeId(currentProfile, Integer.parseInt(rewardValue[1])).isPresent()) {
|
||||
result.put("type", "-1");
|
||||
result.put("value", "-1");
|
||||
result.put("string1", "***");
|
||||
result.put("string2", "***");
|
||||
} else {
|
||||
playerCustomizeRepository.save(new PlayerCustomize(currentProfile, Integer.parseInt(rewardValue[1])));
|
||||
result.put("type", rewardValue[0]);
|
||||
result.put("value", rewardValue[1]);
|
||||
result.put("string1", rewardValue[2]);
|
||||
result.put("string2", rewardValue[3]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,427 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame
|
||||
|
||||
import ext.logger
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.*
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.*
|
||||
import icu.samnyan.aqua.sega.diva.model.StageResultRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.StageResultResponse
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaCalculator
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.springframework.stereotype.Component
|
||||
import java.lang.String
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
import java.util.function.Supplier
|
||||
import kotlin.Any
|
||||
import kotlin.Array
|
||||
import kotlin.Int
|
||||
import kotlin.IntArray
|
||||
import kotlin.arrayOf
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class StageResultHandler(val db: DivaRepos, val calc: DivaCalculator) {
|
||||
private var currentProfile: PlayerProfile? = null
|
||||
val logger = logger()
|
||||
|
||||
fun handle(request: StageResultRequest): Any {
|
||||
if (request.pd_id != -1L) {
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
currentProfile = profile
|
||||
// Get the last played index
|
||||
val stageArr = request.stg_ply_pv_id
|
||||
var stageIndex = 0
|
||||
if (stageArr[0] != -1) {
|
||||
stageIndex = 0
|
||||
}
|
||||
if (stageArr[1] != -1) {
|
||||
stageIndex = 1
|
||||
}
|
||||
if (stageArr[2] != -1) {
|
||||
stageIndex = 2
|
||||
}
|
||||
if (stageArr[3] != -1) {
|
||||
stageIndex = 3
|
||||
}
|
||||
|
||||
// Convert to play log object
|
||||
val log = getLog(request, profile, stageIndex)
|
||||
logger.debug("Stage Result Object: {}", log.toString())
|
||||
|
||||
val record = db.pvRecord.findByPdIdAndPvIdAndEditionAndDifficulty(
|
||||
profile,
|
||||
log.pvId,
|
||||
log.edition,
|
||||
log.difficulty
|
||||
)
|
||||
.orElseGet(Supplier { PlayerPvRecord(profile, log.pvId, log.edition, log.difficulty) })
|
||||
|
||||
// Not save personal record in no fail mode
|
||||
if (request.game_type != 1) {
|
||||
// Only update personal record when using rhythm game option
|
||||
if (log.rhythmGameOptions == "0,0,0") {
|
||||
// Update pvRecord field
|
||||
record.maxScore = max(record.maxScore, log.score)
|
||||
record.maxAttain = max(record.maxAttain, log.attainPoint)
|
||||
|
||||
if (record.result.value < log.clearResult.value) {
|
||||
record.result = log.clearResult
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val updateRgo =
|
||||
log.rhythmGameOptions.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val oldRgo =
|
||||
record.rgoPlayed.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
for (i in updateRgo.indices) {
|
||||
if (updateRgo[i] == "1") {
|
||||
oldRgo[i] = "1"
|
||||
}
|
||||
}
|
||||
record.rgoPlayed = StringUtils.join(oldRgo, ",")
|
||||
|
||||
session.vp = session.vp + log.vp
|
||||
session.lastPvId = log.pvId
|
||||
session.lastUpdateTime = LocalDateTime.now()
|
||||
|
||||
val levelInfo = calc.getLevelInfo(profile)
|
||||
session.oldLevelNumber = session.levelNumber
|
||||
session.oldLevelExp = session.levelExp
|
||||
session.levelNumber = levelInfo.levelNumber
|
||||
session.levelExp = levelInfo.levelExp
|
||||
|
||||
session.stageResultIndex = stageIndex
|
||||
|
||||
// Calculate reward
|
||||
// Contest reward
|
||||
var contestSpecifier = String.join(",", *request.cr_sp)
|
||||
val contestRewardType = arrayOf<kotlin.String?>("-1", "-1", "-1")
|
||||
val contestRewardValue = arrayOf<kotlin.String?>("-1", "-1", "-1")
|
||||
val contestRewardString1 = arrayOf<kotlin.String?>("***", "***", "***")
|
||||
val contestRewardString2 = arrayOf<kotlin.String?>("***", "***", "***")
|
||||
var contestEntryRewardType = -1
|
||||
var contestEntryRewardValue = -1
|
||||
var contestEntryRewardString1: kotlin.String? = "***"
|
||||
var contestEntryRewardString2: kotlin.String? = "***"
|
||||
val contestId = request.cr_cid
|
||||
if (contestId != -1) {
|
||||
val progress = getContestProgress(request.cr_sp)
|
||||
contestSpecifier = getContestSpecifier(progress)
|
||||
|
||||
// Check if the contest info exist
|
||||
val contestOptional = db.g.contest.findById(contestId)
|
||||
if (contestOptional.isPresent) {
|
||||
val contest = contestOptional.get()
|
||||
val playerContestOptional = db.contest.findByPdIdAndContestId(profile, contestId)
|
||||
|
||||
// Contest Entry Reward
|
||||
// Check if this is first stage
|
||||
if (progress.size == 1 && playerContestOptional.isEmpty) {
|
||||
if (StringUtils.isNotBlank(contest.contestEntryReward)) {
|
||||
// Check if this is first time play this contest
|
||||
val reward = contest.contestEntryReward
|
||||
val rewardValue: Array<kotlin.String?> =
|
||||
reward.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
|
||||
contestEntryRewardType = rewardValue[0]!!.toInt()
|
||||
contestEntryRewardValue = rewardValue[1]!!.toInt()
|
||||
contestEntryRewardString1 = rewardValue[2]
|
||||
contestEntryRewardString2 = rewardValue[3]
|
||||
}
|
||||
}
|
||||
|
||||
// Only if this is the first time reach this value
|
||||
val previousValue = progress.stream().limit((progress.size - 1).toLong())
|
||||
.mapToInt { obj: ContestProgress? -> obj!!.getScores() }.sum()
|
||||
val currentValue = progress.stream().mapToInt { obj: ContestProgress? -> obj!!.getScores() }.sum()
|
||||
|
||||
// Bronze Reward
|
||||
val bronze = updateReward(
|
||||
currentValue,
|
||||
previousValue,
|
||||
contest.bronzeBorders,
|
||||
contest.bronzeContestReward
|
||||
)
|
||||
if (bronze != null) {
|
||||
contestRewardType[0] = bronze.get("type")
|
||||
contestRewardValue[0] = bronze.get("value")
|
||||
contestRewardString1[0] = bronze.get("string1")
|
||||
contestRewardString2[2] = bronze.get("string2")
|
||||
}
|
||||
|
||||
// Silver Reward
|
||||
val silver = updateReward(
|
||||
currentValue,
|
||||
previousValue,
|
||||
contest.sliverBorders,
|
||||
contest.sliverContestReward
|
||||
)
|
||||
if (silver != null) {
|
||||
contestRewardType[1] = silver.get("type")
|
||||
contestRewardValue[1] = silver.get("value")
|
||||
contestRewardString1[1] = silver.get("string1")
|
||||
contestRewardString2[2] = silver.get("string2")
|
||||
}
|
||||
|
||||
// Gold Reward
|
||||
val gold = updateReward(
|
||||
currentValue,
|
||||
previousValue,
|
||||
contest.goldBorders,
|
||||
contest.goldContestReward
|
||||
)
|
||||
if (gold != null) {
|
||||
contestRewardType[2] = gold.get("type")
|
||||
contestRewardValue[2] = gold.get("value")
|
||||
contestRewardString1[2] = gold.get("string1")
|
||||
contestRewardString2[2] = gold.get("string2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db.pvRecord.save(record)
|
||||
db.playLog.save(log)
|
||||
db.gameSession.save(session)
|
||||
|
||||
|
||||
return StageResultResponse(
|
||||
ChallengeKind.UNDEFINED.value,
|
||||
session.oldLevelNumber,
|
||||
session.oldLevelExp,
|
||||
session.levelNumber,
|
||||
session.levelExp,
|
||||
profile.levelTitle,
|
||||
profile.plateEffectId,
|
||||
profile.plateId,
|
||||
session.vp,
|
||||
0,
|
||||
request.cr_cid,
|
||||
request.cr_tv,
|
||||
contestSpecifier,
|
||||
String.join(",", *contestRewardType),
|
||||
String.join(",", *contestRewardValue),
|
||||
String.join(",", *contestRewardString1),
|
||||
String.join(",", *contestRewardString2),
|
||||
contestEntryRewardType,
|
||||
contestEntryRewardValue,
|
||||
contestEntryRewardString1,
|
||||
contestEntryRewardString2,
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"-1,-1,-1,-1,-1",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
"xxx,xxx,xxx,xxx,xxx",
|
||||
0,
|
||||
LocalDateTime.now(),
|
||||
-1,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
Const.NULL_QUEST,
|
||||
Const.NULL_QUEST,
|
||||
Const.NULL_QUEST,
|
||||
Const.NULL_QUEST,
|
||||
Const.NULL_QUEST,
|
||||
"-1,-1,-1,-1,-1",
|
||||
"-1,-1,-1,-1,-1",
|
||||
"-1,-1,-1,-1,-1"
|
||||
)
|
||||
} else {
|
||||
return StageResultResponse()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLog(request: StageResultRequest, profile: PlayerProfile, i: Int): PlayLog {
|
||||
return PlayLog(
|
||||
profile,
|
||||
request.stg_ply_pv_id[i],
|
||||
Difficulty.fromValue(request.stg_difficulty[i]),
|
||||
Edition.fromValue(request.stg_edtn[i]),
|
||||
request.stg_scrpt_ver[i],
|
||||
request.stg_score[i],
|
||||
ChallengeKind.fromValue(request.stg_chllng_kind[i]),
|
||||
request.stg_chllng_result[i],
|
||||
ClearResult.fromValue(request.stg_clr_kind[i]),
|
||||
request.stg_vcld_pts[i],
|
||||
request.stg_cool_cnt[i],
|
||||
request.stg_cool_pct[i],
|
||||
request.stg_fine_cnt[i],
|
||||
request.stg_fine_pct[i],
|
||||
request.stg_safe_cnt[i],
|
||||
request.stg_safe_pct[i],
|
||||
request.stg_sad_cnt[i],
|
||||
request.stg_sad_pct[i],
|
||||
request.stg_wt_wg_cnt[i],
|
||||
request.stg_wt_wg_pct[i],
|
||||
request.stg_max_cmb[i],
|
||||
request.stg_chance_tm[i],
|
||||
request.stg_sm_hl[i],
|
||||
request.stg_atn_pnt[i],
|
||||
request.stg_skin_id[i],
|
||||
request.stg_btn_se[i],
|
||||
request.stg_btn_se_vol[i],
|
||||
request.stg_sld_se[i],
|
||||
request.stg_chn_sld_se[i],
|
||||
request.stg_sldr_tch_se[i],
|
||||
slice(request.stg_mdl_id, 3, i),
|
||||
request.stg_cpt_rslt[i],
|
||||
request.stg_sld_scr[i],
|
||||
request.stg_vcl_chg[i],
|
||||
slice(request.stg_c_itm_id, 12, i),
|
||||
slice(request.stg_rgo, 3, i),
|
||||
request.stg_ss_num[i],
|
||||
request.time_stamp.toLocalDateTime()
|
||||
)
|
||||
}
|
||||
|
||||
fun slice(arr: IntArray, length: Int, offset: Int): kotlin.String {
|
||||
val sb = StringBuilder()
|
||||
|
||||
for (i in length * offset..<length * (offset + 1)) {
|
||||
sb.append(arr[i]).append(",")
|
||||
}
|
||||
|
||||
sb.deleteCharAt(sb.length - 1)
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
private fun getContestProgress(arr: Array<kotlin.String?>): MutableList<ContestProgress> {
|
||||
val result: MutableList<ContestProgress> = LinkedList<ContestProgress>()
|
||||
var i = 0
|
||||
while (i < arr.size) {
|
||||
if (arr[i] != "-1") {
|
||||
result.add(
|
||||
ContestProgress(
|
||||
arr[i]!!.toInt(),
|
||||
arr[i + 1]!!.toInt(),
|
||||
arr[i + 2]!!.toInt(),
|
||||
arr[i + 3]!!.toInt(),
|
||||
arr[i + 4]!!.toInt(),
|
||||
arr[i + 5]!!.toInt()
|
||||
)
|
||||
)
|
||||
}
|
||||
i += 6
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun getContestSpecifier(progresses: MutableList<ContestProgress>): kotlin.String {
|
||||
val result: MutableList<kotlin.String?> = LinkedList<kotlin.String?>()
|
||||
for (x in progresses) {
|
||||
result.add(x.getHardness().toString())
|
||||
result.add(x.getEdition().toString())
|
||||
result.add(x.getStars().toString())
|
||||
result.add(x.getScores().toString())
|
||||
result.add(x.getVersion().toString())
|
||||
}
|
||||
while (result.size < 60) {
|
||||
result.add("-1")
|
||||
}
|
||||
return String.join(",", result)
|
||||
}
|
||||
|
||||
private fun updateReward(
|
||||
currentValue: Int,
|
||||
previousValue: Int,
|
||||
borders: Int,
|
||||
reward: kotlin.String?
|
||||
): MutableMap<kotlin.String?, kotlin.String?>? {
|
||||
if (borders in (previousValue + 1)..<currentValue) {
|
||||
if (StringUtils.isNotBlank(reward)) {
|
||||
val rewardValue: Array<kotlin.String?> =
|
||||
reward!!.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val result: MutableMap<kotlin.String?, kotlin.String?> = HashMap<kotlin.String?, kotlin.String?>()
|
||||
when (rewardValue[0]) {
|
||||
"-1" -> return null
|
||||
"0" -> {
|
||||
result["type"] = rewardValue[0]
|
||||
result["value"] = rewardValue[1]
|
||||
result["string1"] = "***"
|
||||
result["string2"] = "***"
|
||||
}
|
||||
|
||||
"1" -> {
|
||||
if (db.inventory.findByPdIdAndTypeAndValue(currentProfile!!, "SKIN", rewardValue[1]!!)
|
||||
.isPresent
|
||||
) {
|
||||
result["type"] = "-1"
|
||||
result["value"] = "-1"
|
||||
result["string1"] = "***"
|
||||
result["string2"] = "***"
|
||||
} else {
|
||||
db.inventory.save(
|
||||
PlayerInventory(
|
||||
currentProfile!!,
|
||||
rewardValue[1]!!,
|
||||
"SKIN"
|
||||
)
|
||||
)
|
||||
result.put("type", rewardValue[0])
|
||||
result.put("value", rewardValue[1])
|
||||
result.put("string1", rewardValue[2])
|
||||
result.put("string2", rewardValue[3])
|
||||
}
|
||||
}
|
||||
|
||||
"2" -> {
|
||||
if (db.inventory.findByPdIdAndTypeAndValue(currentProfile!!, "PLATE", rewardValue[1]!!)
|
||||
.isPresent
|
||||
) {
|
||||
result.put("type", "-1")
|
||||
result.put("value", "-1")
|
||||
result.put("string1", "***")
|
||||
result.put("string2", "***")
|
||||
} else {
|
||||
db.inventory.save(
|
||||
PlayerInventory(
|
||||
currentProfile!!,
|
||||
rewardValue[1]!!,
|
||||
"PLATE"
|
||||
)
|
||||
)
|
||||
result.put("type", rewardValue[0])
|
||||
result.put("value", rewardValue[1])
|
||||
result.put("string1", rewardValue[2])
|
||||
result.put("string2", rewardValue[3])
|
||||
}
|
||||
}
|
||||
|
||||
"3" -> {
|
||||
if (db.customize.findByPdIdAndCustomizeId(currentProfile!!, rewardValue[1]!!.toInt())
|
||||
.isPresent
|
||||
) {
|
||||
result.put("type", "-1")
|
||||
result.put("value", "-1")
|
||||
result.put("string1", "***")
|
||||
result.put("string2", "***")
|
||||
} else {
|
||||
db.customize.save(
|
||||
PlayerCustomize(
|
||||
currentProfile!!,
|
||||
rewardValue[1]!!.toInt()
|
||||
)
|
||||
)
|
||||
result.put("type", rewardValue[0])
|
||||
result.put("value", rewardValue[1])
|
||||
result.put("string1", rewardValue[2])
|
||||
result.put("string2", rewardValue[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
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.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.service.PlayerProfileService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class StageStartHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StageResultHandler.class);
|
||||
private final GameSessionRepository gameSessionRepository;
|
||||
private final PlayerProfileService playerProfileService;
|
||||
|
||||
public String handle(StageStartRequest request) {
|
||||
if (request.getPd_id() != -1) {
|
||||
PlayerProfile profile = playerProfileService.findByPdId(request.getPd_id()).orElseThrow(ProfileNotFoundException::new);
|
||||
GameSession session = gameSessionRepository.findByPdId(profile).orElseThrow(SessionNotFoundException::new);
|
||||
|
||||
int[] stageArr = request.getStg_ply_pv_id();
|
||||
int stageIndex = 0;
|
||||
if(stageArr[0] != -1) {
|
||||
stageIndex = 0;
|
||||
}
|
||||
if(stageArr[1] != -1) {
|
||||
stageIndex = 1;
|
||||
}
|
||||
if(stageArr[2] != -1) {
|
||||
stageIndex = 2;
|
||||
}
|
||||
if(stageArr[3] != -1) {
|
||||
stageIndex = 3;
|
||||
}
|
||||
session.setStageIndex(stageIndex);
|
||||
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,37 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame
|
||||
|
||||
import ext.emptyMap
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.StageStartRequest
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class StageStartHandler(val db: DivaRepos) {
|
||||
fun handle(request: StageStartRequest): Any {
|
||||
if (request.pd_id != -1L) {
|
||||
val (_, session) = db.session(request.pd_id)
|
||||
|
||||
val stageArr = request.stg_ply_pv_id
|
||||
var stageIndex = 0
|
||||
if (stageArr[0] != -1) {
|
||||
stageIndex = 0
|
||||
}
|
||||
if (stageArr[1] != -1) {
|
||||
stageIndex = 1
|
||||
}
|
||||
if (stageArr[2] != -1) {
|
||||
stageIndex = 2
|
||||
}
|
||||
if (stageArr[3] != -1) {
|
||||
stageIndex = 3
|
||||
}
|
||||
session.stageIndex = stageIndex
|
||||
db.gameSession.save(session)
|
||||
}
|
||||
|
||||
return emptyMap
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame;
|
||||
|
||||
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.service.PlayerProfileService;
|
||||
import lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class StoreSsHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StoreSsHandler.class);
|
||||
private final PlayerProfileService playerProfileService;
|
||||
private final PlayerScreenShotRepository screenShotRepository;
|
||||
|
||||
public String handle(StoreSsRequest request, MultipartFile file) {
|
||||
PlayerProfile profile = playerProfileService.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,46 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.ingame
|
||||
|
||||
import ext.csv
|
||||
import ext.logger
|
||||
import icu.samnyan.aqua.sega.diva.DIVA_BAD
|
||||
import icu.samnyan.aqua.sega.diva.DIVA_OK
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.StoreSsRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerScreenShot
|
||||
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
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class StoreSsHandler(val db: DivaRepos) {
|
||||
val logger = logger()
|
||||
fun handle(request: StoreSsRequest, file: MultipartFile): Any {
|
||||
val profile = db.profile(request.pd_id)
|
||||
|
||||
try {
|
||||
val filename = "${request.pd_id}-${LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)}.jpg"
|
||||
Files.write(Paths.get("data/$filename"), file.bytes)
|
||||
|
||||
val ss = PlayerScreenShot(
|
||||
profile,
|
||||
filename,
|
||||
request.pd_id,
|
||||
request.ss_mdl_id.csv,
|
||||
request.ss_c_itm_id.csv
|
||||
)
|
||||
db.screenShot.save(ss)
|
||||
|
||||
return DIVA_OK
|
||||
} catch (e: IOException) {
|
||||
logger.error("Screenshot save failed", e)
|
||||
return DIVA_BAD
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.operation
|
||||
|
||||
import ext.logger
|
||||
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.general.dao.PropertyEntryRepository
|
||||
import icu.samnyan.aqua.sega.general.model.PropertyEntry
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class PingHandler(val rp: PropertyEntryRepository) : BaseHandler() {
|
||||
val logger = logger()
|
||||
|
||||
fun handle(request: BaseRequest): String? {
|
||||
val news: PropertyEntry = rp.findByPropertyKey("diva_news") ?: PropertyEntry("diva_news", "xxx")
|
||||
val warning: PropertyEntry = rp.findByPropertyKey("diva_warning") ?: PropertyEntry("diva_warning", "xxx")
|
||||
|
||||
val response = PingResponse(
|
||||
request.cmd,
|
||||
request.req_id,
|
||||
"ok",
|
||||
news.propertyValue,
|
||||
warning.propertyValue
|
||||
)
|
||||
|
||||
val resp = this.build(mapper.toMap(response))
|
||||
logger.info("Response: {}", resp)
|
||||
|
||||
return resp
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
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 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,83 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DIVA_OK
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
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.db.gamedata.Contest
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerContest
|
||||
import icu.samnyan.aqua.sega.diva.model.StageResultRequest
|
||||
import icu.samnyan.aqua.sega.diva.util.DivaStringUtils
|
||||
import org.springframework.stereotype.Component
|
||||
import java.lang.String
|
||||
import java.time.LocalDateTime
|
||||
import java.util.function.Supplier
|
||||
import kotlin.Any
|
||||
import kotlin.Int
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class EndHandler(val db: DivaRepos) {
|
||||
fun handle(request: StageResultRequest): Any {
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
profile.headphoneVolume = request.hp_vol
|
||||
profile.buttonSeOn = request.btn_se_vol
|
||||
profile.buttonSeVolume = request.btn_se_vol2
|
||||
profile.sliderSeVolume = request.sldr_se_vol2
|
||||
profile.vocaloidPoints = session.vp
|
||||
profile.level = session.levelNumber
|
||||
profile.levelExp = session.levelExp
|
||||
profile.nextPvId = request.nxt_pv_id
|
||||
profile.nextDifficulty = Difficulty.fromValue(request.nxt_dffclty)
|
||||
profile.nextEdition = Edition.fromValue(request.nxt_edtn)
|
||||
profile.sortMode = SortMode.fromValue(request.sort_kind)
|
||||
|
||||
if (request.cr_cid != -1) {
|
||||
val contest = db.g.contest.findById(request.cr_cid).orElseGet(Supplier { Contest() })
|
||||
val currentResultRank = getContestRank(contest, request.cr_tv)
|
||||
if (request.cr_if == 0) {
|
||||
// Do contest is playing
|
||||
profile.contestNowPlayingEnable = true
|
||||
profile.contestNowPlayingId = request.cr_cid
|
||||
profile.contestNowPlayingResultRank = currentResultRank
|
||||
profile.contestNowPlayingValue = request.cr_tv
|
||||
profile.contestNowPlayingSpecifier = String.join(",", *request.cr_sp)
|
||||
} else {
|
||||
val contestRecord =
|
||||
db.contest.findByPdIdAndContestId(profile, request.cr_cid).orElseGet(
|
||||
Supplier { PlayerContest(profile, request.cr_cid) })
|
||||
contestRecord.startCount += 1
|
||||
contestRecord.bestValue = max(contestRecord.bestValue, request.cr_tv)
|
||||
contestRecord.resultRank = if (currentResultRank.value > contestRecord.resultRank
|
||||
.value
|
||||
) currentResultRank else contestRecord.resultRank
|
||||
contestRecord.lastUpdateTime = LocalDateTime.now()
|
||||
|
||||
db.contest.save(contestRecord)
|
||||
profile.contestNowPlayingEnable = false
|
||||
profile.contestNowPlayingId = -1
|
||||
profile.contestNowPlayingResultRank = ContestBorder.NONE
|
||||
profile.contestNowPlayingValue = -1
|
||||
profile.contestNowPlayingSpecifier = DivaStringUtils.getDummyString("-1", 60)
|
||||
}
|
||||
}
|
||||
|
||||
db.profile.save(profile)
|
||||
db.gameSession.delete(session)
|
||||
|
||||
return DIVA_OK
|
||||
}
|
||||
|
||||
private fun getContestRank(contest: Contest, value: Int): ContestBorder {
|
||||
if (value >= contest.goldBorders) return ContestBorder.GOLD
|
||||
if (value >= contest.sliverBorders) return ContestBorder.SILVER
|
||||
if (value >= contest.bronzeBorders) return ContestBorder.BRONZE
|
||||
return ContestBorder.NONE
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class PdUnlockHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PdUnlockHandler.class);
|
||||
private final PlayerProfileService playerProfileService;
|
||||
private final 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,17 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DIVA_OK
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.PdUnlockRequest
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class PdUnlockHandler(val db: DivaRepos) {
|
||||
fun handle(request: PdUnlockRequest): Any {
|
||||
val (_, session) = db.session(request.pd_id)
|
||||
|
||||
db.gameSession.delete(session)
|
||||
|
||||
return DIVA_OK
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
public class PreStartHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PreStartHandler.class);
|
||||
private final PlayerProfileService playerProfileService;
|
||||
private final 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,
|
||||
-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,72 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user
|
||||
|
||||
import ext.invoke
|
||||
import ext.logger
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
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.PreStartRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.user.PreStartResponse
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.GameSession
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
import java.util.concurrent.ThreadLocalRandom
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class PreStartHandler(val db: DivaRepos) {
|
||||
var logger = logger()
|
||||
fun handle(request: PreStartRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.aime_id)() ?: return PreStartResponse(PreStartResult.NEW_REGISTRATION)
|
||||
|
||||
db.gameSession.findByPdId(profile)()?.let { session ->
|
||||
if (!session.lastUpdateTime.isBefore(LocalDateTime.now().minusMinutes(5)) && session.startMode == StartMode.START) {
|
||||
return PreStartResponse(PreStartResult.ALREADY_PLAYING)
|
||||
} else {
|
||||
db.gameSession.delete(session)
|
||||
}
|
||||
}
|
||||
|
||||
val session = GameSession(
|
||||
ThreadLocalRandom.current().nextInt(100, 99999),
|
||||
profile,
|
||||
StartMode.PRE_START,
|
||||
LocalDateTime.now(),
|
||||
LocalDateTime.now(),
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
profile.level,
|
||||
profile.levelExp,
|
||||
profile.level,
|
||||
profile.levelExp,
|
||||
profile.vocaloidPoints
|
||||
)
|
||||
|
||||
db.gameSession.save(session)
|
||||
|
||||
return PreStartResponse(
|
||||
PreStartResult.SUCCESS,
|
||||
session.acceptId,
|
||||
profile.pdId,
|
||||
profile.playerName,
|
||||
profile.sortMode,
|
||||
profile.level,
|
||||
profile.levelExp,
|
||||
profile.levelTitle,
|
||||
profile.plateEffectId,
|
||||
profile.plateId,
|
||||
profile.commonModule,
|
||||
profile.commonModuleSetTime,
|
||||
profile.commonSkin,
|
||||
profile.buttonSe,
|
||||
profile.slideSe,
|
||||
profile.chainSlideSe,
|
||||
profile.sliderTouchSe,
|
||||
profile.vocaloidPoints,
|
||||
profile.passwordStatus
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class SpendCreditHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SpendCreditHandler.class);
|
||||
private final 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,25 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.SpendCreditRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.user.SpendCreditResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class SpendCreditHandler(val db: DivaRepos) {
|
||||
fun handle(request: SpendCreditRequest): Any {
|
||||
val profile = db.profile(request.pd_id)
|
||||
|
||||
return SpendCreditResponse(
|
||||
"-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.vocaloidPoints,
|
||||
profile.levelTitle,
|
||||
profile.plateEffectId,
|
||||
profile.plateId
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
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 lombok.AllArgsConstructor;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
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 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);
|
||||
|
||||
int border = profile.isShowGreatBorder() ? 1 : 0;
|
||||
border = border | ((profile.isShowExcellentBorder() ? 1 : 0) << 1);
|
||||
border = border | ((profile.isShowRivalBorder() ? 1 : 0) << 2);
|
||||
|
||||
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),
|
||||
String.valueOf(border),
|
||||
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,168 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.user
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.*
|
||||
import icu.samnyan.aqua.sega.diva.model.common.collection.ClearTally
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.GameSession
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerContest
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerProfile
|
||||
import icu.samnyan.aqua.sega.diva.model.db.userdata.PlayerPvRecord
|
||||
import icu.samnyan.aqua.sega.diva.model.StartRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.user.StartResponse
|
||||
import icu.samnyan.aqua.sega.diva.util.PvRecordDataException
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
import java.util.stream.Collectors
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class StartHandler(val db: DivaRepos) {
|
||||
fun handle(request: StartRequest): Any {
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
session.startMode = StartMode.START
|
||||
db.gameSession.save<GameSession>(session)
|
||||
|
||||
val module_have = db.s.module.getModuleHaveString(profile)
|
||||
val customize_have = db.s.customize.getModuleHaveString(profile)
|
||||
|
||||
val contestResult = getContestResult(profile)
|
||||
|
||||
var border = if (profile.showGreatBorder) 1 else 0
|
||||
border = border or ((if (profile.showExcellentBorder) 1 else 0) shl 1)
|
||||
border = border or ((if (profile.showRivalBorder) 1 else 0) shl 2)
|
||||
|
||||
return StartResponse(
|
||||
profile.pdId,
|
||||
Result.SUCCESS,
|
||||
session.acceptId,
|
||||
session.acceptId,
|
||||
profile.playerName,
|
||||
profile.headphoneVolume,
|
||||
profile.buttonSeOn,
|
||||
profile.buttonSeVolume,
|
||||
profile.sliderSeVolume,
|
||||
profile.sortMode,
|
||||
profile.level,
|
||||
profile.levelExp,
|
||||
profile.levelTitle,
|
||||
profile.plateEffectId,
|
||||
profile.plateId,
|
||||
profile.commonModule,
|
||||
profile.commonCustomizeItems,
|
||||
profile.moduleSelectItemFlag,
|
||||
LocalDateTime.now(),
|
||||
module_have,
|
||||
customize_have,
|
||||
profile.preferPerPvModule,
|
||||
profile.preferCommonModule,
|
||||
profile.usePerPvSkin,
|
||||
profile.usePerPvButtonSe,
|
||||
profile.usePerPvSliderSe,
|
||||
profile.usePerPvChainSliderSe,
|
||||
profile.usePerPvTouchSliderSe,
|
||||
profile.vocaloidPoints,
|
||||
profile.nextPvId,
|
||||
profile.nextDifficulty,
|
||||
profile.nextEdition,
|
||||
contestResult["cv_cid"], // contest progress
|
||||
contestResult["cv_sc"],
|
||||
contestResult["cv_rr"],
|
||||
contestResult["cv_bv"],
|
||||
contestResult["cv_bf"],
|
||||
if (profile.contestNowPlayingEnable) profile.contestNowPlayingId else -1,
|
||||
profile.contestNowPlayingValue,
|
||||
profile.contestNowPlayingResultRank,
|
||||
profile.contestNowPlayingSpecifier,
|
||||
profile.myList0,
|
||||
profile.myList1,
|
||||
profile.myList2,
|
||||
null,
|
||||
null,
|
||||
border.toString(),
|
||||
profile.showInterimRanking,
|
||||
profile.showClearStatus,
|
||||
countClearStatus(profile),
|
||||
profile.showRgoSetting,
|
||||
null, // Currently quest not working
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
private fun countClearStatus(profile: PlayerProfile): String {
|
||||
val pvRecordList = db.pvRecord.findByPdId(profile)
|
||||
val clearTally = ClearTally()
|
||||
pvRecordList.forEach(Consumer { x: PlayerPvRecord ->
|
||||
when (x.edition) {
|
||||
Edition.ORIGINAL -> {
|
||||
when (x.result) {
|
||||
ClearResult.CHEAP -> getDiff(x, clearTally).addClear()
|
||||
ClearResult.STANDARD -> getDiff(x, clearTally).addClear()
|
||||
ClearResult.GREAT -> getDiff(x, clearTally).addGreat()
|
||||
ClearResult.EXCELLENT -> getDiff(x, clearTally).addExcellent()
|
||||
ClearResult.PERFECT -> getDiff(x, clearTally).addPerfect()
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
Edition.EXTRA -> {
|
||||
when (x.result) {
|
||||
ClearResult.CHEAP -> clearTally.extraExtreme.addClear()
|
||||
ClearResult.STANDARD -> clearTally.extraExtreme.addClear()
|
||||
ClearResult.GREAT -> clearTally.extraExtreme.addGreat()
|
||||
ClearResult.EXCELLENT -> clearTally.extraExtreme.addExcellent()
|
||||
ClearResult.PERFECT -> clearTally.extraExtreme.addPerfect()
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return clearTally.toInternal()
|
||||
}
|
||||
|
||||
private fun getDiff(record: PlayerPvRecord, clearTally: ClearTally) = when (record.difficulty) {
|
||||
Difficulty.EASY -> clearTally.easy
|
||||
Difficulty.NORMAL -> clearTally.normal
|
||||
Difficulty.HARD -> clearTally.hard
|
||||
Difficulty.EXTREME -> clearTally.extreme
|
||||
else -> throw PvRecordDataException("Difficulty data not exist, record id:" + record.id)
|
||||
}
|
||||
|
||||
private fun getContestResult(profile: PlayerProfile): MutableMap<String, String> {
|
||||
val cv_cid: MutableList<Int> = LinkedList<Int>()
|
||||
val cv_sc: MutableList<Int> = LinkedList<Int>()
|
||||
val cv_rr: MutableList<Int> = LinkedList<Int>()
|
||||
val cv_bv: MutableList<Int> = LinkedList<Int>()
|
||||
val cv_bf: MutableList<Int> = LinkedList<Int>()
|
||||
val contestList = db.contest.findTop4ByPdIdOrderByLastUpdateTimeDesc(profile)
|
||||
contestList.forEach(Consumer { x: PlayerContest ->
|
||||
cv_cid.add(x.contestId)
|
||||
cv_sc.add(x.startCount)
|
||||
cv_rr.add(x.resultRank.value)
|
||||
cv_bv.add(x.bestValue)
|
||||
cv_bf.add(-1)
|
||||
})
|
||||
for (i in cv_cid.size..3) {
|
||||
cv_cid.add(-1)
|
||||
cv_sc.add(-1)
|
||||
cv_rr.add(-1)
|
||||
cv_bv.add(-1)
|
||||
cv_bf.add(-1)
|
||||
}
|
||||
val result: MutableMap<String, String> = HashMap<String, String>()
|
||||
result["cv_cid"] = cv_cid.stream().map { it.toString() }.collect(Collectors.joining(","))
|
||||
result["cv_sc"] = cv_sc.stream().map { it.toString() }.collect(Collectors.joining(","))
|
||||
result["cv_rr"] = cv_rr.stream().map { it.toString() }.collect(Collectors.joining(","))
|
||||
result["cv_bv"] = cv_bv.stream().map { it.toString() }.collect(Collectors.joining(","))
|
||||
result["cv_bf"] = cv_bf.stream().map { it.toString() }.collect(Collectors.joining(","))
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package icu.samnyan.aqua.sega.diva.model
|
||||
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
/**
|
||||
* Data format from <url>https://dev.s-ul.eu/mikumiku/minime/wikis/home</url>
|
||||
*
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
open class BaseRequest {
|
||||
var game_id: String = "" // Game Id
|
||||
var place_id: String = "" // Place Id
|
||||
var time_stamp: ZonedDateTime = ZonedDateTime.now() // Timestamp
|
||||
}
|
||||
|
||||
open class PdRequest : BaseRequest() {
|
||||
var pd_id: Long = 0
|
||||
}
|
||||
|
||||
class StageResultRequest : PdRequest() {
|
||||
var hp_vol: Int = 0
|
||||
var btn_se_vol: Boolean = false
|
||||
var btn_se_vol2: Int = 0
|
||||
var sldr_se_vol2: Int = 0
|
||||
var nxt_pv_id: Int = 0
|
||||
var nxt_dffclty: Int = 0
|
||||
var nxt_edtn: Int = 0
|
||||
var sort_kind: Int = 0
|
||||
var game_type: Int = 0
|
||||
var stg_difficulty: IntArray = intArrayOf()
|
||||
var stg_edtn: IntArray = intArrayOf()
|
||||
var stg_ply_pv_id: IntArray = intArrayOf()
|
||||
var stg_scrpt_ver: IntArray = intArrayOf()
|
||||
var stg_score: IntArray = intArrayOf()
|
||||
var stg_chllng_kind: IntArray = intArrayOf()
|
||||
var stg_chllng_result: IntArray = intArrayOf()
|
||||
var stg_clr_kind: IntArray = intArrayOf()
|
||||
var stg_vcld_pts: IntArray = intArrayOf()
|
||||
var stg_cool_cnt: IntArray = intArrayOf()
|
||||
var stg_cool_pct: IntArray = intArrayOf()
|
||||
var stg_fine_cnt: IntArray = intArrayOf()
|
||||
var stg_fine_pct: IntArray = intArrayOf()
|
||||
var stg_safe_cnt: IntArray = intArrayOf()
|
||||
var stg_safe_pct: IntArray = intArrayOf()
|
||||
var stg_sad_cnt: IntArray = intArrayOf()
|
||||
var stg_sad_pct: IntArray = intArrayOf()
|
||||
var stg_wt_wg_cnt: IntArray = intArrayOf()
|
||||
var stg_wt_wg_pct: IntArray = intArrayOf()
|
||||
|
||||
var stg_max_cmb: IntArray = intArrayOf()
|
||||
var stg_chance_tm: IntArray = intArrayOf()
|
||||
var stg_sm_hl: IntArray = intArrayOf()
|
||||
var stg_atn_pnt: IntArray = intArrayOf()
|
||||
var stg_skin_id: IntArray = intArrayOf()
|
||||
var stg_btn_se: IntArray = intArrayOf()
|
||||
var stg_btn_se_vol: IntArray = intArrayOf()
|
||||
var stg_sld_se: IntArray = intArrayOf()
|
||||
var stg_chn_sld_se: IntArray = intArrayOf()
|
||||
var stg_sldr_tch_se: IntArray = intArrayOf()
|
||||
var stg_mdl_id: IntArray = intArrayOf()
|
||||
var stg_cpt_rslt: IntArray = intArrayOf()
|
||||
var stg_sld_scr: IntArray = intArrayOf()
|
||||
var stg_vcl_chg: IntArray = intArrayOf()
|
||||
var stg_c_itm_id: IntArray = intArrayOf()
|
||||
var stg_rgo: IntArray = intArrayOf()
|
||||
var stg_ss_num: IntArray = intArrayOf()
|
||||
|
||||
var cr_cid: Int = 0
|
||||
var cr_tv: Int = 0
|
||||
var cr_if: Int = 0
|
||||
var cr_sp: Array<String?> = arrayOf()
|
||||
}
|
||||
|
||||
class StageStartRequest : PdRequest() {
|
||||
var stg_ply_pv_id: IntArray = intArrayOf()
|
||||
}
|
||||
|
||||
class StartRequest : PdRequest() {
|
||||
}
|
||||
|
||||
class StoreSsRequest : PdRequest() {
|
||||
var ss_mdl_id: IntArray = intArrayOf()
|
||||
var ss_c_itm_id: IntArray = intArrayOf()
|
||||
}
|
||||
|
||||
class SpendCreditRequest : PdRequest() {
|
||||
}
|
||||
|
||||
class ShopExitRequest : PdRequest() {
|
||||
var use_pv_mdl_eqp = 0
|
||||
var ply_pv_id = 0
|
||||
var mdl_eqp_cmn_ary: IntArray = intArrayOf()
|
||||
var c_itm_eqp_cmn_ary: IntArray = intArrayOf()
|
||||
var ms_itm_flg_cmn_ary: IntArray = intArrayOf()
|
||||
var mdl_eqp_pv_ary: IntArray = intArrayOf()
|
||||
var c_itm_eqp_pv_ary: IntArray = intArrayOf()
|
||||
var ms_itm_flg_pv_ary: IntArray = intArrayOf()
|
||||
}
|
||||
|
||||
class RegistrationRequest : BaseRequest() {
|
||||
var idm: String = ""
|
||||
var aime_id: Long = 0
|
||||
var player_name: String = ""
|
||||
}
|
||||
|
||||
class PsRankingRequest : BaseRequest() {
|
||||
var rnk_ps_pv_id_lst: IntArray = intArrayOf()
|
||||
var rnk_ps_idx = 0
|
||||
}
|
||||
|
||||
class PreStartRequest : BaseRequest() {
|
||||
var idm: String = ""
|
||||
var aime_id: Long = 0
|
||||
}
|
||||
|
||||
class PdUnlockRequest : PdRequest() {
|
||||
}
|
||||
|
||||
class GetPvPdRequest : PdRequest() {
|
||||
var difficulty = 0
|
||||
var pd_pv_id_lst: IntArray = intArrayOf()
|
||||
}
|
||||
|
||||
class ChangePasswdRequest : PdRequest() {
|
||||
var new_passwd: String = ""
|
||||
}
|
||||
|
||||
class ChangeNameRequest : PdRequest() {
|
||||
var player_name: String = ""
|
||||
}
|
||||
|
||||
class CardProcedureRequest : BaseRequest() {
|
||||
var aime_id: Long = 0
|
||||
}
|
||||
|
||||
class BuyModuleRequest : PdRequest() {
|
||||
var mdl_id = 0
|
||||
}
|
||||
|
||||
class BuyCstmzItmRequest : PdRequest() {
|
||||
var cstmz_itm_id = 0
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public enum ChallengeKind {
|
||||
COMPLETED(4);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
ChallengeKind(int i) {
|
||||
this.value = i;
|
||||
@@ -22,7 +22,7 @@ public enum ChallengeKind {
|
||||
|
||||
public static ChallengeKind fromValue(int i) {
|
||||
for (ChallengeKind challengeKind :
|
||||
ChallengeKind.values()) {
|
||||
ChallengeKind.values()) {
|
||||
if (challengeKind.getValue() == i) return challengeKind;
|
||||
}
|
||||
return ChallengeKind.UNDEFINED;
|
||||
|
||||
@@ -15,7 +15,7 @@ public enum ClearResult implements ValueEnum {
|
||||
PERFECT(5);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
ClearResult(int i) {
|
||||
this.value = i;
|
||||
@@ -23,7 +23,7 @@ public enum ClearResult implements ValueEnum {
|
||||
|
||||
public static ClearResult fromValue(int i) {
|
||||
for (ClearResult clearResult :
|
||||
ClearResult.values()) {
|
||||
ClearResult.values()) {
|
||||
if (clearResult.getValue() == i) return clearResult;
|
||||
}
|
||||
return ClearResult.NO_CLEAR;
|
||||
|
||||
@@ -5,7 +5,6 @@ package icu.samnyan.aqua.sega.diva.model.common;
|
||||
*/
|
||||
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";
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public enum ContestBorder {
|
||||
GOLD(2);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
ContestBorder(int i) {
|
||||
this.value = i;
|
||||
|
||||
@@ -12,7 +12,7 @@ public enum ContestLeague {
|
||||
PROFESSIONAL(3);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
ContestLeague(int i) {
|
||||
this.value = i;
|
||||
|
||||
@@ -11,7 +11,7 @@ public enum ContestNormaType {
|
||||
COOL_PERCENTAGE(2);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
ContestNormaType(int i) {
|
||||
this.value = i;
|
||||
|
||||
@@ -10,7 +10,7 @@ public enum ContestStageLimit {
|
||||
LIMITED(1);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
ContestStageLimit(int i) {
|
||||
this.value = i;
|
||||
|
||||
@@ -13,7 +13,7 @@ public enum Difficulty {
|
||||
EXTREME(3);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
Difficulty(int i) {
|
||||
this.value = i;
|
||||
@@ -21,7 +21,7 @@ public enum Difficulty {
|
||||
|
||||
public static Difficulty fromValue(int i) {
|
||||
for (Difficulty difficulty :
|
||||
Difficulty.values()) {
|
||||
Difficulty.values()) {
|
||||
if (difficulty.getValue() == i) return difficulty;
|
||||
}
|
||||
return Difficulty.UNDEFINED;
|
||||
|
||||
@@ -10,7 +10,7 @@ public enum Edition {
|
||||
EXTRA(1);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
Edition(int i) {
|
||||
this.value = i;
|
||||
@@ -18,7 +18,7 @@ public enum Edition {
|
||||
|
||||
public static Edition fromValue(int i) {
|
||||
for (Edition edition :
|
||||
Edition.values()) {
|
||||
Edition.values()) {
|
||||
if (edition.getValue() == i) return edition;
|
||||
}
|
||||
return Edition.ORIGINAL;
|
||||
|
||||
@@ -10,7 +10,7 @@ public enum FestaKind {
|
||||
GREEN_FESTA(1);
|
||||
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
FestaKind(int i) {
|
||||
this.value = i;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user