X-Git-Url: https://ruin.nu/git/index.pl?a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FRaids.pm;h=f6b644a7b17465f80005d0bc5ed0765e889fd053;hb=7510a73591d06ced24af063d598029fd9d1bce8a;hp=a6492591be35f365abd670729144da410708f716;hpb=9a036ffed7e1b7aae37274f9963047c564db8be4;p=ndwebbie.git diff --git a/lib/NDWeb/Controller/Raids.pm b/lib/NDWeb/Controller/Raids.pm index a649259..f6b644a 100644 --- a/lib/NDWeb/Controller/Raids.pm +++ b/lib/NDWeb/Controller/Raids.pm @@ -54,7 +54,7 @@ sub index :Path :Args(0) { if ($c->check_user_roles(qw/raids_info/)){ my $query = $dbh->prepare(q{ - SELECT r.id,open ,tick + SELECT r.id,open ,tick, open_tick, released_coords AS releasedcoords ,waves*COUNT(DISTINCT rt.id) AS waves,COUNT(rc.uid) AS claims ,COUNT(nullif(rc.launched,false)) AS launched ,COUNT(NULLIF(uid > 0 OR rc.wave > r.waves,true)) AS blocked @@ -114,7 +114,7 @@ sub view : Local { $c->stash(message => parseMarkup($raid->{message})); $c->stash(landingtick => $raid->{tick}); my $targetquery = $dbh->prepare(q{SELECT r.id, pid AS planet, size, score, value - , p.x,p.y,p.z, race + , p.pid, p.x,p.y,p.z, race , p.value - p.size*200 - COALESCE(ps.metal+ps.crystal+ps.eonium,0)/150 - COALESCE(ds.total ,(SELECT @@ -131,14 +131,14 @@ sub view : Local { LEFT OUTER JOIN current_development_scans ds USING (pid) WHERE r.raid = $1 AND NOT COALESCE(p.x = $2 AND p.y = $3,False) - ORDER BY size}); + ORDER BY size DESC, value DESC, score DESC}); $targetquery->execute($raid->{id},$planet->{x},$planet->{y}); my @targets; while (my $target = $targetquery->fetchrow_hashref){ if ($planet && $planet->{x}){ - if ($planet->{x} == $target->{x}){ - $target->{style} = 'incluster'; - } + #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); @@ -158,8 +158,11 @@ ORDER BY name,tick DESC WHERE fid = ? ORDER BY num }); my @missions; + my $tick = 0; while (my $mission = $unitscans->fetchrow_hashref){ my @ships; + last if $mission->{tick} <= $tick; + $tick = $mission->{tick}; $ships->execute($mission->{fid}); while (my $ship = $ships->fetchrow_hashref){ push @ships,$ship; @@ -203,7 +206,7 @@ ORDER BY name,tick DESC push @targets,$target; } - @targets = sort {$b->{roids}[0]{xp} <=> $a->{roids}[0]{xp} or $b->{size} <=> $a->{size}} @targets; + #@targets = sort {$b->{roids}[0]{xp} <=> $a->{roids}[0]{xp} or $b->{size} <=> $a->{size}} @targets; $c->stash(targets => \@targets); } @@ -212,7 +215,7 @@ sub edit : Local { my ($self, $c, $raid, $order) = @_; my $dbh = $c->model; - my $query = $dbh->prepare(q{SELECT id,tick,waves,message,released_coords,open,ftid + my $query = $dbh->prepare(q{SELECT id,tick,waves,message,released_coords,open,ftid,open_tick FROM raids WHERE id = ? }); $raid = $dbh->selectrow_hashref($query,undef,$raid); @@ -308,10 +311,12 @@ sub postraidupdate : Local { my $dbh = $c->model; $dbh->begin_work; - $dbh->do(q{UPDATE raids SET message = ?, tick = ?, waves = ? WHERE id = ?} + my $tick = $c->req->param('tick'); + my $waves = $c->req->param('waves'); + my $open_tick = $c->req->param('open_tick') || undef; + $dbh->do(q{UPDATE raids SET message = ?, tick = ?, waves = ?, open_tick = ? WHERE id = ?} ,undef,html_escape $c->req->param('message') - ,$c->req->param('tick'),$c->req->param('waves') - ,$raid); + ,$tick,$waves,$open_tick,$raid); $c->forward('log',[$raid, 'BC updated raid']); @@ -513,10 +518,12 @@ sub postcreate : Local { $dbh->begin_work; my $query = $dbh->prepare(q{INSERT INTO raids (tick,waves,message) VALUES(?,?,?) RETURNING (id)}); - $query->execute($c->req->param('tick'),$c->req->param('waves') - ,html_escape $c->req->param('message')); + my $tick = $c->req->param('tick'); + my $waves = $c->req->param('waves'); + my $message = html_escape $c->req->param('message'); + $query->execute($tick,$waves,$message); my $raid = $query->fetchrow_array; - $c->forward('log',[$raid,"Created raid landing at tick: ".$c->req->param('tick')]); + $c->forward('log',[$raid,"Created raid landing at tick: ".$tick]); if ($c->req->param('gal') || $c->req->param('target')) { my @gals = $c->req->param('gal'); @@ -530,7 +537,8 @@ sub postcreate : Local { ) ) }); - $addtarget->execute($raid,\@targets,\@gals,$c->req->param('sizelimit')); + my $sizelimit = $c->req->param('sizelimit'); + $addtarget->execute($raid,\@targets,\@gals,$sizelimit); $c->forward('log',[$raid,"BC added planets (@targets) and the gals for (@gals)"]); } $dbh->do(q{INSERT INTO raid_access (raid,gid) VALUES(?,'M')} @@ -719,9 +727,11 @@ sub postcreateretal : Local { my $dbh = $c->model; $dbh->begin_work; + my $tick = $c->req->param('tick'); + my $waves = $c->req->param('waves'); + my $message = html_escape $c->req->param('message'); my $query = $dbh->prepare(q{INSERT INTO raids (tick,waves,message) VALUES(?,?,?) RETURNING (id)}); - $query->execute($c->req->param('tick'),$c->req->param('waves') - ,html_escape $c->req->param('message')); + $query->execute($tick, $waves, $message); my $raid = $query->fetchrow_array; $c->forward('log',[$raid,"Created retal raid landing at tick: ".$c->req->param('tick')]);