Add PvpDamageInformation insight
This commit is contained in:
26
src/Analysis/ProjectZomboid/PvpDamageInformation.php
Normal file
26
src/Analysis/ProjectZomboid/PvpDamageInformation.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace IndifferentKetchup\Codex\Analysis\ProjectZomboid;
|
||||
|
||||
use IndifferentKetchup\Codex\Analysis\Information;
|
||||
use IndifferentKetchup\Codex\Analysis\PatternInsightInterface;
|
||||
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\PvpPattern;
|
||||
|
||||
class PvpDamageInformation extends Information implements PatternInsightInterface
|
||||
{
|
||||
public static function getPatterns(): array
|
||||
{
|
||||
return [PvpPattern::COMBAT_REAL];
|
||||
}
|
||||
|
||||
public function setMatches(array $matches, mixed $patternKey): void
|
||||
{
|
||||
$this->setLabel('PvP combat');
|
||||
$this->setValue(sprintf(
|
||||
'%s hit %s with %s',
|
||||
$matches['attacker'],
|
||||
$matches['victim'],
|
||||
$matches['weapon']
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -24,4 +24,12 @@ class PvpPattern
|
||||
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)\.$/';
|
||||
|
||||
/**
|
||||
* Real-PvP combat: weapon!="zombie" AND damage>0. Filtering is in the
|
||||
* regex itself so PatternAnalyser produces no insights for zombie/zero
|
||||
* rows. Damage clause matches any positive non-zero float (rejects
|
||||
* 0.000000 and any leading-minus value).
|
||||
*/
|
||||
public const string COMBAT_REAL = '/Combat: "(?<attacker>[^"]+)" \([^)]+\) hit "(?<victim>[^"]+)" \([^)]+\) weapon="(?<weapon>(?!zombie")[^"]+)" damage=(?<damage>0\.0*[1-9][0-9]*|[1-9][0-9]*\.[0-9]+)/';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user