as: Save deck info

Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
2023-06-05 23:58:29 +08:00
parent 6f06b72585
commit 1508cf7812
7 changed files with 10444 additions and 9991 deletions
+1
View File
@@ -5,6 +5,7 @@ data
temp
assets/data.db
assets/dictionary_zh_k.db
assets/masterdata.db
static/llas-dev
+9960 -9960
View File
File diff suppressed because it is too large Load Diff
+122
View File
@@ -0,0 +1,122 @@
{
"user_model": {
"user_status": {
"name": {
"dot_under_text": "梦路2号机@果果厨"
},
"nickname": {
"dot_under_text": "梦路"
},
"last_login_at": 1684754024,
"rank": 122,
"exp": 416263,
"message": {
"dot_under_text": "B站主播:梦路_YumeMichi"
},
"recommend_card_master_id": 200013001,
"max_friend_num": 0,
"live_point_full_at": 1684158189,
"live_point_broken": 150,
"live_point_subscription_recovery_daily_count": 1,
"live_point_subscription_recovery_daily_reset_at": 1656259200,
"activity_point_count": 0,
"activity_point_reset_at": 1684123200,
"activity_point_payment_recovery_daily_count": 10,
"activity_point_payment_recovery_daily_reset_at": 1683734400,
"game_money": 115665089,
"card_exp": 32316167,
"free_sns_coin": 280,
"apple_sns_coin": 0,
"google_sns_coin": 0,
"cash": 0,
"subscription_coin": 30,
"birth_date": null,
"birth_month": 10,
"birth_day": 18,
"latest_live_deck_id": 1,
"main_lesson_deck_id": 1,
"favorite_member_id": 1,
"last_live_difficulty_id": 12092302,
"lp_magnification": 1,
"emblem_id": 13100608,
"device_token": "",
"tutorial_phase": 99,
"tutorial_end_at": 1622217482,
"login_days": 446,
"navi_tap_count": 1,
"navi_tap_recover_at": 1683043200,
"is_auto_mode": false,
"max_score_live_difficulty_master_id": 12037401,
"live_max_score": 40553270,
"max_combo_live_difficulty_master_id": 12037401,
"live_max_combo": 301,
"lesson_resume_status": 1,
"accessory_box_additional": 90,
"terms_of_use_version": 0,
"bootstrap_sifid_check_at": 1683178908,
"gdpr_version": 0,
"member_guild_member_master_id": 1,
"member_guild_last_updated_at": 1659485328
},
"user_member_by_member_id": [],
"user_card_by_card_id": [],
"user_suit_by_suit_id": [],
"user_live_deck_by_id": "DECK_INFO",
"user_live_party_by_id": "PARTY_INFO",
"user_lesson_deck_by_id": [],
"user_live_mv_deck_by_id": [],
"user_live_mv_deck_custom_by_id": [],
"user_live_difficulty_by_difficulty_id": [],
"user_story_main_by_story_main_id": [],
"user_story_main_selected_by_story_main_cell_id": [],
"user_voice_by_voice_id": [],
"user_emblem_by_emblem_id": [],
"user_gacha_ticket_by_ticket_id": [],
"user_gacha_point_by_point_id": [],
"user_lesson_enhancing_item_by_item_id": [],
"user_training_material_by_item_id": [],
"user_grade_up_item_by_item_id": [],
"user_custom_background_by_id": [],
"user_story_side_by_id": [],
"user_story_member_by_id": [],
"user_communication_member_detail_badge_by_id": [],
"user_story_event_history_by_id": [],
"user_recovery_lp_by_id": [],
"user_recovery_ap_by_id": [],
"user_mission_by_mission_id": [],
"user_daily_mission_by_mission_id": [],
"user_weekly_mission_by_mission_id": [],
"user_info_trigger_basic_by_trigger_id": [],
"user_info_trigger_card_grade_up_by_trigger_id": [],
"user_info_trigger_member_guild_support_item_expired_by_trigger_id": [],
"user_info_trigger_member_love_level_up_by_trigger_id": [],
"user_accessory_by_user_accessory_id": [],
"user_accessory_level_up_item_by_id": [],
"user_accessory_rarity_up_item_by_id": [],
"user_unlock_scenes_by_enum": [],
"user_scene_tips_by_enum": [],
"user_rule_description_by_id": [],
"user_exchange_event_point_by_id": [],
"user_school_idol_festival_id_reward_mission_by_id": [],
"user_gps_present_received_by_id": [],
"user_event_marathon_by_event_master_id": [],
"user_event_mining_by_event_master_id": [],
"user_event_coop_by_event_master_id": [],
"user_live_skip_ticket_by_id": [],
"user_story_event_unlock_item_by_id": [],
"user_event_marathon_booster_by_id": [],
"user_reference_book_by_id": [],
"user_review_request_process_flow_by_id": [],
"user_rank_exp_by_id": [],
"user_share_by_id": [],
"user_tower_by_tower_id": [],
"user_recovery_tower_card_used_count_item_by_recovery_tower_card_used_count_item_master_id": [],
"user_story_linkage_by_id": [],
"user_subscription_status_by_id": [],
"user_story_main_part_digest_movie_by_id": [],
"user_member_guild_by_id": [],
"user_member_guild_support_item_by_id": [],
"user_daily_theater_by_daily_theater_id": [],
"user_play_list_by_id": []
}
}
+92 -24
View File
@@ -195,30 +195,30 @@ type ReproInfo struct {
// AsCardInfo ...
type AsCardInfo struct {
CardMasterID int `json:"card_master_id"`
Level int `json:"level"`
Exp int `json:"exp"`
LovePoint int `json:"love_point"`
IsFavorite bool `json:"is_favorite"`
IsAwakening bool `json:"is_awakening"`
IsAwakeningImage bool `json:"is_awakening_image"`
IsAllTrainingActivated bool `json:"is_all_training_activated"`
TrainingActivatedCellCount int `json:"training_activated_cell_count"`
MaxFreePassiveSkill int `json:"max_free_passive_skill"`
Grade int `json:"grade"`
TrainingLife int `json:"training_life"`
TrainingAttack int `json:"training_attack"`
TrainingDexterity int `json:"training_dexterity"`
ActiveSkillLevel int `json:"active_skill_level"`
PassiveSkillALevel int `json:"passive_skill_a_level"`
PassiveSkillBLevel int `json:"passive_skill_b_level"`
PassiveSkillCLevel int `json:"passive_skill_c_level"`
AdditionalPassiveSkill1ID int `json:"additional_passive_skill_1_id"`
AdditionalPassiveSkill2ID int `json:"additional_passive_skill_2_id"`
AdditionalPassiveSkill3ID int `json:"additional_passive_skill_3_id"`
AdditionalPassiveSkill4ID int `json:"additional_passive_skill_4_id"`
AcquiredAt int `json:"acquired_at"`
IsNew bool `json:"is_new"`
CardMasterID int `json:"card_master_id"`
Level int `json:"level"`
Exp int `json:"exp"`
LovePoint int `json:"love_point"`
IsFavorite bool `json:"is_favorite"`
IsAwakening bool `json:"is_awakening"`
IsAwakeningImage bool `json:"is_awakening_image"`
IsAllTrainingActivated bool `json:"is_all_training_activated"`
TrainingActivatedCellCount int `json:"training_activated_cell_count"`
MaxFreePassiveSkill int `json:"max_free_passive_skill"`
Grade int `json:"grade"`
TrainingLife int `json:"training_life"`
TrainingAttack int `json:"training_attack"`
TrainingDexterity int `json:"training_dexterity"`
ActiveSkillLevel int `json:"active_skill_level"`
PassiveSkillALevel int `json:"passive_skill_a_level"`
PassiveSkillBLevel int `json:"passive_skill_b_level"`
PassiveSkillCLevel int `json:"passive_skill_c_level"`
AdditionalPassiveSkill1ID int `json:"additional_passive_skill_1_id"`
AdditionalPassiveSkill2ID int `json:"additional_passive_skill_2_id"`
AdditionalPassiveSkill3ID int `json:"additional_passive_skill_3_id"`
AdditionalPassiveSkill4ID int `json:"additional_passive_skill_4_id"`
AcquiredAt int64 `json:"acquired_at"`
IsNew bool `json:"is_new"`
}
// AsSuitInfo ...
@@ -340,6 +340,74 @@ type AsMemberLovePanelInfo struct {
MemberLovePanelCellIds []int `json:"member_love_panel_cell_ids"`
}
// AsCardRes ...
type AsCardRes struct {
ID int `xorm:"id"`
CardRarityType int `xorm:"card_rarity_type"`
MaxPassiveSkillSlot int `xorm:"max_passive_skill_slot"`
}
// AsSaveDeckReq ...
type AsSaveDeckReq struct {
DeckID int `json:"deck_id"`
CardWithSuit []int `json:"card_with_suit"`
SquadDict []interface{} `json:"squad_dict"`
}
// AsDeckSquadDict ...
type AsDeckSquadDict struct {
CardMasterIds []int `json:"card_master_ids"`
UserAccessoryIds []int64 `json:"user_accessory_ids"`
}
// AsDeckInfo ...
type AsDeckInfo struct {
UserLiveDeckID int `json:"user_live_deck_id"`
Name AsDeckName `json:"name"`
CardMasterID1 int `json:"card_master_id_1"`
CardMasterID2 int `json:"card_master_id_2"`
CardMasterID3 int `json:"card_master_id_3"`
CardMasterID4 int `json:"card_master_id_4"`
CardMasterID5 int `json:"card_master_id_5"`
CardMasterID6 int `json:"card_master_id_6"`
CardMasterID7 int `json:"card_master_id_7"`
CardMasterID8 int `json:"card_master_id_8"`
CardMasterID9 int `json:"card_master_id_9"`
SuitMasterID1 int `json:"suit_master_id_1"`
SuitMasterID2 int `json:"suit_master_id_2"`
SuitMasterID3 int `json:"suit_master_id_3"`
SuitMasterID4 int `json:"suit_master_id_4"`
SuitMasterID5 int `json:"suit_master_id_5"`
SuitMasterID6 int `json:"suit_master_id_6"`
SuitMasterID7 int `json:"suit_master_id_7"`
SuitMasterID8 int `json:"suit_master_id_8"`
SuitMasterID9 int `json:"suit_master_id_9"`
}
// AsDeckName ...
type AsDeckName struct {
DotUnderText string `json:"dot_under_text"`
}
// AsPartyInfo ...
type AsPartyInfo struct {
PartyID int `json:"party_id"`
UserLiveDeckID int `json:"user_live_deck_id"`
Name AsPartyName `json:"name"`
IconMasterID int `json:"icon_master_id"`
CardMasterID1 int `json:"card_master_id_1"`
CardMasterID2 int `json:"card_master_id_2"`
CardMasterID3 int `json:"card_master_id_3"`
UserAccessoryID1 int64 `json:"user_accessory_id_1"`
UserAccessoryID2 int64 `json:"user_accessory_id_2"`
UserAccessoryID3 int64 `json:"user_accessory_id_3"`
}
// AsPartyName ...
type AsPartyName struct {
DotUnderText string `json:"dot_under_text"`
}
// AsReq ...
type AsReq interface{}
+190 -7
View File
@@ -20,6 +20,7 @@ import (
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
"github.com/tidwall/gjson"
"xorm.io/xorm"
)
var (
@@ -638,15 +639,197 @@ func AsRouter(r *gin.Engine) {
ctx.String(http.StatusOK, resp)
})
s.POST("/navi/saveUserNaviVoice", func(ctx *gin.Context) {
reqBody := ctx.GetString("reqBody")
// var emblemId string
gjson.Parse(reqBody).ForEach(func(key, value gjson.Result) bool {
fmt.Println(value)
return true
})
// signBody := strings.ReplaceAll(utils.ReadAllText("assets/as/activateEmblem.json"), `"EMBLEM_ID"`, emblemId)
resp := SignResp(ctx.GetString("ep"), utils.ReadAllText("assets/as/saveUserNaviVoice.json"), sessionKey)
ctx.Header("Content-Type", "application/json")
ctx.String(http.StatusOK, resp)
})
s.POST("/liveDeck/saveDeckAll", func(ctx *gin.Context) {
reqBody := gjson.Parse(ctx.GetString("reqBody")).Array()[0]
// fmt.Println(reqBody.String())
mEng, err := xorm.NewEngine("sqlite", "assets/masterdata.db")
CheckErr(err)
err = mEng.Ping()
CheckErr(err)
defer mEng.Close()
dEng, err := xorm.NewEngine("sqlite", "assets/dictionary_zh_k.db")
CheckErr(err)
err = dEng.Ping()
CheckErr(err)
defer dEng.Close()
req := model.AsSaveDeckReq{}
decoder := json.NewDecoder(strings.NewReader(reqBody.String()))
decoder.UseNumber()
err = decoder.Decode(&req)
CheckErr(err)
// fmt.Println("Raw:", req.SquadDict)
if req.CardWithSuit[1] == 0 {
req.CardWithSuit[1] = req.CardWithSuit[0]
}
if req.CardWithSuit[3] == 0 {
req.CardWithSuit[3] = req.CardWithSuit[2]
}
if req.CardWithSuit[5] == 0 {
req.CardWithSuit[5] = req.CardWithSuit[4]
}
if req.CardWithSuit[7] == 0 {
req.CardWithSuit[7] = req.CardWithSuit[6]
}
if req.CardWithSuit[9] == 0 {
req.CardWithSuit[9] = req.CardWithSuit[8]
}
if req.CardWithSuit[11] == 0 {
req.CardWithSuit[11] = req.CardWithSuit[10]
}
if req.CardWithSuit[13] == 0 {
req.CardWithSuit[13] = req.CardWithSuit[12]
}
if req.CardWithSuit[15] == 0 {
req.CardWithSuit[15] = req.CardWithSuit[14]
}
if req.CardWithSuit[17] == 0 {
req.CardWithSuit[17] = req.CardWithSuit[16]
}
deckInfo := model.AsDeckInfo{
UserLiveDeckID: req.DeckID,
Name: model.AsDeckName{
DotUnderText: "队伍名称变了?",
},
CardMasterID1: req.CardWithSuit[0],
CardMasterID2: req.CardWithSuit[2],
CardMasterID3: req.CardWithSuit[4],
CardMasterID4: req.CardWithSuit[6],
CardMasterID5: req.CardWithSuit[8],
CardMasterID6: req.CardWithSuit[10],
CardMasterID7: req.CardWithSuit[12],
CardMasterID8: req.CardWithSuit[14],
CardMasterID9: req.CardWithSuit[16],
SuitMasterID1: req.CardWithSuit[1],
SuitMasterID2: req.CardWithSuit[3],
SuitMasterID3: req.CardWithSuit[5],
SuitMasterID4: req.CardWithSuit[7],
SuitMasterID5: req.CardWithSuit[9],
SuitMasterID6: req.CardWithSuit[11],
SuitMasterID7: req.CardWithSuit[13],
SuitMasterID8: req.CardWithSuit[15],
SuitMasterID9: req.CardWithSuit[17],
}
// fmt.Println(deckInfo)
deckInfoRes := []model.AsResp{}
deckInfoRes = append(deckInfoRes, req.DeckID)
deckInfoRes = append(deckInfoRes, deckInfo)
partyInfoRes := []model.AsResp{}
for k, v := range req.SquadDict {
if k%2 == 0 {
partyId, err := v.(json.Number).Int64()
CheckErr(err)
// fmt.Println("Party ID:", partyId)
rDictInfo, err := json.Marshal(req.SquadDict[k+1])
CheckErr(err)
dictInfo := model.AsDeckSquadDict{}
if err = json.Unmarshal(rDictInfo, &dictInfo); err != nil {
panic(err)
}
// fmt.Println("Party Info:", dictInfo)
roleIds := []int{}
err = mEng.Table("m_card").
Where("id IN (?,?,?)", dictInfo.CardMasterIds[0], dictInfo.CardMasterIds[1], dictInfo.CardMasterIds[2]).
Cols("role").Find(&roleIds)
CheckErr(err)
// fmt.Println("roleIds:", roleIds)
var partyIcon int
var partyName string
// 脑残逻辑部分
exists, err := mEng.Table("m_live_party_name").
Where("role_1 = ? AND role_2 = ? AND role_3 = ?", roleIds[0], roleIds[1], roleIds[2]).
Cols("name,live_party_icon").Get(&partyName, &partyIcon)
CheckErr(err)
if !exists {
exists, err = mEng.Table("m_live_party_name").
Where("role_1 = ? AND role_2 = ? AND role_3 = ?", roleIds[0], roleIds[2], roleIds[1]).
Cols("name,live_party_icon").Get(&partyName, &partyIcon)
CheckErr(err)
if !exists {
exists, err = mEng.Table("m_live_party_name").
Where("role_1 = ? AND role_2 = ? AND role_3 = ?", roleIds[1], roleIds[0], roleIds[2]).
Cols("name,live_party_icon").Get(&partyName, &partyIcon)
CheckErr(err)
if !exists {
exists, err = mEng.Table("m_live_party_name").
Where("role_1 = ? AND role_2 = ? AND role_3 = ?", roleIds[1], roleIds[2], roleIds[0]).
Cols("name,live_party_icon").Get(&partyName, &partyIcon)
CheckErr(err)
if !exists {
exists, err = mEng.Table("m_live_party_name").
Where("role_1 = ? AND role_2 = ? AND role_3 = ?", roleIds[2], roleIds[0], roleIds[1]).
Cols("name,live_party_icon").Get(&partyName, &partyIcon)
CheckErr(err)
if !exists {
exists, err = mEng.Table("m_live_party_name").
Where("role_1 = ? AND role_2 = ? AND role_3 = ?", roleIds[2], roleIds[1], roleIds[0]).
Cols("name,live_party_icon").Get(&partyName, &partyIcon)
CheckErr(err)
if !exists {
panic("Fuck you!")
}
}
}
}
}
}
var realPartyName string
_, err = dEng.Table("m_dictionary").Where("id = ?", strings.ReplaceAll(partyName, "k.", "")).Cols("message").Get(&realPartyName)
CheckErr(err)
partyInfo := model.AsPartyInfo{
PartyID: int(partyId),
UserLiveDeckID: req.DeckID,
Name: model.AsPartyName{
DotUnderText: realPartyName,
},
IconMasterID: partyIcon,
CardMasterID1: dictInfo.CardMasterIds[0],
CardMasterID2: dictInfo.CardMasterIds[1],
CardMasterID3: dictInfo.CardMasterIds[2],
UserAccessoryID1: dictInfo.UserAccessoryIds[0],
UserAccessoryID2: dictInfo.UserAccessoryIds[1],
UserAccessoryID3: dictInfo.UserAccessoryIds[2],
}
// fmt.Println(partyInfo)
partyInfoRes = append(partyInfoRes, partyId)
partyInfoRes = append(partyInfoRes, partyInfo)
}
}
// fmt.Println(deckInfoRes)
// fmt.Println(partyInfoRes)
m1, err := json.Marshal(deckInfoRes)
CheckErr(err)
m2, err := json.Marshal(partyInfoRes)
CheckErr(err)
respBody := utils.ReadAllText("assets/as/saveDeckAll.json")
respBody = strings.ReplaceAll(respBody, `"DECK_INFO"`, string(m1))
respBody = strings.ReplaceAll(respBody, `"PARTY_INFO"`, string(m2))
// fmt.Println(respBody)
resp := SignResp(ctx.GetString("ep"), respBody, sessionKey)
ctx.Header("Content-Type", "application/json")
ctx.String(http.StatusOK, resp)
})
+6
View File
@@ -8,6 +8,12 @@ import (
"time"
)
func CheckErr(err error) {
if err != nil {
panic(err)
}
}
func SignResp(ep, body, key string) (resp string) {
signBody := fmt.Sprintf("%d,\"%s\",0,%s", time.Now().UnixMilli(), config.MasterVersion, body)
sign := encrypt.HMAC_SHA1_Encrypt([]byte(ep+" "+signBody), []byte(key))
+73
View File
@@ -509,6 +509,79 @@ func init() {
// jsonStr = strings.TrimRight(jsonStr, ",")
// jsonStr += "]"
// fmt.Println(jsonStr)
// eng, err := xorm.NewEngine("sqlite", "assets/masterdata.db")
// CheckErr(err)
// err = eng.Ping()
// CheckErr(err)
// cardRes := []model.AsCardRes{}
// err = eng.Table("m_card").Cols("id,card_rarity_type,max_passive_skill_slot").OrderBy("id ASC").Find(&cardRes)
// CheckErr(err)
// jsonStr := "["
// for _, card := range cardRes {
// // 绊板等级加成
// cardLevel := 0
// cardCellCount := 0
// if card.CardRarityType == 10 {
// cardLevel = 40 + 42
// cardCellCount = 61
// } else if card.CardRarityType == 20 {
// cardLevel = 60 + 24
// cardCellCount = 75
// } else if card.CardRarityType == 30 {
// cardLevel = 80 + 12
// cardCellCount = 87
// }
// var apBuff, stBuff, teBuff int
// _, err := eng.Table("m_training_tree_card_param").Where("id = ? AND training_content_type = ?", card.ID, 2).Select("SUM(value)").Get(&stBuff)
// CheckErr(err)
// // fmt.Println(stBuff)
// _, err = eng.Table("m_training_tree_card_param").Where("id = ? AND training_content_type = ?", card.ID, 3).Select("SUM(value)").Get(&apBuff)
// CheckErr(err)
// // fmt.Println(apBuff)
// _, err = eng.Table("m_training_tree_card_param").Where("id = ? AND training_content_type = ?", card.ID, 4).Select("SUM(value)").Get(&teBuff)
// CheckErr(err)
// // fmt.Println(teBuff)
// cardInfo := model.AsCardInfo{
// CardMasterID: card.ID,
// Level: cardLevel,
// Exp: 0,
// LovePoint: 0,
// IsFavorite: false,
// IsAwakening: true,
// IsAwakeningImage: true,
// IsAllTrainingActivated: true,
// TrainingActivatedCellCount: cardCellCount,
// MaxFreePassiveSkill: card.MaxPassiveSkillSlot,
// Grade: 5,
// TrainingLife: stBuff,
// TrainingAttack: apBuff,
// TrainingDexterity: teBuff,
// ActiveSkillLevel: 5,
// PassiveSkillALevel: 5,
// PassiveSkillBLevel: 1,
// PassiveSkillCLevel: 1,
// AdditionalPassiveSkill1ID: 30000482,
// AdditionalPassiveSkill2ID: 30000482,
// AdditionalPassiveSkill3ID: 30000482,
// AdditionalPassiveSkill4ID: 30000482,
// AcquiredAt: time.Now().Unix(),
// IsNew: false,
// }
// m, err := json.Marshal(cardInfo)
// CheckErr(err)
// jsonStr += fmt.Sprintf("%d,%s,", card.ID, string(m))
// }
// jsonStr = strings.TrimRight(jsonStr, ",")
// jsonStr += "]"
// fmt.Println(jsonStr)
}
func CheckErr(err error) {