fixed lots of bugs
This commit is contained in:
285
utils/helper.go
285
utils/helper.go
@@ -220,3 +220,288 @@ func GetScoreRank(score float64, difficultyMaster map[string]any) string {
|
||||
return "c"
|
||||
}
|
||||
}
|
||||
|
||||
func BuildDecoEquipment(userid string, user map[string]any, m map[string]any) map[string]any {
|
||||
decos, _ := user["decos"].(map[string]any)
|
||||
if decos == nil {
|
||||
decos = map[string]any{}
|
||||
}
|
||||
wc, _ := user["wearingCostume"].(map[string]any)
|
||||
|
||||
decks := user["decks"].([]any)
|
||||
mainDeckIdx := 1
|
||||
if md, ok := user["mainDeck"].(float64); ok {
|
||||
mainDeckIdx = int(md)
|
||||
}
|
||||
mainDeck := decks[mainDeckIdx-1].(map[string]any)
|
||||
|
||||
charSituationMap := m["masterCharacterSituationMap"].(map[string]any)["entries"].(map[string]any)
|
||||
leaderSitId := fmt.Sprintf("%v", mainDeck["leader"])
|
||||
leaderEntry, _ := charSituationMap[leaderSitId].(map[string]any)
|
||||
leaderCharId := any(nil)
|
||||
leaderCharIdStr := ""
|
||||
if leaderEntry != nil {
|
||||
leaderCharId = leaderEntry["characterId"]
|
||||
leaderCharIdStr = fmt.Sprintf("%v", leaderCharId)
|
||||
}
|
||||
|
||||
decoSit, _ := decos["situation"].(map[string]any)
|
||||
decoSitId := any(1)
|
||||
decoSitStatus := any("normal")
|
||||
if decoSit != nil {
|
||||
decoSitId = decoSit["situationId"]
|
||||
decoSitStatus = decoSit["situationStatus"]
|
||||
}
|
||||
|
||||
decoL2d, _ := decos["live2d"].(map[string]any)
|
||||
l2dCharId := leaderCharId
|
||||
l2dCostumeId := any(nil)
|
||||
if wc != nil && wc[leaderCharIdStr] != nil {
|
||||
l2dCostumeId = wc[leaderCharIdStr].(map[string]any)["costumeId"]
|
||||
}
|
||||
l2dMotionId := any(nil)
|
||||
if decoL2dMap, ok := m["masterDecoCharacterLive2dMotionMap"].(map[string]any); ok {
|
||||
var firstMotion map[string]any
|
||||
for _, v := range decoL2dMap["entries"].(map[string]any) {
|
||||
mot := v.(map[string]any)
|
||||
if fmt.Sprintf("%v", mot["characterId"]) == leaderCharIdStr {
|
||||
if firstMotion == nil || mot["seq"].(float64) < firstMotion["seq"].(float64) {
|
||||
firstMotion = mot
|
||||
}
|
||||
}
|
||||
}
|
||||
if firstMotion != nil {
|
||||
l2dMotionId = firstMotion["motionId"]
|
||||
}
|
||||
}
|
||||
l2dBackgroundId := any(1)
|
||||
if decoL2d != nil {
|
||||
if v, ok := decoL2d["characterId"]; ok {
|
||||
l2dCharId = v
|
||||
}
|
||||
if v, ok := decoL2d["costumeId"]; ok {
|
||||
l2dCostumeId = v
|
||||
}
|
||||
if v, ok := decoL2d["motionId"]; ok {
|
||||
l2dMotionId = v
|
||||
}
|
||||
if v, ok := decoL2d["backgroundId"]; ok {
|
||||
l2dBackgroundId = v
|
||||
}
|
||||
}
|
||||
|
||||
deco3d, _ := decos["3d"].(map[string]any)
|
||||
d3dCharId := leaderCharId
|
||||
d3dDressId := any(nil)
|
||||
d3dHairstyleId := any(nil)
|
||||
if wc != nil && wc[leaderCharIdStr] != nil {
|
||||
d3dDressId = wc[leaderCharIdStr].(map[string]any)["dressId"]
|
||||
d3dHairstyleId = wc[leaderCharIdStr].(map[string]any)["hairstyleId"]
|
||||
}
|
||||
d3dMotionId := any(nil)
|
||||
if em3Map, ok := m["masterEnableCharacter3dMotionTypeMap"].(map[string]any); ok {
|
||||
if charEntry, ok := em3Map["entries"].(map[string]any)[leaderCharIdStr].(map[string]any); ok {
|
||||
if decoEntry, ok := charEntry["entries"].(map[string]any)["deco"].(map[string]any); ok {
|
||||
if entries, ok := decoEntry["entries"].([]any); ok {
|
||||
var first map[string]any
|
||||
for _, e := range entries {
|
||||
entry := e.(map[string]any)
|
||||
if first == nil || entry["seq"].(float64) < first["seq"].(float64) {
|
||||
first = entry
|
||||
}
|
||||
}
|
||||
if first != nil {
|
||||
d3dMotionId = first["motionId"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
d3dBackgroundId := any(11)
|
||||
if deco3d != nil {
|
||||
if v, ok := deco3d["characterId"]; ok {
|
||||
d3dCharId = v
|
||||
}
|
||||
if v, ok := deco3d["dressId"]; ok {
|
||||
d3dDressId = v
|
||||
}
|
||||
if v, ok := deco3d["hairstyleId"]; ok {
|
||||
d3dHairstyleId = v
|
||||
}
|
||||
if v, ok := deco3d["motionId"]; ok {
|
||||
d3dMotionId = v
|
||||
}
|
||||
if v, ok := deco3d["backgroundId"]; ok {
|
||||
d3dBackgroundId = v
|
||||
}
|
||||
}
|
||||
|
||||
frameId := any(1)
|
||||
if v, ok := decos["frameId"]; ok {
|
||||
frameId = v
|
||||
}
|
||||
framepins, _ := decos["framepins"].([]any)
|
||||
getPin := func(i int) any {
|
||||
if framepins != nil && i < len(framepins) {
|
||||
return framepins[i]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
userProfileDegree := BuildUserProfileDegree(userid, user)
|
||||
decoProfileDegree := map[string]any{}
|
||||
for k, v := range userProfileDegree {
|
||||
entry := v.(map[string]any)
|
||||
decoProfileDegree[k] = map[string]any{
|
||||
"decoFrameId": entry["userId"],
|
||||
"profileDegreeType": entry["profileDegreeType"],
|
||||
"degreeId": entry["degreeId"],
|
||||
}
|
||||
}
|
||||
|
||||
decoEffectId := any(1)
|
||||
if v, ok := decos["effect"]; ok {
|
||||
decoEffectId = v
|
||||
}
|
||||
|
||||
return map[string]any{
|
||||
"userDecoCharacterSituation": map[string]any{
|
||||
"userId": userid,
|
||||
"situationId": decoSitId,
|
||||
"situationStatus": decoSitStatus,
|
||||
},
|
||||
"userDecoCharacterLive2d": map[string]any{
|
||||
"userId": userid,
|
||||
"characterId": l2dCharId,
|
||||
"costumeId": l2dCostumeId,
|
||||
"motionId": l2dMotionId,
|
||||
"backgroundId": l2dBackgroundId,
|
||||
},
|
||||
"userDecoCharacter3d": map[string]any{
|
||||
"userId": userid,
|
||||
"characterId": d3dCharId,
|
||||
"dressId": d3dDressId,
|
||||
"hairstyleId": d3dHairstyleId,
|
||||
"motionId": d3dMotionId,
|
||||
"backgroundId": d3dBackgroundId,
|
||||
},
|
||||
"userDecoFramePins": map[string]any{
|
||||
"userId": userid,
|
||||
"decoFrameId": frameId,
|
||||
"decoPinsId1": getPin(0),
|
||||
"decoPinsId2": getPin(1),
|
||||
"decoPinsId3": getPin(2),
|
||||
"decoPinsId4": getPin(3),
|
||||
"decoPinsId5": getPin(4),
|
||||
},
|
||||
"userDecoDegreeMap": map[string]any{"entries": decoProfileDegree},
|
||||
"userDecoAppealMap": map[string]any{},
|
||||
"userDecoSetting": map[string]any{
|
||||
"useProfileSettingDegree": user["useProfileSettingDegree"],
|
||||
"useProfileSettingSituation": user["useProfileSettingSituation"],
|
||||
"selectedCharacterType": user["selectedCharacterType"],
|
||||
},
|
||||
"userDecoEffect": map[string]any{
|
||||
"userId": userid,
|
||||
"decoEffectId": decoEffectId,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func BuildEventStoryMemorialMap(userid string, m map[string]any, past map[string]any) map[string]any {
|
||||
entries := map[string]any{}
|
||||
|
||||
pastStoryEntries := map[string]any{}
|
||||
if pse, ok := past["pastEventStoryMap"].(map[string]any); ok {
|
||||
if e, ok := pse["entries"].(map[string]any); ok {
|
||||
pastStoryEntries = e
|
||||
}
|
||||
}
|
||||
|
||||
if escMap, ok := m["masterEventStoryMemorialConfigMap"].(map[string]any); ok {
|
||||
for eventId := range escMap["entries"].(map[string]any) {
|
||||
length := 0
|
||||
if pe, ok := pastStoryEntries[eventId].(map[string]any); ok {
|
||||
if en, ok := pe["entries"].([]any); ok {
|
||||
length = len(en)
|
||||
}
|
||||
}
|
||||
storyEntries := make([]any, length)
|
||||
for i := range storyEntries {
|
||||
storyEntries[i] = map[string]any{
|
||||
"userId": userid,
|
||||
"eventId": eventId,
|
||||
"seq": i,
|
||||
"status": "already_read",
|
||||
}
|
||||
}
|
||||
entries[eventId] = map[string]any{
|
||||
"eventId": eventId,
|
||||
"userEventStoryList": map[string]any{
|
||||
"entries": storyEntries,
|
||||
},
|
||||
"isExistUnReadStory": false,
|
||||
"isLocked": false,
|
||||
}
|
||||
}
|
||||
}
|
||||
return entries
|
||||
}
|
||||
|
||||
func GetMusicInfo(master map[string]any, musicid string, difficulty string) map[string]any {
|
||||
musicList, _ := master["masterMusicDifficultyList"].(map[string]any)
|
||||
entries, _ := musicList["entries"].([]any)
|
||||
|
||||
for _, raw := range entries {
|
||||
entry, ok := raw.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if fmt.Sprintf("%v", entry["musicId"]) == musicid &&
|
||||
fmt.Sprintf("%v", entry["difficulty"]) == difficulty {
|
||||
return entry
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func BuildMusicScoreMap(user map[string]any) map[string]any {
|
||||
result := map[string]any{
|
||||
"entries": map[string]any{},
|
||||
}
|
||||
|
||||
entries := result["entries"].(map[string]any)
|
||||
|
||||
musicScore, _ := user["musicScore"].(map[string]any)
|
||||
for musicid, raw := range musicScore {
|
||||
scoreData, _ := raw.(map[string]any)
|
||||
scoreEntries, _ := scoreData["entries"].([]any)
|
||||
|
||||
normalizedEntries := make([]any, 0, len(scoreEntries))
|
||||
|
||||
for _, rawScore := range scoreEntries {
|
||||
score, ok := rawScore.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
normalizedEntries = append(normalizedEntries, map[string]any{
|
||||
"userId": fmt.Sprintf("%v", user["userId"]),
|
||||
"musicId": musicid,
|
||||
"musicDifficulty": score["musicDifficulty"],
|
||||
"soloHighScore": score["soloHighScore"],
|
||||
"maxCombo": score["maxCombo"],
|
||||
"soloScoreRank": score["soloScoreRank"],
|
||||
"clearStatus": score["clearStatus"],
|
||||
})
|
||||
}
|
||||
|
||||
entries[musicid] = map[string]any{
|
||||
"entries": normalizedEntries,
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user