X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FRaids.pm;h=6b4f16c3081a96527a4c89284af2035ed2ea5f16;hb=2a703f7250ea25f2f556eb25b644dcb7268f92ce;hp=db2618b42417c9b9c5e6cf3d93e4a2fb3fc8e0be;hpb=831088fa9ab0362a5091b54b33db1f61437ccdfc;p=ndwebbie.git diff --git a/lib/NDWeb/Controller/Raids.pm b/lib/NDWeb/Controller/Raids.pm index db2618b..6b4f16c 100644 --- a/lib/NDWeb/Controller/Raids.pm +++ b/lib/NDWeb/Controller/Raids.pm @@ -3,8 +3,10 @@ package NDWeb::Controller::Raids; use strict; use warnings; use parent 'Catalyst::Controller'; +use feature ':5.10'; use POSIX qw/floor pow/; +use List::Util qw/min/; use NDWeb::Include; use ND::Include; @@ -105,8 +107,6 @@ sub view : Local { $c->forward('findRaid'); $raid = $c->stash->{raid}; - $c->stash(comma => \&comma_value); - $c->stash(raid => $raid->{id}); my $planet; if ($c->user->planet){ @@ -141,10 +141,11 @@ sub view : Local { if ($planet->{x} == $target->{x}){ $target->{style} = 'incluster'; } - $target->{scorebash} = 'bash' if ($target->{score}/$planet->{score} < 0.4); + $target->{cap} = min(0.25,0.25 * pow($target->{value}/$planet->{value} , 0.5)); + $target->{scorebash} = 'bash' if ($target->{score}/$planet->{score} < 0.6); $target->{valuebash} = 'bash' if ($target->{value}/$planet->{value} < 0.4); - #next if ($target->{score}/$planet->{score} < 0.4) && ($target->{value}/$planet->{value} < 0.4); } + $target->{cap} //= 0.25; my $unitscans = $dbh->prepare(q{ SELECT DISTINCT ON (name) fid, name, tick, amount @@ -175,8 +176,8 @@ ORDER BY name,tick DESC my @claims; my $size = $target->{size}; for (my $i = 1; $i <= $raid->{waves}; $i++){ - my $roids = floor(0.25*$size); - $size -= $roids; + my $roids = floor($target->{cap}*$size); + $size -= floor(0.25*$size); my $xp = 0; if ($planet && $planet->{score}){ $xp = pa_xp($roids,$planet->{score},$planet->{value},$target->{score},$target->{value}); @@ -247,7 +248,7 @@ sub edit : Local { my $targetquery = $dbh->prepare(qq{SELECT r.id,coords(x,y,z),comment,size ,score,value,race,planet_status,relationship,r.planet, s.scans - ,max(rc.wave) AS waves + ,COALESCE(max(rc.wave),0) AS waves FROM raid_targets r JOIN current_planet_stats p ON p.id = r.planet LEFT OUTER JOIN ( SELECT planet, array_accum(s::text) AS scans @@ -272,7 +273,9 @@ sub edit : Local { my @targets; while (my $target = $targetquery->fetchrow_hashref){ my @waves; - $target->{waves} ||= $raid->{waves}; + if ($target->{waves} < $raid->{waves}){ + $target->{waves} = $raid->{waves} + } for my $i (1 .. $target->{waves}){ $claims->execute($target->{id},$i); my $claimers; @@ -543,7 +546,6 @@ sub targetlist : Local { my ($self, $c, $alliances, $order) = @_; my $dbh = $c->model; - $c->stash(comma => \&comma_value); $c->stash(allies => $alliances); $alliances ||= ''; my @alliances = split /,/, $alliances; @@ -591,7 +593,7 @@ sub targetcalc : Local { my ($self, $c, $target) = @_; my $dbh = $c->model; - my $target = $dbh->selectrow_hashref(q{ + $target = $dbh->selectrow_hashref(q{ SELECT p.id,p.value,p.score,metal_roids, crystal_roids, eonium_roids, ds.total, race FROM raids r JOIN raid_targets rt ON r.id = rt.raid