You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rogueserver/api/savedata/system.go

44 lines
871 B
Go

package savedata
import (
"fmt"
"github.com/pagefaultgames/rogueserver/db"
"github.com/pagefaultgames/rogueserver/defs"
)
func GetSystem(uuid []byte) (defs.SystemSaveData, error) {
system, err := db.ReadSystemSaveData(uuid)
if err != nil {
return system, err
}
return system, nil
}
func UpdateSystem(uuid []byte, data defs.SystemSaveData) error {
if data.TrainerId == 0 && data.SecretId == 0 {
return fmt.Errorf("invalid system data")
}
if data.GameVersion != "1.0.4" {
return fmt.Errorf("client version out of date")
}
err := db.UpdateAccountStats(uuid, data.GameStats, data.VoucherCounts)
if err != nil {
return fmt.Errorf("failed to update account stats: %s", err)
}
return db.StoreSystemSaveData(uuid, data)
}
func DeleteSystem(uuid []byte) error {
err := db.DeleteSystemSaveData(uuid)
if err != nil {
return err
}
return nil
}