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 dynamically generate dialogue.

Subclasses will override these methods:

  • build

  • interpret

Drama methods must declare by annotation the types of their keyword parameters. They must also provide a docstring to define the format of the text commands which apply to them.

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.13.0.tar.gz (28.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: turberfield-catchphrase-0.13.0.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.0

File hashes

Hashes for turberfield-catchphrase-0.13.0.tar.gz
Algorithm Hash digest
SHA256 fba60c1f23c90cf51b9dd48895c3b9a43c873f4a87fa1ff217fa47cbd530fceb
MD5 1095d472ebdfdb498adb321dbc27d993
BLAKE2b-256 12064fb305a9bad4779e17bce65430efeb03b86c0e11251e0ff25b9f084342fb

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