X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=include.pl;h=fe3646d0a1cfe215db5b828eafea2fd9e38a753f;hb=191f4e2ff4e447b1219a4d49975a8cbc1039eb65;hp=eab857ee916101c6c0fff8631c96d099577c4eda;hpb=073463a38ef44b632155ffd6f4e61f4e1370a821;p=ndwebbie.git diff --git a/include.pl b/include.pl index eab857e..fe3646d 100644 --- a/include.pl +++ b/include.pl @@ -36,12 +36,63 @@ sub isBC { return exists $ND::GROUPS{BC}; } +sub isOfficer { + return exists $ND::GROUPS{Officers}; +} + +sub isScanner { + return exists $ND::GROUPS{Scanner}; +} + sub parseMarkup { my ($text) = @_; $text =~ s{\n}{\n
}g; - $text =~ s{\[B\](.*?)\[B\]}{$1}; + $text =~ s{\[B\](.*?)\[/B\]}{$1}; return $text; } +sub min { + my ($x,$y) = @_; + return ($x > $y ? $y : $x); +} + +sub max { + my ($x,$y) = @_; + return ($x < $y ? $y : $x); +} + +sub listTargets { + my $query = $ND::DBH->prepare(qq{SELECT t.id, r.id AS raid, r.tick+c.wave-1 AS landingtick, released_coords, coords(x,y,z),c.launched,c.wave +FROM raid_claims c + JOIN raid_targets t ON c.target = t.id + JOIN raids r ON t.raid = r.id + JOIN current_planet_stats p ON t.planet = p.id +WHERE c.uid = ? AND r.tick+c.wave > ? AND r.open AND not r.removed +ORDER BY r.tick+c.wave,x,y,z}); + $query->execute($ND::UID,$ND::TICK); + my @targets; + while (my $target = $query->fetchrow_hashref){ + my $coords = "Target $target->{id}"; + $coords = $target->{coords} if $target->{released_coords}; + push @targets,{Coords => $coords, Launched => $target->{launched}, Raid => $target->{raid} + , Target => $target->{id}, Tick => $target->{landingtick}, Wave => $target->{wave}}; + } + my $template = HTML::Template->new(filename => "templates/targetlist.tmpl"); + $template->param(Targets => \@targets); + return $template->output; +} + +sub alliances { + my ($alliance) = @_; + my @alliances; + push @alliances,{Id => -1, Name => ' ', Selected => not $alliance}; + my $query = $ND::DBH->prepare(q{SELECT id,name FROM alliances ORDER BY name}); + $query->execute; + while (my $ally = $query->fetchrow_hashref){ + push @alliances,{Id => $ally->{id}, Name => $ally->{name}, Selected => $alliance eq $ally->{name}}; + } + return @alliances; +} + 1;