@@ -237,7 +237,7 @@ def handle_emergency_repair_use(self):
237237 if not self .config .HpControl_UseEmergencyRepair :
238238 return False
239239
240- if self .appear_then_click (EMERGENCY_REPAIR_CONFIRM , offset = True ):
240+ if self .appear_then_click (EMERGENCY_REPAIR_CONFIRM , offset = True , interval = 3 ):
241241 return True
242242 if self .appear (BATTLE_PREPARATION , offset = (20 , 20 )) and self .appear (EMERGENCY_REPAIR_AVAILABLE ):
243243 # When entering battle_preparation page (or after emergency repairing),
@@ -251,16 +251,22 @@ def handle_emergency_repair_use(self):
251251 self .wait_until_stable (stable_checker )
252252 if not self .appear (EMERGENCY_REPAIR_AVAILABLE ):
253253 return False
254+
254255 logger .info ('EMERGENCY_REPAIR_AVAILABLE' )
255256 if not len (self .hp ):
256257 return False
258+ if max (self .hp [:3 ]) <= 0.001 or max (self .hp [3 :]) <= 0.001 :
259+ logger .warning (f'Invalid HP to use emergency repair: { self .hp } ' )
260+ return False
261+
257262 hp = np .array (self .hp )
258263 hp = hp [hp > 0.001 ]
259264 if (len (hp ) and np .min (hp ) < self .config .HpControl_RepairUseSingleThreshold ) \
260- or np . max (self .hp [:3 ]) < self .config .HpControl_RepairUseMultiThreshold \
261- or np . max (self .hp [3 :]) < self .config .HpControl_RepairUseMultiThreshold :
265+ or max (self .hp [:3 ]) < self .config .HpControl_RepairUseMultiThreshold \
266+ or max (self .hp [3 :]) < self .config .HpControl_RepairUseMultiThreshold :
262267 logger .info ('Use emergency repair' )
263268 self .device .click (EMERGENCY_REPAIR_AVAILABLE )
269+ self .interval_clear (EMERGENCY_REPAIR_CONFIRM )
264270 return True
265271
266272 return False
0 commit comments