Created
April 11, 2020 20:33
-
-
Save fabiocolacio/952ea13fc2efa7726fb4fe9bee185024 to your computer and use it in GitHub Desktop.
cyberpunk character generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
sub show_help { | |
print <<~EOH; | |
USAGE | |
===== | |
$0 [type [role [name]]] | |
ARGUMENTS | |
--------- | |
type Determines the character's maximum stat potential. | |
* fast (default) roles 1d10 for each stat (like a player) | |
* average | |
* minors (minor support character) | |
* minorh (minor hero character) | |
* majors (major support character) | |
* majorh (major hero character) | |
role The character's role: | |
* rockerboy | |
* corp | |
* netrunner | |
* fixer | |
* techie | |
* nomad | |
* cop | |
* solo | |
* media | |
name The name for the character | |
EOH | |
} | |
my @roles = qw/ ROCKERBOY CORP NETRUNNER FIXER TECHIE NOMAD COP SOLO MEDIA /; | |
my @stats = qw/ LUCK INT EMP COOL ATT TECH REF MA BODY /; | |
my $first = shift; | |
if ($first) { | |
show_help; | |
exit 0; | |
} | |
my $mode = $first || "fast"; | |
my $role = uc(shift || $roles[int(rand(scalar(@roles)))]); | |
my $name = shift || "Joe Bob"; | |
sub randstat { | |
my $max = shift; | |
return int(rand($max - 1)) + 2; | |
} | |
sub maxstat { | |
my $total = shift; | |
return int($total / 9) + 1; | |
} | |
my %char_max = ( | |
fast => 10, | |
average => maxstat(50), | |
minors => maxstat(60), | |
minorh => maxstat(75), | |
majors => maxstat(70), | |
majorh => maxstat(80) | |
); | |
sub body_type { | |
my $bt = shift; | |
if ($bt < 3) { | |
return "Very Weak"; | |
} elsif ($bt < 5) { | |
return "Weak"; | |
} elsif ($bt < 8) { | |
return "Average" | |
} elsif ($bt < 10) { | |
return "Strong"; | |
} | |
return "Very Strong"; | |
} | |
my %body_type_modifier = ( | |
"Very Weak" => 0, | |
"Weak" => -1, | |
"Average" => -2, | |
"Strong" => -3, | |
"Very Strong" => -4, | |
"Superhuman" => -5 | |
); | |
my $stat_max = $char_max{$mode}; | |
my %stats = map { $_ => randstat($stat_max) } @stats; | |
my $round_run = 3 * $stats{"MA"}; | |
my $turn_run = 3 * $round_run; | |
my $leap = $round_run / 4; | |
my $body_type = body_type($stats{"BODY"}); | |
my $save = $stats{"BODY"}; | |
# DISPLAY | |
print $name, ", the ", $role, "\n\n"; | |
foreach my $key (@stats) { | |
print "$key:\t$stats{$key}\n"; | |
} | |
print "\n"; | |
print "Save: ", $save, "\n"; | |
print "Body Type: ", $body_type, "\n"; | |
print "Body Type Modifier: ", $body_type_modifier{$body_type}, "\n\n"; | |
print "Run Distance (round): ", $round_run, "\n"; | |
print "Run Distance (turn): ", $turn_run, "\n"; | |
print "Leap Distance: ", $leap, "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment