1 #**************************************************************************
2 # Copyright (C) 2006 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 #**************************************************************************/
19 package ND::IRC::Intel;
27 our @ISA = qw/Exporter/;
29 our @EXPORT = qw/checkIntel setHostile findNick setNick setAlly setChannel/;
34 if (officer() || dc()){
35 my $f = $ND::DBH->prepare("SELECT nick,alliance,coords(x,y,z),ruler,planet,hit_us,race,score,size,value,planet_status,relationship FROM current_planet_stats WHERE x = ? AND y = ? and z = ?");
36 $f->execute($x,$y,$z);
37 while (my @row = $f->fetchrow()){
38 @row = map (valuecolor(1),@row);
39 $ND::server->command("notice $ND::target $row[2] - $row[3] OF $row[4], Alliance=$row[1] ($row[11]), Nick=$row[0] ($row[10]), Hostile Count=$row[5], Race=$row[6], Score=$row[7], Size=$row[8], Value=$row[9] ");
42 $ND::server->command("msg $ND::target Only officers are allowed to check that");
50 my $rv = $ND::DBH->do("UPDATE planets SET planet_status = 'Hostile' WHERE id = (SELECT id FROM current_planet_stats WHERE x = ? AND y = ? and z = ?)",undef,$x,$y,$z);
52 $ND::server->command("msg $ND::target $x:$y:$z is now marked s hostile");
61 my $f = $ND::DBH->prepare("SELECT coords(x,y,z), ruler,planet,nick FROM current_planet_stats WHERE nick ILIKE ? ORDER BY x,y,z");
63 $ND::server->command("notice $ND::target No such nick") if $f->rows == 0;
64 while (my @row = $f->fetchrow()){
65 $ND::server->command("notice $ND::target $row[0] $row[1] OF $row[2] is $row[3]");
70 my ($x,$y,$z,$nick) = @_;
73 if ($ND::DBH->do("UPDATE planets SET nick = ? WHERE id = planetid(?,?,?,0)"
74 ,undef,$nick,$x,$y,$z)){
75 $ND::server->command("msg $ND::target $x:$y:$z has been updated");
81 my ($x,$y,$z,$ally) = @_;
85 if ($ally ne 'unknown'){
86 ($aid,$ally) = $ND::DBH->selectrow_array("SELECT id,name FROM alliances WHERE name ILIKE ?",undef,$ally);
89 $ND::DBH->do("UPDATE planets SET alliance_id = ? WHERE id = planetid(?,?,?,0)"
90 ,undef,$aid,$x,$y,$z);
91 $ND::server->command("msg $ND::target Setting $x:$y:$z as $ally");
93 $ND::server->command("msg $ND::target Couldn't find such an alliance");
99 my ($x,$y,$z,$channel) = @_;
102 if ($ND::DBH->do("UPDATE planets SET channel = ? WHERE id = planetid(?,?,?,0)"
103 ,undef,$channel,$x,$y,$z)){
104 $ND::server->command("msg $ND::target $x:$y:$z relay channel has been set to: $channel");