diff --git a/app/Models/LevelHistoryPlayer.php b/app/Models/LevelHistoryPlayer.php index 1c3f02a..56bf1d7 100644 --- a/app/Models/LevelHistoryPlayer.php +++ b/app/Models/LevelHistoryPlayer.php @@ -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; diff --git a/tests/Models/LevelHistoryPlayerTest.php b/tests/Models/LevelHistoryPlayerTest.php index 0e4ff14..920fc6e 100644 --- a/tests/Models/LevelHistoryPlayerTest.php +++ b/tests/Models/LevelHistoryPlayerTest.php @@ -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]