Add: Task to update dashboard

This commit is contained in:
LmeSzinc 2023-09-24 16:46:39 +08:00
parent 4cc4647705
commit 7a8f9f129e
20 changed files with 256 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -129,6 +129,18 @@
"Assignment": {} "Assignment": {}
} }
}, },
"DataUpdate": {
"Scheduler": {
"Enable": true,
"NextRun": "2020-01-01 00:00:00",
"Command": "DataUpdate",
"ServerUpdate": "04:00"
},
"ItemStorage": {
"Credit": {},
"StallerJade": {}
}
},
"Rogue": { "Rogue": {
"Scheduler": { "Scheduler": {
"Enable": false, "Enable": false,

View File

@ -997,6 +997,53 @@
} }
} }
}, },
"DataUpdate": {
"Scheduler": {
"Enable": {
"type": "state",
"value": true,
"option": [
true
],
"option_bold": [
true
]
},
"NextRun": {
"type": "datetime",
"value": "2020-01-01 00:00:00",
"validate": "datetime"
},
"Command": {
"type": "input",
"value": "DataUpdate",
"display": "hide"
},
"ServerUpdate": {
"type": "input",
"value": "04:00",
"display": "hide"
}
},
"ItemStorage": {
"Credit": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredInt",
"order": 7,
"color": "#ab7cf2"
},
"StallerJade": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredInt",
"order": 8,
"color": "#fc8f8b"
}
}
},
"Rogue": { "Rogue": {
"Scheduler": { "Scheduler": {
"Enable": { "Enable": {

View File

@ -168,6 +168,16 @@ Assignment:
order: 3 order: 3
color: "#79dbc4" color: "#79dbc4"
ItemStorage:
Credit:
stored: StoredInt
order: 7
color: "#ab7cf2"
StallerJade:
stored: StoredInt
order: 8
color: "#fc8f8b"
# ==================== Rogue ==================== # ==================== Rogue ====================
RoguePath: RoguePath:

View File

@ -14,7 +14,8 @@
"Dungeon", "Dungeon",
"DailyQuest", "DailyQuest",
"BattlePass", "BattlePass",
"Assignment" "Assignment",
"DataUpdate"
] ]
} }
} }

View File

@ -21,10 +21,12 @@ Restart:
option_bold: [ true, ] option_bold: [ true, ]
ServerUpdate: 04:00 ServerUpdate: 04:00
# ==================== Farm ====================
# ==================== Daily ==================== # ==================== Daily ====================
DataUpdate:
# ==================== Tools ==================== Scheduler:
Enable:
type: state
value: true
option: [ true, ]
option_bold: [ true, ]

View File

@ -64,6 +64,30 @@
"order": 6, "order": 6,
"color": "#8fb5fe" "color": "#8fb5fe"
}, },
"Credit": {
"name": "Credit",
"path": "DataUpdate.ItemStorage.Credit",
"i18n": "ItemStorage.Credit.name",
"stored": "StoredInt",
"attrs": {
"time": "2020-01-01 00:00:00",
"value": 0
},
"order": 7,
"color": "#ab7cf2"
},
"StallerJade": {
"name": "StallerJade",
"path": "DataUpdate.ItemStorage.StallerJade",
"i18n": "ItemStorage.StallerJade.name",
"stored": "StoredInt",
"attrs": {
"time": "2020-01-01 00:00:00",
"value": 0
},
"order": 8,
"color": "#fc8f8b"
},
"DungeonDouble": { "DungeonDouble": {
"name": "DungeonDouble", "name": "DungeonDouble",
"path": "Dungeon.DungeonStorage.DungeonDouble", "path": "Dungeon.DungeonStorage.DungeonDouble",

View File

@ -38,6 +38,9 @@ Daily:
Assignment: Assignment:
- Scheduler - Scheduler
- Assignment - Assignment
DataUpdate:
- Scheduler
- ItemStorage
# ==================== Rogue ==================== # ==================== Rogue ====================

View File

@ -103,6 +103,10 @@ class GeneratedConfig:
Assignment_Duration = 20 # 4, 8, 12, 20 Assignment_Duration = 20 # 4, 8, 12, 20
Assignment_Assignment = {} Assignment_Assignment = {}
# Group `ItemStorage`
ItemStorage_Credit = {}
ItemStorage_StallerJade = {}
# Group `RoguePath` # Group `RoguePath`
RoguePath_Path = 'The_Hunt' # Preservation, Remembrance, Nihility, Abundance, The_Hunt, Destruction, Elation RoguePath_Path = 'The_Hunt' # Preservation, Remembrance, Nihility, Abundance, The_Hunt, Destruction, Elation
RoguePath_Bonus = 'Blessing Cosmos' # Blessing Cosmos, Miracle Cosmos, Fragmented Cosmos RoguePath_Bonus = 'Blessing Cosmos' # Blessing Cosmos, Miracle Cosmos, Fragmented Cosmos

View File

@ -10,7 +10,8 @@ class ManualConfig:
SCHEDULER_PRIORITY = """ SCHEDULER_PRIORITY = """
Restart Restart
> BattlePass > DailyQuest > Assignment > Dungeon > BattlePass > DailyQuest > Assignment > DataUpdate
> Dungeon
""" """
""" """

View File

@ -38,6 +38,10 @@
"name": "Assignment", "name": "Assignment",
"help": "" "help": ""
}, },
"DataUpdate": {
"name": "Dashboard Upd",
"help": ""
},
"Rogue": { "Rogue": {
"name": "Simulated Universe", "name": "Simulated Universe",
"help": "Simulated Universe is in development, task will not be run" "help": "Simulated Universe is in development, task will not be run"
@ -694,7 +698,21 @@
"20": "20 Hours" "20": "20 Hours"
}, },
"Assignment": { "Assignment": {
"name": "Assignment", "name": "Assign.",
"help": ""
}
},
"ItemStorage": {
"_info": {
"name": "ItemStorage._info.name",
"help": "ItemStorage._info.help"
},
"Credit": {
"name": "Credit",
"help": ""
},
"StallerJade": {
"name": "Jade",
"help": "" "help": ""
} }
}, },

View File

@ -38,6 +38,10 @@
"name": "依頼設定", "name": "依頼設定",
"help": "" "help": ""
}, },
"DataUpdate": {
"name": "Task.DataUpdate.name",
"help": "Task.DataUpdate.help"
},
"Rogue": { "Rogue": {
"name": "Task.Rogue.name", "name": "Task.Rogue.name",
"help": "Task.Rogue.help" "help": "Task.Rogue.help"
@ -698,6 +702,20 @@
"help": "Assignment.Assignment.help" "help": "Assignment.Assignment.help"
} }
}, },
"ItemStorage": {
"_info": {
"name": "ItemStorage._info.name",
"help": "ItemStorage._info.help"
},
"Credit": {
"name": "ItemStorage.Credit.name",
"help": "ItemStorage.Credit.help"
},
"StallerJade": {
"name": "ItemStorage.StallerJade.name",
"help": "ItemStorage.StallerJade.help"
}
},
"RoguePath": { "RoguePath": {
"_info": { "_info": {
"name": "RoguePath._info.name", "name": "RoguePath._info.name",

View File

@ -38,6 +38,10 @@
"name": "委托", "name": "委托",
"help": "" "help": ""
}, },
"DataUpdate": {
"name": "仪表盘更新",
"help": ""
},
"Rogue": { "Rogue": {
"name": "模拟宇宙", "name": "模拟宇宙",
"help": "模拟宇宙还在开发中,任务不会被运行" "help": "模拟宇宙还在开发中,任务不会被运行"
@ -698,6 +702,20 @@
"help": "" "help": ""
} }
}, },
"ItemStorage": {
"_info": {
"name": "ItemStorage._info.name",
"help": "ItemStorage._info.help"
},
"Credit": {
"name": "信用点",
"help": ""
},
"StallerJade": {
"name": "星琼",
"help": ""
}
},
"RoguePath": { "RoguePath": {
"_info": { "_info": {
"name": "命途设置", "name": "命途设置",

View File

@ -38,6 +38,10 @@
"name": "委託", "name": "委託",
"help": "" "help": ""
}, },
"DataUpdate": {
"name": "儀表板更新",
"help": ""
},
"Rogue": { "Rogue": {
"name": "模擬宇宙", "name": "模擬宇宙",
"help": "模擬宇宙還在開發中,任務不會被運行" "help": "模擬宇宙還在開發中,任務不會被運行"
@ -698,6 +702,20 @@
"help": "" "help": ""
} }
}, },
"ItemStorage": {
"_info": {
"name": "ItemStorage._info.name",
"help": "ItemStorage._info.help"
},
"Credit": {
"name": "信用點",
"help": ""
},
"StallerJade": {
"name": "星瓊",
"help": ""
}
},
"RoguePath": { "RoguePath": {
"_info": { "_info": {
"name": "命途設定", "name": "命途設定",

View File

@ -26,3 +26,5 @@ class StoredGenerated:
BattlePassLevel = StoredBattlePassLevel("BattlePass.BattlePassStorage.BattlePassLevel") BattlePassLevel = StoredBattlePassLevel("BattlePass.BattlePassStorage.BattlePassLevel")
BattlePassTodayQuest = StoredBattlePassTodayQuest("BattlePass.BattlePassStorage.BattlePassTodayQuest") BattlePassTodayQuest = StoredBattlePassTodayQuest("BattlePass.BattlePassStorage.BattlePassTodayQuest")
Assignment = StoredAssignment("Assignment.Assignment.Assignment") Assignment = StoredAssignment("Assignment.Assignment.Assignment")
Credit = StoredInt("DataUpdate.ItemStorage.Credit")
StallerJade = StoredInt("DataUpdate.ItemStorage.StallerJade")

4
src.py
View File

@ -38,6 +38,10 @@ class StarRailCopilot(AzurLaneAutoScript):
from tasks.assignment.assignment import Assignment from tasks.assignment.assignment import Assignment
Assignment(config=self.config, device=self.device).run() Assignment(config=self.config, device=self.device).run()
def data_update(self):
from tasks.item.data_update import DataUpdate
DataUpdate(config=self.config, device=self.device).run()
if __name__ == '__main__': if __name__ == '__main__':
src = StarRailCopilot('src') src = StarRailCopilot('src')

View File

@ -143,10 +143,11 @@ class UI(PopupHandler, MainPage):
# Reset connection # Reset connection
Page.clear_connection() Page.clear_connection()
def ui_ensure(self, destination, skip_first_screenshot=True): def ui_ensure(self, destination, acquire_lang_checked=True, skip_first_screenshot=True):
""" """
Args: Args:
destination (Page): destination (Page):
acquire_lang_checked:
skip_first_screenshot: skip_first_screenshot:
Returns: Returns:
@ -154,8 +155,10 @@ class UI(PopupHandler, MainPage):
""" """
logger.hr("UI ensure") logger.hr("UI ensure")
self.ui_get_current_page(skip_first_screenshot=skip_first_screenshot) self.ui_get_current_page(skip_first_screenshot=skip_first_screenshot)
if self.acquire_lang_checked():
self.ui_get_current_page(skip_first_screenshot=skip_first_screenshot) if acquire_lang_checked:
if self.acquire_lang_checked():
self.ui_get_current_page(skip_first_screenshot=skip_first_screenshot)
if self.ui_current == destination: if self.ui_current == destination:
logger.info("Already at %s" % destination) logger.info("Already at %s" % destination)

View File

@ -327,5 +327,6 @@ class DailyQuestUI(DungeonUI, RouteLoader):
if KEYWORD_BATTLE_PASS_QUEST.Reach_500_on_Daily_Training_Activity in quests: if KEYWORD_BATTLE_PASS_QUEST.Reach_500_on_Daily_Training_Activity in quests:
logger.info('Achieved battle pass quest Reach_500_on_Daily_Training_Activity') logger.info('Achieved battle pass quest Reach_500_on_Daily_Training_Activity')
self.config.task_call('BattlePass') self.config.task_call('BattlePass')
self.config.task_call('DataUpdate')
# Delay self # Delay self
self.config.task_delay(server_update=True) self.config.task_delay(server_update=True)

View File

@ -0,0 +1,15 @@
from module.base.button import Button, ButtonWrapper
# This file was auto-generated, do not modify it manually. To generate:
# ``` python -m dev_tools.button_extract ```
OCR_DATA = ButtonWrapper(
name='OCR_DATA',
share=Button(
file='./assets/share/item/data/OCR_DATA.png',
area=(843, 13, 1152, 61),
search=(823, 0, 1172, 81),
color=(39, 43, 51),
button=(843, 13, 1152, 61),
),
)

44
tasks/item/data_update.py Normal file
View File

@ -0,0 +1,44 @@
from module.base.timer import Timer
from module.logger import logger
from module.ocr.ocr import Digit
from tasks.base.page import page_item
from tasks.base.ui import UI
from tasks.item.assets.assets_item_data import OCR_DATA
class DataUpdate(UI):
def _get_data(self):
"""
Page:
in: page_item
"""
ocr = Digit(OCR_DATA)
timeout = Timer(2, count=6).start()
credit, jade = 0, 0
while 1:
data = ocr.detect_and_ocr(self.device.image)
if len(data) == 2:
credit, jade = [int(d.ocr_text) for d in data]
if credit > 0 or jade > 0:
break
logger.warning(f'Invalid credit and stellar jade: {data}')
if timeout.reached():
logger.warning('Get data timeout')
break
logger.attr('Credit', credit)
logger.attr('StellarJade', jade)
with self.config.multi_set():
self.config.stored.Credit.value = credit
self.config.stored.StallerJade.value = jade
return credit, jade
def run(self):
self.ui_ensure(page_item, acquire_lang_checked=False)
with self.config.multi_set():
self._get_data()
self.config.task_delay(server_update=True)