Track player vouchers
parent
ba7ab22d4d
commit
a4014feea8
|
@ -66,7 +66,7 @@ func handleSavedataUpdate(uuid []byte, slot int, save any) error {
|
|||
return fmt.Errorf("invalid system data")
|
||||
}
|
||||
|
||||
err = db.UpdateAccountStats(uuid, save.GameStats)
|
||||
err = db.UpdateAccountStats(uuid, save.GameStats, save.VoucherCounts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update account stats: %s", err)
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ func UpdateAccountLastActivity(uuid []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func UpdateAccountStats(uuid []byte, stats defs.GameStats) error {
|
||||
var columns = []string{"playTime", "battles", "classicSessionsPlayed", "sessionsWon", "highestEndlessWave", "highestLevel", "pokemonSeen", "pokemonDefeated", "pokemonCaught", "pokemonHatched", "eggsPulled"}
|
||||
func UpdateAccountStats(uuid []byte, stats defs.GameStats, voucherCounts map[string]int) error {
|
||||
var columns = []string{"playTime", "battles", "classicSessionsPlayed", "sessionsWon", "highestEndlessWave", "highestLevel", "pokemonSeen", "pokemonDefeated", "pokemonCaught", "pokemonHatched", "eggsPulled", "regularVouchers", "plusVouchers", "premiumVouchers", "goldenVouchers"}
|
||||
|
||||
var statCols []string
|
||||
var statValues []interface{}
|
||||
|
@ -64,6 +64,24 @@ func UpdateAccountStats(uuid []byte, stats defs.GameStats) error {
|
|||
}
|
||||
}
|
||||
|
||||
for k, v := range voucherCounts {
|
||||
var column string
|
||||
switch k {
|
||||
case "0":
|
||||
column = "regularVouchers"
|
||||
case "1":
|
||||
column = "plusVouchers"
|
||||
case "2":
|
||||
column = "premiumVouchers"
|
||||
case "3":
|
||||
column = "goldenVouchers"
|
||||
default:
|
||||
continue
|
||||
}
|
||||
statCols = append(statCols, column)
|
||||
statValues = append(statValues, v)
|
||||
}
|
||||
|
||||
var statArgs []interface{}
|
||||
statArgs = append(statArgs, uuid)
|
||||
for range 2 {
|
||||
|
|
Loading…
Reference in New Issue