Compare commits

...

3 Commits

Author SHA1 Message Date
maru
7bfd9dfba7
Fix code 2024-05-21 01:48:07 -04:00
maru
f8f5aefff9
Better logging 2024-05-21 01:45:03 -04:00
maru
fc458fad73
Revert "Remove anti cheat"
This reverts commit 512a24e5c3.
2024-05-21 01:39:07 -04:00
5 changed files with 22 additions and 6 deletions

View File

@ -18,8 +18,6 @@
package daily
import (
"log"
"github.com/pagefaultgames/rogueserver/db"
"github.com/pagefaultgames/rogueserver/defs"
)
@ -28,7 +26,7 @@ import (
func Rankings(category, page int) ([]defs.DailyRanking, error) {
rankings, err := db.FetchRankings(category, page)
if err != nil {
log.Print("failed to retrieve rankings")
return rankings, err
}
return rankings, nil

View File

@ -18,8 +18,6 @@
package daily
import (
"log"
"github.com/pagefaultgames/rogueserver/db"
)
@ -27,7 +25,7 @@ import (
func RankingPageCount(category int) (int, error) {
pageCount, err := db.FetchRankingPageCount(category)
if err != nil {
log.Print("failed to retrieve ranking page count")
return pageCount, err
}
return pageCount, nil

View File

@ -50,6 +50,10 @@ func Clear(uuid []byte, slot int, seed string, save defs.SessionSaveData) (Clear
waveCompleted--
}
if save.Score >= 20000 {
db.SetAccountBanned(uuid, true)
}
err = db.AddOrUpdateAccountDailyRun(uuid, save.Score, waveCompleted)
if err != nil {
log.Printf("failed to add or update daily run record: %s", err)

View File

@ -42,6 +42,13 @@ func Update(uuid []byte, slot int, save any) error {
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.SetAccountBanned(uuid, true)
}
err = db.UpdateAccountStats(uuid, save.GameStats, save.VoucherCounts)
if err != nil {
return fmt.Errorf("failed to update account stats: %s", err)

View File

@ -145,6 +145,15 @@ func UpdateAccountStats(uuid []byte, stats defs.GameStats, voucherCounts map[str
return nil
}
func SetAccountBanned(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) {
var compensations = make(map[int]int)