playtesterplugin
A seat that plays itself: a think reads the rows and names a press each frame.
Putting it in a scene
List it with the plugins of the page that is to play itself. It has no settings and no row. One exists per client, so the think a game hands it belongs to that client's scene. Until play is called it does nothing. A game's actor calls play in its setup:
"plugins": ["loader", "scenemanager", "player", "playtester", "render2d"]
plugins.playtester.play(plugins.player, rows => {
const me = rows.find(r => r.kind === 'player' && r.data.mine)
return me ? ['fire', 0, -1] : undefined
})
Methods
On the page
Through plugins.playtester.
play( player, think )
Hands the plugin the player to press through, normally plugins.player, and the think. Each frame the plugin calls think(rows) with the rows this seat is sent. The think returns [act, ...args] to press that act, or undefined to press nothing. The press goes through the player the way a key's would: a message at the seat's player row, with the args as given. Calling play again replaces the player and the think.
The think
A function ( rows ) => [act, ...args] | undefined. rows is the array of rows the seat sees this frame, and act is the name of an act of the player row.
Used by
No module uses it. For a seat the server drives itself, with no page, see playtest in player.