Skip to main content

Catchphrase provides software components to build parser-based interactive fiction for the web.

Catchphrase is a Python library, and part of the Turberfield namespace.

For a demonstration of such a project, see the repository tea_and_sympathy. You are free to download and experiment with that example.

This framework makes heavy use of the turberfield-dialogue library. The documentation is at an early stage.

Framework

  • A drama class to encapsulate game logic.

  • A parser system which maps text phrases to drama methods and parameters.

  • A presenter class which combines static dialogue with drama output.

  • Renderer functions to animate the output in HTML or plain text.

Drama

Drama objects are responsible for the game logic of your story. Any calculations, computations and state transitions get done there.

I recommend the following techniques for organising your Drama code:

  • Write unit tests for the dramas in your story, to drive out the bugs in your story logic.

  • Partition your code into loosely-coupled modules, allowing you to share and re-use that logic.

  • Use Python multiple inheritance to layer story-specific behaviour on top of mundane mechanics.

Dramas work by implementing a generator method for a group of semantically similar free-text commands. Each method declares the syntax of those commands in its docstring.

The responsibility of a Drama method is also to yield strings of dialogue. You splice these into the main narrative dialogue of your story.

Drama methods can add or discard themselves or other methods from active duty. In this way complex scenarios can be achieved while minimising the potential for unplanned behaviour in game logic.

Parser

The parser module provides functions to help drama objects respond to text input.

The CommandParser class interrogates drama methods to determine what parameters they require. Based on this information, and the declaration made in method docstrings, the parser generates all commands understood in the current context of the drama.

Presenter

The Presenter combines static dialogue with the generated output from a Drama object.

  • Prepare a turberfield-dialogue Folder object.

  • Create a Presenter from the Folder and the drama output.

  • Call the animate method to generate web frames ready for rendering.

Renderer

The Renderer is a namespace for functions which generate HTML5 elements from Presenter frames. There is also support for plain text output.

Metadata

Release files for turberfield-catchphrase 0.25.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for turberfield-catchphrase 0.25.0
File Size Uploaded Provenance
turberfield-catchphrase-0.25.0.tar.gz 30.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for turberfield-catchphrase 0.25.0
File Interpreter ABI Platform
turberfield_catchphrase-0.25.0-py3-none-any.whl Python 3 none any Details

Total release size: 67.0 kB

Release files / turberfield-catchphrase-0.25.0.tar.gz

Download URL turberfield-catchphrase-0.25.0.tar.gz
Size 30.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc947f228df771f095701fda696ca13c7610b06f7bd92b532025123446bada2f
BLAKE2b-256 checksum
How to use checksums
fa166ec048eebe7a045dfa9c5c5858c12b65ba6d5e97076b029332185158f2fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5

Release files / turberfield_catchphrase-0.25.0-py3-none-any.whl

Download URL turberfield_catchphrase-0.25.0-py3-none-any.whl
Size 36.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c1f358fe60f7da4e34993c9a84360b5f8aa7e801c3b617cbc73b978f3f06075
BLAKE2b-256 checksum
How to use checksums
5aee61731ed891c6447d91af225fa720aef2a8c5e748d73069af2d7a4066cf36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5

Security for turberfield-catchphrase 0.25.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page