Harry73 / Barbs

1 stars 2 forks source link

Barbs

Barbs is a custom tabletop RPG made by a friend of mine. As this is a custom system, we've built our own support for it.

Barbs Rulebook

The Barbs rulebook is a minimalistic website, served by a very simple Flask application running on an EC2 instance.

Website

The HTML for the rulebook webpage is generated by python scripts. Most of the HTML for the page is based on a collection of templates in html/templates/. The python scripts read these templates and fill out placeholders in the templates with information from rulebook/ files. The rulebook/ files contain information on the various components of the game. These are the source of truth for things like attributes, abilities, races, classes, etc.

website.pyw is a script to assist in managing the rulebook website. It presents users with a simple UI with four buttons. Their usages are described below:

  1. "Validate rulebook" - Goes through the rulebook/ files and performs various checks on the data.
  2. "Generate rulebook website HTML" - Reads the rulebook/ and html/templates/ files and builds the HTML page for the rulebook website.
  3. "View local" - Opens the generated rulebook HTML so that the user can inspect it locally before updating the actual server.
  4. "Update website" - Copies the generated rulebook HTML to the server running the website and restarts the server.

Original rulebook parsing

The Barbs rulebook was originally a large, hand-typed document. Since this wasn't conducive to a programmatic system, the src/parsing/ folder holds a bunch of Python code that could parse that document into objects. src/parsing/parser.py::parse_data() was the entry point for this code. The rulebook was read from data/data.txt, which was a copy-pasted version of the document. This code was used to take the original rulebook and convert it into the rulebook/ json files we now use as the source of truth.

Barbs on Roll20

The barbs_character_sheet/ folder holds the HTML and CSS for a Barbs character sheet, along with a set of API scripts for use on Roll20.net. The sheet is reliant on the API. This is a frowned-upon practice, but many actions are far to complex, or impossible, to implement directly in the character sheet. As a result, you will often see buttons in the character sheet simply make an API call, assuming that the API call will do and show whatever is necessary.

There are two JavaScript API scripts for Barbs. barbs.js is the main script that handles API calls. components.js holds many definitions of baser components from the rulebook - characters, rolls, stats, skills, classes, etc.

parse.py

This script generates a few things:

  1. data/skills_to_attribute.json - A mapping of skills to scaling attributes. This tells us what attribute to add to a skill check. This is copied and hardcoded into a sheet worker in the character sheet.
  2. data/skills.txt - JS code for an enum of the skills. This is copied and hardcoded into thecomponents.js API script.
  3. data/components.json - A json blob of all components in the game.

The first two outputs are still used in the API scripts. (3) has been discarded in favor of copying the classes and abilities from the rulebook/ files.

API Usage

Every ability in Barbs is painfully unique. Practically, this means that every ability is implemented separately in the API scripts. Additionally, many abilities require the user to input extra information for the ability to work properly. This means that, while the API simplifies calculations, there can be a lot to remember for users on what is necessary.

To help with this, there is a separate webpage linked from the Barbs rulebook webpage. The API usage page describes every class passive and ability, noting what the API will not handle, and stating what parameters may be required from the user. Each class is linked to the corresponding section in the API usage page. Both pages are additionally linked to each other in the sidebars.