1 #**************************************************************************
2 # Copyright (C) 2008 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package NDIRC::Commands::PA;
26 use MooseX::MethodAttributes;
31 : Help(usage: .p X:Y:Z | or .p nick with high enough access)
33 my ($self, $c, $msg) = @_;
36 if ($msg =~ /(\d+)\D+(\d+)\D+(\d+)/){
40 }elsif ($msg && $c->check_user_roles(qw/irc_p_nick/)){
46 my $f = $c->model->prepare(q{
47 SELECT coords(x,y,z),ruler,planet,race,score,size,value,scorerank,sizerank,
48 valuerank, xp, xprank, alliance, relationship, nick, planet_status, hit_us, channel
49 FROM current_planet_stats WHERE (x = $1 AND y = $2 and z = $3) OR nick ILIKE $4 LIMIT 1
51 $f->execute($x,$y,$z,$nick);
52 if (my $planet = $f->fetchrow_hashref()){
53 for (keys %{$planet}){
54 $planet->{$_} = valuecolor(1,$planet->{$_});
57 if ($c->check_user_roles(qw/irc_p_intel/)){
58 $ally = "Alliance=$planet->{alliance} ($planet->{relationship}), Nick=$planet->{nick} ($planet->{planet_status}), Channel: $planet->{channel}, Hostile Count: $planet->{hit_us},";
60 $c->reply("$planet->{coords} $planet->{ruler} OF $planet->{planet},$ally Race=$planet->{race}, Score=$planet->{score} ($planet->{scorerank}), Size=$planet->{size} ($planet->{sizerank}), Value=$planet->{value} ($planet->{valuerank}), XP=$planet->{xp} ($planet->{xprank})");
62 $c->reply("Couldn't find planet: $msg");
69 my ($self, $c, $msg) = @_;
71 my ($x,$y) = ($msg =~ /(\d+)\D+(\d+)/) or die 'ARGS';
73 my $f = $c->model->prepare(q{
74 SELECT score,scorerank,size,sizerank,value,valuerank,planets
75 FROM galaxies WHERE x = ? AND y = ? AND tick = (SELECT max(tick) from galaxies)
78 while (my @row = $f->fetchrow()){
79 @row = map (valuecolor(1),@row);
80 $c->reply("$x:$y Score=$row[0] ($row[1]), Size=$row[2] ($row[3]), Value=$row[4] ($row[5]), Planets=$row[6]");