Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: add maa close down task #4168

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions config/template.maa.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,19 @@
"Storage": {}
}
},
"MaaAftercareOperation": {
"Scheduler": {
"Enable": false,
"NextRun": "2020-01-01 04:00:00",
"Command": "MaaAftercareOperation",
"SuccessInterval": 0,
"FailureInterval": 0,
"ServerUpdate": "04:00"
},
"MaaAftercareOperation": {
"WhenTaskQueueEmpty": "stay_there"
}
},
"MaaReclamationAlgorithm": {
"Scheduler": {
"Enable": false,
Expand Down
3 changes: 3 additions & 0 deletions submodule/AlasMaaBridge/maa.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def maa_award(self):
def maa_roguelike(self):
AssistantHandler(config=self.config, asst=self.asst).roguelike()

def maa_aftercare_operation(self):
AssistantHandler(config=self.config, asst=self.asst).aftercare_operation()

def maa_reclamation_algorithm(self):
AssistantHandler(config=self.config, asst=self.asst).reclamation_algorithm()

Expand Down
44 changes: 44 additions & 0 deletions submodule/AlasMaaBridge/module/config/argument/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,50 @@
}
}
},
"MaaAftercareOperation": {
"Scheduler": {
"Enable": {
"type": "checkbox",
"value": true,
"display": "disabled"
},
"NextRun": {
"type": "datetime",
"value": "2020-01-01 04:00:00",
"validate": "datetime"
},
"Command": {
"type": "input",
"value": "MaaAftercareOperation",
"display": "hide"
},
"SuccessInterval": {
"type": "input",
"value": 0,
"display": "hide"
},
"FailureInterval": {
"type": "input",
"value": 0,
"display": "hide"
},
"ServerUpdate": {
"type": "input",
"value": "04:00",
"display": "hide"
}
},
"MaaAftercareOperation": {
"WhenTaskQueueEmpty": {
"type": "select",
"value": "stay_there",
"option": [
"stay_there",
"close_game"
]
}
}
},
"MaaReclamationAlgorithm": {
"Scheduler": {
"Enable": {
Expand Down
5 changes: 5 additions & 0 deletions submodule/AlasMaaBridge/module/config/argument/argument.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ MaaRoguelike:
option: [ no_use, start_with_elite_two, only_start_with_elite_two ]
refreshTraderWithDice: false

MaaAftercareOperation:
WhenTaskQueueEmpty:
value: stay_there
option: [ stay_there, close_game ]

MaaAward:
Mail: False
Recruit: False
Expand Down
4 changes: 4 additions & 0 deletions submodule/AlasMaaBridge/module/config/argument/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ MaaMaterial:
MaaFight:
Scheduler:
SuccessInterval: 240

MaaAftercareOperation:
Scheduler:
Enable: true
1 change: 1 addition & 0 deletions submodule/AlasMaaBridge/module/config/argument/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"MaaMall",
"MaaAward",
"MaaRoguelike",
"MaaAftercareOperation",
"MaaReclamationAlgorithm"
]
},
Expand Down
9 changes: 9 additions & 0 deletions submodule/AlasMaaBridge/module/config/argument/override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,12 @@ MaaRecruit:
MaaAward:
Scheduler:
ServerUpdate: 04:00, 16:00

MaaAftercareOperation
Scheduler
Enable:
value: true
display: disabled
SuccessInterval: 0
FailureInterval: 0
ServerUpdate: 04:00
3 changes: 3 additions & 0 deletions submodule/AlasMaaBridge/module/config/argument/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Maa:
MaaRoguelike:
- Scheduler
- MaaRoguelike
MaaAftercareOperation:
- Scheduler
- MaaAftercareOperation
MaaReclamationAlgorithm:
- Scheduler

Expand Down
1 change: 1 addition & 0 deletions submodule/AlasMaaBridge/module/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ArknightsConfig(AzurLaneConfig, ConfigUpdater, GeneratedConfig):
> MaaFight > MaaAward
> MaaReclamationAlgorithm
> MaaRoguelike
> MaaAftercareOperation
"""

def __init__(self, config_name, task=None):
Expand Down
3 changes: 3 additions & 0 deletions submodule/AlasMaaBridge/module/config/config_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ class GeneratedConfig:
MaaAward_Orundum = False
MaaAward_Specialaccess = False

# Group 'MaaAftercareOperation'
MaaAftercareOperation_WhenTaskQueueEmpty = 'stay_there'

# Group `MaaCopilot`
MaaCopilot_FileName = None
MaaCopilot_Identify = False
Expand Down
17 changes: 17 additions & 0 deletions submodule/AlasMaaBridge/module/config/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
"name": "Roguelike (I.S.)",
"help": "auto for Integrated strategies"
},
"MaaAftercareOperation": {
"name": "EndTask",
"help": ""
},
"MaaReclamationAlgorithm": {
"name": "ReclamationAlgorithm",
"help": "auto for Reclamation Algorithm"
Expand Down Expand Up @@ -613,6 +617,19 @@
"help": "MaaAward.Specialaccess.help"
}
},
"MaaAftercareOperation": {
"_info": {
"name": "MaaAftercareOperation._info.name",
"help": "MaaAftercareOperation._info.help"
},
"WhenTaskQueueEmpty": {
"name": "MaaAftercareOperation.WhenTaskQueueEmpty.name",
"help": "MaaAftercareOperation.WhenTaskQueueEmpty.help",
"stay_there": "Stay There",
"goto_main": "Goto Main Page",
"close_game": "Close Game"
}
},
"MaaCopilot": {
"_info": {
"name": "MaaCopilot",
Expand Down
17 changes: 17 additions & 0 deletions submodule/AlasMaaBridge/module/config/i18n/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
"name": "Task.MaaRoguelike.name",
"help": "Task.MaaRoguelike.help"
},
"MaaAftercareOperation": {
"name": "Task.MaaAftercareOperation.name",
"help": "Task.MaaAftercareOperation.help"
},
"MaaReclamationAlgorithm": {
"name": "Task.MaaReclamationAlgorithm.name",
"help": "Task.MaaReclamationAlgorithm.help"
Expand Down Expand Up @@ -613,6 +617,19 @@
"help": "MaaAward.Specialaccess.help"
}
},
"MaaAftercareOperation": {
"_info": {
"name": "MaaAftercareOperation._info.name",
"help": "MaaAftercareOperation._info.help"
},
"WhenTaskQueueEmpty": {
"name": "MaaAftercareOperation.WhenTaskQueueEmpty.name",
"help": "MaaAftercareOperation.WhenTaskQueueEmpty.help",
"stay_there": "Stay There",
"goto_main": "Goto Main Page",
"close_game": "Close Game"
}
},
"MaaCopilot": {
"_info": {
"name": "MaaCopilot._info.name",
Expand Down
17 changes: 17 additions & 0 deletions submodule/AlasMaaBridge/module/config/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
"name": "自动肉鸽",
"help": ""
},
"MaaAftercareOperation": {
"name": "结束任务",
"help": ""
},
"MaaReclamationAlgorithm": {
"name": "生息演算",
"help": "警告:该功能仍在开发中,只能无限刷取,一旦启用会导致所有其他任务无法正常运行"
Expand Down Expand Up @@ -613,6 +617,19 @@
"help": ""
}
},
"MaaAftercareOperation": {
"_info": {
"name": "任务完成后",
"help": ""
},
"WhenTaskQueueEmpty": {
"name": "当任务队列清空后",
"help": "无任务时关闭游戏,能在收菜期间降低 CPU 占用",
"stay_there": "停在原处",
"goto_main": "前往主界面",
"close_game": "关闭游戏"
}
},
"MaaCopilot": {
"_info": {
"name": "作业设置",
Expand Down
17 changes: 17 additions & 0 deletions submodule/AlasMaaBridge/module/config/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
"name": "Task.MaaRoguelike.name",
"help": "Task.MaaRoguelike.help"
},
"MaaAftercareOperation": {
"name": "Task.MaaAftercareOperation.name",
"help": "Task.MaaAftercareOperation.help"
},
"MaaReclamationAlgorithm": {
"name": "Task.MaaReclamationAlgorithm.name",
"help": "Task.MaaReclamationAlgorithm.help"
Expand Down Expand Up @@ -613,6 +617,19 @@
"help": "MaaAward.Specialaccess.help"
}
},
"MaaAftercareOperation": {
"_info": {
"name": "MaaAftercareOperation._info.name",
"help": "MaaAftercareOperation._info.help"
},
"WhenTaskQueueEmpty": {
"name": "MaaAftercareOperation.WhenTaskQueueEmpty.name",
"help": "MaaAftercareOperation.WhenTaskQueueEmpty.help",
"stay_there": "Stay There",
"goto_main": "Goto Main Page",
"close_game": "Close Game"
}
},
"MaaCopilot": {
"_info": {
"name": "MaaCopilot._info.name",
Expand Down
11 changes: 11 additions & 0 deletions submodule/AlasMaaBridge/module/handler/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def startup(self):
"client_type": self.config.MaaEmulator_PackageName,
"start_game_enabled": True
})
self.config.task_call('MaaAftercareOperation', force_call=False)
self.config.task_delay(server_update=True)

def fight(self):
Expand Down Expand Up @@ -493,6 +494,16 @@ def reclamation_algorithm(self):
})
self.config.task_delay(server_update=True)

def aftercare_operation(self):
if self.config.MaaAftercareOperation_WhenTaskQueueEmpty == 'close_game':
self.maa_start('CloseDown', {
"client_type": self.config.MaaEmulator_PackageName
})
if self.config.waiting_task:
nexttime = self.config.waiting_task[0].next_run
self.config.task_delay(target=nexttime, task="MaaStartup")
self.config.task_delay(server_update=True)
Comment on lines +497 to +505
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

等待下一个任务应该是调度器层次考虑的,任务层次应该只完成自己的任务

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有办法,需要保证关闭游戏后, 下一个任务执行前游戏是开启的


def copilot(self):
filename = self.config.MaaCopilot_FileName
if filename.startswith('maa://'):
Expand Down