heardaddon
What a truth's steps answered, for a test or the simulator to read.
Using it
A truth keeps no message it has answered, so a server that never asks holds none. Calling heard on a truth starts a list of every message its steps answer from then on. The list is the caller's to read and to empty.
import { heard } from '#addons/heard/heard.addon.ts'
const answered = heard(truth)
// after some steps
const presses = answered.filter(h => h.seat === 0).length
answered.length = 0
A test uses it to count the presses the server took. The simulator uses it to write down which page's message each step took.
A message is answered on the step it is stamped with, or on the first step after it reaches the truth. A message held for a later step is in the list once that step runs, and never before. A message that a piece attached to the truth earlier refused is not in the list, because the truth did not take it.
On a server that rewinds (see rewind), steps run again take the messages they took before, and a late press is put back on its step. A message that the steps run again answer on the step it was written down at is not written down again. A message answered on a different step than before, a late press or one a late press moved, is written down again at the step that answers it now.
Methods
heard( truth ) : Heard[]
Starts writing down the messages the truth answers and returns the list they are added to. Each entry is:
| Field | Meaning |
|---|---|
at | The step that answered the message. |
seat | The seat that sent it. |
msg | The message as the seat sent it. |
Used by
- simulatorWrites down which page's message each step took.