mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 01:49:41 +00:00
Add: Task DailyQuest
This commit is contained in:
parent
c8fcd5f0f3
commit
74562d03e4
@ -37,11 +37,19 @@
|
|||||||
"Enable": false,
|
"Enable": false,
|
||||||
"NextRun": "2020-01-01 00:00:00",
|
"NextRun": "2020-01-01 00:00:00",
|
||||||
"Command": "Dungeon",
|
"Command": "Dungeon",
|
||||||
"ServerUpdate": "00:00"
|
"ServerUpdate": "04:00"
|
||||||
},
|
},
|
||||||
"Dungeon": {
|
"Dungeon": {
|
||||||
"Name": "Calyx_Golden_Memories",
|
"Name": "Calyx_Golden_Memories",
|
||||||
"Team": 1
|
"Team": 1
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"DailyQuest": {
|
||||||
|
"Scheduler": {
|
||||||
|
"Enable": false,
|
||||||
|
"NextRun": "2020-01-01 00:00:00",
|
||||||
|
"Command": "DailyQuest",
|
||||||
|
"ServerUpdate": "04:00"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -163,7 +163,7 @@
|
|||||||
},
|
},
|
||||||
"ServerUpdate": {
|
"ServerUpdate": {
|
||||||
"type": "input",
|
"type": "input",
|
||||||
"value": "00:00",
|
"value": "04:00",
|
||||||
"display": "hide"
|
"display": "hide"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -212,5 +212,28 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"DailyQuest": {
|
||||||
|
"Scheduler": {
|
||||||
|
"Enable": {
|
||||||
|
"type": "checkbox",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"NextRun": {
|
||||||
|
"type": "datetime",
|
||||||
|
"value": "2020-01-01 00:00:00",
|
||||||
|
"validate": "datetime"
|
||||||
|
},
|
||||||
|
"Command": {
|
||||||
|
"type": "input",
|
||||||
|
"value": "DailyQuest",
|
||||||
|
"display": "hide"
|
||||||
|
},
|
||||||
|
"ServerUpdate": {
|
||||||
|
"type": "input",
|
||||||
|
"value": "04:00",
|
||||||
|
"display": "hide"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ Scheduler:
|
|||||||
NextRun: 2020-01-01 00:00:00
|
NextRun: 2020-01-01 00:00:00
|
||||||
Command: Alas
|
Command: Alas
|
||||||
ServerUpdate:
|
ServerUpdate:
|
||||||
value: 00:00
|
value: 04:00
|
||||||
display: hide
|
display: hide
|
||||||
Emulator:
|
Emulator:
|
||||||
Serial:
|
Serial:
|
||||||
@ -67,7 +67,7 @@ Optimization:
|
|||||||
value: goto_main
|
value: goto_main
|
||||||
option: [ stay_there, goto_main, close_game ]
|
option: [ stay_there, goto_main, close_game ]
|
||||||
|
|
||||||
# ==================== Farm ====================
|
# ==================== Daily ====================
|
||||||
|
|
||||||
Dungeon:
|
Dungeon:
|
||||||
Name:
|
Name:
|
||||||
@ -77,9 +77,3 @@ Dungeon:
|
|||||||
Team:
|
Team:
|
||||||
value: 1
|
value: 1
|
||||||
option: [ 1, 2, 3, 4, 5, 6 ]
|
option: [ 1, 2, 3, 4, 5, 6 ]
|
||||||
|
|
||||||
# ==================== Daily ====================
|
|
||||||
|
|
||||||
|
|
||||||
# ==================== Tools ====================
|
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"menu": "list",
|
"menu": "list",
|
||||||
"page": "setting",
|
"page": "setting",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
"Dungeon"
|
"Dungeon",
|
||||||
|
"DailyQuest"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,3 +25,5 @@ Daily:
|
|||||||
Dungeon:
|
Dungeon:
|
||||||
- Scheduler
|
- Scheduler
|
||||||
- Dungeon
|
- Dungeon
|
||||||
|
DailyQuest:
|
||||||
|
- Scheduler
|
||||||
|
@ -13,7 +13,7 @@ class GeneratedConfig:
|
|||||||
Scheduler_Enable = False
|
Scheduler_Enable = False
|
||||||
Scheduler_NextRun = datetime.datetime(2020, 1, 1, 0, 0)
|
Scheduler_NextRun = datetime.datetime(2020, 1, 1, 0, 0)
|
||||||
Scheduler_Command = 'Alas'
|
Scheduler_Command = 'Alas'
|
||||||
Scheduler_ServerUpdate = '00:00'
|
Scheduler_ServerUpdate = '04:00'
|
||||||
|
|
||||||
# Group `Emulator`
|
# Group `Emulator`
|
||||||
Emulator_Serial = 'auto'
|
Emulator_Serial = 'auto'
|
||||||
|
@ -10,7 +10,7 @@ class ManualConfig:
|
|||||||
|
|
||||||
SCHEDULER_PRIORITY = """
|
SCHEDULER_PRIORITY = """
|
||||||
Restart
|
Restart
|
||||||
> Dungeon
|
> Dungeon > DailyQuest
|
||||||
"""
|
"""
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
"Dungeon": {
|
"Dungeon": {
|
||||||
"name": "Dungeon",
|
"name": "Dungeon",
|
||||||
"help": ""
|
"help": ""
|
||||||
|
},
|
||||||
|
"DailyQuest": {
|
||||||
|
"name": "Daily Quest",
|
||||||
|
"help": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Scheduler": {
|
"Scheduler": {
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
"Dungeon": {
|
"Dungeon": {
|
||||||
"name": "Task.Dungeon.name",
|
"name": "Task.Dungeon.name",
|
||||||
"help": "Task.Dungeon.help"
|
"help": "Task.Dungeon.help"
|
||||||
|
},
|
||||||
|
"DailyQuest": {
|
||||||
|
"name": "Task.DailyQuest.name",
|
||||||
|
"help": "Task.DailyQuest.help"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Scheduler": {
|
"Scheduler": {
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
"Dungeon": {
|
"Dungeon": {
|
||||||
"name": "每日副本",
|
"name": "每日副本",
|
||||||
"help": ""
|
"help": ""
|
||||||
|
},
|
||||||
|
"DailyQuest": {
|
||||||
|
"name": "每日任务",
|
||||||
|
"help": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Scheduler": {
|
"Scheduler": {
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
"Dungeon": {
|
"Dungeon": {
|
||||||
"name": "每日副本",
|
"name": "每日副本",
|
||||||
"help": ""
|
"help": ""
|
||||||
|
},
|
||||||
|
"DailyQuest": {
|
||||||
|
"name": "每日任務",
|
||||||
|
"help": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Scheduler": {
|
"Scheduler": {
|
||||||
|
4
src.py
4
src.py
@ -26,6 +26,10 @@ class StarRailCopilot(AzurLaneAutoScript):
|
|||||||
from tasks.dungeon.dungeon import Dungeon
|
from tasks.dungeon.dungeon import Dungeon
|
||||||
Dungeon(config=self.config, device=self.device).run()
|
Dungeon(config=self.config, device=self.device).run()
|
||||||
|
|
||||||
|
def daily_quest(self):
|
||||||
|
from tasks.daily.daily_quest import DailyQuestUI
|
||||||
|
DailyQuestUI(config=self.config, device=self.device).run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
src = StarRailCopilot('src')
|
src = StarRailCopilot('src')
|
||||||
|
@ -17,6 +17,7 @@ class CameraUI(UI):
|
|||||||
in: Any
|
in: Any
|
||||||
out: page_camera, TAKE_PICTURE
|
out: page_camera, TAKE_PICTURE
|
||||||
"""
|
"""
|
||||||
|
logger.hr('Take picture', level=2)
|
||||||
self.ui_ensure(page_camera, skip_first_screenshot)
|
self.ui_ensure(page_camera, skip_first_screenshot)
|
||||||
# Take picture
|
# Take picture
|
||||||
skip_first_screenshot = True
|
skip_first_screenshot = True
|
||||||
|
@ -5,7 +5,9 @@ from module.logger import *
|
|||||||
from module.ocr.ocr import Ocr, OcrResultButton
|
from module.ocr.ocr import Ocr, OcrResultButton
|
||||||
from module.ocr.utils import split_and_pair_buttons
|
from module.ocr.utils import split_and_pair_buttons
|
||||||
from tasks.daily.assets.assets_daily_reward import *
|
from tasks.daily.assets.assets_daily_reward import *
|
||||||
from tasks.daily.keywords import DailyQuest, DailyQuestState, KEYWORDS_DAILY_QUEST_STATE
|
from tasks.daily.camera import CameraUI
|
||||||
|
from tasks.daily.keywords import DailyQuest, DailyQuestState, KEYWORDS_DAILY_QUEST, KEYWORDS_DAILY_QUEST_STATE
|
||||||
|
from tasks.daily.synthesize import SynthesizeConsumablesUI
|
||||||
from tasks.dungeon.keywords import KEYWORDS_DUNGEON_TAB
|
from tasks.dungeon.keywords import KEYWORDS_DUNGEON_TAB
|
||||||
from tasks.dungeon.ui import DungeonUI
|
from tasks.dungeon.ui import DungeonUI
|
||||||
|
|
||||||
@ -20,6 +22,11 @@ class DailyQuestOcr(Ocr):
|
|||||||
result = result.replace("J", "」")
|
result = result.replace("J", "」")
|
||||||
result = result.replace(";", "」")
|
result = result.replace(";", "」")
|
||||||
result = result.replace("宇审", "宇宙")
|
result = result.replace("宇审", "宇宙")
|
||||||
|
# 进行中」hbadarin
|
||||||
|
if "进行中" in result:
|
||||||
|
result = "进行中"
|
||||||
|
if "已领取" in result:
|
||||||
|
result = "已领取"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@ -85,8 +92,6 @@ class DailyQuestUI(DungeonUI):
|
|||||||
results = [result.matched_keyword for result in results]
|
results = [result.matched_keyword for result in results]
|
||||||
logger.info("Daily quests recognition complete")
|
logger.info("Daily quests recognition complete")
|
||||||
logger.info(f"Daily quests: {results}")
|
logger.info(f"Daily quests: {results}")
|
||||||
if len(results) != 6:
|
|
||||||
logger.warning(f'Unexpected amount of daily quests: {len(results)}')
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _get_quest_reward(self, skip_first_screenshot=True):
|
def _get_quest_reward(self, skip_first_screenshot=True):
|
||||||
@ -111,6 +116,9 @@ class DailyQuestUI(DungeonUI):
|
|||||||
and (self.appear(ACTIVE_POINTS_5_LOCKED) or self.appear(ACTIVE_POINTS_5_CHECKED))
|
and (self.appear(ACTIVE_POINTS_5_LOCKED) or self.appear(ACTIVE_POINTS_5_CHECKED))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _all_reward_got(self):
|
||||||
|
return self.appear(ACTIVE_POINTS_5_CHECKED)
|
||||||
|
|
||||||
def _get_active_point_reward(self, skip_first_screenshot=True):
|
def _get_active_point_reward(self, skip_first_screenshot=True):
|
||||||
while 1:
|
while 1:
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
@ -134,9 +142,55 @@ class DailyQuestUI(DungeonUI):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
def get_daily_rewards(self):
|
def get_daily_rewards(self):
|
||||||
|
"""
|
||||||
|
Returns:
|
||||||
|
int: If all reward got.
|
||||||
|
|
||||||
|
Pages:
|
||||||
|
in: Any
|
||||||
|
out: page_guide, Daily_Training
|
||||||
|
"""
|
||||||
|
logger.hr('Get daily rewards', level=2)
|
||||||
self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Daily_Training)
|
self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Daily_Training)
|
||||||
logger.info("Getting quest rewards")
|
logger.info("Getting quest rewards")
|
||||||
self._get_quest_reward()
|
self._get_quest_reward()
|
||||||
logger.info("Getting active point rewards")
|
logger.info("Getting active point rewards")
|
||||||
self._get_active_point_reward()
|
self._get_active_point_reward()
|
||||||
|
if self._all_reward_got():
|
||||||
logger.info("All daily reward got")
|
logger.info("All daily reward got")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
logger.info('Daily reward got but not yet claimed')
|
||||||
|
return False
|
||||||
|
|
||||||
|
def do_daily_quests(self):
|
||||||
|
"""
|
||||||
|
Returns:
|
||||||
|
int: Number of quests done
|
||||||
|
"""
|
||||||
|
logger.hr('Recognize quests', level=1)
|
||||||
|
quests = self.daily_quests_recognition()
|
||||||
|
|
||||||
|
done = 0
|
||||||
|
logger.hr('Do quests', level=1)
|
||||||
|
if KEYWORDS_DAILY_QUEST.Take_1_photo in quests:
|
||||||
|
CameraUI(self.config, self.device).take_picture()
|
||||||
|
done += 1
|
||||||
|
if KEYWORDS_DAILY_QUEST.Synthesize_Consumable_1_time in quests:
|
||||||
|
SynthesizeConsumablesUI(self.config, self.device).synthesize_consumables()
|
||||||
|
done += 1
|
||||||
|
|
||||||
|
return done
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
for _ in range(5):
|
||||||
|
got = self.get_daily_rewards()
|
||||||
|
if got:
|
||||||
|
break
|
||||||
|
done = self.do_daily_quests()
|
||||||
|
if not done:
|
||||||
|
logger.info('No more quests able to do')
|
||||||
|
break
|
||||||
|
|
||||||
|
# Scheduler
|
||||||
|
self.config.task_delay(server_update=True)
|
||||||
|
@ -57,7 +57,7 @@ class SynthesizeUI(UI):
|
|||||||
|
|
||||||
|
|
||||||
class SynthesizeConsumablesUI(SynthesizeUI):
|
class SynthesizeConsumablesUI(SynthesizeUI):
|
||||||
def synthesize(self) -> bool:
|
def synthesize_consumables(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Returns:
|
Returns:
|
||||||
bool:
|
bool:
|
||||||
@ -65,9 +65,9 @@ class SynthesizeConsumablesUI(SynthesizeUI):
|
|||||||
Examples:
|
Examples:
|
||||||
self = SynthesizeConsumablesUI('alas')
|
self = SynthesizeConsumablesUI('alas')
|
||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
result = self.synthesize()
|
result = self.synthesize_consumables()
|
||||||
"""
|
"""
|
||||||
|
logger.hr('Synthesize consumables', level=2)
|
||||||
# If the current page is not the menu page,
|
# If the current page is not the menu page,
|
||||||
# the menu scroll bar must be at the top when opening the menu page from other page,
|
# the menu scroll bar must be at the top when opening the menu page from other page,
|
||||||
# so first step is determine whether the scroll bar is at the top
|
# so first step is determine whether the scroll bar is at the top
|
||||||
|
Loading…
Reference in New Issue
Block a user