Advertisement
JeffBobbo

Untitled

Mar 12th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.97 KB | None | 0 0
  1. sub condense {
  2.     my ($augs) = @_;
  3.  
  4.     my $augRef = {
  5.         MINOR => 0x01,
  6.         BASIC => 0x02,
  7.         STD   => 0x04,
  8.         GOOD  => 0x08,
  9.         EXC   => 0x10,
  10.         SUP   => 0x20,
  11.     ULT   => 0x40,
  12.     };
  13.     my $destination = shift(@{$augs});
  14.     my $augCount = {
  15.         Minor => shift(@{$augs}) || 0,
  16.         Basic => shift(@{$augs}) || 0,
  17.         Std   => shift(@{$augs}) || 0,
  18.         Good  => shift(@{$augs}) || 0,
  19.         Exc   => shift(@{$augs}) || 0,
  20.         Sup   => shift(@{$augs}) || 0,
  21.     Ult   => shift(@{$augs}) || 0,
  22.     };
  23.     if (!defined $augRef->{(uc($destination))}) {
  24.         return "Augmenter type $destination does not seem to exist. Maybe you included a '.'?";
  25.     }
  26.     my $totalPoints = 0;
  27.     while (my ($type, $num) = each (%{$augCount})) {
  28.         if (!isNumber($num)) {
  29.             return "Not a number for aug type $type\n";
  30.         }
  31.         $totalPoints += ($augRef->{(uc($type))} * $num);
  32.     }
  33.     my $result = floor($totalPoints/($augRef->{(uc($destination))}));
  34.     return "The combination of those augmenters will make $result $destination augs.";
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement