initial commit

master
Rachel Fae Fox (foxiepaws) 2021-10-19 14:49:24 -04:00
commit 1d0d940a68
40 changed files with 3912 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
local/
.#*

4
Changes Normal file
View File

@ -0,0 +1,4 @@
This file documents the revision history for Perl extension PathfinderGen.
0.01 2021-10-18 20:51:39
- initial revision, generated by Catalyst

26
Makefile.PL Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env perl
# IMPORTANT: if you delete this file your app will not work as
# expected. You have been warned.
use lib '.';
use inc::Module::Install 1.02;
use Module::Install::Catalyst; # Complain loudly if you don't have
# Catalyst::Devel installed or haven't said
# 'make dist' to create a standalone tarball.
name 'PathfinderGen';
all_from 'lib/PathfinderGen.pm';
requires 'Catalyst::Runtime' => '5.90128';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Action::RenderView';
requires 'Moose';
requires 'namespace::autoclean';
requires 'Config::General'; # This should reflect the config file format you've chosen
# See Catalyst::Plugin::ConfigLoader for supported formats
test_requires 'Test::More' => '0.88';
catalyst;
install_script glob('script/*.pl');
auto_install;
WriteAll;

1
README Normal file
View File

@ -0,0 +1 @@
Run script/pathfindergen_server.pl to test the application.

4
cpanfile Normal file
View File

@ -0,0 +1,4 @@
requires 'Catalyst';
requires 'Catalyst::Runtime';
requires 'Catalyst::Devel';
requires 'Catalyst::Helper::View::TT';

2968
cpanfile.snapshot Normal file

File diff suppressed because it is too large Load Diff

78
lib/PathfinderGen.pm Normal file
View File

@ -0,0 +1,78 @@
package PathfinderGen;
use Moose;
use namespace::autoclean;
use Catalyst::Runtime 5.80;
# Set flags and add plugins for the application.
#
# Note that ORDERING IS IMPORTANT here as plugins are initialized in order,
# therefore you almost certainly want to keep ConfigLoader at the head of the
# list if you're using it.
#
# -Debug: activates the debug mode for very useful log messages
# ConfigLoader: will load the configuration from a Config::General file in the
# application's home directory
# Static::Simple: will serve static files from the application's root
# directory
use Catalyst qw/
-Debug
ConfigLoader
Static::Simple
/;
extends 'Catalyst';
our $VERSION = '0.01';
# Configure the application.
#
# Note that settings in pathfindergen.conf (or other external
# configuration file that you set up manually) take precedence
# over this when using ConfigLoader. Thus configuration
# details given here can function as a default configuration,
# with an external configuration file acting as an override for
# local deployment.
__PACKAGE__->config(
name => 'PathfinderGen',
# Disable deprecated behavior needed by old applications
disable_component_resolution_regex_fallback => 1,
enable_catalyst_header => 1, # Send X-Catalyst header
encoding => 'UTF-8', # Setup request decoding and response encoding
);
# Start the application
__PACKAGE__->setup();
=encoding utf8
=head1 NAME
PathfinderGen - Catalyst based application
=head1 SYNOPSIS
script/pathfindergen_server.pl
=head1 DESCRIPTION
[enter your description here]
=head1 SEE ALSO
L<PathfinderGen::Controller::Root>, L<Catalyst>
=head1 AUTHOR
Rachel Fox
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
1;

View File

@ -0,0 +1,290 @@
package PathfinderGen::Controller::RandomCharacter;
use Moose;
use namespace::autoclean;
use strict;
use warnings;
use utf8;
use List::Util qw(head shuffle);
use Data::Dumper;
binmode STDOUT, ":utf8";
BEGIN { extends 'Catalyst::Controller'; }
my %core_races = (
Human => 1,
"Half-Elf" => 1,
"Half-Orc" => 1,
Elf => 1,
Gnome => 1,
Halfling => 1,
Dwarf => 1);
my %pf_races = (
Aasimar => 1,
Catfolk => 1,
Dhampir => 1,
Drow => 1,
Fetchling => 1,
Goblin => 1,
Hobgoblin => 1,
Ifrit => 1,
Kobold => 1,
Orc => 1,
Oread => 1,
Ratfolk => 1,
Sylph => 1,
Tengu => 1,
Tiefling => 1,
Undine => 1,
Changeling => 0.5,
Duergar => 0.5,
Gillman => 0.5,
Grippli => 0.5,
Kitsune => 0.5,
Merfolk => 0.5,
Nagaji => 0.5,
Samsaran => 0.5,
Strix => 0.5,
Suli => 0.5,
Svirfneblin => 0.5,
Vanara => 0.5,
Vishkanya => 0.5,
Wayang => 0.5,
Android => .25,
);
my %dd_races = (
Dragonborn => 1,
Tiefling => 1,
Leonin => 1,
Satyr => 1,
Fairy => 1,
Harengon => 1,
Aarakocra => 1,
Genasi => 1,
Goliath => 1,
Aasimar => 1,
Bugbear => 1,
Firbolg => 1,
Goblin => 1,
Hobgoblin => 1,
Kenku => 1,
Kobold => 1,
Lizardfolk => 1,
Orc => 1,
Tabaxi => 1,
Triton => 1,
"Yuan-Ti Pureblood" => 1,
"Feral Tiefling" => 1,
Tortle => 1,
Changling => 1,
Kalashtar => 1,
Shifter => 1,
Warforged => 1,
Gith => 1,
Centaur => 1,
Loxodon => 1,
Minotaur => 1,
"Simic Hybrid" => 1,
Vedalken => 1,
Verden => 1,
Locathah => 1,
Grung => 1
);
my %genders = (
Genderfluid => .5,
"Female" => 1,
"Male" => 1,
Agender => .5,
"Non-Binary (leaning femme)" => .5,
"Non-Binary (leaning masc)" => .5,
);
my %core_classes = (
Barbarian => 1,
Bard => 1,
Cleric => 1,
Druid => 1,
Fighter => 1,
Monk => 1,
Paladin => 1,
Ranger => 1,
Sorcerer => 1,
Wizard => 1);
my %base_classes = (
Alchemist => 1,
Cavalier => 1,
Gunslinger => 1,
Inquisitor => 1,
Magus => 1,
Oracle => 1,
Summoner => 1,
Vigalante => 1,
Witch => 1);
my %hybrid_classes = (
Arcanist => .25,
Bloodrager => .25,
Brawler => .25,
Hunter => .25,
Investigator => .25,
Shaman => .25,
Skald => .25,
Slayer => .25,
Swashbuckler => .25,
Warpriest => .25);
my %dd_classes = (
Warlock => 1,
Artificer => 1,
"Blood Hunter" => .1,
Mystic => .1
);
my $pfstatement = "Pathfinder SRD, Core Rulebook, Advanced Player Guide, Advanced Class Guide, Advanced Race Guide, Iron Gods Players Guide";
my $ddstatement = "D&D Beyond, PHB, MOoT, VRGtR, TWBtW, EEPC, VGtM, SCAG, TTP, ERftLW, MToF, GGtR, AI, LR";
=head1 NAME
PathfinderGen::Controller::RandomCharacter - Catalyst Controller
=head1 DESCRIPTION
Catalyst Controller.
=head1 METHODS
=cut
sub dundra :Local {
my ( $self, $c ) = @_;
my %ddraces = (%core_races, %dd_races);
my %ddclasses = (%core_classes, %dd_classes);
my $gen_races = (sub {
my @r;
for my $k (keys %ddraces) {
my $v = $ddraces{$k};
for (1..$v*10) {
push @r, $k;
}
}
return shuffle @r;
});
my $gen_classes = (sub {
my @c;
for my $class (keys %ddclasses) {
for (my $x = 0; $x <= ($ddclasses{$class} * 10); $x++) {
push @c, $class;
}
}
return shuffle @c;
});
my $gen_der = (sub {
my @g;
for my $gender (keys %genders) {
for (my $x = 0; $x <= ($genders{$gender} * 10); $x++) {
push @g, $gender;
}
}
return shuffle @g;
});
my @r = &$gen_races();
my @c = &$gen_classes();
my @g = &$gen_der();
my @characters;
for (my $x = 0; $x < 10; $x++) {
my $race = $r[int(rand(scalar @r))];
my $gender = $g[int(rand(scalar @g))];
my $class = $c[int(rand(scalar @c))];
my $cr = $race;
push @characters, sprintf("%s %s %s\n", $gender, $cr, $class);
}
$c->stash({title => "random pathfinder character concept generator", game => "D&D 5e", sources => $ddstatement, chars => \@characters, template => 'char.tt'});
}
=head2 index
=cut
sub pathfinder :Local {
my ( $self, $c ) = @_;
my %races = (%core_races, %pf_races);
my %classes = (%core_classes, %base_classes, %hybrid_classes);
sub gen_races {
my @r;
for my $k (keys %races) {
my $v = $races{$k};
for (1..$v*10) {
push @r, $k;
}
}
return shuffle @r;
}
sub gen_classes {
my @c;;
for my $class (keys %classes) {
for (my $x = 0; $x <= ($classes{$class} * 10); $x++) {
push @c, $class;
}
}
return shuffle @c;
}
sub gen_der {
my @g;;
for my $gender (keys %genders) {
for (my $x = 0; $x <= ($genders{$gender} * 10); $x++) {
push @g, $gender;
}
}
return shuffle @g;
}
my @r = gen_races();
my @c = gen_classes();
my @g = gen_der();
my @characters;
for (my $x = 0; $x < 10; $x++) {
my $race = $r[int(rand(scalar @r))];
my $gender = $g[int(rand(scalar @g))];
my $class = $c[int(rand(scalar @c))];
my $cr = $race;
push @characters, sprintf("%s %s %s\n", $gender, $cr, $class);
}
$c->stash({title => "random pathfinder character concept generator", game => "pathfinder", sources => $pfstatement, chars => \@characters, template => 'char.tt'});
}
sub index :Path :Arg(0) {
my ( $self, $c ) = @_;
$c->stash({title => "random pathfinder character concept generator", template => 'index.tt'});
}
sub end : ActionClass('RenderView') {}
=encoding utf8
=head1 AUTHOR
Rachel Fox
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
__PACKAGE__->meta->make_immutable;
1;

View File

@ -0,0 +1,81 @@
package PathfinderGen::Controller::Root;
use Moose;
use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller' }
#
# Sets the actions in this controller to be registered with no prefix
# so they function identically to actions created in MyApp.pm
#
__PACKAGE__->config(namespace => '');
=encoding utf-8
=head1 NAME
PathfinderGen::Controller::Root - Root Controller for PathfinderGen
=head1 DESCRIPTION
[enter your description here]
=head1 METHODS
=head2 index
The root page (/)
=cut
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
# Hello World
$c->response->body( $c->welcome_message );
}
=head2 default
Standard 404 error page
=cut
sub default :Path {
my ( $self, $c ) = @_;
$c->response->body( 'Page not found' );
$c->response->status(404);
}
=head2 char
=cut
sub char :Global {
my ( $self, $c ) = @_;
$c->stash(template => 'hello.tt');
}
=head2 end
Attempt to render a view, if needed.
=cut
sub end : ActionClass('RenderView') {}
=head1 AUTHOR
Rachel Fox
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
__PACKAGE__->meta->make_immutable;
1;

View File

@ -0,0 +1,37 @@
package PathfinderGen::View::Char;
use Moose;
use namespace::autoclean;
extends 'Catalyst::View::TT';
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt',
render_die => 1,
TIMER => 1,
WRAPPER => "base.tt",
);
=head1 NAME
PathfinderGen::View::Char - TT View for PathfinderGen
=head1 DESCRIPTION
TT View for PathfinderGen.
=head1 SEE ALSO
L<PathfinderGen>
=head1 AUTHOR
Rachel Fox
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
1;

View File

@ -0,0 +1,35 @@
package PathfinderGen::View::Char;
use Moose;
use namespace::autoclean;
extends 'Catalyst::View::TT';
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt',
render_die => 1,
);
=head1 NAME
PathfinderGen::View::Char - TT View for PathfinderGen
=head1 DESCRIPTION
TT View for PathfinderGen.
=head1 SEE ALSO
L<PathfinderGen>
=head1 AUTHOR
Rachel Fox
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
1;

View File

@ -0,0 +1,36 @@
package PathfinderGen::View::Index;
use Moose;
use namespace::autoclean;
extends 'Catalyst::View::TT';
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt',
render_die => 1,
WRAPPER => "base.tt",
);
=head1 NAME
PathfinderGen::View::Index - TT View for PathfinderGen
=head1 DESCRIPTION
TT View for PathfinderGen.
=head1 SEE ALSO
L<PathfinderGen>
=head1 AUTHOR
Rachel Fox
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
1;

3
pathfindergen.conf Normal file
View File

@ -0,0 +1,3 @@
# rename this file to pathfindergen.yml and put a ':' after 'name' if
# you want to use YAML like in old versions of Catalyst
name PathfinderGen

8
pathfindergen.psgi Normal file
View File

@ -0,0 +1,8 @@
use strict;
use warnings;
use PathfinderGen;
my $app = PathfinderGen->apply_default_middlewares(PathfinderGen->psgi_app);
$app;

15
root/base.tt Normal file
View File

@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<title>[% title %]</title>
<link href="https://foxiepa.ws/assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://foxiepa.ws/assets/css/foxiepaws.css" rel="stylesheet" />
<link href="https://foxiepa.ws/assets/css/index.css" rel="stylesheet" />
</head>
<body>
<div class="container">
[% content %]
</div>
</body>
</html>

11
root/char.tt Normal file
View File

@ -0,0 +1,11 @@
<h1> Random Characters </h1>
<p>This generates 10 random [% game %] character concepts by a gender, race, and class. </p>
<ul>
[% FOREACH c IN chars %]
<li>[% c %]</li>
[% END %]
</ul>
<h2>Sources</h2>
<p>Sources are [% sources %]</p>

8
root/ddchar.tt Normal file
View File

@ -0,0 +1,8 @@
<h1> Random Characters </h1>
<p>This generates 10 random dungeons & dragons (5e) character concepts by a gender, race, and class. </p>
<ul>
[% FOREACH c IN chars %]
<li>[% c %]</li>
[% END %]
</ul>

BIN
root/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

1
root/hello.tt Normal file
View File

@ -0,0 +1 @@
<p> suffering </p>

6
root/index.tt Normal file
View File

@ -0,0 +1,6 @@
<h1>Generators</h1>
<ul>
<li><a href="pathfinder">Pathfinder</a></li>
<li><a href="dundra">Dungeons & Dragons 5e</a></li>
</ul>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

30
script/pathfindergen_cgi.pl Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env perl
use Catalyst::ScriptRunner;
Catalyst::ScriptRunner->run('PathfinderGen', 'CGI');
1;
=head1 NAME
pathfindergen_cgi.pl - Catalyst CGI
=head1 SYNOPSIS
See L<Catalyst::Manual>
=head1 DESCRIPTION
Run a Catalyst application as a CGI script.
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm
=head1 COPYRIGHT
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

60
script/pathfindergen_create.pl Executable file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Catalyst::ScriptRunner;
Catalyst::ScriptRunner->run('PathfinderGen', 'Create');
1;
=head1 NAME
pathfindergen_create.pl - Create a new Catalyst Component
=head1 SYNOPSIS
pathfindergen_create.pl [options] model|view|controller name [helper] [options]
Options:
--force don't create a .new file where a file to be created exists
--mechanize use Test::WWW::Mechanize::Catalyst for tests if available
--help display this help and exits
Examples:
pathfindergen_create.pl controller My::Controller
pathfindergen_create.pl --mechanize controller My::Controller
pathfindergen_create.pl view My::View
pathfindergen_create.pl view HTML TT
pathfindergen_create.pl model My::Model
pathfindergen_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
dbi:SQLite:/tmp/my.db
pathfindergen_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
[Loader opts like db_schema, naming] dbi:Pg:dbname=foo root 4321
[connect_info opts like quote_char, name_sep]
See also:
perldoc Catalyst::Manual
perldoc Catalyst::Manual::Intro
perldoc Catalyst::Helper::Model::DBIC::Schema
perldoc Catalyst::Model::DBIC::Schema
perldoc Catalyst::View::TT
=head1 DESCRIPTION
Create a new Catalyst Component.
Existing component files are not overwritten. If any of the component files
to be created already exist the file will be written with a '.new' suffix.
This behavior can be suppressed with the C<-force> option.
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm
=head1 COPYRIGHT
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

48
script/pathfindergen_fastcgi.pl Executable file
View File

@ -0,0 +1,48 @@
#!/usr/bin/env perl
use Catalyst::ScriptRunner;
Catalyst::ScriptRunner->run('PathfinderGen', 'FastCGI');
1;
=head1 NAME
pathfindergen_fastcgi.pl - Catalyst FastCGI
=head1 SYNOPSIS
pathfindergen_fastcgi.pl [options]
Options:
-? --help display this help and exit
-l --listen socket path to listen on
(defaults to standard input)
can be HOST:PORT, :PORT or a
filesystem path
-n --nproc specify number of processes to keep
to serve requests (defaults to 1,
requires --listen)
-p --pidfile specify filename for pid file
(requires --listen)
-d --daemon daemonize (requires --listen)
-M --manager specify alternate process manager
(FCGI::ProcManager sub-class)
or empty string to disable
-e --keeperr send error messages to STDOUT, not
to the webserver
--proc_title Set the process title (if possible)
=head1 DESCRIPTION
Run a Catalyst application as FastCGI.
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm
=head1 COPYRIGHT
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

60
script/pathfindergen_server.pl Executable file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env perl
BEGIN {
$ENV{CATALYST_SCRIPT_GEN} = 40;
}
use Catalyst::ScriptRunner;
Catalyst::ScriptRunner->run('PathfinderGen', 'Server');
1;
=head1 NAME
pathfindergen_server.pl - Catalyst Test Server
=head1 SYNOPSIS
pathfindergen_server.pl [options]
-d --debug force debug mode
-f --fork handle each request in a new process
(defaults to false)
-? --help display this help and exits
-h --host host (defaults to all)
-p --port port (defaults to 3000)
-k --keepalive enable keep-alive connections
-r --restart restart when files get modified
(defaults to false)
-rd --restart_delay delay between file checks
(ignored if you have Linux::Inotify2 installed)
-rr --restart_regex regex match files that trigger
a restart when modified
(defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
--restart_directory the directory to search for
modified files, can be set multiple times
(defaults to '[SCRIPT_DIR]/..')
--follow_symlinks follow symlinks in search directories
(defaults to false. this is a no-op on Win32)
--background run the process in the background
--pidfile specify filename for pid file
See also:
perldoc Catalyst::Manual
perldoc Catalyst::Manual::Intro
=head1 DESCRIPTION
Run a Catalyst Testserver for this application.
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm
=head1 COPYRIGHT
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

40
script/pathfindergen_test.pl Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env perl
use Catalyst::ScriptRunner;
Catalyst::ScriptRunner->run('PathfinderGen', 'Test');
1;
=head1 NAME
pathfindergen_test.pl - Catalyst Test
=head1 SYNOPSIS
pathfindergen_test.pl [options] uri
Options:
--help display this help and exits
Examples:
pathfindergen_test.pl http://localhost/some_action
pathfindergen_test.pl /some_action
See also:
perldoc Catalyst::Manual
perldoc Catalyst::Manual::Intro
=head1 DESCRIPTION
Run a Catalyst action from the command line.
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm
=head1 COPYRIGHT
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

10
t/01app.t Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Catalyst::Test 'PathfinderGen';
ok( request('/')->is_success, 'Request should succeed' );
done_testing();

10
t/02pod.t Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
eval "use Test::Pod 1.14";
plan skip_all => 'Test::Pod 1.14 required' if $@;
all_pod_files_ok();

14
t/03podcoverage.t Normal file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
eval "use Test::Pod::Coverage 1.04";
plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
eval "use Pod::Coverage 0.20";
plan skip_all => 'Pod::Coverage 0.20 required' if $@;
all_pod_coverage_ok();

View File

@ -0,0 +1,10 @@
use strict;
use warnings;
use Test::More;
use Catalyst::Test 'PathfinderGen';
use PathfinderGen::Controller::RandomCharacter;
ok( request('/randomcharacter')->is_success, 'Request should succeed' );
done_testing();

8
t/view_Char.t Normal file
View File

@ -0,0 +1,8 @@
use strict;
use warnings;
use Test::More;
BEGIN { use_ok 'PathfinderGen::View::Char' }
done_testing();

8
t/view_Index.t Normal file
View File

@ -0,0 +1,8 @@
use strict;
use warnings;
use Test::More;
BEGIN { use_ok 'PathfinderGen::View::Index' }
done_testing();