X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FPA.pm;h=b629592f9216af1eede5465c3251c7f619e04581;hb=944bc0326027cf0746351c3d2aad255da7ef3a6a;hp=a71e897b3d6eb81239aaf4e861fa0d27c1d6ae80;hpb=113d72c69d686a58b41b0a055ff5a582fab5d2c8;p=NDIRC.git diff --git a/Commands/PA.pm b/Commands/PA.pm index a71e897..b629592 100644 --- a/Commands/PA.pm +++ b/Commands/PA.pm @@ -146,4 +146,38 @@ WHERE x = ? AND y = ? and z = ? $c->reply("You will gain $xp XP, $score score, if you steal $roids roids ($value value), from $x:$y:$z, who will have $tsize roids left, total score gain will be: $totscore in total,"); } +sub fco + : Help(syntax: .fco agents stolen [tick] | tick can be omitted if you're doing this the same tick you got cov opped, if you have different amount of your resources stolen, specify the highest amount. Only works if less than 10% of your resources and < 10,000*agents were stolen) +{ + my ($self, $c, $msg) = @_; + + my ($agents,$stolen,$tick) = $msg =~ /^(\d+)\s+(\d+)\s*(\d+)?$/ or die 'ARGS'; + + $tick //= $c->model->selectrow_array(q{SELECT tick()}); + + my ($value,$score) = $c->model->selectrow_array(q{ +SELECT value,score FROM planet_stats WHERE tick = $2 AND + id = (SELECT planet FROM users WHERE hostmask ILIKE $1) + }, undef, $c->host,$tick); + unless ($value){ + $c->reply("You don't have a planet registered."); + return; + } + my $attackers = $c->model->prepare(q{ +SELECT coords(p.x,p.y,p.z), ruler, planet FROM current_planet_stats p + JOIN planet_stats ps using (id) +WHERE ps.tick = $1 AND (2000.0*$2*$3/ps.value)::int = $4 + }); + $attackers->execute($tick,$agents,$value,$stolen); + if ($attackers->rows == 0){ + $c->reply("No cov opper found, did you specify the right tick, and was the stolen amount not capped?"); + }else{ + my $coords = ''; + while (my $attacker = $attackers->fetchrow_hashref){ + $coords .= " ($attacker->{coords} : $attacker->{ruler} OF $attacker->{planet})"; + } + $c->reply("The planet that cov opped you is one of: $coords"); + } +} + 1;