]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Raids.pm
Add opening tick to raids
[ndwebbie.git] / lib / NDWeb / Controller / Raids.pm
index ae9c7a61a7c8eb4a632dcbcb62785741edb75106..f6b644a7b17465f80005d0bc5ed0765e889fd053 100644 (file)
@@ -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
@@ -136,9 +136,9 @@ sub view : Local {
        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);
@@ -215,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);
@@ -313,9 +313,10 @@ sub postraidupdate : Local {
        $dbh->begin_work;
        my $tick = $c->req->param('tick');
        my $waves = $c->req->param('waves');
-       $dbh->do(q{UPDATE raids SET message = ?, tick = ?, waves = ? WHERE id = ?}
+       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')
-               ,$tick,$waves,$raid);
+               ,$tick,$waves,$open_tick,$raid);
 
        $c->forward('log',[$raid, 'BC updated raid']);