]> ruin.nu Git - ndwebbie.git/commitdiff
Fetch and present def missions too
authorMichael Andreen <harv@ruin.nu>
Tue, 11 Sep 2007 17:40:16 +0000 (19:40 +0200)
committerMichael Andreen <harv@ruin.nu>
Tue, 11 Sep 2007 17:40:16 +0000 (19:40 +0200)
NDWeb/Pages/MemberIntel.pm
templates/memberIntel.tmpl

index 0974b5ab6fab7e70be44ddaaa81317b5ca9dbdec..ae5cb2d8ad83cd7918edc36f10c55849015ef953 100644 (file)
@@ -19,7 +19,7 @@
 
 package NDWeb::Pages::MemberIntel;
 use strict;
-use warnings FATAL => 'all';
+use warnings;
 use CGI qw/:standard/;
 use NDWeb::Include;
 
@@ -73,7 +73,7 @@ sub render_body {
                $query->execute($user->{uid}) or $error .= $DBH->errstr;
                my @nd_attacks;
                my @retals;
-               my @other;
+               my @other_attacks;
                while (my $intel = $query->fetchrow_hashref){
                        my $attack = {target => $intel->{coords}, tick => $intel->{tick}};
                        if ($intel->{ndtarget}){
@@ -84,14 +84,42 @@ sub render_body {
                                }
                                push @nd_attacks, $attack;
                        }else{
-                               push @other, $attack;
+                               push @other_attacks, $attack;
                        }
                }
                my @attacks;
                push @attacks, {name => 'ND Attacks', list => \@nd_attacks};
-               push @attacks, {name => 'Other', list => \@other};
+               push @attacks, {name => 'Other', list => \@other_attacks};
                $BODY->param(Attacks => \@attacks);
 
+               $query = $DBH->prepare(q{
+                       SELECT coords(t.x,t.y,t.z),t.alliance_id, t.alliance, i.eta, i.tick, i.ingal
+                       FROM users u
+                       JOIN (SELECT * FROM intel WHERE amount = -1) i ON i.sender = u.planet
+                       LEFT OUTER JOIN current_planet_stats t ON i.target = t.id
+                       WHERE u.uid = $1 AND (i.mission = 'Defend' OR i.mission = 'AllyDef')
+                       ORDER BY (i.tick - i.eta)
+                       });
+               $query->execute($user->{uid}) or $error .= $DBH->errstr;
+               my @nd_def;
+               my @ingal_def;
+               my @other_def;
+               while (my $intel = $query->fetchrow_hashref){
+                       my $def = {target => $intel->{coords}.(defined $intel->{alliance} ? " ($intel->{alliance})" : ''), tick => $intel->{tick}};
+                       if (defined $intel->{alliance_id} && $intel->{alliance_id} == 1){
+                               push @nd_def, $def;
+                       }elsif($intel->{ingal}){
+                               push @ingal_def, $def;
+                       }else{
+                               push @other_def, $def;
+                       }
+               }
+               my @defenses;
+               push @defenses, {name => 'ND Def', list => \@nd_def};
+               push @defenses, {name => 'Ingal Def', list => \@ingal_def};
+               push @defenses, {name => 'Other', list => \@other_def};
+               $BODY->param(Defenses => \@defenses);
+
        }else{
                my $query = $DBH->prepare(q{SELECT u.uid,u.username,u.attack_points, u.defense_points, n.tick
                        ,count(CASE WHEN i.mission = 'Attack' THEN 1 ELSE NULL END) AS attacks
index 95a7d56007c72de7dbb0dfa27c1ba8f1b68c0cde..13e69674ffab0c53e8b2ffb2cba290468c9498a8 100644 (file)
                </TMPL_LOOP>
        </TMPL_LOOP>
 </table>
+<table>
+       <tr>
+               <th>Defense</th><th>Pt</th><th></th>
+       </tr>
+       <TMPL_LOOP Defenses>
+               <tr><td><TMPL_VAR NAME=NAME></td></tr>
+               <TMPL_LOOP LIST>
+       <tr class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+               <td><TMPL_VAR NAME=Target></td>
+               <td><TMPL_VAR NAME=tick></td>
+               <td><TMPL_VAR NAME=Other></td>
+       </tr>
+               </TMPL_LOOP>
+       </TMPL_LOOP>
+</table>
 <TMPL_ELSE>
 <table>
        <tr>