feat: atmo suits, door lock/one-way, critter attack APIs

Atmo Suits:
- GET /api/state/atmo_suits: check suit docks, suit presence, O2 levels

Door Control:
- POST /api/action/door_lock {x, y, locked}: lock/unlock doors
- POST /api/action/door_one_way {x, y, direction}: set one-way passage

Critter Control:
- POST /api/action/critter_attack {x, y}: toggle attack on critter

CLI: atmo_suits, door_lock, door_one_way, critter_attack
This commit is contained in:
root
2026-05-22 09:43:02 +08:00
parent 1608357040
commit bbde9acadd
2 changed files with 240 additions and 1 deletions

View File

@ -967,6 +967,54 @@ def cmd_printing_pod_select(args):
result = api_post('/api/action/printing_pod_select', {"index": index})
_print_feedback(result)
# ---------------------------------------------------------------------------
# Atmo Suits / Critter Attack / Door Control
# ---------------------------------------------------------------------------
def cmd_atmo_suits(args):
"""Check atmo suit docks. Usage: atmo_suits"""
data = api_get('/api/state/atmo_suits')
if 'error' in data:
print(f"Error: {data['error']}")
return
print(f"Atmo Suit Docks: {data.get('dockCount', 0)}")
has = data.get('hasAtmoSuits', False)
print(f"Has suits available: {'YES' if has else 'NO'}")
for d in data.get('docks', []):
suit = "HAS SUIT" if d.get('hasSuit') else "empty"
o2 = d.get('o2Level', 0)
print(f" {d.get('name', '?'):20s} at ({d.get('x', '?')},{d.get('y', '?')}) "
f"{suit:10s} O2={o2:.0f} {'ON' if d.get('isOperational') else 'OFF'}")
def cmd_critter_attack(args):
"""Toggle critter attack. Usage: critter_attack <x> <y>"""
if len(args) < 2:
print("Usage: critter_attack <x> <y>")
return
result = api_post('/api/action/critter_attack', {"x": int(args[0]), "y": int(args[1])})
_print_feedback(result)
def cmd_door_lock(args):
"""Lock/unlock a door. Usage: door_lock <x> <y> <on|off>"""
if len(args) < 3:
print("Usage: door_lock <x> <y> <on|off>")
return
locked = args[2].lower() in ('on', 'true', '1', 'lock', 'locked', 'yes')
result = api_post('/api/action/door_lock', {
"x": int(args[0]), "y": int(args[1]), "locked": locked
})
_print_feedback(result)
def cmd_door_one_way(args):
"""Set door one-way. Usage: door_one_way <x> <y> <left|right|up|down|none>"""
if len(args) < 3:
print("Usage: door_one_way <x> <y> <left|right|up|down|none>")
return
result = api_post('/api/action/door_one_way', {
"x": int(args[0]), "y": int(args[1]), "direction": args[2]
})
_print_feedback(result)
# ---------------------------------------------------------------------------
# Screenshot / Camera
# ---------------------------------------------------------------------------
@ -1143,6 +1191,10 @@ COMMANDS = {
'set_automation': cmd_set_automation,
'printing_pod': cmd_printing_pod,
'printing_pod_select': cmd_printing_pod_select,
'atmo_suits': cmd_atmo_suits,
'critter_attack': cmd_critter_attack,
'door_lock': cmd_door_lock,
'door_one_way': cmd_door_one_way,
}
if __name__ == '__main__':
@ -1171,7 +1223,12 @@ if __name__ == '__main__':
print(" gas <x> <y> [r] Gas analysis in radius r")
print(" explore <x> <y> <w> <h> AI-friendly region summary")
print("")
print("=== Events / Printing Pod ===")
print("=== Door / Critter / Suits ===")
print(" door_lock <x> <y> on|off Lock/unlock a door")
print(" door_one_way <x> <y> <dir> Set door to one-way (left/right/up/down/none)")
print(" critter_attack <x> <y> Toggle critter attack mode")
print(" atmo_suits Check atmo suit dock status")
print("")
print(" events [since] [limit] Poll new game events")
print(" printing_pod Check Printing Pod status (ready/options)")
print(" printing_pod_select <0|1|2> Select Printing Pod option")