oops, clean up

master
Michael Smith 2012-02-29 13:08:44 -07:00
parent 871e2702b4
commit c67c74c2b4
3 changed files with 0 additions and 75 deletions

View File

@ -1,22 +0,0 @@
# Outputs the query in binary format.
if (!$type && $q_check =~ m/^(.*) (?:in|to) binary$/i) {
sub bin {
my @tex = shift;
my $bin;
for(my $x = 0; $x <= $#tex; $x++) {
$bin .= unpack("B*", $tex[$x]);
}
return $bin;
}
my @tex = $1;
$answer_results = bin(@tex);
if ($answer_results) {
$answer_type = 'binary';
$type = 'E';
}
}

View File

@ -1,53 +0,0 @@
if (!$type && $q_check_lc =~ m/^(?:roll|throw)/) {
if (!$type && $q_check_lc =~ m/^(?:roll|throw)(?:\sdie|(\d{0,2}\s)*dice)$/ ) {
my $rolls = 1; # If "die" is entered
my $choices = 6; # To be replace with input string in the future
if (defined($1)) { # Not defined if number of "dice" not specified
if ($1 eq " ") {
$rolls = 2;
}
else {
$rolls = $1;
}
}
for (1 .. $rolls) {
my $roll = int(rand($choices)) + 1;
$answer_results .= " $roll";
}
$answer_type = 'dice';
$is_memcached = 0;
} elsif (!$type && $q_check_lc =~ m/^(?:roll|throw)\s(\d{0,2})d(\d+)\s?([+-])?\s?(\d+|[lh])?$/) {
my $number_of_dice = $1 || 1;
my $number_of_faces = $2;
my @rolls;
my $sum = 0;
for (1 .. $number_of_dice) {
push(@rolls, int(rand($number_of_faces)) + 1);
}
if (defined($3) && defined($4)) {
# handle special case of " - L" or " - H"
if ($3 eq '-' && ($4 eq 'l' || $4 eq 'h')) {
@rolls = sort(@rolls);
if ($4 eq 'l') {
push(@rolls, -(shift(@rolls)));
} else {
push(@rolls, -(pop(@rolls)));
}
} else {
push(@rolls, int("$3$4"));
}
}
for (@rolls) {
$sum += $_;
}
if (@rolls > 1) {
$answer_results = join(' + ', @rolls);
$answer_results =~ s/\+\s\-/\- /g;
$answer_results .= " = $sum";
} else {
$answer_results = $sum;
}
$answer_type = 'dice';
$is_memcached = 0;
}
}