Fixed API Issues with Flyff Collector Node

This commit is contained in:
Nicole Rappe 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 import re
from OdenGraphQt import BaseNode from OdenGraphQt import BaseNode
from PyQt5.QtWidgets import QMessageBox from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtCore import QTimer # Corrected import from PyQt5.QtCore import QTimer
from Modules import data_manager, data_collector from Modules import data_manager, data_collector
class FlyffCharacterStatusNode(BaseNode): class FlyffCharacterStatusNode(BaseNode):
@ -42,14 +42,20 @@ class FlyffCharacterStatusNode(BaseNode):
def parse_character_stats(self, raw_text): def parse_character_stats(self, raw_text):
""" """
Extract HP, MP, FP, EXP from the raw OCR text lines. 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()] 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 hp_current, hp_total = 0, 0
mp_current, mp_total = 0, 0 mp_current, mp_total = 0, 0
fp_current, fp_total = 0, 0 fp_current, fp_total = 0, 0
exp_value = 0.0 exp_value = 0.0
if len(lines) >= 4: if len(lines) == 4:
# line 1: HP # line 1: HP
hp_match = re.search(r"(\d+)\s*/\s*(\d+)", lines[0]) hp_match = re.search(r"(\d+)\s*/\s*(\d+)", lines[0])
if hp_match: if hp_match:
@ -72,8 +78,10 @@ class FlyffCharacterStatusNode(BaseNode):
exp_match = re.search(r"(\d+(?:\.\d+)?)", lines[3]) exp_match = re.search(r"(\d+(?:\.\d+)?)", lines[3])
if exp_match: if exp_match:
val = float(exp_match.group(1)) val = float(exp_match.group(1))
if val < 0: val = 0 if val < 0:
if val > 100: val = 100 val = 0
if val > 100:
val = 100
exp_value = val exp_value = val
return hp_current, hp_total, mp_current, mp_total, fp_current, fp_total, exp_value 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. Called periodically to update character status from OCR.
""" """
raw_text = data_collector.get_raw_text(self.region_id) 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) hp_c, hp_t, mp_c, mp_t, fp_c, fp_t, exp_v = self.parse_character_stats(raw_text)

View File

@ -9,10 +9,10 @@
"reject_connection_types":{} "reject_connection_types":{}
}, },
"nodes":{ "nodes":{
"0x25062603f80":{ "0x191410fec90":{
"type_":"bunny-lab.io.data_node.DataNode", "type_":"bunny-lab.io.flyff_character_status_node.FlyffCharacterStatusNode",
"icon":null, "icon":null,
"name":"Data Node", "name":"Flyff - Character Status",
"color":[ "color":[
13, 13,
18, 18,
@ -34,23 +34,26 @@
"disabled":false, "disabled":false,
"selected":false, "selected":false,
"visible":true, "visible":true,
"width":269.0, "width":278.0,
"height":74.2, "height":200.20000000000002,
"pos":[ "pos":[
-183.12907239097774, -234.47843187544638,
203.3685322819906 171.50740184739476
], ],
"layout_direction":0, "layout_direction":0,
"port_deletion_allowed":false, "port_deletion_allowed":false,
"subgraph_session":{}, "subgraph_session":{},
"custom":{ "custom":{
"value":"25" "hp":"HP: 5848/5848",
"mp":"MP: 955/555",
"fp":"FP: 0/0",
"exp":"EXP: 49.0%"
} }
}, },
"0x250626141a0":{ "0x19173496de0":{
"type_":"bunny-lab.io.data_node.DataNode", "type_":"bunny-lab.io.flyff_exp_current_node.FlyffEXPCurrentNode",
"icon":null, "icon":null,
"name":"Data Node 1", "name":"Flyff - EXP (API Connected)",
"color":[ "color":[
13, 13,
18, 18,
@ -72,23 +75,64 @@
"disabled":false, "disabled":false,
"selected":false, "selected":false,
"visible":true, "visible":true,
"width":269.0, "width":339.0,
"height":74.2, "height":74.2,
"pos":[ "pos":[
279.96246102035116, -237.34556433027646,
512.9884977805091 77.62806051403777
], ],
"layout_direction":0, "layout_direction":0,
"port_deletion_allowed":false, "port_deletion_allowed":false,
"subgraph_session":{}, "subgraph_session":{},
"custom":{ "custom":{
"value":"25" "value":"49.0"
} }
}, },
"0x250626159d0":{ "0x191735ae690":{
"type_":"bunny-lab.io.flyff_leveling_predictor_node.FlyffLevelingPredictorNode",
"icon":null,
"name":"Flyff - Leveling Predictor",
"color":[
13,
18,
23,
255
],
"border_color":[
74,
84,
85,
255
],
"text_color":[
255,
255,
255,
180
],
"disabled":false,
"selected":false,
"visible":true,
"width":324.0,
"height":200.20000000000002,
"pos":[
170.42482250783007,
77.62806051403777
],
"layout_direction":0,
"port_deletion_allowed":false,
"subgraph_session":{},
"custom":{
"exp_track_count":"7",
"time_to_level":"Insufficient data",
"time_between_kills":"N/A",
"exp_per_kill":"N/A"
}
},
"0x191735ae9c0":{
"type_":"bunny-lab.io.backdrop.BackdropNode", "type_":"bunny-lab.io.backdrop.BackdropNode",
"icon":null, "icon":null,
"name":"flask", "name":"Track EXP Changes Over Time to Predict Leveling Up",
"color":[ "color":[
5, 5,
129, 129,
@ -110,11 +154,11 @@
"disabled":false, "disabled":false,
"selected":false, "selected":false,
"visible":true, "visible":true,
"width":804.65254462634, "width":777.8842478973615,
"height":483.4329838785975, "height":380.82117975084645,
"pos":[ "pos":[
-205.22360825550223, -264.113861059255,
146.33335545174936 23.199190498448075
], ],
"layout_direction":0, "layout_direction":0,
"port_deletion_allowed":false, "port_deletion_allowed":false,
@ -127,12 +171,12 @@
"connections":[ "connections":[
{ {
"out":[ "out":[
"0x25062603f80", "0x19173496de0",
"Output" "value"
], ],
"in":[ "in":[
"0x250626141a0", "0x191735ae690",
"Input" "exp"
] ]
} }
] ]

View File

@ -1,101 +0,0 @@
{
"graph":{
"layout_direction":0,
"acyclic":true,
"pipe_collision":false,
"pipe_slicing":true,
"pipe_style":1,
"accept_connection_types":{},
"reject_connection_types":{}
},
"nodes":{
"0x25032ceeae0":{
"type_":"bunny-lab.io.data_node.DataNode",
"icon":null,
"name":"Data Node",
"color":[
13,
18,
23,
255
],
"border_color":[
74,
84,
85,
255
],
"text_color":[
255,
255,
255,
180
],
"disabled":false,
"selected":false,
"visible":true,
"width":269.0,
"height":74.2,
"pos":[
-140.9796961059538,
314.0813482866816
],
"layout_direction":0,
"port_deletion_allowed":false,
"subgraph_session":{},
"custom":{
"value":"56"
}
},
"0x250626018b0":{
"type_":"bunny-lab.io.data_node.DataNode",
"icon":null,
"name":"Data Node 1",
"color":[
13,
18,
23,
255
],
"border_color":[
74,
84,
85,
255
],
"text_color":[
255,
255,
255,
180
],
"disabled":false,
"selected":false,
"visible":true,
"width":269.0,
"height":74.2,
"pos":[
436.3232366823503,
297.12809369166183
],
"layout_direction":0,
"port_deletion_allowed":false,
"subgraph_session":{},
"custom":{
"value":"56"
}
}
},
"connections":[
{
"out":[
"0x25032ceeae0",
"Output"
],
"in":[
"0x250626018b0",
"Input"
]
}
]
}