feat: game pause/speed control API with AI pause protocol
- POST /api/action/pause - pause game (AI must call before operations) - POST /api/action/unpause - resume game at desired speed - POST /api/action/speed - set game speed (1x/2x/3x) - Game state now includes isPaused and gameSpeed - AI pause protocol documented in SKILL.md: pause before every operation - Introduces cell.isDiggable flag that filters neutronium properly - pause/unpause/speed CLI commands added to oni_api.py
This commit is contained in:
@ -474,6 +474,30 @@ def cmd_priority_type(args):
|
||||
})
|
||||
_print_feedback(result)
|
||||
|
||||
def cmd_pause(args):
|
||||
"""Pause the game. Usage: pause [reason]"""
|
||||
reason = ' '.join(args) if args else 'AI operation in progress'
|
||||
result = api_post('/api/action/pause', {} if not args else {"reason": reason})
|
||||
_print_feedback(result)
|
||||
|
||||
def cmd_unpause(args):
|
||||
"""Unpause the game. Usage: unpause [speed]"""
|
||||
speed = int(args[0]) if args else 1
|
||||
result = api_post('/api/action/unpause', {"speed": speed})
|
||||
_print_feedback(result)
|
||||
|
||||
def cmd_speed(args):
|
||||
"""Set game speed. Usage: speed <1|2|3>"""
|
||||
if not args:
|
||||
print("Usage: speed <1|2|3>")
|
||||
return
|
||||
speed = int(args[0])
|
||||
if speed < 1 or speed > 3:
|
||||
print("Speed must be 1, 2, or 3")
|
||||
return
|
||||
result = api_post('/api/action/speed', {"speed": speed})
|
||||
_print_feedback(result)
|
||||
|
||||
def _print_feedback(result):
|
||||
"""Pretty-print action feedback."""
|
||||
if result.get('success'):
|
||||
@ -584,6 +608,9 @@ COMMANDS = {
|
||||
'batch': cmd_batch,
|
||||
'priority_global': cmd_priority_global,
|
||||
'priority_type': cmd_priority_type,
|
||||
'pause': cmd_pause,
|
||||
'unpause': cmd_unpause,
|
||||
'speed': cmd_speed,
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -631,6 +658,11 @@ if __name__ == '__main__':
|
||||
print(" mop <x> <y> Mop liquid")
|
||||
print(" harvest <x> <y> Harvest plant")
|
||||
print("")
|
||||
print("=== Game Speed Control ===")
|
||||
print(" pause [reason] Pause the game (AI should always pause before ops)")
|
||||
print(" unpause [speed] Unpause the game at 1x/2x/3x speed")
|
||||
print(" speed <1|2|3> Set game speed while running")
|
||||
print("")
|
||||
print("=== Batch / Priority (Advanced) ===")
|
||||
print(" batch <json_file> Execute batch plan")
|
||||
print(" priority_global <t> <p> Set global default priority")
|
||||
|
||||
Reference in New Issue
Block a user