Add ProjectZomboidItemLog (item.txt)
Per-line item gain/loss event log. Parser captures only the timestamp; analysers decompose location/delta/item via ItemPattern::FIELDS. Detectors: filename match plus content signature on the container/floor/inventory location verbs paired with a signed delta.
This commit is contained in:
44
src/Log/ProjectZomboid/ProjectZomboidItemLog.php
Normal file
44
src/Log/ProjectZomboid/ProjectZomboidItemLog.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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\ItemPattern;
|
||||
|
||||
class ProjectZomboidItemLog extends ProjectZomboidEventLog
|
||||
{
|
||||
public static function getDefaultParser(): ParserInterface
|
||||
{
|
||||
return static::makePatternParser(
|
||||
ItemPattern::LINE,
|
||||
[PatternParser::TIME]
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDefaultAnalyser(): AnalyserInterface
|
||||
{
|
||||
return new PatternAnalyser();
|
||||
}
|
||||
|
||||
public static function getDetectors(): array
|
||||
{
|
||||
return [
|
||||
(new FilenameDetector())
|
||||
->setPattern('/_item\.txt$/')
|
||||
->setWeight(0.95),
|
||||
(new WeightedSinglePatternDetector())
|
||||
->setPattern('/^\[[^\]]+\] \d{17} "[^"]+" (?:container|floor|inventory) [+\-]\d+ /m')
|
||||
->setWeight(0.90),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return "Project Zomboid Item Log";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user