1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-12 12:08:21 +08:00
This commit is contained in:
sui-feng-cb
2026-01-30 12:22:02 +08:00
3 changed files with 36 additions and 17 deletions

View File

@@ -56,28 +56,39 @@ class ConnectionAttr:
self.config.DEVICE_OVER_HTTP = self.is_over_http
@staticmethod
def revise_serial(serial):
serial = serial.replace(' ', '')
def revise_serial(serial: str):
"""
Tons of fool-proof fixes to handle manual serial input
To load a serial:
serial = SerialStr.revise_serial(serial)
"""
serial = serial.strip().replace(' ', '')
# 127。0。0。15555
serial = serial.replace('', '.').replace('', '.').replace(',', '.').replace('', ':')
# 127.0.0.1.5555
serial = serial.replace('127.0.0.1.', '127.0.0.1:')
# Mumu12 5.0 shows double serials, some people may just copy-paste it
# 5555,16384 -> replaced to 5555.16384
# 5555,16384 (actually "5555.16384" because replace(',', '.'))
if '.' in serial:
left, _, right = serial.partition('.')
if left.startswith('55') and right.startswith('16'):
serial = right
try:
left = int(left)
right = int(right)
if 5500 < left < 6000 and 16300 < right < 20000:
serial = str(right)
except ValueError:
pass
# 16384
try:
port = int(serial)
if 1000 < port < 65536:
serial = f'127.0.0.1:{port}'
except ValueError:
pass
if serial.isdigit():
try:
port = int(serial)
if 1000 < port < 65536:
serial = f'127.0.0.1:{port}'
except ValueError:
pass
# 夜神模拟器 127.0.0.1:62001
# MuMu模拟器12127.0.0.1:16384
if '模拟' in serial:
import re
res = re.search(r'(127\.\d+\.\d+\.\d+:\d+)', serial)
if res:
serial = res.group(1)

View File

@@ -279,19 +279,19 @@ def get_serial_pair(serial):
serial (str):
Returns:
str, str: `127.0.0.1:5555+{X}` and `emulator-5554+{X}`, 0 <= X <= 32
tuple[Optional[str], Optional[str]]: `127.0.0.1:5555+{X}` and `emulator-5554+{X}`, 0 <= X <= 32
"""
if serial.startswith('127.0.0.1:'):
try:
port = int(serial[10:])
if 5555 <= port <= 5555 + 32:
if 5555 <= port <= 5555 + 64:
return f'127.0.0.1:{port}', f'emulator-{port - 1}'
except (ValueError, IndexError):
pass
if serial.startswith('emulator-'):
try:
port = int(serial[9:])
if 5554 <= port <= 5554 + 32:
if 5554 <= port <= 5554 + 64:
return f'127.0.0.1:{port + 1}', f'emulator-{port}'
except (ValueError, IndexError):
pass

View File

@@ -11,13 +11,20 @@ PORT_CHECK = PORT_GOTO_SUPPLY
class PortHandler(OSShop):
def port_enter(self, skip_first_screenshot=True):
def port_enter(self):
"""
Pages:
in: IN_MAP
out: PORT_CHECK
"""
self.ui_click(PORT_ENTER, check_button=PORT_CHECK, skip_first_screenshot=skip_first_screenshot)
logger.info('Port enter')
for _ in self.loop():
if self.appear(PORT_CHECK, offset=(20, 20)):
break
if self.appear_then_click(PORT_ENTER, offset=(20, 20), interval=5):
continue
if self.handle_map_event():
continue
# Buttons at the bottom has an animation to show
pass # Already ensured in ui_click
@@ -27,6 +34,7 @@ class PortHandler(OSShop):
in: PORT_CHECK
out: IN_MAP
"""
logger.info('Port quit')
self.ui_back(appear_button=PORT_CHECK, check_button=self.is_in_map,
skip_first_screenshot=skip_first_screenshot)
# Buttons at the bottom has an animation to show