+ my ( $self, $c ) = @_;
+ $c->res->body( 'Page not found' );
+ $c->response->status(404);
+}
+
+sub login : Local {
+ my ($self, $c) = @_;
+ if ($c->login){
+ $c->res->redirect($c->uri_for('index'));
+ return;
+ }
+
+ $c->stash(error => 'Bad password');
+ $c->stash(template => 'index.tt2');
+ $c->forward('index');
+}
+
+sub logout : Local {
+ my ($self, $c) = @_;
+ $c->logout;
+ $c->res->redirect($c->uri_for('index'));
+}
+
+#sub begin : private {
+#}
+
+sub listTargets : Private {
+ my ($self, $c) = @_;
+
+ my $dbh = $c ->model;
+
+ my $query = $dbh->prepare(q{SELECT t.id, r.id AS raid, r.tick+c.wave-1 AS landingtick,
+ (released_coords AND old_claim(timestamp)) AS released_coords, coords(x,y,z),c.launched,c.wave,c.joinable
+FROM raid_claims c
+ JOIN raid_targets t ON c.target = t.id
+ JOIN raids r ON t.raid = r.id
+ JOIN current_planet_stats p ON t.planet = p.id
+WHERE c.uid = $1 AND r.tick+c.wave > tick() AND r.open AND not r.removed
+ORDER BY r.tick+c.wave,x,y,z});
+ $query->execute($c->user->id) or die $dbh->errstr;
+ my @targets;
+ while (my $target = $query->fetchrow_hashref){
+ push @targets, $target;
+ }
+
+ $c->stash(targets => \@targets);
+}
+
+sub auto : Private {
+ my ($self, $c) = @_;
+ my $dbh = $c ->model;
+
+ $c->stash(dbh => $dbh);
+
+ $dbh->do(q{SET timezone = 'GMT'});
+
+ $c->stash(TICK =>$dbh->selectrow_array('SELECT tick()',undef));
+ $c->stash->{game}->{tick} = $c->stash->{TICK};
+
+ if ($c->user_exists){
+ $c->stash(UID => $c->user->id);
+ }else{
+ $c->stash(UID => -4);
+ }
+
+}
+
+sub access_denied : Private {
+ my ($self, $c, $action) = @_;
+
+ $c->log->debug('moo' . $action);
+
+ # Set the error message
+ $c->stash->{template} = 'access_denied.tt2';
+