From 51eb2de282b330671269d3539f29d46a3dcfb672 Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Thu, 30 Apr 2026 21:47:51 +0000 Subject: [PATCH] Wire ProjectZomboidPvpLog default analyser --- .../ProjectZomboid/ProjectZomboidPvpLog.php | 4 +- .../Analyser/PvpLogAnalysisTest.php | 51 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/tests/Games/ProjectZomboid/Analyser/PvpLogAnalysisTest.php diff --git a/src/Log/ProjectZomboid/ProjectZomboidPvpLog.php b/src/Log/ProjectZomboid/ProjectZomboidPvpLog.php index 37760d8..c4bda1b 100644 --- a/src/Log/ProjectZomboid/ProjectZomboidPvpLog.php +++ b/src/Log/ProjectZomboid/ProjectZomboidPvpLog.php @@ -4,6 +4,7 @@ namespace IndifferentKetchup\Codex\Log\ProjectZomboid; use IndifferentKetchup\Codex\Analyser\AnalyserInterface; use IndifferentKetchup\Codex\Analyser\PatternAnalyser; +use IndifferentKetchup\Codex\Analysis\ProjectZomboid\PvpDamageInformation; use IndifferentKetchup\Codex\Detective\FilenameDetector; use IndifferentKetchup\Codex\Detective\WeightedSinglePatternDetector; use IndifferentKetchup\Codex\Parser\ParserInterface; @@ -22,7 +23,8 @@ class ProjectZomboidPvpLog extends ProjectZomboidEventLog public static function getDefaultAnalyser(): AnalyserInterface { - return new PatternAnalyser(); + return (new PatternAnalyser()) + ->addPossibleInsightClass(PvpDamageInformation::class); } public static function getDetectors(): array diff --git a/test/tests/Games/ProjectZomboid/Analyser/PvpLogAnalysisTest.php b/test/tests/Games/ProjectZomboid/Analyser/PvpLogAnalysisTest.php new file mode 100644 index 0000000..0f45852 --- /dev/null +++ b/test/tests/Games/ProjectZomboid/Analyser/PvpLogAnalysisTest.php @@ -0,0 +1,51 @@ +setLogFile(new PathLogFile($this->fixturePath())); + $log->parse(); + $analysis = $log->analyse(); + + $insights = $analysis->getFilteredInsights(PvpDamageInformation::class); + + $values = array_map(fn($i) => $i->getValue(), $insights); + sort($values); + + $this->assertSame( + [ + 'AdminUser hit Player1 with Hunting Knife', + 'Player1 hit Player2 with Bare Hands', + 'Player1 hit Player2 with Tire Iron (Worn)', + ], + $values + ); + } + + public function testZombieAndZeroDamageAreFilteredOut(): void + { + $log = (new ProjectZomboidPvpLog())->setLogFile(new PathLogFile($this->fixturePath())); + $log->parse(); + $analysis = $log->analyse(); + + $insights = $analysis->getFilteredInsights(PvpDamageInformation::class); + + foreach ($insights as $insight) { + $this->assertStringNotContainsString('zombie', $insight->getValue()); + $this->assertStringNotContainsString('vehicle', $insight->getValue()); + } + } +}