mirror of
https://github.com/Walter-Sparrow/lunar-tear.git
synced 2026-07-02 05:43:41 +03:00
Implement Fate Boards
Build and Push Docker images to Docker Hub / build-and-push (push) Has been cancelled
Build and Push Docker images to Docker Hub / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -27,6 +27,8 @@ func CloneUserState(u UserState) UserState {
|
||||
}
|
||||
out.CageOrnamentRewards = maps.Clone(u.CageOrnamentRewards)
|
||||
out.TowerAccumulationRewards = maps.Clone(u.TowerAccumulationRewards)
|
||||
out.LabyrinthSeasons = maps.Clone(u.LabyrinthSeasons)
|
||||
out.LabyrinthStages = maps.Clone(u.LabyrinthStages)
|
||||
out.ConsumableItems = maps.Clone(u.ConsumableItems)
|
||||
out.Materials = maps.Clone(u.Materials)
|
||||
out.Parts = maps.Clone(u.Parts)
|
||||
|
||||
@@ -125,6 +125,8 @@ func SeedUserState(userId int64, uuid string, nowMillis int64, platform model.Cl
|
||||
},
|
||||
CageOrnamentRewards: make(map[int32]CageOrnamentRewardState),
|
||||
TowerAccumulationRewards: make(map[int32]TowerAccumulationRewardState),
|
||||
LabyrinthSeasons: make(map[int32]LabyrinthSeasonState),
|
||||
LabyrinthStages: make(map[LabyrinthStageKey]LabyrinthStageState),
|
||||
ConsumableItems: make(map[int32]int32),
|
||||
Materials: make(map[int32]int32),
|
||||
Thoughts: make(map[string]ThoughtState),
|
||||
|
||||
@@ -78,6 +78,8 @@ func initMaps(u *store.UserState) {
|
||||
u.ExploreScores = make(map[int32]store.ExploreScoreState)
|
||||
u.CageOrnamentRewards = make(map[int32]store.CageOrnamentRewardState)
|
||||
u.TowerAccumulationRewards = make(map[int32]store.TowerAccumulationRewardState)
|
||||
u.LabyrinthSeasons = make(map[int32]store.LabyrinthSeasonState)
|
||||
u.LabyrinthStages = make(map[store.LabyrinthStageKey]store.LabyrinthStageState)
|
||||
u.CharacterBoards = make(map[int32]store.CharacterBoardState)
|
||||
u.CharacterBoardAbilities = make(map[store.CharacterBoardAbilityKey]store.CharacterBoardAbilityState)
|
||||
u.CharacterBoardStatusUps = make(map[store.CharacterBoardStatusUpKey]store.CharacterBoardStatusUpState)
|
||||
@@ -659,6 +661,22 @@ func loadMapTables(db *sql.DB, uid int64, u *store.UserState) {
|
||||
u.TowerAccumulationRewards[v.EventQuestChapterId] = v
|
||||
})
|
||||
|
||||
queryRows(db, `SELECT event_quest_chapter_id, last_join_season_number, last_season_reward_received_season_number, latest_version
|
||||
FROM user_event_quest_labyrinth_seasons WHERE user_id=?`, uid, func(rows *sql.Rows) {
|
||||
var v store.LabyrinthSeasonState
|
||||
rows.Scan(&v.EventQuestChapterId, &v.LastJoinSeasonNumber, &v.LastSeasonRewardReceivedSeasonNumber, &v.LatestVersion)
|
||||
u.LabyrinthSeasons[v.EventQuestChapterId] = v
|
||||
})
|
||||
|
||||
queryRows(db, `SELECT event_quest_chapter_id, stage_order, is_received_stage_clear_reward, accumulation_reward_received_quest_mission_count, latest_version
|
||||
FROM user_event_quest_labyrinth_stages WHERE user_id=?`, uid, func(rows *sql.Rows) {
|
||||
var v store.LabyrinthStageState
|
||||
var rcvd int
|
||||
rows.Scan(&v.EventQuestChapterId, &v.StageOrder, &rcvd, &v.AccumulationRewardReceivedQuestMissionCount, &v.LatestVersion)
|
||||
v.IsReceivedStageClearReward = rcvd != 0
|
||||
u.LabyrinthStages[store.LabyrinthStageKey{EventQuestChapterId: v.EventQuestChapterId, StageOrder: v.StageOrder}] = v
|
||||
})
|
||||
|
||||
queryRows(db, `SELECT shop_item_id, bought_count, latest_bought_count_changed_datetime, latest_version
|
||||
FROM user_shop_items WHERE user_id=?`, uid, func(rows *sql.Rows) {
|
||||
var v store.UserShopItemState
|
||||
|
||||
@@ -460,6 +460,18 @@ func writeUserState(tx *sql.Tx, uid int64, u *store.UserState) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for _, v := range u.LabyrinthSeasons {
|
||||
if err := exec(`INSERT INTO user_event_quest_labyrinth_seasons (user_id, event_quest_chapter_id, last_join_season_number, last_season_reward_received_season_number, latest_version) VALUES (?,?,?,?,?)`,
|
||||
uid, v.EventQuestChapterId, v.LastJoinSeasonNumber, v.LastSeasonRewardReceivedSeasonNumber, v.LatestVersion); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for k, v := range u.LabyrinthStages {
|
||||
if err := exec(`INSERT INTO user_event_quest_labyrinth_stages (user_id, event_quest_chapter_id, stage_order, is_received_stage_clear_reward, accumulation_reward_received_quest_mission_count, latest_version) VALUES (?,?,?,?,?,?)`,
|
||||
uid, k.EventQuestChapterId, k.StageOrder, boolToInt(v.IsReceivedStageClearReward), v.AccumulationRewardReceivedQuestMissionCount, v.LatestVersion); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for _, v := range u.ShopItems {
|
||||
if err := exec(`INSERT INTO user_shop_items (user_id, shop_item_id, bought_count, latest_bought_count_changed_datetime, latest_version) VALUES (?,?,?,?,?)`,
|
||||
uid, v.ShopItemId, v.BoughtCount, v.LatestBoughtCountChangedDatetime, v.LatestVersion); err != nil {
|
||||
@@ -1005,6 +1017,22 @@ func diffAndSave(tx *sql.Tx, uid int64, before, after *store.UserState) error {
|
||||
return []any{v.EventQuestChapterId, v.LatestRewardReceiveQuestMissionClearCount, v.LatestVersion}
|
||||
},
|
||||
"event_quest_chapter_id, latest_reward_receive_quest_mission_clear_count, latest_version")
|
||||
diffMapInt32(tx, uid, before.LabyrinthSeasons, after.LabyrinthSeasons, "user_event_quest_labyrinth_seasons", "event_quest_chapter_id",
|
||||
func(v store.LabyrinthSeasonState) []any {
|
||||
return []any{v.EventQuestChapterId, v.LastJoinSeasonNumber, v.LastSeasonRewardReceivedSeasonNumber, v.LatestVersion}
|
||||
},
|
||||
"event_quest_chapter_id, last_join_season_number, last_season_reward_received_season_number, latest_version")
|
||||
for k, v := range after.LabyrinthStages {
|
||||
if old, ok := before.LabyrinthStages[k]; !ok || old != v {
|
||||
exec(`INSERT OR REPLACE INTO user_event_quest_labyrinth_stages (user_id, event_quest_chapter_id, stage_order, is_received_stage_clear_reward, accumulation_reward_received_quest_mission_count, latest_version) VALUES (?,?,?,?,?,?)`,
|
||||
uid, k.EventQuestChapterId, k.StageOrder, boolToInt(v.IsReceivedStageClearReward), v.AccumulationRewardReceivedQuestMissionCount, v.LatestVersion)
|
||||
}
|
||||
}
|
||||
for k := range before.LabyrinthStages {
|
||||
if _, ok := after.LabyrinthStages[k]; !ok {
|
||||
exec(`DELETE FROM user_event_quest_labyrinth_stages WHERE user_id=? AND event_quest_chapter_id=? AND stage_order=?`, uid, k.EventQuestChapterId, k.StageOrder)
|
||||
}
|
||||
}
|
||||
diffMapInt32(tx, uid, before.ShopItems, after.ShopItems, "user_shop_items", "shop_item_id",
|
||||
func(v store.UserShopItemState) []any {
|
||||
return []any{v.ShopItemId, v.BoughtCount, v.LatestBoughtCountChangedDatetime, v.LatestVersion}
|
||||
|
||||
@@ -79,6 +79,8 @@ func (s *SQLiteStore) ImportUser(u *store.UserState) error {
|
||||
|
||||
// Child tables in reverse-dependency order (matches schema's goose Down).
|
||||
childTables := []string{
|
||||
"user_event_quest_labyrinth_stages",
|
||||
"user_event_quest_labyrinth_seasons",
|
||||
"user_event_quest_tower_accumulation_rewards",
|
||||
"user_cage_ornament_rewards",
|
||||
"user_shop_replaceable_lineup",
|
||||
|
||||
@@ -78,6 +78,8 @@ type UserState struct {
|
||||
Gimmick GimmickState
|
||||
CageOrnamentRewards map[int32]CageOrnamentRewardState
|
||||
TowerAccumulationRewards map[int32]TowerAccumulationRewardState
|
||||
LabyrinthSeasons map[int32]LabyrinthSeasonState
|
||||
LabyrinthStages map[LabyrinthStageKey]LabyrinthStageState
|
||||
ConsumableItems map[int32]int32
|
||||
Materials map[int32]int32
|
||||
Parts map[string]PartsState
|
||||
@@ -196,6 +198,12 @@ func (u *UserState) EnsureMaps() {
|
||||
if u.TowerAccumulationRewards == nil {
|
||||
u.TowerAccumulationRewards = make(map[int32]TowerAccumulationRewardState)
|
||||
}
|
||||
if u.LabyrinthSeasons == nil {
|
||||
u.LabyrinthSeasons = make(map[int32]LabyrinthSeasonState)
|
||||
}
|
||||
if u.LabyrinthStages == nil {
|
||||
u.LabyrinthStages = make(map[LabyrinthStageKey]LabyrinthStageState)
|
||||
}
|
||||
if u.ConsumableItems == nil {
|
||||
u.ConsumableItems = make(map[int32]int32)
|
||||
}
|
||||
@@ -878,6 +886,27 @@ type TowerAccumulationRewardState struct {
|
||||
LatestVersion int64
|
||||
}
|
||||
|
||||
type LabyrinthSeasonState struct {
|
||||
EventQuestChapterId int32
|
||||
LastJoinSeasonNumber int32
|
||||
LastSeasonRewardReceivedSeasonNumber int32
|
||||
LatestVersion int64
|
||||
}
|
||||
|
||||
// LabyrinthStageKey is the composite key for UserState.LabyrinthStages.
|
||||
type LabyrinthStageKey struct {
|
||||
EventQuestChapterId int32
|
||||
StageOrder int32
|
||||
}
|
||||
|
||||
type LabyrinthStageState struct {
|
||||
EventQuestChapterId int32
|
||||
StageOrder int32
|
||||
IsReceivedStageClearReward bool
|
||||
AccumulationRewardReceivedQuestMissionCount int32
|
||||
LatestVersion int64
|
||||
}
|
||||
|
||||
type PartsState struct {
|
||||
UserPartsUuid string
|
||||
PartsId int32
|
||||
|
||||
Reference in New Issue
Block a user