Fixed API Issues with Flyff Collector Node

This commit is contained in:
2025-02-25 00:20:33 -07:00
parent e736622213
commit 038de06bfd
4 changed files with 83 additions and 131 deletions

View File

@ -8,7 +8,7 @@ Flyff Character Status Node:
import re
from OdenGraphQt import BaseNode
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtCore import QTimer # Corrected import
from PyQt5.QtCore import QTimer
from Modules import data_manager, data_collector
class FlyffCharacterStatusNode(BaseNode):
@ -42,14 +42,20 @@ class FlyffCharacterStatusNode(BaseNode):
def parse_character_stats(self, raw_text):
"""
Extract HP, MP, FP, EXP from the raw OCR text lines.
We strip out empty lines, then only look at the first 4 lines.
"""
# Split on newlines, strip each line, and discard blank lines
lines = [l.strip() for l in raw_text.splitlines() if l.strip()]
# Only consider the first 4 lines (HP, MP, FP, EXP)
lines = lines[:4]
hp_current, hp_total = 0, 0
mp_current, mp_total = 0, 0
fp_current, fp_total = 0, 0
exp_value = 0.0
if len(lines) >= 4:
if len(lines) == 4:
# line 1: HP
hp_match = re.search(r"(\d+)\s*/\s*(\d+)", lines[0])
if hp_match:
@ -72,8 +78,10 @@ class FlyffCharacterStatusNode(BaseNode):
exp_match = re.search(r"(\d+(?:\.\d+)?)", lines[3])
if exp_match:
val = float(exp_match.group(1))
if val < 0: val = 0
if val > 100: val = 100
if val < 0:
val = 0
if val > 100:
val = 100
exp_value = val
return hp_current, hp_total, mp_current, mp_total, fp_current, fp_total, exp_value
@ -83,7 +91,8 @@ class FlyffCharacterStatusNode(BaseNode):
Called periodically to update character status from OCR.
"""
raw_text = data_collector.get_raw_text(self.region_id)
# print("Raw OCR Text:", raw_text) # Debugging OCR text reading
# Uncomment below for debugging if needed:
# print("Raw OCR Text:", repr(raw_text))
hp_c, hp_t, mp_c, mp_t, fp_c, fp_t, exp_v = self.parse_character_stats(raw_text)