feat: add mining collection automation
This commit is contained in:
1 parent
b6bd78dc66
commit
bf758bab01
16 files changed
+276
-4
No files matched your search
@@ -0,0 +1,41 @@
|
||||
"""Run from the project root: python claim_mining.py [--dry-run]."""
|
||||
import argparse
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from automation.engine import Matcher, WorkflowError, load_flow
|
||||
from automation.mining import MiningRunner
|
||||
from automation.offers import MacGameDesktop
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='狂鼠之家:一键收矿、优先罗盘雇佣、返回首页')
|
||||
parser.add_argument('--dry-run', action='store_true', help='只验证首页并显示计划,不点击')
|
||||
args = parser.parse_args()
|
||||
if sys.platform != 'darwin':
|
||||
print('当前脚本已验证 macOS;Windows 版将在校准入口完成后接入。', file=sys.stderr)
|
||||
return 2
|
||||
try:
|
||||
desktop = MacGameDesktop()
|
||||
# Focusing the empty WeChat title area prevents the first capture from
|
||||
# observing another foreground surface. It does not touch game content.
|
||||
desktop.activate()
|
||||
print('3 秒后开始;请保持游戏在前台。鼠标移到主屏幕左上角可紧急停止。', flush=True)
|
||||
time.sleep(3)
|
||||
runner = MiningRunner(desktop, Matcher(ROOT / 'assets'),
|
||||
load_flow(ROOT / 'workflows/mining_claim.json'), desktop.region_for)
|
||||
runner.run(args.dry_run)
|
||||
return 0
|
||||
except KeyboardInterrupt:
|
||||
print('已停止。', file=sys.stderr)
|
||||
return 130
|
||||
except Exception as exc:
|
||||
print('流程停止:' + str(exc), file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user