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.
28 lines
1.0 KiB
PHP
28 lines
1.0 KiB
PHP
<?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)\.$/';
|
|
}
|