]> ruin.nu Git - ndwebbie.git/blobdiff - NDWeb/Pages/Check.pm
Storing government for planets
[ndwebbie.git] / NDWeb / Pages / Check.pm
index eb0aa848c3f9605a5001d35521079b319cb4bd93..a0062ab3568b7a67327e171ecdf68d2cff7b67ea 100644 (file)
@@ -78,7 +78,7 @@ sub render_body {
                $extra_columns = ", planet_status,hit_us, alliance,relationship";
        }
 
-       my $query = $DBH->prepare(qq{Select p.id,coords(x,y,z), ((ruler || ' OF ') || p.planet) as planet,race,
+       my $query = $DBH->prepare(qq{Select p.id,coords(x,y,z), ((ruler || ' OF ') || p.planet) as planet,race,gov,
                size, size_gain, size_gain_day,
                score,score_gain,score_gain_day,
                value,value_gain,value_gain_day,
@@ -107,7 +107,6 @@ sub render_body {
        }
        my @planets;
        my $planet_id = undef;
-       my $i = 0;
        while (my $planet = $query->fetchrow_hashref){
                $planet_id = $planet->{id};
                for my $type (qw/size score value xp/){
@@ -126,8 +125,6 @@ sub render_body {
                                log_message $ND::UID,"BC browsing ND planet $planet->{coords} tick $self->{TICK}";
                        }
                }
-               $i++;
-               $planet->{ODD} = $i % 2;
                delete $planet->{id};
                push @planets,$planet;
        }
@@ -150,17 +147,15 @@ sub render_body {
                        ORDER BY i.tick,x,y,z
                });
                $query->execute($planet_id);
-               my $ships = $DBH->prepare(q{SELECT ship,amount FROM fleet_ships WHERE id = ?});
+               my $ships = $DBH->prepare(q{SELECT ship,amount FROM fleet_ships
+                       WHERE id = ? ORDER BY num
+               });
                my @missions;
-               $i = 0;
                while (my $mission = $query->fetchrow_hashref){
-                       $mission->{ODD} = $i++ % 2;
                        $mission->{CLASS} = $mission->{mission};
                        my @ships;
                        $ships->execute($mission->{id});
-                       my $j = 0;
                        while (my $ship = $ships->fetchrow_hashref){
-                               $ship->{ODD} = $j++ % 2;
                                push @ships,$ship;
                        }
                        push @ships, {ship => 'No', amount => 'ships'} if @ships == 0;
@@ -184,15 +179,11 @@ sub render_body {
                });
                $query->execute($planet_id);
                my @incomings;
-               $i = 0;
                while (my $mission = $query->fetchrow_hashref){
-                       $mission->{ODD} = $i++ % 2;
                        $mission->{CLASS} = $mission->{mission};
                        my @ships;
                        $ships->execute($mission->{id});
-                       my $j = 0;
                        while (my $ship = $ships->fetchrow_hashref){
-                               $ship->{ODD} = $j++ % 2;
                                push @ships,$ship;
                        }
                        push @ships, {ship => 'No', amount => 'ships'} if @ships == 0;
@@ -218,9 +209,7 @@ sub render_body {
                });
                $query->execute($planet_id);
                my @scans;
-               $i = 0;
                while (my $scan = $query->fetchrow_hashref){
-                       $scan->{ODD} = $i++ % 2;
                        push @scans,$scan;
                }
                $BODY->param(Scans => \@scans);
@@ -244,9 +233,7 @@ sub render_body {
                });
                $query->execute($planet_id);
                my @pdata;
-               $i = 0;
                while (my $data = $query->fetchrow_hashref){
-                       $data->{ODD} = ++$i % 2;
                        $data->{amount} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000
                        push @pdata,$data;
                }
@@ -270,7 +257,6 @@ sub render_body {
        $query->execute($x,$y) or $ND::ERROR .= p($DBH->errstr);
 
        my @galaxies;
-       $i = 0;
        while (my $galaxy = $query->fetchrow_hashref){
                for my $type (qw/planets size score xp value/){
                        #$galaxy->{$type} = prettyValue($galaxy->{$type});
@@ -287,8 +273,6 @@ sub render_body {
                                $galaxy->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000
                        }
                }
-               $i++;
-               $galaxy->{ODD} = $i % 2;
                push @galaxies,$galaxy;
        }
        $BODY->param(Galaxies => \@galaxies);