Skip to content

Commit

Permalink
修复自动战斗报错
Browse files Browse the repository at this point in the history
修复椿结束战斗可能不切人
  • Loading branch information
ok-oldking committed Jan 15, 2025
1 parent e47b71e commit 21bb22a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/task/AutoCombatTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ def run(self):
self.log_error(f'Characters dead', notify=True, tray=True)
break
except NotInCombatException as e:
current_char = self.get_current_char()
logger.info(f'auto_combat_task_out_of_combat {current_char} {e}')
current_char.on_combat_end(self.chars)
logger.info(f'auto_combat_task_out_of_combat {e}')
if self.debug:
self.screenshot(f'auto_combat_task_out_of_combat {e}')
break
self.combat_end()

def realm_perform(self):
if not self.last_is_click:
Expand Down
19 changes: 12 additions & 7 deletions src/task/BaseCombatTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ def combat_once(self, wait_combat_time=200, wait_before=1.5):
except CharDeadException as e:
raise e
except NotInCombatException as e:
self.get_current_char().on_combat_end(self.chars)
logger.info(f'combat_once out of combat break {e}')
# self.screenshot(f'combat_once_ooc {self.out_of_combat_reason}')
break
self.combat_end()
self.wait_in_team_and_world(time_out=10)
self.sleep(1)
self.middle_click()
Expand Down Expand Up @@ -279,14 +279,19 @@ def has_cd(self, box_name):
self.logger.debug(f'{box_name} has_cd {has_cd} {invalid_count} {number_count} {has_dot}')
return has_cd

def get_current_char(self) -> BaseChar:
def get_current_char(self, raise_exception=True) -> BaseChar:
for char in self.chars:
if char.is_current_char:
if char and char.is_current_char:
return char
if not self.in_team()[0]:
self.raise_not_in_combat('can find current char!!')
self.load_chars()
return self.get_current_char()
if raise_exception and not self.in_team()[0]:
self.raise_not_in_combat('can find current char!!')
# self.load_chars()
return None

def combat_end(self):
current_char = self.get_current_char(raise_exception=False)
if current_char:
self.get_current_char().on_combat_end(self.chars)

def sleep_check_combat(self, timeout, check_combat=True):
start = time.time()
Expand Down

0 comments on commit 21bb22a

Please sign in to comment.