From 8d92aa43e048f1ac7f48aa78804563dadb4a3fc9 Mon Sep 17 00:00:00 2001 From: fireartist Date: Wed, 23 Jan 2013 12:42:33 +0000 Subject: [PATCH] admin/move-building check plot is empty and add a lock on it --- lib/Lacuna/Web/Admin.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/Web/Admin.pm b/lib/Lacuna/Web/Admin.pm index 00b7bf69..095158a2 100644 --- a/lib/Lacuna/Web/Admin.pm +++ b/lib/Lacuna/Web/Admin.pm @@ -391,10 +391,24 @@ sub www_add_building { sub www_set_efficiency { my ($self, $request) = @_; my $building = Lacuna->db->resultset('Lacuna::DB::Result::Building')->find($request->param('building_id')); + my $body = Lacuna->db->resultset('Map::Body')->find($building->body_id); + my $x = $request->param('x'); + my $y = $request->param('y'); + + # check the plot lock + if ($body->is_plot_locked($x, $y)) { + confess [1013, "That plot is reserved for another building.", [$x,$y]]; + } + else { + $body->lock_plot($x,$y); + } + # is the plot empty? + $body->check_for_available_build_space( $x, $y ); + $building->update({ efficiency => $request->param('efficiency'), - x => $request->param('x'), - y => $request->param('y'), + x => $x, + y => $y, level => $request->param('level'), }); return $self->www_view_buildings($request, $building->body_id); -- 2.51.2