forked from Cookies_Github_mirror/AquaDX
[+] Minato migration
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
package icu.samnyan.aqua.sega.aimedb
|
||||
|
||||
import ext.logger
|
||||
import ext.toHex
|
||||
import ext.*
|
||||
import icu.samnyan.aqua.net.BotProps
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import icu.samnyan.aqua.sega.allnet.AllNetProps
|
||||
import icu.samnyan.aqua.sega.general.model.Card
|
||||
import icu.samnyan.aqua.sega.general.model.CardStatus
|
||||
import icu.samnyan.aqua.sega.general.service.CardService
|
||||
import io.netty.buffer.ByteBuf
|
||||
import io.netty.buffer.ByteBufUtil
|
||||
@@ -124,11 +125,16 @@ class AimeDB(
|
||||
}
|
||||
}
|
||||
|
||||
fun getCard(accessCode: String) = cardService.getCardByAccessCode(accessCode).getOrNull()?.let { card ->
|
||||
fun getCard(accessCode: String) = us.cardRepo.findByLuid(accessCode)()?.let { card ->
|
||||
// If it's migrated to Minato, return the Minato card for 24 hours
|
||||
if (card.status == CardStatus.MIGRATED_TO_MINATO && card.accessTime.plusDays(1).isAfter(utcNow()))
|
||||
return BotProps.MINATO_CARD_EXT.long
|
||||
|
||||
// Update card access time
|
||||
cardService.cardRepo.save(card.apply { accessTime = LocalDateTime.now() }).let {
|
||||
it.aquaUser?.ghostCard ?: it
|
||||
}?.extId
|
||||
us.cardRepo.save(card.apply { accessTime = LocalDateTime.now() })
|
||||
|
||||
// If it's a ghost card, return the ghost card. Otherwise, return the original card
|
||||
(card.aquaUser?.ghostCard ?: card).extId
|
||||
} ?: -1
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,26 @@ import icu.samnyan.aqua.net.db.AquaNetUser
|
||||
import jakarta.persistence.*
|
||||
import java.time.LocalDateTime
|
||||
|
||||
enum class CardStatus {
|
||||
NORMAL,
|
||||
|
||||
// Reserved for future use
|
||||
NORMAL_RESERVED_1,
|
||||
NORMAL_RESERVED_2,
|
||||
NORMAL_RESERVED_3,
|
||||
NORMAL_RESERVED_4,
|
||||
NORMAL_RESERVED_5,
|
||||
NORMAL_RESERVED_6,
|
||||
NORMAL_RESERVED_7,
|
||||
NORMAL_RESERVED_8,
|
||||
NORMAL_RESERVED_9,
|
||||
|
||||
// Deleted statuses
|
||||
OVERWRITTEN,
|
||||
DELETED,
|
||||
MIGRATED_TO_MINATO,
|
||||
}
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@@ -44,6 +64,9 @@ class Card(
|
||||
// Unfortunately some people decide to cheat and upload all perfect scores :(
|
||||
// This will not affect gameplay behavior, but will hide the user from ranking
|
||||
var rankingBanned: Boolean = false,
|
||||
|
||||
@Enumerated(EnumType.ORDINAL)
|
||||
var status: CardStatus = CardStatus.NORMAL,
|
||||
) {
|
||||
@Suppress("unused") // Used by serialization
|
||||
val isLinked get() = aquaUser != null
|
||||
|
||||
@@ -31,16 +31,6 @@ class CardService(val cardRepo: CardRepository)
|
||||
*/
|
||||
fun getCardByExtId(extId: Long?): Optional<Card> = cardRepo.findByExtId(extId)
|
||||
|
||||
/**
|
||||
* Find a card by its access code
|
||||
*
|
||||
* @param accessCode String represent of an access code
|
||||
* @return Optional of a Card
|
||||
*/
|
||||
fun getCardByAccessCode(accessCode: String?): Optional<Card> = Optional.ofNullable(
|
||||
cardRepo.findByLuid(accessCode).getOrNull()
|
||||
)
|
||||
|
||||
/**
|
||||
* Register a new card with access code
|
||||
* @param accessCode String represent of an access code
|
||||
|
||||
Reference in New Issue
Block a user