Wire ProjectZomboidPvpLog default analyser
This commit is contained in:
@@ -4,6 +4,7 @@ namespace IndifferentKetchup\Codex\Log\ProjectZomboid;
|
|||||||
|
|
||||||
use IndifferentKetchup\Codex\Analyser\AnalyserInterface;
|
use IndifferentKetchup\Codex\Analyser\AnalyserInterface;
|
||||||
use IndifferentKetchup\Codex\Analyser\PatternAnalyser;
|
use IndifferentKetchup\Codex\Analyser\PatternAnalyser;
|
||||||
|
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\PvpDamageInformation;
|
||||||
use IndifferentKetchup\Codex\Detective\FilenameDetector;
|
use IndifferentKetchup\Codex\Detective\FilenameDetector;
|
||||||
use IndifferentKetchup\Codex\Detective\WeightedSinglePatternDetector;
|
use IndifferentKetchup\Codex\Detective\WeightedSinglePatternDetector;
|
||||||
use IndifferentKetchup\Codex\Parser\ParserInterface;
|
use IndifferentKetchup\Codex\Parser\ParserInterface;
|
||||||
@@ -22,7 +23,8 @@ class ProjectZomboidPvpLog extends ProjectZomboidEventLog
|
|||||||
|
|
||||||
public static function getDefaultAnalyser(): AnalyserInterface
|
public static function getDefaultAnalyser(): AnalyserInterface
|
||||||
{
|
{
|
||||||
return new PatternAnalyser();
|
return (new PatternAnalyser())
|
||||||
|
->addPossibleInsightClass(PvpDamageInformation::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDetectors(): array
|
public static function getDetectors(): array
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace IndifferentKetchup\Codex\Test\Tests\Games\ProjectZomboid\Analyser;
|
||||||
|
|
||||||
|
use IndifferentKetchup\Codex\Analysis\ProjectZomboid\PvpDamageInformation;
|
||||||
|
use IndifferentKetchup\Codex\Log\File\PathLogFile;
|
||||||
|
use IndifferentKetchup\Codex\Log\ProjectZomboid\ProjectZomboidPvpLog;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class PvpLogAnalysisTest extends TestCase
|
||||||
|
{
|
||||||
|
private function fixturePath(): string
|
||||||
|
{
|
||||||
|
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/pvp-minimal.txt';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAnalyseProducesOnlyRealPvpInsights(): void
|
||||||
|
{
|
||||||
|
$log = (new ProjectZomboidPvpLog())->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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user