Add ProjectZomboidClientActionLog (ClientActionLog.txt)

Strict 5-field bracketed format. Parser captures only the timestamp;
analysers that want steamid/action/player/coords/param decompose the
Line text via ClientActionPattern::FIELDS. Detectors: filename match
plus content signature on the IS{Enter,Exit}Vehicle / ISWalkToTimedAction
action tokens.
This commit is contained in:
2026-04-30 20:35:40 +00:00
parent 28e8fc8dc6
commit e74c105625
4 changed files with 119 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
[29-04-26 21:41:25.084] [76561198000000001][ISEnterVehicle][Player1][1000,2000,0][Van_LectroMax].
[29-04-26 21:42:30.152] [76561198000000001][ISExitVehicle][Player1][1001,2001,0][Van_LectroMax].
[29-04-26 21:46:31.034] [76561198000000001][ISEnterVehicle][Player1][1002,2002,0][Van_LectroMax].
[29-04-26 21:46:53.257] [76561198000000001][ISExitVehicle][Player1][1003,2003,0][Van_LectroMax].
[29-04-26 21:47:04.159] [76561198000000002][ISEnterVehicle][Player2][1010,2010,0][Pickup_Truck].
[29-04-26 21:47:30.512] [76561198000000002][ISWalkToTimedAction][Player2][1011,2011,0][None].
[29-04-26 21:48:00.812] [76561198000000002][ISExitVehicle][Player2][1011,2011,0][Pickup_Truck].
[29-04-26 21:50:14.221] [76561198000000003][ISEnterVehicle][AdminUser][1020,2020,0][SUV_Modern].
[29-04-26 21:51:00.512] [76561198000000003][ISExitVehicle][AdminUser][1021,2021,0][SUV_Modern].
[29-04-26 21:52:15.018] [76561198000000001][ISEnterVehicle][Player1][1004,2004,0][Van_LectroMax].

View File

@@ -0,0 +1,44 @@
<?php
namespace IndifferentKetchup\Codex\Test\Tests\Games\ProjectZomboid\Log;
use IndifferentKetchup\Codex\Detective\Detective;
use IndifferentKetchup\Codex\Log\File\PathLogFile;
use IndifferentKetchup\Codex\Log\ProjectZomboid\ProjectZomboidClientActionLog;
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\ClientActionPattern;
use PHPUnit\Framework\TestCase;
class ProjectZomboidClientActionLogTest extends TestCase
{
private function fixturePath(): string
{
return __DIR__ . '/../../../../src/Games/ProjectZomboid/fixtures/client-action-minimal.txt';
}
public function testParsesEachLineAsAnEntry(): void
{
$log = (new ProjectZomboidClientActionLog())->setLogFile(new PathLogFile($this->fixturePath()));
$log->parse();
$this->assertCount(10, $log->getEntries());
}
public function testFieldsRegexExtractsStructuredData(): void
{
$line = "[29-04-26 21:41:25.084] [76561198000000001][ISEnterVehicle][Player1][1000,2000,0][Van_LectroMax].";
$this->assertSame(1, preg_match(ClientActionPattern::FIELDS, $line, $m));
$this->assertSame('76561198000000001', $m['steamid']);
$this->assertSame('ISEnterVehicle', $m['action']);
$this->assertSame('Player1', $m['player']);
$this->assertSame('Van_LectroMax', $m['param']);
}
public function testDetectiveDispatchesByContent(): void
{
$detective = (new Detective())
->setLogFile(new PathLogFile($this->fixturePath()))
->addPossibleLogClass(ProjectZomboidClientActionLog::class);
$this->assertInstanceOf(ProjectZomboidClientActionLog::class, $detective->detect());
}
}