This website requires JavaScript.
0
Issues
Pull Requests
Milestones
Explore
0
Create…
New Repository
New Migration
New Organization
public
Signed in as
public
Profile
Starred
Subscriptions
Settings
Help
Sign Out
yws
/
lc-mcp
Watch
1
Star
0
Fork
0
Code
Issues
Pull Requests
Actions
Packages
Projects
Releases
Wiki
Activity
Files
lc-mcp
/
scripts
/
or
Cancel
Edit File
Preview
Preview Changes
Spaces
Tabs
2
4
8
Wrap
No wrap
"""Bounded Win Rate batches through MCP, with a fresh UI check per turn.""" import argparse import json import math import os import time from pathlib import Path from mcp_session import Session, SessionCancelled, SessionTimeout from game_scenes import battle_is_terminal, battle_is_visible STOP_FILE = Path(os.environ.get('LC_JEV_HOME', str(Path.home() / 'lc_mcp' / 'jev'))) / 'JEV_STOP' def is_terminal(state): return battle_is_terminal(state) def main(): parser = argparse.ArgumentParser() parser.add_argument('--seconds', type=float, default=40) parser.add_argument('--battle-confirmed', action='store_true') args = parser.parse_args() if not math.isfinite(args.seconds) or args.seconds <= 0: parser.error('--seconds must be finite and positive') deadline = time.monotonic() + min(50, max(1, args.seconds)) pairs = 0 state = {} def cancelled(): return STOP_FILE.exists() or time.monotonic() >= deadline try: if cancelled(): raise SessionCancelled('Battle batch stopped before connecting') with Session(cancelled=cancelled, raise_on_error=False) as client: state = client.call('get_state') active = args.battle_confirmed or battle_is_visible(state) while not cancelled(): # Cinematics hide the HUD; explicit scene boundaries end combat. if not state.get('ok') or not active or is_terminal(state): break # P cycles between Win Rate and Damage in current game versions. # Only start a turn when its explicit Win Rate control is visible. items = state.get('items', []) labels = [item['text'].replace(' ', '').lower() for item in items] target = next((item['text'] for item, label in zip(items, labels) if label in ('win', 'winrate', '胜率')), None) # OCR 常把回合数连在一起(如 'WAVE 1' -> 'wave1'), 用包含匹配 if target and any(m in label for label in labels for m in ('turn', 'wave', '回合', '波次')): selected = client.call('click_text', {'text': target}) if selected.get('ok'): time.sleep(.5) if cancelled(): raise SessionCancelled('Battle batch stopped between Win Rate and Enter') client.call('keypress', {'key': 'enter'}) pairs += 1 time.sleep(min(2.5, max(0, deadline - time.monotonic()))) if cancelled(): break state = client.call('get_state') result = {'pairs': pairs, 'state': state, 'stopped': cancelled()} except (SessionCancelled, SessionTimeout) as error: result = {'pairs': pairs, 'state': state, 'stopped': True, 'error': str(error), 'outcome_unknown': error.outcome_unknown} print(json.dumps(result, ensure_ascii=False)) if __name__ == '__main__': main()
Commit Changes
Add a Signed-off-by trailer by the committer at the end of the commit log message.
Commit directly to the
fix/team-scroll-patch
branch.
Create a
new branch
for this commit and start a pull request.
Commit Changes
Cancel