From c58e53cf25bbd2ecf5e3cff6a4545aee1dfd1e51 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Thu, 25 Jan 2007 12:42:25 +0000 Subject: [PATCH] changed layout and more information --- ND/Include.pm | 10 ++++++++-- ND/Web/Pages/Check.pm | 44 ++++++++++++++++++++++++++---------------- images/down.png | Bin 0 -> 204 bytes images/stay.png | Bin 0 -> 189 bytes images/up.png | Bin 0 -> 196 bytes templates/check.tmpl | 32 ++++++++++++++++++++++-------- 6 files changed, 59 insertions(+), 27 deletions(-) create mode 100644 images/down.png create mode 100644 images/stay.png create mode 100644 images/up.png diff --git a/ND/Include.pm b/ND/Include.pm index 421d81e..27d0eb1 100644 --- a/ND/Include.pm +++ b/ND/Include.pm @@ -50,14 +50,20 @@ sub parseValue { } sub prettyValue { - my ($value) = @_; + my ($value,$decimals) = @_; my $unit = ''; my @units = ('k','M','G','T'); for (my $i = 0; $value >= 1000;$i++){ $value /= 1000; $unit = $units[$i]; } - return sprintf('%.2f%s', $value,$unit); + unless (defined $decimals){ + $decimals = '.0'; + $decimals = '.1' if $value < 100 && $unit; + $decimals = '.2' if $value < 10 && $unit; + } + + return sprintf('%'.$decimals.'f%s', $value,$unit); } diff --git a/ND/Web/Pages/Check.pm b/ND/Web/Pages/Check.pm index c36382e..832eeb9 100644 --- a/ND/Web/Pages/Check.pm +++ b/ND/Web/Pages/Check.pm @@ -79,7 +79,16 @@ sub render_body { $extra_columns = ", planet_status,hit_us, alliance,relationship"; } - my $query = $DBH->prepare(qq{Select id,coords(x,y,z), ((ruler || ' OF ') || p.planet) as planet,race, size, score, value, xp, sizerank, scorerank, valuerank, xprank, p.value - p.size*200 - coalesce(c.metal+c.crystal+c.eonium,0)/150 - coalesce(c.structures,(SELECT avg(structures) FROM covop_targets)::int)*1500 AS fleetvalue,(c.metal+c.crystal+c.eonium)/100 AS resvalue $extra_columns from current_planet_stats p LEFT OUTER JOIN covop_targets c ON p.id = c.planet where x = ? AND y = ? $where order by x,y,z asc}); + my $query = $DBH->prepare(qq{Select id,coords(x,y,z), ((ruler || ' OF ') || p.planet) as planet,race, + size, size_gain, size_gain_day, + score,score_gain,score_gain_day, + value,value_gain,value_gain_day, + xp,xp_gain,xp_gain_day, + sizerank,sizerank_gain,sizerank_gain_day, + scorerank,scorerank_gain,scorerank_gain_day, + valuerank,valuerank_gain,valuerank_gain_day, + xprank,xprank_gain,xprank_gain_day, + p.value - p.size*200 - coalesce(c.metal+c.crystal+c.eonium,0)/150 - coalesce(c.structures,(SELECT avg(structures) FROM covop_targets)::int)*1500 AS fleetvalue,(c.metal+c.crystal+c.eonium)/100 AS resvalue $extra_columns from current_planet_stats_full p LEFT OUTER JOIN covop_targets c ON p.id = c.planet where x = ? AND y = ? $where order by x,y,z asc}); if (defined $z){ $query->execute($x,$y,$z); @@ -92,26 +101,27 @@ sub render_body { my @planets; my $planet_id = undef; my $i = 0; - while (my ($id,$coords,$planet,$race,$size,$score,$value,$xp,$sizerank,$scorerank,$valuerank,$xprank - ,$fleetvalue,$resvalue,$planet_status,$hit_us,$alliance,$relationship,$nick) = $query->fetchrow){ - $planet_id = $id; - my %planet = (Coords => $coords, Planet => $planet, Race => $race, Size => "$size ($sizerank)" - , Score => "$score ($scorerank)", Value => "$value ($valuerank)", XP => "$xp ($xprank)" - , FleetValue => "$fleetvalue ($resvalue)"); + while (my $planet = $query->fetchrow_hashref){ + $planet_id = $planet->{id}; + for my $type (qw/size score value xp/){ + #$planet->{$type} = prettyValue($planet->{$type}); + $planet->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000 + $planet->{"${type}img"} = 'stay'; + $planet->{"${type}img"} = 'up' if $planet->{"${type}_gain_day"} > 0; + $planet->{"${type}img"} = 'down' if $planet->{"${type}_gain_day"} < 0; + $planet->{"${type}rankimg"} = 'stay'; + $planet->{"${type}rankimg"} = 'up' if $planet->{"${type}rank_gain_day"} < 0; + $planet->{"${type}rankimg"} = 'down' if $planet->{"${type}rank_gain_day"} > 0; + } if ($self->isMember && ($self->isOfficer || $self->isBC)){ - $planet{HitUs} = $hit_us; - $planet{Alliance} = "$alliance ($relationship)"; - $planet{Nick} = "$nick ($planet_status)"; - $planet{PlanetStatus} = $planet_status; - $planet{Relationship} = $relationship; - #$planet{isBC} = 1; - if ($z && $alliance eq 'NewDawn' && not ($self->isHC || $self->isOfficer)){ - log_message $ND::UID,"BC browsing ND planet $coords tick $self->{TICK}"; + if ($z && $planet->{alliance} eq 'NewDawn' && not ($self->isHC || $self->isOfficer)){ + log_message $ND::UID,"BC browsing ND planet $planet->{coords} tick $self->{TICK}"; } } $i++; - $planet{ODD} = $i % 2; - push @planets,\%planet; + $planet->{ODD} = $i % 2; + delete $planet->{id}; + push @planets,$planet; } $BODY->param(Planets => \@planets); diff --git a/images/down.png b/images/down.png new file mode 100644 index 0000000000000000000000000000000000000000..69663f9a97c22813f3dea148c1c52756e642e1e0 GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^oIuRV!3HF!2OrA@Qfx`y?k)`fL2$v|<&!~53Opi< z85p>QL70(Y)*K0-AbW|YuPgg?MoDft!9*+fIG~VhiEBiObAE1aYF-J0b5UwyNotBh zd1gt5LP$ocg1e`0!21-{JfK1YPZ!4!j_b*P&K~$MzmXv!B_Scf qf@l_p@+O5%PGKgNY%yGk3=A(1asK?*!nqTum%-E3&t;ucLK6UF6FemV literal 0 HcmV?d00001 diff --git a/images/stay.png b/images/stay.png new file mode 100644 index 0000000000000000000000000000000000000000..e4282437e8425f6db6e044d9eb4913a83d633434 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^oIuRV!3HF!2OrA@Qfx`y?k)`fL2$v|<&!~53Opi< z85p>QL70(Y)*K0-AbW|YuPgg?MoDgE^&=UxDuF_>C9V-A&iT2ysd*&~&PAz-C8;S2 z<(VZJ3LzP(3hti10q;{(^MDE!JzX3_IIbtBG&J4km-uJAfH91f&5aER)Yz05=87^h Y@YXPM?JbY604iqiboFyt=akR{0A%1VEdT%j literal 0 HcmV?d00001 diff --git a/images/up.png b/images/up.png new file mode 100644 index 0000000000000000000000000000000000000000..698a42a30d1c31ae4366dc99730d821e704d7d39 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^oIuRV!3HF!2OrA@Qfx`y?k)`fL2$v|<&!~53Opi< z85p>QL70(Y)*K0-AbW|YuPgg?MoDf7?TGo0LF hxF(1iJql)EW_VD}%UV&s?l({mgQu&X%Q~loCIE4~H+KL4 literal 0 HcmV?d00001 diff --git a/templates/check.tmpl b/templates/check.tmpl index c4c10f0..efdd9ab 100644 --- a/templates/check.tmpl +++ b/templates/check.tmpl @@ -1,15 +1,31 @@

Do arbiter check on gal

- - + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + -- 2.39.2
CoordsPlanetRaceSize (rank)Score (rank)Value (rank)XP (rank)Fleet (Resouce) valueNickHit usAlliance
Rank
SizeScoreValue XPCoordsPlanetRaceSizeScoreValue XPFleet (Resouce) valueNickHit usAlliance
<TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg> <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg> ()()