Game-HexDescribe
view release on metacpan or search on metacpan
lib/Game/HexDescribe.pm view on Meta::CPAN
#!/usr/bin/env perl
# Copyright (C) 2018â2022 Alex Schroeder <alex@gnu.org>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
=encoding utf8
=head1 NAME
Game::HexDescribe - a web app to add random table driven data to map data
=head1 DESCRIPTION
Hex Describe is a web application which uses recursive random tables to create
the description of a map. A map in this context is a hex map. This is different
from other such tools like Tracery because a collection of locations on a maps
differ from a list of unrelated items. Neighbouring locations can share features
and thus a river can flow through many locations, a forest can cover many
locations, and so on.
On a technical level, Hex Describe is a web app based on the Mojolicious
framework. This class in particular uses L<Mojolicious::Lite>.
See L<Mojolicious::Guides> for more information.
=cut
package Game::HexDescribe;
our $VERSION = 1.04;
use Modern::Perl;
use Mojolicious::Lite;
use Mojo::UserAgent;
use Mojo::Util qw(html_unescape);
use Mojo::ByteStream;
use Game::HexDescribe::Utils qw(init describe_text parse_table load_table
describe_map parse_map load_map markdown);
use Game::HexDescribe::Log;
use Encode qw(decode_utf8);
use File::ShareDir qw(dist_dir);
use Cwd;
# Commands for the command line!
push @{app->commands->namespaces}, 'Game::HexDescribe::Command';
=head2 Configuration
As a Mojolicious application, it will read a config file called
F<hex-describe.conf> in the same directory, if it exists. As the default log
level is 'warn', one use of the config file is to change the log level using
the C<loglevel> key, and if you're not running the server in a terminal, using
the C<logfile> key to set a file.
The default map and table are stored in the F<contrib> directory. You can change
this directory using the C<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.
{
loglevel => 'debug',
logfile => undef,
contrib => 'share',
};
The default map was created using Text Mapper's Alpine algorithm at one point in
time and the code has changed in the mean time, so it cannot be recreated
anymore.
=cut
plugin Config => {
default => {
loglevel => 'warn',
logfile => undef,
contrib => undef,
},
file => getcwd() . '/hex-describe.conf',
};
my $log = Game::HexDescribe::Log->get;
$log->level(app->config('loglevel'));
$log->path(app->config('logfile'));
$log->info($log->path ? "Logfile is " . $log->path : "Logging to stderr");
=head2 URLs
The code needs to know where Text Mapper and the Face Generator can be found.
You can add these to the same config file we mentioned above. This is what you
probably want as a developer:
{
( run in 1.302 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )