Skip to content

Commit

Permalink
Fix: Skip using emergency repair if all HP is 0 (#4501)
Browse files Browse the repository at this point in the history
  • Loading branch information
LmeSzinc committed Jan 9, 2025
1 parent c98ea50 commit 156a988
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions module/combat/combat.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def handle_emergency_repair_use(self):
if not self.config.HpControl_UseEmergencyRepair:
return False

if self.appear_then_click(EMERGENCY_REPAIR_CONFIRM, offset=True):
if self.appear_then_click(EMERGENCY_REPAIR_CONFIRM, offset=True, interval=3):
return True
if self.appear(BATTLE_PREPARATION, offset=(20, 20)) and self.appear(EMERGENCY_REPAIR_AVAILABLE):
# When entering battle_preparation page (or after emergency repairing),
Expand All @@ -251,16 +251,22 @@ def handle_emergency_repair_use(self):
self.wait_until_stable(stable_checker)
if not self.appear(EMERGENCY_REPAIR_AVAILABLE):
return False

logger.info('EMERGENCY_REPAIR_AVAILABLE')
if not len(self.hp):
return False
if max(self.hp[:3]) <= 0.001 or max(self.hp[3:]) <= 0.001:
logger.warning(f'Invalid HP to use emergency repair: {self.hp}')
return False

hp = np.array(self.hp)
hp = hp[hp > 0.001]
if (len(hp) and np.min(hp) < self.config.HpControl_RepairUseSingleThreshold) \
or np.max(self.hp[:3]) < self.config.HpControl_RepairUseMultiThreshold \
or np.max(self.hp[3:]) < self.config.HpControl_RepairUseMultiThreshold:
or max(self.hp[:3]) < self.config.HpControl_RepairUseMultiThreshold \
or max(self.hp[3:]) < self.config.HpControl_RepairUseMultiThreshold:
logger.info('Use emergency repair')
self.device.click(EMERGENCY_REPAIR_AVAILABLE)
self.interval_clear(EMERGENCY_REPAIR_CONFIRM)
return True

return False
Expand Down

0 comments on commit 156a988

Please sign in to comment.