diff --git a/bin/util/everyone_gets_a_ssd.pl b/bin/util/everyone_gets_a_ssd.pl new file mode 100644 index 00000000..26639cf0 --- /dev/null +++ b/bin/util/everyone_gets_a_ssd.pl @@ -0,0 +1,52 @@ +use 5.010; +use strict; +use lib '/data/Lacuna-Server/lib'; +use Lacuna::DB; +use Lacuna; +use Lacuna::Util qw(randint format_date); +use Getopt::Long; +$|=1; +our $quiet; +GetOptions( + 'quiet' => \$quiet, +); + + +out('Started'); +my $start = time; + +out('Loading DB'); +our $db = Lacuna->db; + +out('Giving SSD'); +my $empires = $db->resultset('Lacuna::DB::Result::Empire'); +while (my $empire = $empires->next) { + my $home = $empire->home_planet; + say "Adding to ".$home->name; + my ($x, $y) = $home->find_free_space; + my $ssd = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({ + body_id => $home->id, + x => $x, + y => $y, + class => 'Lacuna::DB::Result::Building::SubspaceSupplyDepot', + }); + $home->build_building($ssd); +} + +my $finish = time; +out('Finished'); +out((($finish - $start)/60)." minutes have elapsed"); + + +############### +## SUBROUTINES +############### + +sub out { + my $message = shift; + unless ($quiet) { + say format_date(DateTime->now), " ", $message; + } +} + + diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 25d511ab..a0104909 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 2.3300; +our $VERSION = 2.3500; my $config = Config::JSON->new('/data/Lacuna-Server/etc/lacuna.conf'); my $db = Lacuna::DB->connect($config->get('db/dsn'),$config->get('db/username'),$config->get('db/password'), { mysql_enable_utf8 => 1}); diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index e72752af..5e5efb62 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -374,6 +374,18 @@ sub is_space_free { return 1; } +sub find_free_space { + my $self; + foreach my $x (-5..5) { + foreach my $y (-5..5) { + if ($self->is_space_free($x, $y)) { + return ($x, $y); + } + } + } + confess [1009, 'No free space found.']; +} + sub check_for_available_build_space { my ($self, $x, $y) = @_; if ($x > 5 || $x < -5 || $y > 5 || $y < -5) { diff --git a/lib/Lacuna/Tutorial.pm b/lib/Lacuna/Tutorial.pm index 45e99d6b..6171a64b 100644 --- a/lib/Lacuna/Tutorial.pm +++ b/lib/Lacuna/Tutorial.pm @@ -283,6 +283,13 @@ sub the_end { $home->add_energy(2000); $home->add_water(2000); $home->update; + my ($x, $y) = $home->find_free_space; + my $ssd = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({ + x => $x, + y => $y, + class => 'Lacuna::DB::Result::Building::SubspaceSupplyDepot', + }); + $home->build_building($ssd); $self->start('turing'); return undef; } diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 00394712..e72206e0 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,6 +1,7 @@ 2.3500 - Development ministry now immediately returns "needs_surface_refresh" on subsidize build queue. - Scows can't launch unless there is enough waste to fill them. + - Added Subspace Supply Depot to the end of the tutorial. 2.3400 - Fixed Archaeology Ministry to have a University prereq of 11 rather than 10.