-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacter_mutations_generator.pl
executable file
·56 lines (49 loc) · 2.54 KB
/
Character_mutations_generator.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
#!/usr/bin/perl
use strict;
use warnings FATAL => qw( all );
use CGI::Simple;
use CGI::Carp qw(fatalsToBrowser);
use FindBin qw($Bin);
use HTML::Entities qw(encode_entities);
use Lingua::EN::Inflect qw(ORD NUMWORDS);
use lib "$Bin/../../files/lib";
use Page::Base qw(page);
use Page::HTML qw(section paragraph list form fieldset inputs);
use Page::RolePlaying::Character::Mutation qw(random_mutations);
my $cgi = CGI::Simple->new();
my $iterations = $cgi->param('iterations') ? encode_entities($cgi->param('iterations'),'<>"') : 1;
my $file = "Character_mutations_generator.pl";
page( 'code' => sub {
section(3, '
The character mutations generator is a tool to use to make your PCs more interesting. The character could be the child of a powerful magic user who used spells too much, or the character may have been experimented on some time in life. This page is devoted to make your characters a little more unique. There are things on here that would make your character more powerful or much weaker.
All effects are cumulative, and one can be cancelled out by another. There is also the chance nothing could happen.
I am not particularly happy with some of the sentence structures, but in some cases, it can not be helped.
If you are looking for a random name generator, please look into the <a href="http://ebon.pyorre.net" target="ex_tab">Everchanging Book of Names</a>.
');
form(3, sub {
fieldset(4, sub {
inputs(5, [
{ type => 'text', name => 'iterations', placeholder => '# of characters or names?' },
{ type => 'submit', value => 'Mutate!' },
{ type => 'button', value => 'Start over', onclick => "location='$file'" },
]);
paragraph(5, 'Please separate names by a comma (,) or a semicolon (;).', { style => 'font-size: smaller' })
}, { legend => "How many chracters do you wish to mutate?" });
}, { action => $file, method => 'get'});
my @m_iterations = $iterations =~ /^\d+$/ ? (1..$iterations) : split(/(?:,|;)/,$iterations);
for my $iteration (@m_iterations) {
my $heading = $iteration !~ /^\d+$/ ? "$iteration mutated" :
@m_iterations == 1 ? 'A character mutated' :
ucfirst NUMWORDS(ORD($iteration)).' character mutated';
section(3, sub {
my $mutations = random_mutations;
if (scalar @{$mutations} > 0) {
list(5, 'u', $mutations);
}
else {
paragraph(5, 'Your character is completely normal.');
}
}, { 'heading' => [2, $heading] });
++$iteration unless $iteration !~ /^\d/;
}
});