mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-15 14:37:20 +08:00
Merge branch 'master' of https://github.com/LmeSzinc/AzurLaneAutoScript
This commit is contained in:
@@ -56,28 +56,39 @@ class ConnectionAttr:
|
|||||||
self.config.DEVICE_OVER_HTTP = self.is_over_http
|
self.config.DEVICE_OVER_HTTP = self.is_over_http
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def revise_serial(serial):
|
def revise_serial(serial: str):
|
||||||
serial = serial.replace(' ', '')
|
"""
|
||||||
|
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。1:5555
|
# 127。0。0。1:5555
|
||||||
serial = serial.replace('。', '.').replace(',', '.').replace(',', '.').replace(':', ':')
|
serial = serial.replace('。', '.').replace(',', '.').replace(',', '.').replace(':', ':')
|
||||||
# 127.0.0.1.5555
|
# 127.0.0.1.5555
|
||||||
serial = serial.replace('127.0.0.1.', '127.0.0.1:')
|
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 (actually "5555.16384" because replace(',', '.'))
|
||||||
# 5555,16384 -> replaced to 5555.16384
|
|
||||||
if '.' in serial:
|
if '.' in serial:
|
||||||
left, _, right = serial.partition('.')
|
left, _, right = serial.partition('.')
|
||||||
if left.startswith('55') and right.startswith('16'):
|
try:
|
||||||
serial = right
|
left = int(left)
|
||||||
|
right = int(right)
|
||||||
|
if 5500 < left < 6000 and 16300 < right < 20000:
|
||||||
|
serial = str(right)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
# 16384
|
# 16384
|
||||||
try:
|
if serial.isdigit():
|
||||||
port = int(serial)
|
try:
|
||||||
if 1000 < port < 65536:
|
port = int(serial)
|
||||||
serial = f'127.0.0.1:{port}'
|
if 1000 < port < 65536:
|
||||||
except ValueError:
|
serial = f'127.0.0.1:{port}'
|
||||||
pass
|
except ValueError:
|
||||||
|
pass
|
||||||
# 夜神模拟器 127.0.0.1:62001
|
# 夜神模拟器 127.0.0.1:62001
|
||||||
# MuMu模拟器12127.0.0.1:16384
|
# MuMu模拟器12127.0.0.1:16384
|
||||||
if '模拟' in serial:
|
if '模拟' in serial:
|
||||||
|
import re
|
||||||
res = re.search(r'(127\.\d+\.\d+\.\d+:\d+)', serial)
|
res = re.search(r'(127\.\d+\.\d+\.\d+:\d+)', serial)
|
||||||
if res:
|
if res:
|
||||||
serial = res.group(1)
|
serial = res.group(1)
|
||||||
|
|||||||
@@ -279,19 +279,19 @@ def get_serial_pair(serial):
|
|||||||
serial (str):
|
serial (str):
|
||||||
|
|
||||||
Returns:
|
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:'):
|
if serial.startswith('127.0.0.1:'):
|
||||||
try:
|
try:
|
||||||
port = int(serial[10:])
|
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}'
|
return f'127.0.0.1:{port}', f'emulator-{port - 1}'
|
||||||
except (ValueError, IndexError):
|
except (ValueError, IndexError):
|
||||||
pass
|
pass
|
||||||
if serial.startswith('emulator-'):
|
if serial.startswith('emulator-'):
|
||||||
try:
|
try:
|
||||||
port = int(serial[9:])
|
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}'
|
return f'127.0.0.1:{port + 1}', f'emulator-{port}'
|
||||||
except (ValueError, IndexError):
|
except (ValueError, IndexError):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -11,13 +11,20 @@ PORT_CHECK = PORT_GOTO_SUPPLY
|
|||||||
|
|
||||||
|
|
||||||
class PortHandler(OSShop):
|
class PortHandler(OSShop):
|
||||||
def port_enter(self, skip_first_screenshot=True):
|
def port_enter(self):
|
||||||
"""
|
"""
|
||||||
Pages:
|
Pages:
|
||||||
in: IN_MAP
|
in: IN_MAP
|
||||||
out: PORT_CHECK
|
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
|
# Buttons at the bottom has an animation to show
|
||||||
pass # Already ensured in ui_click
|
pass # Already ensured in ui_click
|
||||||
|
|
||||||
@@ -27,6 +34,7 @@ class PortHandler(OSShop):
|
|||||||
in: PORT_CHECK
|
in: PORT_CHECK
|
||||||
out: IN_MAP
|
out: IN_MAP
|
||||||
"""
|
"""
|
||||||
|
logger.info('Port quit')
|
||||||
self.ui_back(appear_button=PORT_CHECK, check_button=self.is_in_map,
|
self.ui_back(appear_button=PORT_CHECK, check_button=self.is_in_map,
|
||||||
skip_first_screenshot=skip_first_screenshot)
|
skip_first_screenshot=skip_first_screenshot)
|
||||||
# Buttons at the bottom has an animation to show
|
# Buttons at the bottom has an animation to show
|
||||||
|
|||||||
Reference in New Issue
Block a user