Streams

class turnable.streams.BaseInputStream

An input stream knows how to acquire input from the player. In a CLI interface it might read from stdin, while in a network interface it might read from a socket.

request(request: turnable.streams.CommandRequest) turnable.streams.CommandResponse

Handles CommandRequest and builds an appropiate CommandResponse.

class turnable.streams.BaseOutputStream

An output stream knows how to send info to the user, and in which format.

send(game: Game)

Handles how the information gets to the player.

class turnable.streams.CommandRequest(label: str, commands: Optional[list] = None, instream: Optional[turnable.streams.BaseInputStream] = None)

Represents a request for user input. Part of the Command Series that allows for CLI gameplay.

get_command(tag: str) Optional[turnable.command.Command]

Returns turnable.command.Command based on tag.

send(retry: bool = False) turnable.streams.CommandResponse

Sends request through stream.

class turnable.streams.CommandResponse(request: turnable.streams.CommandRequest, command: str)

Represents the response built from a request and user input.

exception turnable.streams.StreamException