From ec27c0cf1a0cb6ad3cce5ea0f1bf284e979ff95e Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 4 Sep 2007 19:25:26 +0200 Subject: [PATCH] eff and stop using new command parsing --- PA.pm | 54 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/PA.pm b/PA.pm index 63a41d2..e6a2e33 100644 --- 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{ -- 2.39.2