Skip to main content

Catchphrase

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.14.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.14.0
File Size Uploaded
turberfield-catchphrase-0.14.0.tar.gz 29.6 kB Details

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

Download URL turberfield-catchphrase-0.14.0.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2d15427d404d69906403a1b5ee203c6755881e7370ca186ac661736f1635c046
BLAKE2b-256 checksum
How to use checksums
6f01f8fb9f25d606486700c44626d065dce13639b255a3f3e94ca9fae42dcaa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.0

Release history Release notifications | RSS feed

0.25.0

2 release files

0.24.0

2 release files

0.22.0

2 release files

0.21.0

1 release file

0.20.0

1 release file

0.19.0

1 release file

0.18.0

1 release file

0.17.0

1 release file

0.16.0

1 release file

0.15.0

1 release file

This release

0.14.0 This release

1 release file

0.13.0

1 release file

0.12.0

1 release file

0.11.0

1 release file

0.10.0

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

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