]> ruin.nu Git - ndwebbie.git/commitdiff
Add support for variable cap
authorMichael Andreen <harv@ruin.nu>
Mon, 29 Jun 2009 08:02:21 +0000 (10:02 +0200)
committerMichael Andreen <harv@ruin.nu>
Mon, 29 Jun 2009 08:02:21 +0000 (10:02 +0200)
lib/NDWeb/Controller/Raids.pm
root/src/raids/view.tt2

index 944b6914d2a1f3371ab7799b4bc9e3f90af9a29c..ab1adb5e26737f1581c65212a22cdac255b08aaa 100644 (file)
@@ -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;
 
@@ -141,10 +143,11 @@ sub view : Local {
                        if ($planet->{x} == $target->{x}){
                                $target->{style} = 'incluster';
                        }
+                       $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 +178,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});
@@ -593,7 +596,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
index d30885d01b33a0bb8b14033d342c68f62e40ee2c..f076c8f4ceac58fac8449d73ec272feb550db608 100644 (file)
@@ -31,6 +31,7 @@
                <li>Hidden value: [% t.hidden %]</li>
                <li>Factory Usage: [% t.light %], [% t.medium %], [% t.heavy %]</li>
                <li>Race: [% t.race %]</li>
+               <li>Cap: [% t.cap * 100 | format('%.02f') %]</li>
                [% FOR r IN t.roids %]
                        <li>Roids wave [% r.wave %]: [% r.roids %] ([% comma(r.xp) %] xp)</li>
                [% END %]