diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 0e3a83c5..7cde8745 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -1419,8 +1419,20 @@ sub tick_to { my $seconds = $now->epoch - $self->last_tick->epoch; my $tick_rate = $seconds / 3600; $self->last_tick($now); + if ($self->happiness < 0) { + $self->needs_recalc if ($self->happiness_hour < -20_000); + if ($self->depressed) { +# Nothing for now... + } + else { + $self->depressed(1); + $self->depression($now); + } + } + else { + $self->depressed(0); + } # Check to see if downward spiral still happening in happiness from negative plots. - $self->needs_recalc(1) if ($self->happiness < 0 and $self->happiness_hour < -20_000); if ($self->needs_recalc) { $self->recalc_stats; } diff --git a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm index f549e368..f3de8689 100644 --- a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm +++ b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm @@ -1,6 +1,6 @@ package Lacuna::RPC::Building::BlackHoleGenerator; # Upcoming enhancements -# Email empires of planets modified. +# Play balance mods for hopping planets. use Moose; use utf8; @@ -573,7 +573,10 @@ sub generate_singularity { my $side = randint(0,99); if ($task->{side_chance} > $side) { my $side_type = randint(0,99); - if ($side_type < 25) { + if ($side_type < 5) { + $return_stats = bhg_random_fissure($building); + } + elsif ($side_type < 25) { $return_stats = bhg_random_size($building); } elsif ($side_type < 40) { @@ -1008,6 +1011,44 @@ sub bhg_random_resource { return $return; } +sub bhg_random_fissure { + my ($building) = @_; + my $body = $building->body; + my $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search( + { zone => $body->zone, empire_id => undef }, + {rows => 1, order_by => 'rand()' } + )->single; + my $btype = $target->get_type; + my $return = { + id => $target->id, + name => $target->name, + type => $btype, + }; + if ($btype eq 'habitable planet') { + my ($x, $y) = eval { $body->find_free_space}; + unless ($@) { + my $building = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({ + x => $x, + y => $y, + level => randint(1, 30), + body_id => $target->id, + body => $target, + class => + }); + $body->build_building($building, undef, 1); + $body->add_news(50, sprintf('Astromers detect a gravitational anomoly on %s.', $target->name)); + $return->{message} = "Fissure formed"; + } + else { + $return->{message} = "No warp"; + } + } + else { + $return->{message} = "No warp"; + } + return $return; +} + sub bhg_random_decor { my ($building) = @_; my $body = $building->body; diff --git a/var/upgrades/3.0873.sql b/var/upgrades/3.0873.sql index 63c1923e..c1698f88 100644 --- a/var/upgrades/3.0873.sql +++ b/var/upgrades/3.0873.sql @@ -1,3 +1,3 @@ alter table body add column `depression` datetime NOT NULL default '2012-11-10 04:00:00'; -alter table body add column `depressed` tinyint(4) not null default 0, -alter table spies add column next_task varchar(30) NOT NULL defualt 'Idle'; +alter table body add column `depressed` tinyint(4) NOT NULL default 0; +alter table spies add column `next_task` varchar(30) NOT NULL default 'Idle';