Skip to content

Commit 166862e

Browse files
authored
Merge pull request #1698 from LmeSzinc/bug_fix
Bug fix
2 parents 0db836b + 00ac710 commit 166862e

8 files changed

Lines changed: 67 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ GUI development, thanks **[@18870](https://github.com/18870)** , say HURRAY.
150150

151151
## 参与开发 Join Development
152152

153-
我们会不定期发布未来的工作在 [Issues](https://github.com/LmeSzinc/AzurLaneAutoScript/issues) 上并标记为 `help wanted`,欢迎向 Alas 提交 [Pull Requests](https://github.com/LmeSzinc/AzurLaneAutoScript/pulls),我们会认真阅读你的每一行代码的。
153+
Alas 仍在活跃开发中,我们会不定期发布未来的工作在 [Issues](https://github.com/LmeSzinc/AzurLaneAutoScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) 上并标记为 `help wanted`,欢迎向 Alas 提交 [Pull Requests](https://github.com/LmeSzinc/AzurLaneAutoScript/pulls),我们会认真阅读你的每一行代码的。
154154

155155
哦对,别忘了阅读 [开发文档](https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/1.-Start)
156156

README_en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Development documents, refer to [WIKI](https://github.com/LmeSzinc/AzurLaneAutoS
9292

9393
## Join Development
9494

95-
We will occasionally publish future work on [Issues](https://github.com/LmeSzinc/AzurLaneAutoScript/issues) and mark it as `help wanted`, feel free to submit [Pull Requests](https://github.com.com/LmeSzinc/AzurLaneAutoScript/pulls) to Alas, we will read every line of your code.
95+
Alas is still in active development, we will occasionally publish future work on [Issues](https://github.com/LmeSzinc/AzurLaneAutoScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) and mark it as `help wanted`, feel free to submit [Pull Requests](https://github.com.com/LmeSzinc/AzurLaneAutoScript/pulls) to Alas, we will read every line of your code.
9696

9797
Oh yeah, don't forget to read the [development documentation](https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/1.-Start).
9898

deploy/set.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import sys
2+
import typing as t
3+
4+
from deploy.utils import poor_yaml_read, poor_yaml_write, DEPLOY_TEMPLATE
5+
6+
"""
7+
Set config/deploy.yaml with commands like
8+
9+
python -m deploy.set GitExecutable=/usr/bin/git PythonExecutable=/usr/bin/python3.8
10+
"""
11+
12+
13+
def get_args() -> t.Dict[str, str]:
14+
args = {}
15+
for arg in sys.argv[1:]:
16+
if '=' not in arg:
17+
continue
18+
k, v = arg.split('=')
19+
k, v = k.strip(), v.strip()
20+
args[k] = v
21+
return args
22+
23+
24+
def config_set(output='./config/deploy.yaml'):
25+
data = poor_yaml_read(DEPLOY_TEMPLATE)
26+
data.update(poor_yaml_read(output))
27+
for k, v in get_args().items():
28+
if k in data:
29+
print(f'{k} set')
30+
data[k] = v
31+
else:
32+
print(f'{k} not exist')
33+
poor_yaml_write(data, file=output)
34+
35+
36+
if __name__ == '__main__':
37+
config_set()

module/device/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def __init__(self, config):
8080
config (AzurLaneConfig, str): Name of the user config under ./config
8181
"""
8282
super().__init__(config)
83-
self.detect_device()
83+
if not self.is_over_http:
84+
self.detect_device()
8485

8586
# Connect
8687
self.adb_connect(self.serial)

module/device/connection_attr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ def serial_check(self):
8787
self.config.Emulator_ScreenshotMethod = 'uiautomator2'
8888
self.config.Emulator_ControlMethod = 'uiautomator2'
8989
if self.is_over_http:
90-
if self.config.Emulator_ScreenshotMethod not in ["ADB", "uiautomator2"] \
90+
if self.config.Emulator_ScreenshotMethod not in ["ADB", "uiautomator2", "aScreenCap"] \
9191
or self.config.Emulator_ControlMethod not in ["ADB", "uiautomator2", "minitouch"]:
9292
logger.warning(
9393
f'When connecting to a device over http: {self.serial} '
94-
f'ScreenshotMethod can only use ["ADB", "uiautomator2"], '
94+
f'ScreenshotMethod can only use ["ADB", "uiautomator2", "aScreenCap"], '
9595
f'ControlMethod can only use ["ADB", "uiautomator2", "minitouch"]'
9696
)
9797
raise RequestHumanTakeover

module/handler/info_handler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ def handle_popup_cancel(self, name='', interval=2):
9191
return True
9292
return False
9393

94-
def handle_popup_single(self, name=''):
95-
if self.appear(GET_MISSION, offset=self._popup_offset, interval=2):
94+
def handle_popup_single(self, name='', offset=None):
95+
if offset is None:
96+
offset = self._popup_offset
97+
if self.appear(GET_MISSION, offset=offset, interval=2):
9698
prev_name = GET_MISSION.name
9799
GET_MISSION.name = POPUP_CONFIRM.name + '_' + name
98100
self.device.click(GET_MISSION)

module/os_handler/shop.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111
OCR_SHOP_PURPLE_COINS = Digit(SHOP_PURPLE_COINS, letter=(255, 255, 255), name='OCR_SHOP_PURPLE_COINS')
1212

1313

14+
class ShopPriceOcr(Digit):
15+
def __init__(self, *args, **kwargs):
16+
kwargs['alphabet'] = '0123456789ID'
17+
super().__init__(*args, **kwargs)
18+
19+
def after_process(self, result):
20+
result = ''.join(result)
21+
22+
# I00 -> 100
23+
result = result.replace('I', '1')
24+
# 1D -> 10
25+
result = result.replace('D', '0')
26+
result = int(result) if result else 0
27+
return result
28+
29+
1430
class OSShopHandler(UI, MapEventHandler):
1531
_shop_yellow_coins = 0
1632
_shop_purple_coins = 0
@@ -31,6 +47,7 @@ def os_shop_items(self):
3147
shop_items = ItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
3248
shop_items.load_template_folder('./assets/shop/os')
3349
shop_items.load_cost_template_folder('./assets/shop/os_cost')
50+
shop_items.price_ocr = ShopPriceOcr([], letter=(255, 223, 57), threshold=32, name='Price_ocr')
3451
return shop_items
3552

3653
def os_shop_get_items(self, name=True):

module/ui/ui.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from module.base.button import Button
22
from module.base.decorator import run_once
33
from module.base.timer import Timer
4+
from module.battle_pass.assets import PURCHASE_POPUP
45
from module.combat.assets import GET_ITEMS_1, GET_SHIP
56
from module.exception import (GameNotRunningError, GamePageUnknownError,
67
RequestHumanTakeover)
78
from module.handler.assets import (AUTO_SEARCH_MENU_EXIT, BATTLE_PASS_NOTICE,
8-
GAME_TIPS, GET_MISSION, LOGIN_ANNOUNCE,
9+
GAME_TIPS, LOGIN_ANNOUNCE,
910
LOGIN_CHECK, LOGIN_RETURN_SIGN,
1011
MONTHLY_PASS_NOTICE)
1112
from module.handler.info_handler import InfoHandler
@@ -15,7 +16,6 @@
1516
from module.ocr.ocr import Ocr
1617
from module.os_handler.assets import (EXCHANGE_CHECK, RESET_FLEET_PREPARATION,
1718
RESET_TICKET_POPUP)
18-
from module.battle_pass.assets import PURCHASE_POPUP
1919
from module.raid.assets import RAID_FLEET_PREPARATION
2020
from module.ui.assets import (BACK_ARROW, DORM_FEED_CANCEL, DORM_INFO,
2121
DORM_TROPHY_CONFIRM, EVENT_LIST_CHECK, GOTO_MAIN,
@@ -424,7 +424,7 @@ def ui_page_main_popups(self):
424424
if self.appear_then_click(PURCHASE_POPUP, offset=(44, -77, 84, -37), interval=3):
425425
return True
426426
# Item expired offset=(37, 72), skin expired, offset=(24, 68)
427-
if self.appear_then_click(GET_MISSION, offset=(-6, 48, 54, 88), interval=3):
427+
if self.handle_popup_single(offset=(-6, 48, 54, 88), name='ITEM_EXPIRED'):
428428
return True
429429

430430
return False

0 commit comments

Comments
 (0)