Add score to session save data

This commit is contained in:
Flashfyre committed 2024-03-17 11:34:11 -04:00
1 parent 5214c4aff4
commit 71889f7daa
3 files changed
+13 -8

No files matched your search

+2
View File
@@ -63,6 +63,7 @@ type SessionSaveData struct {
Arena ArenaData `json:"arena"`
PokeballCounts PokeballCounts `json:"pokeballCounts"`
Money int `json:"money"`
Score int `json:"score"`
WaveIndex int `json:"waveIndex"`
BattleType BattleType `json:"battleType"`
Trainer TrainerData `json:"trainer"`
@@ -92,6 +93,7 @@ type SessionHistoryData struct {
Party []PokemonData `json:"party"`
Modifiers []PersistentModifierData `json:"modifiers"`
Money int `json:"money"`
Score int `json:"score"`
WaveIndex int `json:"waveIndex"`
BattleType BattleType `json:"battleType"`
GameVersion string `json:"gameVersion"`
+5 -4
View File
@@ -268,9 +268,10 @@ func (s *Server) HandleSavedataClear(w http.ResponseWriter, r *http.Request) {
return
}
session, err := GetSessionSaveData(uuid, slotId)
var session SessionSaveData
err = json.NewDecoder(r.Body).Decode(&session)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("failed to decode request body: %s", err), http.StatusBadRequest)
return
}
@@ -278,9 +279,9 @@ func (s *Server) HandleSavedataClear(w http.ResponseWriter, r *http.Request) {
newCompletion := false
if sessionCompleted {
newCompletion, err = db.TryAddSeedCompletion(uuid, session.Seed, int(session.GameMode))
newCompletion, err = db.TryAddSeedCompletion(uuid, session.Seed, int(session.GameMode), session.Score)
if err != nil {
log.Print("failed to mark seed as completed")
log.Printf("failed to mark seed as completed: %s", err.Error())
}
}