From cc61b15adfbf9aeb6fffd152ae87c47f3d4361a7 Mon Sep 17 00:00:00 2001 From: fireartist Date: Wed, 23 Jan 2013 12:07:17 +0000 Subject: [PATCH] /admin/ function to add a building bypassing normal requirements + costs --- lib/Lacuna/Web/Admin.pm | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/lib/Lacuna/Web/Admin.pm b/lib/Lacuna/Web/Admin.pm index ae876125..5b567899 100644 --- a/lib/Lacuna/Web/Admin.pm +++ b/lib/Lacuna/Web/Admin.pm @@ -324,9 +324,59 @@ sub www_view_buildings { $out .= sprintf(''); } $out .= ''; + $out .= '

Add Building

'; + $out .= '

This costs no resources or plans, and bypasses normal restrictions '; + $out .= 'such as tech-level, plot-count, etc.
'; + $out .= 'Level is the final level after the build is complete.
'; + $out .= 'X and Y are not required.

'; + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
TypeXYLevelSkip build queue
'; return $self->wrap($out); } +sub www_add_building { + my ($self, $request) = @_; + my $body = Lacuna->db->resultset('Map::Body')->find($request->param('body_id')); + unless (defined $body) { + confess [404, 'Body not found.']; + } + my $class = $request->param('class'); + my $x = $request->param('x'); + my $y = $request->param('y'); + my $level = $request->param('level') || 1; + $level--; + if ( !length $x || !length $y ) { + ($x, $y) = $body->find_free_space; + } + my $building = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({ + x => $x, + y => $y, + level => $level, + body_id => $body->id, + body => $body, + class => $class, + }); + $body->build_building( $building ); + if ( $request->param('skip_build_queue') ) { + $building->finish_upgrade; + } + return $self->www_view_buildings($request, $body->id); +} + sub www_set_efficiency { my ($self, $request) = @_; my $building = Lacuna->db->resultset('Lacuna::DB::Result::Building')->find($request->param('building_id')); -- 2.51.2