Ban if vouchers over a certain threshold

pull/4/head
maru 5 months ago
parent bc8084b70b
commit e184e9da91
No known key found for this signature in database
GPG Key ID: 37689350E9CD0F0D

@ -39,6 +39,13 @@ func Update(uuid []byte, slot int, save any) error {
return fmt.Errorf("client version out of date") return fmt.Errorf("client version out of date")
} }
if save.VoucherCounts["0"] > 300 ||
save.VoucherCounts["1"] > 150 ||
save.VoucherCounts["2"] > 100 ||
save.VoucherCounts["3"] > 10 {
db.UpdateAccountBanned(uuid, true)
}
err = db.UpdateAccountStats(uuid, save.GameStats, save.VoucherCounts) err = db.UpdateAccountStats(uuid, save.GameStats, save.VoucherCounts)
if err != nil { if err != nil {
return fmt.Errorf("failed to update account stats: %s", err) return fmt.Errorf("failed to update account stats: %s", err)

@ -127,6 +127,15 @@ func UpdateAccountStats(uuid []byte, stats defs.GameStats, voucherCounts map[str
return nil return nil
} }
func UpdateAccountBanned(uuid []byte, banned bool) error {
_, err := handle.Exec("UPDATE accounts SET banned = ? WHERE uuid = ?", banned, uuid)
if err != nil {
return err
}
return nil
}
func FetchAndClaimAccountCompensations(uuid []byte) (map[int]int, error) { func FetchAndClaimAccountCompensations(uuid []byte) (map[int]int, error) {
var compensations = make(map[int]int) var compensations = make(map[int]int)

Loading…
Cancel
Save