Skip to main content

A Python framework for parser-based web adventures.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turberfield-catchphrase-0.24.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

turberfield_catchphrase-0.24.0-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

Details for the file turberfield-catchphrase-0.24.0.tar.gz.

File metadata

  • Download URL: turberfield-catchphrase-0.24.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for turberfield-catchphrase-0.24.0.tar.gz
Algorithm Hash digest
SHA256 f8820bced391d43d2e81d52256e882ad9fe06fc3a07a64c953aeb16c66d806ba
MD5 87e1372da5f465a67c0b97102484e56a
BLAKE2b-256 7a516e5bce94475d287e5ec7e3f3d19e12aafde125b781b7017913f63b44bee4

See more details on using hashes here.

File details

Details for the file turberfield_catchphrase-0.24.0-py3-none-any.whl.

File metadata

  • Download URL: turberfield_catchphrase-0.24.0-py3-none-any.whl
  • Upload date:
  • Size: 36.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for turberfield_catchphrase-0.24.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07f1829ac664c7878c170c36df7cf0af7c8cd57ce32d54231d20c9c18e09bcba
MD5 1cbaa49263296ad9e1575373eac85994
BLAKE2b-256 654a792ee3ec2772bb1920256a3fd0402941b0be666bd9e974fa3828a4a170b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page