mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-27 23:39:41 +08:00
2
alas.py
2
alas.py
@@ -444,7 +444,7 @@ class AzurLaneAutoScript:
|
|||||||
# So update it once recovered
|
# So update it once recovered
|
||||||
del_cached_property(self, 'config')
|
del_cached_property(self, 'config')
|
||||||
logger.info('Server or network is recovered. Restart game client')
|
logger.info('Server or network is recovered. Restart game client')
|
||||||
self.run('restart')
|
self.config.task_call('Restart')
|
||||||
# Get task
|
# Get task
|
||||||
task = self.get_next_task()
|
task = self.get_next_task()
|
||||||
# Init device and change server
|
# Init device and change server
|
||||||
|
|||||||
@@ -331,12 +331,11 @@ class GemsFarming(CampaignRun, Dock, EquipmentChange):
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
# End
|
# End
|
||||||
success = True
|
|
||||||
if self._trigger_lv32 or self._trigger_emotion:
|
if self._trigger_lv32 or self._trigger_emotion:
|
||||||
success = success and self.flagship_change()
|
self.flagship_change()
|
||||||
|
|
||||||
if self.config.GemsFarming_LowEmotionRetreat:
|
if self.config.GemsFarming_LowEmotionRetreat:
|
||||||
success = success and self.vanguard_change()
|
self.vanguard_change()
|
||||||
|
|
||||||
if is_limit and self.config.StopCondition_RunCount <= 0:
|
if is_limit and self.config.StopCondition_RunCount <= 0:
|
||||||
logger.hr('Triggered stop condition: Run count')
|
logger.hr('Triggered stop condition: Run count')
|
||||||
@@ -353,10 +352,6 @@ class GemsFarming(CampaignRun, Dock, EquipmentChange):
|
|||||||
if self.config.task_switched():
|
if self.config.task_switched():
|
||||||
self.campaign.ensure_auto_search_exit()
|
self.campaign.ensure_auto_search_exit()
|
||||||
self.config.task_stop()
|
self.config.task_stop()
|
||||||
# Delay
|
|
||||||
if not success:
|
|
||||||
self.campaign.ensure_auto_search_exit()
|
|
||||||
self.config.task_delay(minute=30)
|
|
||||||
|
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
|
import time
|
||||||
|
|
||||||
import uiautomator2 as u2
|
import uiautomator2 as u2
|
||||||
from adbutils import AdbTimeout, _AdbStreamConnection
|
from adbutils import AdbTimeout, _AdbStreamConnection
|
||||||
@@ -59,6 +60,8 @@ def recv_all(stream, chunk_size=4096) -> bytes:
|
|||||||
chunk = stream.recv(chunk_size)
|
chunk = stream.recv(chunk_size)
|
||||||
if chunk:
|
if chunk:
|
||||||
fragments.append(chunk)
|
fragments.append(chunk)
|
||||||
|
# See https://stackoverflow.com/questions/23837827/python-server-program-has-high-cpu-usage/41749820#41749820
|
||||||
|
time.sleep(0.001)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
return remove_shell_warning(b''.join(fragments))
|
return remove_shell_warning(b''.join(fragments))
|
||||||
@@ -196,10 +199,21 @@ def remove_shell_warning(s):
|
|||||||
Returns:
|
Returns:
|
||||||
str, bytes:
|
str, bytes:
|
||||||
"""
|
"""
|
||||||
|
# WARNING: linker: [vdso]: unused DT entry: type 0x70000001 arg 0x0\n\x89PNG\r\n\x1a\n\x00\x00\x00\rIH
|
||||||
if isinstance(s, bytes):
|
if isinstance(s, bytes):
|
||||||
return re.sub(b'^WARNING.+\n', b'', s)
|
if s.startswith(b'WARNING'):
|
||||||
|
try:
|
||||||
|
s = s.split(b'\n', maxsplit=1)[1]
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
return s
|
||||||
|
# return re.sub(b'^WARNING.+\n', b'', s)
|
||||||
elif isinstance(s, str):
|
elif isinstance(s, str):
|
||||||
return re.sub('^WARNING.+\n', '', s)
|
if s.startswith('WARNING'):
|
||||||
|
try:
|
||||||
|
s = s.split('\n', maxsplit=1)[1]
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment):
|
|||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
|
|
||||||
if self.appear(BATTLE_PREPARATION):
|
if self.appear(BATTLE_PREPARATION):
|
||||||
|
|
||||||
# self.equipment_take_on()
|
# self.equipment_take_on()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -45,6 +44,7 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment):
|
|||||||
logger.info('Combat execute')
|
logger.info('Combat execute')
|
||||||
self.low_hp_confirm_timer = Timer(self.config.Exercise_LowHpConfirmWait, count=2).start()
|
self.low_hp_confirm_timer = Timer(self.config.Exercise_LowHpConfirmWait, count=2).start()
|
||||||
show_hp_timer = Timer(5)
|
show_hp_timer = Timer(5)
|
||||||
|
pause_interval = Timer(0.5, count=1)
|
||||||
success = True
|
success = True
|
||||||
end = False
|
end = False
|
||||||
|
|
||||||
@@ -78,25 +78,24 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Quit
|
# Quit
|
||||||
|
if self.appear_then_click(QUIT_CONFIRM, offset=(20, 20), interval=5):
|
||||||
|
success = False
|
||||||
|
end = True
|
||||||
|
continue
|
||||||
|
if self.appear_then_click(QUIT_RECONFIRM, offset=(20, 20), interval=5):
|
||||||
|
self.interval_reset(QUIT_CONFIRM)
|
||||||
|
continue
|
||||||
if not end:
|
if not end:
|
||||||
if self._at_low_hp(image=self.device.image):
|
if self._at_low_hp(image=self.device.image):
|
||||||
logger.info('Exercise quit')
|
logger.info('Exercise quit')
|
||||||
if self.appear_then_click(PAUSE, interval=0.5):
|
if pause_interval.reached() and self.appear_then_click(PAUSE):
|
||||||
|
pause_interval.reset()
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if show_hp_timer.reached():
|
if show_hp_timer.reached():
|
||||||
show_hp_timer.reset()
|
show_hp_timer.reset()
|
||||||
self._show_hp()
|
self._show_hp()
|
||||||
|
|
||||||
if self.appear_then_click(QUIT_CONFIRM, offset=(20, 20), interval=5):
|
|
||||||
success = False
|
|
||||||
end = True
|
|
||||||
continue
|
|
||||||
|
|
||||||
if self.appear_then_click(QUIT_RECONFIRM, offset=True, interval=5):
|
|
||||||
self.interval_reset(QUIT_CONFIRM)
|
|
||||||
continue
|
|
||||||
|
|
||||||
# End
|
# End
|
||||||
if self._in_exercise() or self.appear(BATTLE_PREPARATION, offset=(20, 20)):
|
if self._in_exercise() or self.appear(BATTLE_PREPARATION, offset=(20, 20)):
|
||||||
logger.hr('Combat end')
|
logger.hr('Combat end')
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class OSCamera(OSMapOperation, Camera):
|
|||||||
radar: Radar
|
radar: Radar
|
||||||
fleet_current: tuple
|
fleet_current: tuple
|
||||||
|
|
||||||
def _map_swipe(self, vector, box=(234, 123, 998, 633)):
|
def _map_swipe(self, vector, box=(239, 128, 993, 628)):
|
||||||
return super()._map_swipe(vector, box=box)
|
return super()._map_swipe(vector, box=box)
|
||||||
|
|
||||||
def _view_init(self):
|
def _view_init(self):
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class Retirement(Enhancement):
|
|||||||
amount = self._retire_amount
|
amount = self._retire_amount
|
||||||
end = False
|
end = False
|
||||||
total = 0
|
total = 0
|
||||||
|
click_count = 0
|
||||||
|
|
||||||
if self.config.RETIRE_KEEP_COMMON_CV:
|
if self.config.RETIRE_KEEP_COMMON_CV:
|
||||||
self._have_kept_cv = False
|
self._have_kept_cv = False
|
||||||
@@ -172,8 +173,15 @@ class Retirement(Enhancement):
|
|||||||
logger.info('No more ships to retire.')
|
logger.info('No more ships to retire.')
|
||||||
end = True
|
end = True
|
||||||
break
|
break
|
||||||
|
if click_count >= 3:
|
||||||
|
logger.warning('Failed to select ships using ONE_CLICK_RETIREMENT after 3 trial, '
|
||||||
|
'probably because game bugged, a re-enter should fix it')
|
||||||
|
# Mark as retire finished, higher level will call retires
|
||||||
|
end = True
|
||||||
|
break
|
||||||
# Click
|
# Click
|
||||||
if self.appear_then_click(ONE_CLICK_RETIREMENT, interval=2):
|
if self.appear_then_click(ONE_CLICK_RETIREMENT, interval=2):
|
||||||
|
click_count += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if end:
|
if end:
|
||||||
|
|||||||
Reference in New Issue
Block a user