Skip to content

Commit

Permalink
Merge pull request #377 from LmeSzinc/dev
Browse files Browse the repository at this point in the history
Support cloud HSR on Android | 支持云星穹铁道安卓端
  • Loading branch information
LmeSzinc authored Mar 20, 2024
2 parents ff82687 + f2ada19 commit 5b710ef
Show file tree
Hide file tree
Showing 46 changed files with 995 additions and 99 deletions.
Binary file added assets/share/base/daemon/DUNGEON_EXIT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/share/base/daemon/TUTORIAL_CHECK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/share/base/daemon/TUTORIAL_CLOSE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/share/base/daemon/TUTORIAL_NEXT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/share/login/LOGIN_CONFIRM.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/share/map/control/TECHNIQUE_POINT_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/share/map/control/TECHNIQUE_POINT_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/share/map/control/TECHNIQUE_POINT_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/share/map/control/TECHNIQUE_POINT_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/share/map/control/TECHNIQUE_POINT_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/share/map/control/TECHNIQUE_POINT_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"Alas": {
"Emulator": {
"Serial": "auto",
"GameClient": "android",
"PackageName": "auto",
"GameLanguage": "auto",
"ScreenshotMethod": "scrcpy",
Expand All @@ -23,6 +24,11 @@
"ScreenshotInterval": 0.2,
"CombatScreenshotInterval": 1.0,
"WhenTaskQueueEmpty": "goto_main"
},
"CloudStorage": {
"CloudRemainSeasonPass": {},
"CloudRemainPaid": {},
"CloudRemainFree": {}
}
},
"Restart": {
Expand Down
5 changes: 3 additions & 2 deletions dev_tools/button_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ def iter_images():
for server in ASSET_SERVER:
for path, folders, files in os.walk(os.path.join(AzurLaneConfig.ASSETS_FOLDER, server)):
for file in files:
file = os.path.join(path, file).replace('\\', '/')
yield AssetsImage(file)
if not file.startswith('.'):
file = os.path.join(path, file).replace('\\', '/')
yield AssetsImage(file)


@dataclass
Expand Down
14 changes: 13 additions & 1 deletion module/alas.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ def checker(self):
logger.exception(e)
exit(1)

def restart(self):
raise NotImplemented

def start(self):
raise NotImplemented

def stop(self):
raise NotImplemented

def goto_main(self):
raise NotImplemented

def run(self, command):
try:
self.device.screenshot()
Expand Down Expand Up @@ -211,7 +223,7 @@ def get_next_task(self):
method = self.config.Optimization_WhenTaskQueueEmpty
if method == 'close_game':
logger.info('Close game during wait')
self.device.app_stop()
self.run('stop')
release_resources()
self.device.release_during_wait()
if not self.wait_until(task.next_run):
Expand Down
50 changes: 49 additions & 1 deletion module/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from module.base.utils import *
from module.config.config import AzurLaneConfig
from module.device.device import Device
from module.device.method.utils import HierarchyButton
from module.logger import logger
from module.webui.setting import cached_class_property

Expand Down Expand Up @@ -132,9 +133,56 @@ def match_template_color(self, button, interval=0, similarity=0.85, threshold=30

return appear

appear = match_template
def xpath(self, xpath) -> HierarchyButton:
if isinstance(xpath, str):
return HierarchyButton(self.device.hierarchy, xpath)
else:
return xpath

def xpath_appear(self, xpath: str, interval=0):
button = self.xpath(xpath)

self.device.stuck_record_add(button)

if interval and not self.interval_is_reached(button, interval=interval):
return False

appear = bool(button)

if appear and interval:
self.interval_reset(button, interval=interval)

return appear

def appear(self, button, interval=0, similarity=0.85):
"""
Args:
button (Button, ButtonWrapper, HierarchyButton, str):
interval (int, float): interval between two active events.
Returns:
bool:
Examples:
Template match:
```
self.device.screenshot()
self.appear(POPUP_CONFIRM)
```
Hierarchy detection (detect elements with xpath):
```
self.device.dump_hierarchy()
self.appear('//*[@resource-id="..."]')
```
"""
if isinstance(button, (HierarchyButton, str)):
return self.xpath_appear(button, interval=interval)
else:
return self.match_template(button, interval=interval, similarity=similarity)

def appear_then_click(self, button, interval=5, similarity=0.85):
button = self.xpath(button)
appear = self.appear(button, interval=interval, similarity=similarity)
if appear:
self.device.click(button)
Expand Down
62 changes: 48 additions & 14 deletions module/config/argument/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
"value": "auto",
"valuetype": "str"
},
"GameClient": {
"type": "select",
"value": "android",
"option": [
"android",
"cloud_android"
]
},
"PackageName": {
"type": "select",
"value": "auto",
Expand Down Expand Up @@ -131,6 +139,26 @@
"close_game"
]
}
},
"CloudStorage": {
"CloudRemainSeasonPass": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredInt"
},
"CloudRemainPaid": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredInt"
},
"CloudRemainFree": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredInt"
}
}
},
"Restart": {
Expand Down Expand Up @@ -165,11 +193,13 @@
"Dungeon": {
"Scheduler": {
"Enable": {
"type": "checkbox",
"type": "state",
"value": true,
"option": [
true,
false
true
],
"option_bold": [
true
]
},
"NextRun": {
Expand Down Expand Up @@ -243,7 +273,6 @@
"type": "select",
"value": "Calyx_Golden_Treasures",
"option": [
"do_not_participate",
"Calyx_Golden_Memories_Jarilo_VI",
"Calyx_Golden_Memories_The_Xianzhou_Luofu",
"Calyx_Golden_Memories_Penacony",
Expand All @@ -269,7 +298,6 @@
"type": "select",
"value": "Cavern_of_Corrosion_Path_of_Providence",
"option": [
"do_not_participate",
"Cavern_of_Corrosion_Path_of_Gelid_Wind",
"Cavern_of_Corrosion_Path_of_Jabbing_Punch",
"Cavern_of_Corrosion_Path_of_Drifting",
Expand Down Expand Up @@ -476,11 +504,13 @@
"DailyQuest": {
"Scheduler": {
"Enable": {
"type": "checkbox",
"type": "state",
"value": true,
"option": [
true,
false
true
],
"option_bold": [
true
]
},
"NextRun": {
Expand Down Expand Up @@ -911,11 +941,13 @@
"BattlePass": {
"Scheduler": {
"Enable": {
"type": "checkbox",
"type": "state",
"value": true,
"option": [
true,
false
true
],
"option_bold": [
true
]
},
"NextRun": {
Expand Down Expand Up @@ -996,11 +1028,13 @@
"Assignment": {
"Scheduler": {
"Enable": {
"type": "checkbox",
"type": "state",
"value": true,
"option": [
true,
false
true
],
"option_bold": [
true
]
},
"NextRun": {
Expand Down
14 changes: 12 additions & 2 deletions module/config/argument/argument.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Emulator:
Serial:
value: auto
valuetype: str
GameClient:
value: android
option: [ android, cloud_android ]
PackageName:
value: auto
option: [ auto, ]
Expand Down Expand Up @@ -72,6 +75,13 @@ Optimization:
WhenTaskQueueEmpty:
value: goto_main
option: [ stay_there, goto_main, close_game ]
CloudStorage:
CloudRemainSeasonPass:
stored: StoredInt
CloudRemainPaid:
stored: StoredInt
CloudRemainFree:
stored: StoredInt

# ==================== Daily ====================

Expand All @@ -82,10 +92,10 @@ Dungeon:
option: [ ]
NameAtDoubleCalyx:
value: Calyx_Golden_Treasures
option: [ do_not_participate, ]
option: [ ]
NameAtDoubleRelic:
value: Cavern_of_Corrosion_Path_of_Providence
option: [ do_not_participate, ]
option: [ ]
Team:
value: 1
option: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
Expand Down
28 changes: 28 additions & 0 deletions module/config/argument/override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ Restart:

# ==================== Daily ====================

Dungeon:
Scheduler:
Enable:
type: state
value: true
option: [ true, ]
option_bold: [ true, ]
DailyQuest:
Scheduler:
Enable:
type: state
value: true
option: [ true, ]
option_bold: [ true, ]
BattlePass:
Scheduler:
Enable:
type: state
value: true
option: [ true, ]
option_bold: [ true, ]
Assignment:
Scheduler:
Enable:
type: state
value: true
option: [ true, ]
option_bold: [ true, ]
DataUpdate:
Scheduler:
Enable:
Expand Down
36 changes: 36 additions & 0 deletions module/config/argument/stored.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,42 @@
"order": 8,
"color": "#fc8f8b"
},
"CloudRemainSeasonPass": {
"name": "CloudRemainSeasonPass",
"path": "Alas.CloudStorage.CloudRemainSeasonPass",
"i18n": "CloudStorage.CloudRemainSeasonPass.name",
"stored": "StoredInt",
"attrs": {
"time": "2020-01-01 00:00:00",
"value": 0
},
"order": 0,
"color": "#777777"
},
"CloudRemainPaid": {
"name": "CloudRemainPaid",
"path": "Alas.CloudStorage.CloudRemainPaid",
"i18n": "CloudStorage.CloudRemainPaid.name",
"stored": "StoredInt",
"attrs": {
"time": "2020-01-01 00:00:00",
"value": 0
},
"order": 0,
"color": "#777777"
},
"CloudRemainFree": {
"name": "CloudRemainFree",
"path": "Alas.CloudStorage.CloudRemainFree",
"i18n": "CloudStorage.CloudRemainFree.name",
"stored": "StoredInt",
"attrs": {
"time": "2020-01-01 00:00:00",
"value": 0
},
"order": 0,
"color": "#777777"
},
"Immersifier": {
"name": "Immersifier",
"path": "Dungeon.DungeonStorage.Immersifier",
Expand Down
1 change: 1 addition & 0 deletions module/config/argument/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Alas:
- EmulatorInfo
- Error
- Optimization
- CloudStorage
Restart:
- Scheduler

Expand Down
6 changes: 6 additions & 0 deletions module/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ def close_game(self):
self.data, keys="Alas.Optimization.CloseGameDuringWait", default=False
)

@property
def is_cloud_game(self):
return deep_get(
self.data, keys="Alas.Emulator.GameClient"
) == 'cloud_android'

@cached_property
def stored(self) -> StoredGenerated:
stored = StoredGenerated()
Expand Down
Loading

0 comments on commit 5b710ef

Please sign in to comment.