feat(heal): add English self-heal and attribute patterns
- Add English self-heal: 'You healed yourself X points' - Add English attribute gain: 'Your Agility has improved by X' / 'You gained X Agility' - Update EVENT_PATTERNS with all language variants - Add parsing logic for English heal and attribute events Based on user-provided regex reference code.
This commit is contained in:
parent
b28b3915fd
commit
f957165394
|
|
@ -153,9 +153,16 @@ class LogWatcher:
|
|||
|
||||
# HEALING
|
||||
# Swedish: "Du läkte dig själv 4.0 poäng"
|
||||
# English: "You healed yourself 25.5 points"
|
||||
PATTERN_HEAL_SV = re.compile(
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+'
|
||||
r'Du\s+läkte\s+dig\själv\s+(\d+(?:\.\d+)?)\s+poäng',
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+\[?\]?\s*'
|
||||
r'Du\s+läkte\s+dig\s+jälv\s+(\d+(?:\.\d+)?)\s+poäng',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
PATTERN_HEAL_EN = re.compile(
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+\[?\]?\s*'
|
||||
r'You\s+healed\s+yourself\s+(\d+(?:\.\d+)?)\s+points?',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
|
|
@ -199,12 +206,19 @@ class LogWatcher:
|
|||
|
||||
# ATTRIBUTE GAIN (Agility, etc)
|
||||
# Swedish: "Din Agility har förbättrats med 0.0001"
|
||||
# English: "Your Agility has improved by 0.0001" OR "You gained 0.0001 Agility"
|
||||
PATTERN_ATTRIBUTE_SV = re.compile(
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+'
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+\[?\]?\s*'
|
||||
r'Din\s+(\w+)\s+har\s+förbättrats\s+med\s+(\d+(?:\.\d+)?)',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
PATTERN_ATTRIBUTE_EN = re.compile(
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+\[?\]?\s*'
|
||||
r'(?:Your\s+(\w+)\s+has\s+improved\s+by|You\s+gained)\s+(\d+(?:\.\d+)?)\s+(\w+)',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
EVENT_PATTERNS = {
|
||||
'loot_en': PATTERN_LOOT_EN,
|
||||
'loot_sv': PATTERN_LOOT_SV,
|
||||
|
|
@ -215,15 +229,19 @@ class LogWatcher:
|
|||
'skill_sv': PATTERN_SKILL_SV,
|
||||
'damage_dealt_sv': PATTERN_DAMAGE_DEALT_SV,
|
||||
'damage_dealt_en': PATTERN_DAMAGE_DEALT_EN,
|
||||
'critical_hit': PATTERN_CRITICAL_SV,
|
||||
'critical_hit_sv': PATTERN_CRITICAL_SV,
|
||||
'critical_hit_en': PATTERN_CRITICAL_EN,
|
||||
'damage_taken_sv': PATTERN_DAMAGE_TAKEN_SV,
|
||||
'damage_taken_en': PATTERN_DAMAGE_TAKEN_EN,
|
||||
'heal': PATTERN_HEAL_SV,
|
||||
'weapon_tier': PATTERN_WEAPON_TIER_SV,
|
||||
'heal_sv': PATTERN_HEAL_SV,
|
||||
'heal_en': PATTERN_HEAL_EN,
|
||||
'weapon_tier_sv': PATTERN_WEAPON_TIER_SV,
|
||||
'weapon_tier_en': PATTERN_WEAPON_TIER_EN,
|
||||
'evade': PATTERN_EVADE,
|
||||
'decay': PATTERN_DECAY,
|
||||
'ped_transfer': PATTERN_PED_TRANSFER,
|
||||
'attribute': PATTERN_ATTRIBUTE_SV,
|
||||
'attribute_sv': PATTERN_ATTRIBUTE_SV,
|
||||
'attribute_en': PATTERN_ATTRIBUTE_EN,
|
||||
}
|
||||
|
||||
def __init__(self, log_path: Optional[str] = None,
|
||||
|
|
@ -454,14 +472,24 @@ class LogWatcher:
|
|||
data={'damage': Decimal(match.group(2)), 'language': 'english'}
|
||||
)
|
||||
|
||||
# HEALING
|
||||
# HEALING - Swedish
|
||||
match = self.PATTERN_HEAL_SV.match(line)
|
||||
if match:
|
||||
return LogEvent(
|
||||
timestamp=self._parse_timestamp(match.group(1)),
|
||||
event_type='heal',
|
||||
raw_line=line,
|
||||
data={'heal_amount': Decimal(match.group(2))}
|
||||
data={'heal_amount': Decimal(match.group(2)), 'language': 'swedish'}
|
||||
)
|
||||
|
||||
# HEALING - English
|
||||
match = self.PATTERN_HEAL_EN.match(line)
|
||||
if match:
|
||||
return LogEvent(
|
||||
timestamp=self._parse_timestamp(match.group(1)),
|
||||
event_type='heal',
|
||||
raw_line=line,
|
||||
data={'heal_amount': Decimal(match.group(2)), 'language': 'english'}
|
||||
)
|
||||
|
||||
# WEAPON TIER/LEVEL - Swedish
|
||||
|
|
@ -512,7 +540,7 @@ class LogWatcher:
|
|||
data={'item': match.group(2).strip()}
|
||||
)
|
||||
|
||||
# ATTRIBUTE GAIN
|
||||
# ATTRIBUTE GAIN - Swedish
|
||||
match = self.PATTERN_ATTRIBUTE_SV.match(line)
|
||||
if match:
|
||||
return LogEvent(
|
||||
|
|
@ -521,7 +549,22 @@ class LogWatcher:
|
|||
raw_line=line,
|
||||
data={
|
||||
'attribute': match.group(2),
|
||||
'increase': Decimal(match.group(3))
|
||||
'increase': Decimal(match.group(3)),
|
||||
'language': 'swedish'
|
||||
}
|
||||
)
|
||||
|
||||
# ATTRIBUTE GAIN - English
|
||||
match = self.PATTERN_ATTRIBUTE_EN.match(line)
|
||||
if match:
|
||||
return LogEvent(
|
||||
timestamp=self._parse_timestamp(match.group(1)),
|
||||
event_type='attribute',
|
||||
raw_line=line,
|
||||
data={
|
||||
'attribute': match.group(4) if match.group(4) else match.group(2),
|
||||
'increase': Decimal(match.group(3)),
|
||||
'language': 'english'
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue