The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Game::CharacterSheetGenerator - a web app to generate character sheets

DESCRIPTION

Character Sheet Generator is a web application that generates characters for the Halberts & Helmets game. It does two things: it generates the stats for random characters, and it populates a SVG file with those values.

Here's an example of the stats generated:

name: Diara
str: 11
dex: 10
con: 13
int: 10
wis: 9
cha: 7
level: 1
xp: 0
thac0: 19
class: halfling
hp: 4
ac: 6
property: backpack
property: rope
property: leather armour
property: silver dagger
property: sling
property: pouch with 30 stones
abilities: 1/6 for normal tasks
abilities: 2/6 to hide and sneak
abilities: 5/6 to hide and sneak outside
abilities: +1 for ranged weapons
abilities: AC -2 against giants
charsheet: Charaktersheet.svg
breath: 13
poison: 8
petrify: 10
wands: 9
spells: 12

Think of it as key value pairs. Some keys have multiple values, resulting in multiline values.

The SVG file acts as a template. For every key in the character, a text element with a matching id is searched and if found, tspan elements matching the value are inserted.

The charsheet key is special because it tells the app which file to load.

On a technical level, Character Sheet Generator is a web app based on the Mojolicious framework. This class in particular uses Mojolicious::Lite.

See Mojolicious::Guides for more information.

Configuration

As a Mojolicious application, it will read a config file called character-sheet-generator.conf in the same directory, if it exists. As the default log level is "debug", one use of the config file is to change the log level using the loglevel key, and if you're not running the server in a terminal, using the logfile key to set a file.

The default map and table are stored in the contrib directory. You can change this directory using the contrib key. By default, the directory included with the distribution is used. Thus, if you're a developer, you probably want to use something like the following to use the files from the source directory.

The code also needs to know where the Face Generator can be found, if at all. You can set the URL using the face_generator_url key. If you're a developer and have it running locally on port 3020, this is what you'd use:

{
  loglevel => "debug",
  logfile => undef,
  contrib => "share",
  face_generator_url => "http://localhost:3020",
}