Add ProjectZomboidPvpLog (pvp.txt)
Two row variants share the file: Safe House toggles ([LOG] Safety:) and Combat events ([INFO] Combat: ... weapon=... damage=...). Parser captures time, level, and the subsystem token (Safety|Combat) as the entry prefix. COMBAT and SAFETY regexes extract structured fields, including support for negative Z coordinates from basement levels. Synthetic fixture covers both variants and represents zombie/vehicle/ real-PvP weapon types so analysers can later filter on damage>0 and weapon!=zombie.
This commit is contained in:
47
src/Log/ProjectZomboid/ProjectZomboidPvpLog.php
Normal file
47
src/Log/ProjectZomboid/ProjectZomboidPvpLog.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace IndifferentKetchup\Codex\Log\ProjectZomboid;
|
||||
|
||||
use IndifferentKetchup\Codex\Analyser\AnalyserInterface;
|
||||
use IndifferentKetchup\Codex\Analyser\PatternAnalyser;
|
||||
use IndifferentKetchup\Codex\Detective\FilenameDetector;
|
||||
use IndifferentKetchup\Codex\Detective\WeightedSinglePatternDetector;
|
||||
use IndifferentKetchup\Codex\Parser\ParserInterface;
|
||||
use IndifferentKetchup\Codex\Parser\PatternParser;
|
||||
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\PvpPattern;
|
||||
|
||||
class ProjectZomboidPvpLog extends ProjectZomboidEventLog
|
||||
{
|
||||
public static function getDefaultParser(): ParserInterface
|
||||
{
|
||||
return static::makePatternParser(
|
||||
PvpPattern::LINE,
|
||||
[PatternParser::TIME, PatternParser::LEVEL, PatternParser::PREFIX]
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDefaultAnalyser(): AnalyserInterface
|
||||
{
|
||||
return new PatternAnalyser();
|
||||
}
|
||||
|
||||
public static function getDetectors(): array
|
||||
{
|
||||
return [
|
||||
(new FilenameDetector())
|
||||
->setPattern('/_pvp\.txt$/')
|
||||
->setWeight(0.95),
|
||||
(new WeightedSinglePatternDetector())
|
||||
->setPattern('/^\[[^\]]+\]\[\w+\] Combat: "[^"]+" \(/m')
|
||||
->setWeight(0.95),
|
||||
(new WeightedSinglePatternDetector())
|
||||
->setPattern('/^\[[^\]]+\]\[\w+\] Safety: "/m')
|
||||
->setWeight(0.85),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return "Project Zomboid PvP Log";
|
||||
}
|
||||
}
|
||||
27
src/Pattern/ProjectZomboid/PvpPattern.php
Normal file
27
src/Pattern/ProjectZomboid/PvpPattern.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace IndifferentKetchup\Codex\Pattern\ProjectZomboid;
|
||||
|
||||
/**
|
||||
* Regex constants for the Project Zomboid pvp.txt format.
|
||||
*
|
||||
* Two row variants share the file: Safe House toggles
|
||||
* [time][LOG] Safety: "player" (x,y,z) restore true.
|
||||
* and Combat events
|
||||
* [time][INFO] Combat: "attacker" (x,y,z) hit "victim" (x,y,z) weapon="W" damage=N.NN.
|
||||
*
|
||||
* Z coordinates can be negative (basement levels: -1, -2).
|
||||
*
|
||||
* LINE captures, in order:
|
||||
* 1. time
|
||||
* 2. level (LOG | INFO | WARN | ERROR)
|
||||
* 3. subsystem (Safety | Combat)
|
||||
*/
|
||||
class PvpPattern
|
||||
{
|
||||
public const string LINE = '/^\[(\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3})\]\[(LOG|INFO|WARN|ERROR)\] (\w+): .+\.$/';
|
||||
|
||||
public const string COMBAT = '/^Combat: "(?<attacker>[^"]+)" \((?<ax>\d+),(?<ay>\d+),(?<az>-?\d+)\) hit "(?<victim>[^"]+)" \((?<vx>\d+),(?<vy>\d+),(?<vz>-?\d+)\) weapon="(?<weapon>[^"]+)" damage=(?<damage>-?\d+\.\d+)\.$/';
|
||||
|
||||
public const string SAFETY = '/^Safety: "(?<player>[^"]+)" \((?<x>\d+),(?<y>\d+),(?<z>-?\d+)\) (?<verb>\w+) (?<state>true|false)\.$/';
|
||||
}
|
||||
Reference in New Issue
Block a user