|
|
@ -25,19 +25,28 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// /savedata/newclear - return whether a session is a new clear for its seed
|
|
|
|
// /savedata/newclear - return whether a session is a new clear for its seed
|
|
|
|
func NewClear(uuid []byte, slot int) (bool, error) {
|
|
|
|
func NewClear(uuid []byte, slot int, result bool) (bool, error) {
|
|
|
|
if slot < 0 || slot >= defs.SessionSlotCount {
|
|
|
|
if slot < 0 || slot >= defs.SessionSlotCount {
|
|
|
|
return false, fmt.Errorf("slot id %d out of range", slot)
|
|
|
|
return false, fmt.Errorf("slot id %d out of range", slot)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
session, err := db.ReadSessionSaveData(uuid, slot)
|
|
|
|
session, err := db.ReadSessionSaveData(uuid, slot)
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gameMode := getGameModeKey(session.GameMode)
|
|
|
|
completed, err := db.ReadSeedCompleted(uuid, session.Seed)
|
|
|
|
waveIndex := fmt.Sprintf("%d", session.WaveIndex)
|
|
|
|
if err != nil {
|
|
|
|
completed := true
|
|
|
|
return false, fmt.Errorf("failed to read seed completed: %s", err)
|
|
|
|
if result {
|
|
|
|
|
|
|
|
runResultCounter.WithLabelValues("victory", waveIndex, gameMode).Inc()
|
|
|
|
|
|
|
|
completed, err := db.ReadSeedCompleted(uuid, session.Seed)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return false, fmt.Errorf("failed to read seed completed: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return !completed, err
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
runResultCounter.WithLabelValues("loss", waveIndex, gameMode).Inc()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return !completed, nil
|
|
|
|
return !completed, nil
|
|
|
|