A minimal code sceleton for a textadveture parser written in python.

Overview

Textadventure sceleton written in python

Use with a map file generated on https://www.trizbort.io

Use the following Sockets for walking directions:

 nw         n   up    ne
    x---0---x---x---x
    0               0
  w x               x e
    0               0
    x---0---x---x---x
 sw         s  down   se

0: Socket not in use. You can still use one of these to enter a room, but it is not possible to exit the room via this socket. However it is recommanded to mark the connector as oneway for readability.

Execute the file play.py to start a game.

Command Parsing

The Command parsing is handled in a Command Base Class. The action words are taken from the translation file. It is also possible to provide regex parsing or even overwriting the parsing in a command child class.

Every command is a child of the Base Class. If the player enters a command, all command classes try to parse the input. The first command wich successfully parses the textinput will be executed.

By now, the parser supports the following commands:

  • go
  • look
  • take
  • drop
  • inventory

Localisation

The localisation is provided in a json file. It needs to have the following directory mapping:

  • "generic_fills": list of articles
  • "commands": dictionary of commands
    • "-command class name-": directory of command values
      • "action": list of action words of the command
      • "action_regex": (optional) list of regex parsing
      • "filler": (optinal) list of fillers of the command
      • more command specific values. (eg. direction mapping for the go command)
  • "all": list of words translating to all
  • "-your text-": your translation

Example:

{
    "generic_fills": [
        "the",
        "this",
        "a"
    ],
    "commands": {
        "go": {
            "action": [
                "go",
                "goto"
            ],
            "filler": [
                "to"
            ],
            "directions": {
                "n": 0,
                "north": 0,
                "ne": 2,
                "northeast": 2,
                "...": 4
            }
        }
    },
    "all": ["all", "everything"],
    "no way": "There is no way in this direction"
}
You might also like...
Microsoft's Cascadia Code font customized to my liking.

Microsoft's Cascadia Code font customized to my liking. Also includes some simple batch patch and bake scripts to batch patch glyphs and bake font features into fonts!

Hamming code generation, error detection & correction.

Hamming code generation, error detection & correction.

LazyText is inspired b the idea of lazypredict, a library which helps build a lot of basic models without much code.
LazyText is inspired b the idea of lazypredict, a library which helps build a lot of basic models without much code.

LazyText is inspired b the idea of lazypredict, a library which helps build a lot of basic models without much code. LazyText is for text what lazypredict is for numeric data.

Python character encoding detector

Chardet: The Universal Character Encoding Detector Detects ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants) Big5, GB2312, EUC-TW, HZ-GB-2312, IS

Fuzzy String Matching in Python

FuzzyWuzzy Fuzzy string matching like a boss. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.

The Levenshtein Python C extension module contains functions for fast computation of Levenshtein distance and string similarity

Contents Maintainer wanted Introduction Installation Documentation License History Source code Authors Maintainer wanted I am looking for a new mainta

Paranoid text spacing in Python

pangu.py Paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width charact

Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.

TextDistance TextDistance -- python library for comparing distance between two or more sequences by many algorithms. Features: 30+ algorithms Pure pyt

Python flexible slugify function

awesome-slugify Python flexible slugify function PyPi: https://pypi.python.org/pypi/awesome-slugify Github: https://github.com/dimka665/awesome-slugif

Owner
null
A minimal python script for generating multiple onetime use bip39 seed phrases

seed_signer_ontimes WARNING This project has mainly been used for local development, and creation should be ran on a air-gapped machine. A minimal pyt

CypherToad 4 Sep 12, 2022
Chilean Digital Vaccination Pass Parser (CDVPP) parses digital vaccination passes from PDF files

cdvpp Chilean Digital Vaccination Pass Parser (CDVPP) parses digital vaccination passes from PDF files Reads a Digital Vaccination Pass PDF file as in

Esteban Borai 1 Nov 17, 2021
An implementation of figlet written in Python

All of the documentation and the majority of the work done was by Christopher Jones ([email protected]). Packaged by Peter Waller <[email protected]>,

Peter Waller 1.1k Jan 2, 2023
This is a text summarizing tool written in Python

Summarize Written by: Ling Li Ya This is a text summarizing tool written in Python. User Guide Some things to note: The application is accessible here

Marcus Lee 2 Feb 18, 2022
BaseCrack is a tool written in Python that can decode all alphanumeric base encoding schemes.

BaseCrack Decoder For Base Encoding Schemes BaseCrack is a tool written in Python that can decode all alphanumeric base encoding schemes. This tool ca

Mufeed VH 383 Dec 27, 2022
Convert text to morse code and play morse code sound.

Convert text(english) to morse codes and play morse sound!

Mohammad Dori 5 Jul 15, 2022
Simple python program to auto credit your code, text, book, whatever!

Credit Simple python program to auto credit your code, text, book, whatever! Setup First change credit_text to whatever text you would like to credit

Hashm 1 Jan 29, 2022
Implementation of hashids (http://hashids.org) in Python. Compatible with Python 2 and Python 3

hashids for Python 2.7 & 3 A python port of the JavaScript hashids implementation. It generates YouTube-like hashes from one or many numbers. Use hash

David Aurelio 1.4k Jan 2, 2023
Repository containing the code for An-Gocair text normaliser

Scottish Gaelic Text Normaliser The following project contains the code and resources for the Scottish Gaelic text normalisation project. The repo can

null 3 Jun 28, 2022
Code Jam for creating a text-based adventure game engine and custom worlds

Text Based Adventure Jam Author: Devin McIntyre Our goal is two-fold: Create a text based adventure game engine that can parse a standard file format

HTTPChat 4 Dec 26, 2021