mirror of https://github.com/hykilpikonna/AquaDX
[+] Wacca: More database fields
parent
aa1caacfd6
commit
abc21badb1
|
@ -84,7 +84,6 @@ data class GenericItemMeta(
|
||||||
// Here are some interfaces to generalize across multiple games
|
// Here are some interfaces to generalize across multiple games
|
||||||
interface IGenericUserData {
|
interface IGenericUserData {
|
||||||
val userName: String
|
val userName: String
|
||||||
val iconId: Int
|
|
||||||
val playerRating: Int
|
val playerRating: Int
|
||||||
val highestRating: Int
|
val highestRating: Int
|
||||||
val firstPlayDate: Any
|
val firstPlayDate: Any
|
||||||
|
|
|
@ -120,9 +120,9 @@ fun WaccaServer.init() {
|
||||||
u.run { ls(u.lStatus(),
|
u.run { ls(u.lStatus(),
|
||||||
o[SET_TITLE_ID], o[SET_ICON_ID],
|
o[SET_TITLE_ID], o[SET_ICON_ID],
|
||||||
"status" - if (ru == null) 1 else 0, // 0 = GOOD, 1 = Register
|
"status" - if (ru == null) 1 else 0, // 0 = GOOD, 1 = Register
|
||||||
"version" - ls(req.appVersion.shortVer().compareTo(lastGameVer.shortVer())
|
"version" - ls(req.appVersion.shortVer().compareTo(this.lastRomVersion.shortVer())
|
||||||
.let { if (it < 0) 1 else if (it > 0) 2 else 0 }, // 0 = Version GOOD, 1 = Game is newer, 2 = Game is older
|
.let { if (it < 0) 1 else if (it > 0) 2 else 0 }, // 0 = Version GOOD, 1 = Game is newer, 2 = Game is older
|
||||||
lastGameVer.shortVer()),
|
this.lastRomVersion.shortVer()),
|
||||||
o.map { (k, v) -> ls(k, v) }
|
o.map { (k, v) -> ls(k, v) }
|
||||||
) }
|
) }
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ fun WaccaServer.init() {
|
||||||
|
|
||||||
val u = rp.user.save(WaccaUser().apply {
|
val u = rp.user.save(WaccaUser().apply {
|
||||||
card = cardRepo.findByExtId(uid.long())() ?: (404 - "Card not found")
|
card = cardRepo.findByExtId(uid.long())() ?: (404 - "Card not found")
|
||||||
username = name.toString()
|
userName = name.toString()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Starter items
|
// Starter items
|
||||||
|
@ -160,13 +160,13 @@ fun WaccaServer.init() {
|
||||||
loginCountDays++
|
loginCountDays++
|
||||||
loginCountToday = 0
|
loginCountToday = 0
|
||||||
lastConsecDate = Date()
|
lastConsecDate = Date()
|
||||||
if (millis() - lastLoginDate.time < 2 * 24 * 60 * 60 * 1000) loginCountDaysConsec++
|
if (millis() - this.lastPlayDate.time < 2 * 24 * 60 * 60 * 1000) loginCountDaysConsec++
|
||||||
}
|
}
|
||||||
loginCountToday++
|
loginCountToday++
|
||||||
lastLoginDate = Date()
|
this.lastPlayDate = Date()
|
||||||
})
|
})
|
||||||
|
|
||||||
"[[], [], [], 0, [2077, 1, 1, 1, [], []], ${u.lastLoginDate.time / 1000}, []]"
|
"[[], [], [], 0, [2077, 1, 1, 1, [], []], ${u.lastPlayDate.time / 1000}, []]"
|
||||||
}
|
}
|
||||||
|
|
||||||
"user/status/GetDetail" api@ { _, (uid) ->
|
"user/status/GetDetail" api@ { _, (uid) ->
|
||||||
|
@ -176,7 +176,7 @@ fun WaccaServer.init() {
|
||||||
val scores = rp.bestScore.findByUser(u)
|
val scores = rp.bestScore.findByUser(u)
|
||||||
val gates = rp.gate.findByUser(u)
|
val gates = rp.gate.findByUser(u)
|
||||||
val bingo = rp.bingo.findByUser(u).firstOrNull()
|
val bingo = rp.bingo.findByUser(u).firstOrNull()
|
||||||
val go = u.card.aquaUser?.gameOptions
|
val go = u.card?.aquaUser?.gameOptions
|
||||||
|
|
||||||
// TODO: make this and vip configurable
|
// TODO: make this and vip configurable
|
||||||
// u.wp = 999999
|
// u.wp = 999999
|
||||||
|
@ -195,12 +195,12 @@ fun WaccaServer.init() {
|
||||||
},
|
},
|
||||||
"4 scores" - scores.map { it.ls() },
|
"4 scores" - scores.map { it.ls() },
|
||||||
"5 songPlayStatus" - ls(lastSongInfo[0], 1),
|
"5 songPlayStatus" - ls(lastSongInfo[0], 1),
|
||||||
"6 seasonInfo" - ls(xp, wpTotal, wpSpent, scores.sumOf { it.score },
|
"6 seasonInfo" - ls(xp, wpTotal, wpSpent, u.totalScore,
|
||||||
items[TITLE()]?.size ?: 0, items[ICON()]?.size ?: 0, 0,
|
items[TITLE()]?.size ?: 0, items[ICON()]?.size ?: 0, 0,
|
||||||
items[NOTE_COLOR()]?.size ?: 0, items[NOTE_SOUND()]?.size ?: 0, items[USER_PLATE()]?.size ?: 0,
|
items[NOTE_COLOR()]?.size ?: 0, items[NOTE_SOUND()]?.size ?: 0, items[USER_PLATE()]?.size ?: 0,
|
||||||
gates.sumOf { it.totalPoints }),
|
gates.sumOf { it.totalPoints }),
|
||||||
"7 playAreaList" - "[[0],[0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0],[0,0,0,0],[0,0,0,0,0,0,0],[0]]".jsonArray(),
|
"7 playAreaList" - "[[0],[0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0],[0,0,0,0],[0,0,0,0,0,0,0],[0]]".jsonArray(),
|
||||||
"8 songUpdateTime" - lastLoginDate.time / 1000,
|
"8 songUpdateTime" - this.lastPlayDate.time / 1000,
|
||||||
"9 favorites" - u.favoriteSongs,
|
"9 favorites" - u.favoriteSongs,
|
||||||
"10 stoppedSongIds" - empty,
|
"10 stoppedSongIds" - empty,
|
||||||
"11 events" - empty,
|
"11 events" - empty,
|
||||||
|
@ -306,6 +306,9 @@ fun WaccaServer.init() {
|
||||||
rating = waccaRating(score, song.level)
|
rating = waccaRating(score, song.level)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Re-calculate user total score
|
||||||
|
rp.user.save(u.apply { totalScore = rp.bestScore.sumScoreByUser(u) })
|
||||||
|
|
||||||
ls(best.lsMusicUpdate(), ls(song.songId, best.clears[0]), "seasonalInfo" - (1..11).map { 0 }, "ranking" - empty)
|
ls(best.lsMusicUpdate(), ls(song.songId, best.clears[0]), "seasonalInfo" - (1..11).map { 0 }, "ranking" - empty)
|
||||||
}
|
}
|
||||||
"user/music/UpdateCoop" redirect "user/music/update"
|
"user/music/UpdateCoop" redirect "user/music/update"
|
||||||
|
@ -335,7 +338,6 @@ fun WaccaServer.init() {
|
||||||
|
|
||||||
"user/rating/update" empty { _, (uid, newRating, songs) ->
|
"user/rating/update" empty { _, (uid, newRating, songs) ->
|
||||||
val u = user(uid) ?: (404 - "User not found")
|
val u = user(uid) ?: (404 - "User not found")
|
||||||
rp.user.save(u.apply { rating = newRating.int() })
|
|
||||||
|
|
||||||
// Update best record
|
// Update best record
|
||||||
(songs as List<List<Any>>).forEach { (songId, diff, newRating) ->
|
(songs as List<List<Any>>).forEach { (songId, diff, newRating) ->
|
||||||
|
@ -343,6 +345,12 @@ fun WaccaServer.init() {
|
||||||
best.rating = newRating.int()
|
best.rating = newRating.int()
|
||||||
rp.bestScore.save(best)
|
rp.bestScore.save(best)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rp.user.save(u.apply {
|
||||||
|
playerRating = newRating.int()
|
||||||
|
highestRating = max(highestRating, newRating.int())
|
||||||
|
totalScore = rp.bestScore.sumScoreByUser(u)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun incrUses(u: WaccaUser, opts: Map<Int, Int>) {
|
fun incrUses(u: WaccaUser, opts: Map<Int, Int>) {
|
||||||
|
@ -356,7 +364,7 @@ fun WaccaServer.init() {
|
||||||
rp.user.save(u.apply {
|
rp.user.save(u.apply {
|
||||||
playCounts[playType.int() - 1]++
|
playCounts[playType.int() - 1]++
|
||||||
addItems(items, u, itmGrp(u))
|
addItems(items, u, itmGrp(u))
|
||||||
lastGameVer = version
|
lastRomVersion = version
|
||||||
incrUses(u, options(u))
|
incrUses(u, options(u))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package icu.samnyan.aqua.sega.wacca.model.db
|
||||||
|
|
||||||
import jakarta.transaction.Transactional
|
import jakarta.transaction.Transactional
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import org.springframework.data.jpa.repository.Query
|
||||||
import org.springframework.data.repository.NoRepositoryBean
|
import org.springframework.data.repository.NoRepositoryBean
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
|
@ -31,6 +32,8 @@ interface WcUserItemRepo : IWaccaUserLinked<WcUserItem> {
|
||||||
}
|
}
|
||||||
interface WcUserBestScoreRepo : IWaccaUserLinked<WcUserScore> {
|
interface WcUserBestScoreRepo : IWaccaUserLinked<WcUserScore> {
|
||||||
fun findByUserAndSongIdAndDifficulty(user: WaccaUser, songId: Int, difficulty: Int): WcUserScore?
|
fun findByUserAndSongIdAndDifficulty(user: WaccaUser, songId: Int, difficulty: Int): WcUserScore?
|
||||||
|
@Query("SELECT SUM(score) FROM WcUserScore WHERE user = :user")
|
||||||
|
fun sumScoreByUser(user: WaccaUser): Long
|
||||||
}
|
}
|
||||||
interface WcUserPlayLogRepo : IWaccaUserLinked<WcUserPlayLog>
|
interface WcUserPlayLogRepo : IWaccaUserLinked<WcUserPlayLog>
|
||||||
interface WcUserStageUpRepo : IWaccaUserLinked<WcUserStageUp>
|
interface WcUserStageUpRepo : IWaccaUserLinked<WcUserStageUp>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import ext.ls
|
||||||
import ext.sec
|
import ext.sec
|
||||||
import ext.toDate
|
import ext.toDate
|
||||||
import icu.samnyan.aqua.net.games.BaseEntity
|
import icu.samnyan.aqua.net.games.BaseEntity
|
||||||
|
import icu.samnyan.aqua.net.games.IGenericUserData
|
||||||
import icu.samnyan.aqua.sega.general.IntegerListConverter
|
import icu.samnyan.aqua.sega.general.IntegerListConverter
|
||||||
import icu.samnyan.aqua.sega.general.model.Card
|
import icu.samnyan.aqua.sega.general.model.Card
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
|
@ -14,13 +15,13 @@ import java.util.*
|
||||||
* General user information
|
* General user information
|
||||||
*/
|
*/
|
||||||
@Entity @Table(name = "wacca_user")
|
@Entity @Table(name = "wacca_user")
|
||||||
class WaccaUser : BaseEntity() {
|
class WaccaUser : BaseEntity(), IGenericUserData {
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "aime_card_id", unique = true)
|
@JoinColumn(name = "aime_card_id", unique = true)
|
||||||
var card: Card = Card()
|
override var card: Card? = Card()
|
||||||
|
|
||||||
@Column(length = 8)
|
@Column(length = 8)
|
||||||
var username = ""
|
override var userName = ""
|
||||||
|
|
||||||
var xp = 0
|
var xp = 0
|
||||||
var wp = 500
|
var wp = 500
|
||||||
|
@ -30,7 +31,8 @@ class WaccaUser : BaseEntity() {
|
||||||
var danLevel = 0
|
var danLevel = 0
|
||||||
@Convert(converter = IntegerListConverter::class)
|
@Convert(converter = IntegerListConverter::class)
|
||||||
var titles: MutableList<Int> = mutableListOf(0, 0, 0)
|
var titles: MutableList<Int> = mutableListOf(0, 0, 0)
|
||||||
var rating = 0
|
override var playerRating = 0
|
||||||
|
override var highestRating = 0
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
var vipExpireTime: Date = "2077-01-01".isoDate().toDate()
|
var vipExpireTime: Date = "2077-01-01".isoDate().toDate()
|
||||||
var alwaysVip = false
|
var alwaysVip = false
|
||||||
|
@ -43,17 +45,22 @@ class WaccaUser : BaseEntity() {
|
||||||
@Convert(converter = IntegerListConverter::class)
|
@Convert(converter = IntegerListConverter::class)
|
||||||
var friendViews: MutableList<Int> = mutableListOf(0, 0, 0)
|
var friendViews: MutableList<Int> = mutableListOf(0, 0, 0)
|
||||||
@Column(length = 50)
|
@Column(length = 50)
|
||||||
var lastGameVer = "1.0.0"
|
override var lastRomVersion = "1.0.0"
|
||||||
@Convert(converter = IntegerListConverter::class)
|
@Convert(converter = IntegerListConverter::class)
|
||||||
var lastSongInfo: MutableList<Int> = mutableListOf(0, 0, 0, 0, 0)
|
var lastSongInfo: MutableList<Int> = mutableListOf(0, 0, 0, 0, 0)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
var lastConsecDate: Date = Date(0)
|
var lastConsecDate: Date = Date(0)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
var lastLoginDate: Date = Date()
|
override var lastPlayDate: Date = Date()
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
override var firstPlayDate: Date = Date()
|
||||||
var gateTutorialFlags: String = "[[1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]"
|
var gateTutorialFlags: String = "[[1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]"
|
||||||
@Convert(converter = IntegerListConverter::class)
|
@Convert(converter = IntegerListConverter::class)
|
||||||
var favoriteSongs: MutableList<Int> = mutableListOf()
|
var favoriteSongs: MutableList<Int> = mutableListOf()
|
||||||
|
override var totalScore = 0L
|
||||||
|
|
||||||
fun lStatus() = ls(card.extId, username, 1, xp, danLevel, danType, wp, ls(0, 0, 0), loginCount, loginCountDays,
|
fun lStatus() = ls(card?.extId,
|
||||||
(loginCount - 1).coerceAtLeast(0), loginCountDaysConsec, vipExpireTime.sec, loginCountToday, rating)
|
userName, 1, xp, danLevel, danType, wp, ls(0, 0, 0), loginCount, loginCountDays,
|
||||||
|
(loginCount - 1).coerceAtLeast(0), loginCountDaysConsec, vipExpireTime.sec, loginCountToday, this.playerRating
|
||||||
|
)
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ create table wacca_user
|
||||||
id bigint auto_increment
|
id bigint auto_increment
|
||||||
primary key,
|
primary key,
|
||||||
aime_card_id bigint not null,
|
aime_card_id bigint not null,
|
||||||
username varchar(8) not null,
|
user_name varchar(8) not null,
|
||||||
xp int not null,
|
xp int not null,
|
||||||
wp int not null,
|
wp int not null,
|
||||||
wp_total int not null,
|
wp_total int not null,
|
||||||
|
@ -15,7 +15,8 @@ create table wacca_user
|
||||||
dan_type int not null,
|
dan_type int not null,
|
||||||
dan_level int not null,
|
dan_level int not null,
|
||||||
titles varchar(255) not null,
|
titles varchar(255) not null,
|
||||||
rating int not null,
|
player_rating int not null,
|
||||||
|
highest_rating int not null,
|
||||||
always_vip bit not null,
|
always_vip bit not null,
|
||||||
login_count int not null,
|
login_count int not null,
|
||||||
login_count_days int not null,
|
login_count_days int not null,
|
||||||
|
@ -23,13 +24,15 @@ create table wacca_user
|
||||||
login_count_today int not null,
|
login_count_today int not null,
|
||||||
play_counts varchar(255) not null,
|
play_counts varchar(255) not null,
|
||||||
friend_views varchar(255) not null,
|
friend_views varchar(255) not null,
|
||||||
last_game_ver varchar(50) not null,
|
last_rom_version varchar(50) not null,
|
||||||
last_song_info varchar(255) not null,
|
last_song_info varchar(255) not null,
|
||||||
gate_tutorial_flags varchar(255) not null,
|
gate_tutorial_flags varchar(255) not null,
|
||||||
last_login_date datetime not null,
|
last_play_date datetime not null,
|
||||||
|
first_play_date datetime not null,
|
||||||
vip_expire_time datetime not null,
|
vip_expire_time datetime not null,
|
||||||
last_consec_date datetime not null,
|
last_consec_date datetime not null,
|
||||||
favorite_songs TEXT not null,
|
favorite_songs TEXT not null,
|
||||||
|
total_score bigint not null,
|
||||||
constraint wacca_user_detail_unique
|
constraint wacca_user_detail_unique
|
||||||
unique (aime_card_id),
|
unique (aime_card_id),
|
||||||
constraint wacca_user_detail_fk
|
constraint wacca_user_detail_fk
|
||||||
|
|
Loading…
Reference in New Issue