format_version: 1
key: maker.sonar_console
version: 1
name: A signal from the deep
description: A button starts a sonar cue. Its completion requests a story observation.
characters:
  orion:
    name: Navigator Orion
    personality: Observant, patient, and quietly amused by unexpected discoveries.
    prompt: You navigate a homemade submarine on an imagined ocean expedition. Help
      its captain listen, investigate, and name what they discover. Begin with
      an unexplained sound beyond the windows. Let the captain decide whether to
      follow it, wait, or ask a question. A whale is one possible encounter, not
      a guaranteed result of a button press.
    voice: orion_voice
    initial_presence: submarine
story_rules:
  - A completed sonar cue requests an observation; it does not prove that any
    particular creature was found.
  - Keep each dialogue segment to one complete thought. Attach consequences to
    the segment that reveals them.
  - Remember exact accepted names and choices. Continue from durable state and
    confirmed heard dialogue.
initial_state:
  facts:
    contact.identity: unknown
  knowledge:
    captain: {}
    orion: {}
  relationships:
    orion:
      captain:
        trust: 0.7
  device:
    map_key: sonar
    map_revision: 1
    presentation: {}
allowed_effects:
  - fact_set
  - knowledge_set
inputs:
  contact_requested:
    mode: director
    instruction: The captain completed a sonar ping. Describe one observation
      supported by the current underwater story, then invite a choice. Do not
      assume a successful discovery from the local sound alone.
device:
  requires:
    primary_action: button
    push_to_talk: button
    status_indicator: light
    main_audio: speaker
    microphone: microphone
  media:
    narration: main_audio
    capture: microphone
  local_state:
    ready:
      type: boolean
      default: true
  events:
    contact_requested:
      direction: device_to_server
      payload: {}
  maps:
    sonar:
      playable: true
      routes:
        - id: send_ping
          on: primary_action.pressed
          when:
            - path: state.ready
              op: eq
              value: true
          actions:
            - state.set:
                path: ready
                value: false
            - light.set:
                target: status_indicator
                value: true
            - sound.play:
                asset: sonar_ping
                key: ping
            - timer.start:
                timer: ping_timeout
                delay_ms: 8000
        - id: hear_contact
          on: sound.completed
          when:
            - path: event.key
              op: eq
              value: ping
          actions:
            - light.set:
                target: status_indicator
                value: false
            - timer.cancel:
                timer: ping_timeout
            - state.set:
                path: ready
                value: true
            - server.emit:
                event: contact_requested
        - id: ping_timed_out
          on: timer.ping_timeout
          actions:
            - sound.stop:
                target: main_audio
            - light.set:
                target: status_indicator
                value: false
            - state.set:
                path: ready
                value: true
        - id: reconnect_controls
          on: connection.ready
          actions:
            - timer.cancel:
                timer: ping_timeout
            - light.set:
                target: status_indicator
                value: false
            - state.set:
                path: ready
                value: true
        - id: capture_begin
          on: push_to_talk.pressed
          actions:
            - timer.cancel:
                timer: ping_timeout
            - light.set:
                target: status_indicator
                value: false
            - state.set:
                path: ready
                value: true
            - capture.begin: {}
        - id: capture_stop
          on: push_to_talk.released
          actions:
            - capture.stop: {}
  state_sync: []
assets:
  sonar_ping:
    sha256: 79702b4710f37597a1bc7adb28d853592620a81625725f563dca6ed7267952c0
    required: true
