]> ruin.nu Git - NDIRC.git/blobdiff - PA.pm
eff and stop using new command parsing
[NDIRC.git] / PA.pm
diff --git a/PA.pm b/PA.pm
index 63a41d2efd5dcd0bf6bfa4f541f90219c441f0d9..e6a2e330a85eaee3c6cbf6ccf68e29f684061c99 100644 (file)
--- a/PA.pm
+++ b/PA.pm
@@ -74,11 +74,22 @@ sub checkGal {
 }
 
 sub shipEff {
-       my ($amount,$ship,$value) = @_;
-       $ship = "\%$ship\%";
-       $amount = parseValue($amount);
-       $value = parseValue($value);
-       $value *= -1.5 if defined $value and $value < 0;
+       my ($msg,$value) = @_;
+       my ($amount,$ship);
+       if($msg =~ /^(-?\d+(?:\.\d+)?[hkMG]?) (\w+)$/){
+               if (defined $value){
+                       $value = parseValue($1);
+                       $value *= -1.5 if $value < 0;
+                       my $feud = '';
+               }else{
+                       $amount = parseValue($1);
+               }
+               $ship = "\%$2\%";
+       }else{
+               my $command = (defined $value ? "veff" : "eff");
+               $ND::server->command("notice $ND::nick syntax: .$command amount ship");
+               return;
+       }
        my $feud = '';
 
        my @ship = $ND::DBH->selectrow_array(q{
@@ -90,8 +101,10 @@ FROM ship_stats WHERE name ILIKE ?
                $type = "stun" if $ship[2] eq 'Emp';
                $type = "steal" if ($ship[2] eq 'Steal') or ($ship[2] eq 'Pod');
 
-               $amount = int(($value*100/$ship[4])) if $amount eq 'value';
-               $feud = '(FEUD: '.prettyValue(int($amount/0.80)).') ' if defined $value;
+               if (defined $value){
+                       $amount = int(($value*100/$ship[4]));
+                       $feud = '(FEUD: '.prettyValue(int($amount/0.80)).') ';
+               }
                $value = prettyValue(($amount*$ship[4]/100));
                my $text = prettyValue($amount)." $feud $ship[0] ($ship[5]:$value) will $type:";
                my $st = $ND::DBH->prepare(q{
@@ -119,11 +132,22 @@ FROM ship_stats WHERE name ILIKE ?
 }
 
 sub shipStop {
-       my ($amount,$ship,$value) = @_;
-       $ship = "\%$ship\%";
-       $amount = parseValue($amount);
-       $value = parseValue($value);
-       $value *= -1.5 if defined $value and $value < 0;
+       my ($msg,$value) = @_;
+       my ($amount,$ship);
+       if($msg =~ /^(-?\d+(?:\.\d+)?[hkMG]?) (\w+)$/){
+               if (defined $value){
+                       $value = parseValue($1);
+                       $value *= -1.5 if $value < 0;
+                       my $feud = '';
+               }else{
+                       $amount = parseValue($1);
+               }
+               $ship = "\%$2\%";
+       }else{
+               my $command = (defined $value ? "vstop" : "stop");
+               $ND::server->command("notice $ND::nick syntax: .$command amount ship");
+               return;
+       }
        my $feud = '';
 
        my @ship = $ND::DBH->selectrow_array(q{
@@ -135,8 +159,10 @@ FROM ship_stats WHERE name ILIKE ?
                $ship[0] = "${ND::C}12$ship[0]$ND::C" if $ship[2] eq 'Emp';
                $ship[0] = "${ND::C}13$ship[0]$ND::C" if $ship[2] eq 'Steal';
 
-               $amount = int(($value*100/$ship[4])) if $amount eq 'value';
-               $feud = '(FEUD: '.int($amount/0.80).') ' if defined $value;
+               if (defined $value){
+                       $amount = int(($value*100/$ship[4]));
+                       $feud = '(FEUD: '.prettyValue(int($amount/0.80)).') ';
+               }
                $value = prettyValue(($amount*$ship[4]/100));
                my $text = "To stop $amount $feud $ship[0] ($ship[5]:$value) you need:";
                my $st = $ND::DBH->prepare(q{