-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.pl
executable file
·73 lines (61 loc) · 2.88 KB
/
index.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl
# This is the index for Role_playing - Player_characters.
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Simple;
use FindBin qw($Bin);
use HTML::Entities qw(encode_entities);
use Lingua::EN::Inflect qw(PL_N);
use lib "$Bin/../../files/lib";
use Page::Base qw(page);
use Page::Data qw(make_hash);
use Page::File qw(file_directory);
use Page::HTML qw(section list table);
use Page::Story qw(story);
use Page::Convert qw(idify);
use Page::Number::Pretty qw(commify);
use Page::RolePlaying::Alignment qw(expand_alignment);
use Page::RolePlaying::Character::AbilityScores qw(ability_box);
use Page::RolePlaying::Character::Class qw(player_classes_simple);
use Page::RolePlaying::Character::Info qw(pc_info_list);
use Fancy::Join::Defined qw(join_defined);
my $cgi = CGI::Simple->new;
my $page = $cgi->param('page') ? encode_entities($cgi->param('page'),'/<>"') : undef;
my $player_characters = make_hash(
'file' => ['Role_playing','player_characters.txt'],
'headings' => ['full name', 'id', 'last name', 'first name', qw(alignment class+ experience race special_race gender strength dexterity constitution intelligence wisdom charisma)],
);
my @pc_info_headings = qw(experience alignment race gender);
my $heading = $page && $page eq 'House rules' ? 'House rules' : undef;
page( 'heading' => $heading, 'selected' => $page, 'code' => sub {
if ($page && $page eq 'House rules') {
my $pages_dir = file_directory('Role_playing/Player_characters', 'text');
story('file' => "$pages_dir/House_rules.txt");
}
else {
section(3,
'I have taken down all of the individual pages for my player characters for a while. I am revamping this whole section of my site and the current files are a mess. Please bear with me as I working on getting them back online.'
);
for my $character (sort {$a->{'last name'} cmp $b->{'last name'} || $a->{'first name'} cmp $b->{'first name'}} values %$player_characters) {
my $name = $character->{'full name'};
my $ability_scores = ability_box($character);
my $race = join_defined(' / ', ($character->{'race'}, $character->{'special_race'}));
my @classes = @{$character->{'class'}};
my $class_key = PL_N('class', scalar @classes);
unshift @pc_info_headings, $class_key;
my %pc_info = (
experience => commify($character->{experience} + 0),
alignment => expand_alignment($character->{alignment}),
gender => $character->{gender},
race => $race
);
$pc_info{$class_key} = player_classes_simple(\@classes);
section(3, sub {
table(4, { rows => [['whead', $ability_scores]], class => 'ab_box', 'caption' => 'Ability scores' });
list(4, 'u', pc_info_list(\%pc_info, \@pc_info_headings), { 'class' => 'headed' });
}, { 'heading' => [2, $name, { id => idify($name) }], 'class' => 'pc_top' });
shift @pc_info_headings;
}
}
});