[O] Wacca: Simplify data storage, re-init database

pull/29/head
Azalea 2024-03-28 19:04:16 -04:00
parent f97cb4a1bb
commit 40fb1c8868
5 changed files with 208 additions and 187 deletions

View File

@ -5,6 +5,7 @@ import ext.ls
import ext.sec
import ext.toDate
import icu.samnyan.aqua.net.games.BaseEntity
import icu.samnyan.aqua.sega.general.IntegerListConverter
import icu.samnyan.aqua.sega.general.model.Card
import jakarta.persistence.*
import java.util.*
@ -22,44 +23,37 @@ class WaccaUser : BaseEntity() {
var username = ""
var xp = 0
var wp = 0
var wpTotal = 0
var wp = 500
var wpTotal = 500
var wpSpent = 0
var danType = 0
var danLevel = 0
var title0 = 0
var title1 = 0
var title2 = 0
@Convert(converter = IntegerListConverter::class)
var titles: MutableList<Int> = mutableListOf(0, 0, 0)
var rating = 0
@Temporal(TemporalType.TIMESTAMP)
var vipExpireTime: Date = "2077-01-01".isoDate().toDate()
var alwaysVip = false
var loginCount = 0
var loginCountConsec = 0
var loginCountDays = 0
var loginCountDaysConsec = 0
var loginCountToday = 0
var playcountSingle = 0
var playcountMultiVs = 0
var playcountMultiCoop = 0
var playcountStageup = 0
var playcountTimeFree = 0
var friendView1 = 0
var friendView2 = 0
var friendView3 = 0
@Convert(converter = IntegerListConverter::class)
var playCounts: MutableList<Int> = mutableListOf(0, 0, 0, 0, 0)
@Convert(converter = IntegerListConverter::class)
var friendViews: MutableList<Int> = mutableListOf(0, 0, 0)
@Column(length = 50)
var lastGameVer = "1.0.0"
var lastSongId = 0
var lastSongDifficulty = 0
var lastFolderOrder = 0
var lastFolderId = 0
var lastSongOrder = 0
@Convert(converter = IntegerListConverter::class)
var lastSongInfo: MutableList<Int> = mutableListOf(0, 0, 0, 0, 0)
@Temporal(TemporalType.TIMESTAMP)
var lastConsecDate: Date = Date(0)
@Temporal(TemporalType.TIMESTAMP)
var lastLoginDate: Date = Date()
var gateTutorialFlags: String = "[[1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]"
@Convert(converter = IntegerListConverter::class)
var favoriteSongs: MutableList<Int> = mutableListOf()
fun lStatus() = ls(card.extId, username, 1, xp, danLevel, danType, wp, ls(0, 0, 0), loginCount, loginCountDays,
loginCountConsec, loginCountDaysConsec, vipExpireTime.sec, loginCountToday, rating)
(loginCount - 1).coerceAtLeast(0), loginCountDaysConsec, vipExpireTime.sec, loginCountToday, rating)
}

View File

@ -26,10 +26,10 @@ open class WaccaUserEntity : BaseEntity() {
* In-game option key-value storage
*/
@Entity @Table(name = "wacca_user_option", uniqueConstraints = [UC("", ["user_id", "opt_id"])])
class WcUserOption : WaccaUserEntity() {
var optId = 0
var value = 0
}
class WcUserOption(
var optId: Int = 0,
var value: Int = 0
) : WaccaUserEntity()
@Entity @Table(name = "wacca_user_bingo", uniqueConstraints = [UC("", ["user_id", "page_number"])])
class WcUserBingo : WaccaUserEntity() {
@ -47,24 +47,19 @@ class WcUserFriend : WaccaUserEntity() {
var isAccepted = false
}
@Entity @Table(name = "wacca_user_favorite_song", uniqueConstraints = [UC("", ["user_id", "song_id"])])
class WcUserFavoriteSong : WaccaUserEntity() {
// TODO: Make this into a list instead?
var songId = 0
}
@Entity @Table(name = "wacca_user_gate", uniqueConstraints = [UC("", ["user_id", "gate_id"])])
class WcUserGate : WaccaUserEntity() {
var gateId = 0
var page = 1
var progress = 0
var loops = 0
@Temporal(TemporalType.TIMESTAMP)
var lastUsed = Date(0)
var missionFlag = 0
var totalPoints = 0
fun ls() = ls(gateId, 1, page, progress, loops, lastUsed, missionFlag)
fun ls() = ls(gateId, 1, page, progress, loops, lastUsed.sec, missionFlag)
}
@Entity @Table(name = "wacca_user_item", uniqueConstraints = [UC("", ["user_id", "item_id", "type"])])

View File

@ -1,36 +0,0 @@
ALTER TABLE wacca_user_song_unlock
DROP FOREIGN KEY fku_wacca_user_song_unlock;
ALTER TABLE wacca_user_ticket
DROP FOREIGN KEY fku_wacca_user_ticket;
ALTER TABLE wacca_user_trophy
DROP FOREIGN KEY fku_wacca_user_trophy;
DROP TABLE maimai2_game_ticket;
DROP TABLE wacca_user_song_unlock;
DROP TABLE wacca_user_ticket;
DROP TABLE wacca_user_trophy;
ALTER TABLE wacca_user_gate
ADD last_used datetime NOT NULL;
ALTER TABLE wacca_user_item
ADD p1 BIGINT NOT NULL,
ADD p2 BIGINT NOT NULL,
ADD p3 BIGINT NOT NULL,
DROP COLUMN acquire_date,
DROP COLUMN use_count,
ADD acquired_date datetime NOT NULL,
DROP CONSTRAINT wacca_user_item_unique,
ADD CONSTRAINT wacca_user_item_unique UNIQUE (user_id, item_id, type);
ALTER TABLE wacca_user
DROP COLUMN last_login_date,
DROP COLUMN vip_expire_time,
ADD last_login_date datetime NOT NULL,
ADD vip_expire_time datetime NOT NULL,
ADD last_consec_date datetime NOT NULL;

View File

@ -0,0 +1,188 @@
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE wacca_friend, wacca_user_bingo, wacca_user_favorite_song, wacca_user_gate, wacca_user_item, wacca_user_option, wacca_user_playlog, wacca_user_score, wacca_user_stageup, wacca_user;
SET FOREIGN_KEY_CHECKS=1;
create table wacca_user
(
id bigint auto_increment
primary key,
aime_card_id bigint not null,
username varchar(8) not null,
xp int not null,
wp int not null,
wp_total int not null,
wp_spent int not null,
dan_type int not null,
dan_level int not null,
titles varchar(255) not null,
rating int not null,
always_vip bit not null,
login_count int not null,
login_count_days int not null,
login_count_days_consec int not null,
login_count_today int not null,
play_counts varchar(255) not null,
friend_views varchar(255) not null,
last_game_ver varchar(50) not null,
last_song_info varchar(255) not null,
gate_tutorial_flags varchar(255) not null,
last_login_date datetime not null,
vip_expire_time datetime not null,
last_consec_date datetime not null,
favorite_songs TEXT not null,
constraint wacca_user_detail_unique
unique (aime_card_id),
constraint wacca_user_detail_fk
foreign key (aime_card_id) references sega_card (id)
);
create table wacca_friend
(
id bigint auto_increment
primary key,
user_id bigint not null,
`with` bigint not null,
is_accepted bit not null,
constraint wacca_friend_unique
unique (user_id, `with`),
constraint fku_wacca_friend
foreign key (user_id) references wacca_user (id)
on update cascade on delete cascade,
constraint fku_wacca_friend_2
foreign key (`with`) references wacca_user (id)
on update cascade on delete cascade
);
create table wacca_user_bingo
(
id bigint auto_increment
primary key,
user_id bigint not null,
page_number int not null,
page_progress varchar(255) null,
constraint wacca_user_bingo_unique
unique (user_id, page_number),
constraint fku_wacca_user_bingo
foreign key (user_id) references wacca_user (id)
on update cascade on delete cascade
);
create table wacca_user_gate
(
id bigint auto_increment
primary key,
user_id bigint not null,
gate_id int not null,
page int not null,
progress int not null,
loops int not null,
mission_flag int not null,
total_points int not null,
last_used datetime not null,
constraint wacca_user_gate_unique
unique (user_id, gate_id),
constraint fku_wacca_user_gate
foreign key (user_id) references wacca_user (id)
on update cascade on delete cascade
);
create table wacca_user_item
(
id bigint auto_increment
primary key,
user_id bigint not null,
item_id int not null,
type int not null,
p1 bigint not null,
p2 bigint not null,
p3 bigint not null,
acquired_date datetime not null,
constraint wacca_user_item_unique
unique (user_id, item_id, type),
constraint fku_wacca_user_item
foreign key (user_id) references wacca_user (id)
on update cascade on delete cascade
);
create table wacca_user_option
(
id bigint auto_increment
primary key,
user_id bigint not null,
opt_id int not null,
value int not null,
constraint wacca_user_option_unique
unique (user_id, opt_id),
constraint fku_wacca_user_option
foreign key (user_id) references wacca_user (id)
on update cascade on delete cascade
);
create table wacca_user_playlog
(
id bigint auto_increment
primary key,
user_id bigint not null,
song_id int not null,
difficulty int not null,
score int not null,
grade int not null,
max_combo int not null,
fast_ct int not null,
late_ct int not null,
all_marv bit not null,
full_combo bit not null,
give_up bit not null,
judgements varchar(255) not null,
level double not null,
missless bit not null,
new_record bit not null,
skill_pt int not null,
clear bit not null,
date_scored datetime not null,
constraint wacca_user_playlog_unique
unique (user_id, song_id, difficulty, date_scored),
constraint fku_wacca_user_playlog
foreign key (user_id) references wacca_user (id)
on update cascade on delete cascade
);
create table wacca_user_score
(
id bigint auto_increment
primary key,
user_id bigint not null,
song_id int not null,
difficulty int not null,
score int not null,
best_combo int not null,
lowest_miss_ct int not null,
rating int not null,
clears varchar(255) not null,
grades varchar(255) not null,
constraint wacca_user_score_unique
unique (user_id, song_id, difficulty),
constraint fku_wacca_user_score
foreign key (user_id) references wacca_user (id)
on update cascade on delete cascade
);
create table wacca_user_stageup
(
id bigint auto_increment
primary key,
user_id bigint not null,
version int not null,
stage_id int not null,
clear_status int not null,
clear_song_ct int not null,
song1score int not null,
song2score int not null,
song3score int not null,
play_ct int not null,
constraint wacca_user_stageup_unique
unique (user_id, version, stage_id),
constraint fku_wacca_user_stageup
foreign key (user_id) references wacca_user (id)
on update cascade on delete cascade
);

View File

@ -1,120 +0,0 @@
ALTER TABLE wacca_user_playlog
ADD all_marv BIT(1) NOT NULL;
ALTER TABLE wacca_user_playlog
ADD full_combo BIT(1) NOT NULL;
ALTER TABLE wacca_user_playlog
ADD give_up BIT(1) NOT NULL;
ALTER TABLE wacca_user_playlog
ADD judgements VARCHAR(255) NOT NULL;
ALTER TABLE wacca_user_playlog
ADD level DOUBLE NOT NULL;
ALTER TABLE wacca_user_playlog
ADD missless BIT(1) NOT NULL;
ALTER TABLE wacca_user_playlog
ADD new_record BIT(1) NOT NULL;
ALTER TABLE wacca_user_playlog
ADD skill_pt INT NOT NULL;
ALTER TABLE wacca_user_playlog
MODIFY all_marv BIT(1) NOT NULL;
ALTER TABLE wacca_user_score
ADD clears VARCHAR(255) NOT NULL;
ALTER TABLE wacca_user_score
ADD grades VARCHAR(255) NOT NULL;
ALTER TABLE wacca_user_score
DROP COLUMN allmarv_ct;
ALTER TABLE wacca_user_score RENAME COLUMN chart_id TO difficulty;
ALTER TABLE wacca_user_score
DROP COLUMN clear_ct;
ALTER TABLE wacca_user_score
DROP COLUMN fullcombo_ct;
ALTER TABLE wacca_user_score
DROP COLUMN grade_master_ct;
ALTER TABLE wacca_user_score
DROP COLUMN grade_sp_ct;
ALTER TABLE wacca_user_score
DROP COLUMN grade_ssp_ct;
ALTER TABLE wacca_user_score
DROP COLUMN grade_sssp_ct;
ALTER TABLE wacca_user_score
DROP COLUMN gradeaaact;
ALTER TABLE wacca_user_score
DROP COLUMN gradeaact;
ALTER TABLE wacca_user_score
DROP COLUMN gradeact;
ALTER TABLE wacca_user_score
DROP COLUMN gradebct;
ALTER TABLE wacca_user_score
DROP COLUMN gradecct;
ALTER TABLE wacca_user_score
DROP COLUMN gradedct;
ALTER TABLE wacca_user_score
DROP COLUMN gradesct;
ALTER TABLE wacca_user_score
DROP COLUMN gradessct;
ALTER TABLE wacca_user_score
DROP COLUMN gradesssct;
ALTER TABLE wacca_user_score
DROP COLUMN missless_ct;
ALTER TABLE wacca_user_score
DROP COLUMN play_ct;
ALTER TABLE wacca_user_playlog RENAME COLUMN chart_id TO difficulty;
ALTER TABLE wacca_user_playlog
DROP COLUMN good_ct;
ALTER TABLE wacca_user_playlog
DROP COLUMN great_ct;
ALTER TABLE wacca_user_playlog
DROP COLUMN marv_ct;
ALTER TABLE wacca_user_playlog
DROP COLUMN miss_ct;
ALTER TABLE wacca_user_playlog
DROP COLUMN season;
ALTER TABLE wacca_user_playlog
DROP COLUMN clear;
ALTER TABLE wacca_user_playlog
DROP COLUMN date_scored;
ALTER TABLE wacca_user_item
MODIFY acquired_date datetime NOT NULL;
ALTER TABLE wacca_user_playlog
ADD clear BIT(1) NOT NULL;
ALTER TABLE wacca_user_playlog
ADD date_scored datetime NOT NULL;