#! /usr/bin/perl -w
use strict;
use diagnostics;

###################
# Just writing a simple script that will
#  generate a set of randomized stats for
#  a character used in my colloseum.
###################

my $MAX_STAT	= 6;
my $MIN_STAT	= 1;
my $STAT_POINTS	= 21;

my %stats = 	(
		power => '',
		quick => '',
		tough => '',
		intel => '',
		will  => '',
		presn => '',
		);


my $i = 0;
my $total = 0;
my @keys = keys(%stats);
while ($keys[$i] && $i <= 22) {
 $stats{$keys[$i]} = int(rand($MAX_STAT)+1);
 print $keys[$i] . " = " . $stats{$keys[$i]} . "\n";
 $total += $stats{$keys[$i]};
 $i++;
}
print "points = " . $total . "\n\n\n";

if ($total != 21) {
 while ($total < 21) { raiseStats(); }
 while ($total > 21) { lowerStats(); }
}

sub raiseStats {
 my $which_stat = int(rand(6)+1);
 if ($stats{$keys[$which_stat]} == 6) { return; }
 $stats{$keys[$which_stat]}++;
 $total++;
}

sub lowerStats {
 my $which_stat = int(rand(6)+1);
 if ($stats{$keys[$which_stat]} == 1) { return; }
 $stats{$keys[$which_stat]}--;
 $total--;
}

my $count = 0;
while ($keys[$count] && $count <= 10) {
 print $keys[$count] . " = " . $stats{$keys[$count]} . "\n";
 $count++;
}
print "total = " . $total . "\n";

