Skip to content

Commit

Permalink
fix: oops don't flag incomplete scores as cheats
Browse files Browse the repository at this point in the history
  • Loading branch information
roydejong committed Jan 12, 2024
1 parent 875c92a commit ddb9c66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/Models/LevelHistoryPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,14 @@ public function save(): bool

public function sniffTestCheating(): bool
{
if (!$this->multipliedScore || !$this->modifiedScore)
// Not enough data to sniff
return false;

// A bit rough but good enough score check -- Good cuts x 115 score; 8x multiplier (ignoring modifiers)
$maxMultipliedPotential = $this->goodCuts * 115 * 8;
if ($this->multipliedScore >= $maxMultipliedPotential) {
if ($this->multipliedScore > $maxMultipliedPotential)
return true;
}

// Passed the sniff test
return false;
Expand Down
3 changes: 3 additions & 0 deletions tests/Models/LevelHistoryPlayerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ private function assertCheatNotDetected(int $finalScore, int $goodCuts, int $bad

public function testSniffTestCheating()
{
// Do not trigger on incomplete
$this->assertCheatNotDetected(0, 0, 0, 0, 0);

// https://bssb.app/results/610b733c-921a-4f75-b042-c977a6478dd0 [final score cheat]
$this->assertCheatDetected(173758256, 837, 13, 95, 136);
// https://bssb.app/results/a5df9330-7558-4aee-9d86-140b2df79f2d [final score cheat]
Expand Down

0 comments on commit ddb9c66

Please sign in to comment.