Save / load deck info
This fixed game crashing when fetching "/main.php/live/reward" Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
+9
-22
@@ -428,7 +428,7 @@ func PlayScoreHandler(ctx *gin.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println(string(mm))
|
// fmt.Println(string(mm))
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||||
@@ -503,27 +503,14 @@ func PlayRewardHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK UnitList
|
|
||||||
unitsList := []model.PlayRewardUnitList{}
|
unitsList := []model.PlayRewardUnitList{}
|
||||||
unitId := 3071290940
|
deck, err := database.LevelDb.Get([]byte("deck_info"))
|
||||||
for i := 0; i < 9; i++ {
|
if err != nil {
|
||||||
unitList := model.PlayRewardUnitList{
|
panic(err)
|
||||||
UnitOwningUserID: int64(unitId + i),
|
}
|
||||||
UnitID: 2122,
|
err = json.Unmarshal(deck, &unitsList)
|
||||||
Position: i + 1,
|
if err != nil {
|
||||||
Level: 120,
|
panic(err)
|
||||||
LevelLimitID: 1,
|
|
||||||
DisplayRank: 2,
|
|
||||||
Love: 1000,
|
|
||||||
UnitSkillLevel: 8,
|
|
||||||
IsRankMax: true,
|
|
||||||
IsLoveMax: true,
|
|
||||||
IsLevelMax: true,
|
|
||||||
IsSigned: true,
|
|
||||||
BeforeLove: 1000,
|
|
||||||
MaxLove: 1000,
|
|
||||||
}
|
|
||||||
unitsList = append(unitsList, unitList)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
|
totalScore := playRewardReq.ScoreSmile + playRewardReq.ScoreCool + playRewardReq.ScoreCute
|
||||||
@@ -689,7 +676,7 @@ func PlayRewardHandler(ctx *gin.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println(string(mm))
|
// fmt.Println(string(mm))
|
||||||
|
|
||||||
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
xms := encrypt.RSA_Sign_SHA1(mm, "privatekey.pem")
|
||||||
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
xms64 := base64.RawStdEncoding.EncodeToString(xms)
|
||||||
|
|||||||
+14
-14
@@ -398,20 +398,20 @@ type EffortPoint struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PlayRewardUnitList struct {
|
type PlayRewardUnitList struct {
|
||||||
UnitOwningUserID int64 `json:"unit_owning_user_id"`
|
UnitOwningUserID int `json:"unit_owning_user_id"`
|
||||||
UnitID int `json:"unit_id"`
|
UnitID int `json:"unit_id"`
|
||||||
Position int `json:"position"`
|
Position int `json:"position"`
|
||||||
Level int `json:"level"`
|
Level int `json:"level"`
|
||||||
LevelLimitID int `json:"level_limit_id"`
|
LevelLimitID int `json:"level_limit_id"`
|
||||||
DisplayRank int `json:"display_rank"`
|
DisplayRank int `json:"display_rank"`
|
||||||
Love int `json:"love"`
|
Love int `json:"love"`
|
||||||
UnitSkillLevel int `json:"unit_skill_level"`
|
UnitSkillLevel int `json:"unit_skill_level"`
|
||||||
IsRankMax bool `json:"is_rank_max"`
|
IsRankMax bool `json:"is_rank_max"`
|
||||||
IsLoveMax bool `json:"is_love_max"`
|
IsLoveMax bool `json:"is_love_max"`
|
||||||
IsLevelMax bool `json:"is_level_max"`
|
IsLevelMax bool `json:"is_level_max"`
|
||||||
IsSigned bool `json:"is_signed"`
|
IsSigned bool `json:"is_signed"`
|
||||||
BeforeLove int `json:"before_love"`
|
BeforeLove int `json:"before_love"`
|
||||||
MaxLove int `json:"max_love"`
|
MaxLove int `json:"max_love"`
|
||||||
// Costume Costume `json:"costume,omitempty"`
|
// Costume Costume `json:"costume,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+32
-5
@@ -4,6 +4,7 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"honoka-chan/database"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -127,7 +128,7 @@ func GenApi1Data() {
|
|||||||
oId := 3000000000 // 起始卡片 ID,随意设置
|
oId := 3000000000 // 起始卡片 ID,随意设置
|
||||||
sdt := time.Now().Add(-time.Hour * 24 * 30)
|
sdt := time.Now().Add(-time.Hour * 24 * 30)
|
||||||
|
|
||||||
defaultDeckUnits := []int{}
|
defaultDeckUnitList := []model.PlayRewardUnitList{}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
unitData := model.Active{}
|
unitData := model.Active{}
|
||||||
@@ -242,7 +243,21 @@ func GenApi1Data() {
|
|||||||
case int64:
|
case int64:
|
||||||
if album_series_id == 615 {
|
if album_series_id == 615 {
|
||||||
// 仆光套
|
// 仆光套
|
||||||
defaultDeckUnits = append(defaultDeckUnits, oId)
|
defaultDeckUnitList = append(defaultDeckUnitList, model.PlayRewardUnitList{
|
||||||
|
UnitOwningUserID: oId,
|
||||||
|
UnitID: uid,
|
||||||
|
Level: 100,
|
||||||
|
LevelLimitID: 2,
|
||||||
|
DisplayRank: 2,
|
||||||
|
Love: 1000,
|
||||||
|
UnitSkillLevel: 8,
|
||||||
|
IsRankMax: true,
|
||||||
|
IsLoveMax: true,
|
||||||
|
IsLevelMax: true,
|
||||||
|
IsSigned: unitData.IsSigned,
|
||||||
|
BeforeLove: 1000,
|
||||||
|
MaxLove: 1000,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,10 +276,12 @@ func GenApi1Data() {
|
|||||||
|
|
||||||
// unit_deck_result
|
// unit_deck_result
|
||||||
oUids := []model.UnitOwningUserIds{}
|
oUids := []model.UnitOwningUserIds{}
|
||||||
for k, v := range defaultDeckUnits[0:9] {
|
for k, v := range defaultDeckUnitList[0:9] {
|
||||||
|
position := k + 1
|
||||||
|
defaultDeckUnitList[k].Position = position
|
||||||
oUids = append(oUids, model.UnitOwningUserIds{
|
oUids = append(oUids, model.UnitOwningUserIds{
|
||||||
Position: k + 1,
|
Position: position,
|
||||||
UnitOwningUserID: v,
|
UnitOwningUserID: v.UnitOwningUserID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
unitDeckResp := model.UnitDeckInfoResp{
|
unitDeckResp := model.UnitDeckInfoResp{
|
||||||
@@ -283,6 +300,16 @@ func GenApi1Data() {
|
|||||||
}
|
}
|
||||||
respAll = append(respAll, unitDeckResp)
|
respAll = append(respAll, unitDeckResp)
|
||||||
|
|
||||||
|
// HACK 保存卡组信息
|
||||||
|
deck, err := json.Marshal(defaultDeckUnitList)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = database.LevelDb.Put([]byte("deck_info"), deck)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
// unit_support_result
|
// unit_support_result
|
||||||
unitSupportResp := model.UnitSupportResp{
|
unitSupportResp := model.UnitSupportResp{
|
||||||
// _ = model.UnitSupportResp{
|
// _ = model.UnitSupportResp{
|
||||||
|
|||||||
Reference in New Issue
Block a user