261 lines
5.3 KiB
Perl
261 lines
5.3 KiB
Perl
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,
|
|
);
|
|
|
|
# allowed Races for my iron gods game
|
|
my %ig_allowed = (
|
|
Ratfolk => .5,
|
|
Aasimar => .25,
|
|
Tiefling => .25,
|
|
Orc => .25,
|
|
Changling => .25,
|
|
Androids => .1,
|
|
);
|
|
|
|
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
|
|
|
|
|
|
# generates a random array using the probabilities in the list
|
|
sub gen_array {
|
|
my %list = @_;
|
|
my @a;
|
|
for my $k (keys %list) {
|
|
my $v = $list{$k};
|
|
for (1..$v*10) {
|
|
push @a, $k;
|
|
}
|
|
}
|
|
return shuffle @a;
|
|
}
|
|
|
|
sub randomlist($$$) {
|
|
my $count = shift;
|
|
my %races = %{shift()};
|
|
my %classes = %{shift()};
|
|
|
|
my @r = gen_array(%races);
|
|
my @c = gen_array(%classes);
|
|
my @g = gen_array(%genders);
|
|
my @characters;
|
|
for (my $x = 0; $x < $count; $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);
|
|
}
|
|
return @characters;
|
|
}
|
|
|
|
sub dundra :Local {
|
|
my ( $self, $c ) = @_;
|
|
|
|
my %races = (%core_races, %dd_races);
|
|
my %classes = (%core_classes, %dd_classes);
|
|
|
|
my @characters = randomlist(10, \%races, \%classes);
|
|
$c->stash({title => "random D&D 5e 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);
|
|
|
|
my @characters = randomlist(10, \%races, \%classes);
|
|
$c->stash({title => "random pathfinder character concept generator", game => "pathfinder", sources => $pfstatement, chars => \@characters, template => 'char.tt'});
|
|
}
|
|
|
|
sub irongods :Local {
|
|
my ( $self, $c ) = @_;
|
|
|
|
my %races = (%core_races, %ig_allowed);
|
|
my %classes = (%core_classes, %base_classes, %hybrid_classes);
|
|
|
|
my @characters = randomlist(10, \%races, \%classes);
|
|
$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 character concept generators", template => 'index.tt'});
|
|
}
|
|
|
|
|
|
=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;
|