From 7b3342b3d23136d39133684d2d84ea529458bf10 Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Thu, 30 Apr 2026 20:41:31 +0000 Subject: [PATCH] Add ProjectZomboidAdminLog (admin.txt) Free-form English message body with verb-dispatched analyser regexes (ADDED_ITEM, ADDED_XP, GRANTED_ACCESS, CHANGED_OPTION, RELOADED_OPTIONS, TELEPORTED). Parser captures only the timestamp, since the admin name itself can include parentheses or whitespace. Detectors: filename match plus content signatures on 'added item Base.X in Y's inventory' and 'granted ROLE access level on'. --- .../ProjectZomboid/ProjectZomboidAdminLog.php | 47 +++++++++++ src/Pattern/ProjectZomboid/AdminPattern.php | 28 +++++++ .../ProjectZomboid/fixtures/admin-minimal.txt | 12 +++ .../Log/ProjectZomboidAdminLogTest.php | 83 +++++++++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 src/Log/ProjectZomboid/ProjectZomboidAdminLog.php create mode 100644 src/Pattern/ProjectZomboid/AdminPattern.php create mode 100644 test/src/Games/ProjectZomboid/fixtures/admin-minimal.txt create mode 100644 test/tests/Games/ProjectZomboid/Log/ProjectZomboidAdminLogTest.php diff --git a/src/Log/ProjectZomboid/ProjectZomboidAdminLog.php b/src/Log/ProjectZomboid/ProjectZomboidAdminLog.php new file mode 100644 index 0000000..0e9b986 --- /dev/null +++ b/src/Log/ProjectZomboid/ProjectZomboidAdminLog.php @@ -0,0 +1,47 @@ +setPattern('/_admin\.txt$/') + ->setWeight(0.95), + (new WeightedSinglePatternDetector()) + ->setPattern('/^\[[^\]]+\] .+? added item Base\.\S+ in .+?\'s inventory/m') + ->setWeight(0.90), + (new WeightedSinglePatternDetector()) + ->setPattern('/^\[[^\]]+\] .+? granted (?:admin|user|moderator|gm|observer) access level on /m') + ->setWeight(0.85), + ]; + } + + public function getTitle(): string + { + return "Project Zomboid Admin Log"; + } +} diff --git a/src/Pattern/ProjectZomboid/AdminPattern.php b/src/Pattern/ProjectZomboid/AdminPattern.php new file mode 100644 index 0000000..ee206d9 --- /dev/null +++ b/src/Pattern/ProjectZomboid/AdminPattern.php @@ -0,0 +1,28 @@ + ...' Verb dispatch is left + * to the analyser layer. The admin name itself can contain parentheses + * (Nathan(Weerd)) or whitespace (silly goose) so the parser captures + * only the timestamp. + */ +class AdminPattern +{ + public const string LINE = '/^\[(\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3})\] .+\.$/'; + + public const string ADDED_ITEM = '/^(?.+?) added item (?Base\.\S+) in (?.+?)\'s inventory$/'; + + public const string ADDED_XP = '/^(?.+?) added (?[\d.]+) (?\S+) xp\'s to (?.+)$/'; + + public const string GRANTED_ACCESS = '/^(?.+?) granted (?\w+) access level on (?.+)$/'; + + public const string CHANGED_OPTION = '/^(?.+?) changed option (?