From 77eb0a83bbbf45a21d69c17fcf84c094fc411d3a Mon Sep 17 00:00:00 2001 From: lemming552 Date: Sun, 25 Nov 2012 20:15:36 -0700 Subject: [PATCH 01/15] Gas Giants may benefit from imploding planets. --- bin/tick_fissures.pl | 38 ++++++++++++++++++++++++++++++++++++-- lib/Lacuna.pm | 2 +- var/www/public/changes.txt | 4 ++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/bin/tick_fissures.pl b/bin/tick_fissures.pl index 40033edb..52af685e 100644 --- a/bin/tick_fissures.pl +++ b/bin/tick_fissures.pl @@ -124,6 +124,7 @@ for my $body_id (sort keys %has_fissures) { is_working => 0, work_ends => $now, is_upgrading => 0, + date_created => $now, }); } @@ -245,10 +246,43 @@ for my $body_id (sort keys %has_fissures) { alliance_id => undef, }); - # Damage planets in range (damage depends upon distance from the event) - # get 10 closest planets my $minus_x = 0 - $body->x; my $minus_y = 0 - $body->y; + my $gas_giants = Lacuna->db->resultset('Map::Body')->search({ + -and => [ + { class => { like => 'Lacuna::DB::Result::Map::Body::Planet::G%' }}, + ], + },{ + '+select' => [ + { ceil => \"pow(pow(me.x + $minus_x,2) + pow(me.y + $minus_y,2), 0.5)", '-as' => 'distance' }, + ], + '+as' => [ + 'distance', + ], + order_by => 'distance', + }); + my $grown = 0; + GASSY: + while (my $to_grab_mass = $gas_giants->next) { + my $size = $to_grab_mass->size; + next if $size >= 121; + my $new_size = $size + randint(1,5); + $new_size = 121 if $new_size > 121; + $to_grab_mass->size($new_size); + $to_grab_mass->update; + out("Growing ".$to_grab_mass->name." to ".$size."."); + if ($to_grab_mass->empire) { + $to_grab_mass->empire->send_predefined_message( + tags => ['Colonization','Alert'], + filename => 'changed_size.txt', + params => [$to_grab_mass->name, $size, $new_size], + ); + } + last GASSY if (++$grown >= 5); + } + + # Damage planets in range (damage depends upon distance from the event) + # get 10 closest planets my $closest = Lacuna->db->resultset('Map::Body')->search({ -and => [ { empire_id => { '>' => 1 }}, diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 43ecfbd1..56809c01 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0873; +our $VERSION = 3.0874; 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/var/www/public/changes.txt b/var/www/public/changes.txt index 2f966a24..0825a970 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,6 @@ +3.0874: + - Mod: Fissures have an interesting effect on gas giants. + 3.0873: - Mod: Observatory can only abandon a probe it controls. - Add: New Observatory abandon_all_probes API method. @@ -17,6 +20,7 @@ - Add: BHG can be neutralized in certain areas. - Add: Space Stations can emit a field to neutralize BHGs. - Mod: Assembly of glyphs can make up to 5000 at a time. + - Mod: Fissures imploding do not harm colonies in a neutral zone. 3.0872: - Fix: Spies need working infrastructure. -- 2.51.2 From cc26b505880eab1d3ad79b2aed3a45e8764c4cde Mon Sep 17 00:00:00 2001 From: lemming552 Date: Mon, 26 Nov 2012 09:10:00 -0700 Subject: [PATCH 02/15] Slight target selection change. --- bin/tick_fissures.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/tick_fissures.pl b/bin/tick_fissures.pl index 52af685e..601c2552 100644 --- a/bin/tick_fissures.pl +++ b/bin/tick_fissures.pl @@ -301,6 +301,7 @@ for my $body_id (sort keys %has_fissures) { DAMAGED: while (my $to_damage = $closest->next) { next if ($to_damage->in_neutral_area); + next if ($to_damage->type eq "space station"); # Since supply chains etc, will probably be damaged, they'll still be threatened. # damage planet out("Damaging planet ".$to_damage->name." at distance ".$to_damage->get_column('distance')); -- 2.51.2 From 97fe57eaa24302ee5b93c421e49fdbdbd68ab496 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Mon, 26 Nov 2012 12:15:09 -0700 Subject: [PATCH 03/15] Make view_plans from PCC match Trade get_plan_summary. --- lib/Lacuna/RPC/Building/PlanetaryCommand.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Lacuna/RPC/Building/PlanetaryCommand.pm b/lib/Lacuna/RPC/Building/PlanetaryCommand.pm index 6a937e26..d870de8a 100644 --- a/lib/Lacuna/RPC/Building/PlanetaryCommand.pm +++ b/lib/Lacuna/RPC/Building/PlanetaryCommand.pm @@ -36,11 +36,15 @@ sub view_plans { my @out; my $sorted_plans = $building->body->sorted_plans; foreach my $plan (@$sorted_plans) { + my $plan_type = $plan->class; + $plan_type =~ s/Lacuna::DB::Result::Building:://; + $plan_type =~ s/::/_/g; my $item = { - quantity => $plan->quantity, name => $plan->class->name, - level => $plan->level, - extra_build_level => $plan->extra_build_level, + plan_type => $plan_type, + level => int($plan->level), + extra_build_level => int($plan->extra_build_level), + quantity => $plan->quantity, }; push @out, $item; } -- 2.51.2 From 32a65554371dd2b3911161bb01abcb4b24c663ef Mon Sep 17 00:00:00 2001 From: lemming552 Date: Tue, 27 Nov 2012 14:31:12 -0700 Subject: [PATCH 04/15] Fixed type and get_type. --- bin/tick_fissures.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/tick_fissures.pl b/bin/tick_fissures.pl index 601c2552..76679fba 100644 --- a/bin/tick_fissures.pl +++ b/bin/tick_fissures.pl @@ -19,11 +19,13 @@ my $start = time; out('Loading DB'); our $db = Lacuna->db; -out('Ticking fissures'); my %has_fissures = map { $_->body_id => 1 } $db->resultset('Building')->search({ class => 'Lacuna::DB::Result::Building::Permanent::Fissure', })->all; +my $num_body = scalar keys %has_fissures; +out('Ticking '.$num_body.' bodies with fissures'); + for my $body_id (sort keys %has_fissures) { my $body = $db->resultset('Map::Body')->find($body_id); out('Ticking Fissures on '.$body->name); @@ -77,7 +79,7 @@ for my $body_id (sort keys %has_fissures) { # get number of Fissures at 0% efficiency and maximum level my $max_fissures = grep { $_->efficiency == 0 and $_->level >= 30 } @fissures; - if (($max_fissures == @fissures) or (scalar @fissures == 3)) { + if (($max_fissures == @fissures) or (scalar @fissures >= 3)) { if (scalar @fissures == 1) { out(" adding a second fissure!!!"); # Then add a second fissure @@ -301,7 +303,7 @@ for my $body_id (sort keys %has_fissures) { DAMAGED: while (my $to_damage = $closest->next) { next if ($to_damage->in_neutral_area); - next if ($to_damage->type eq "space station"); # Since supply chains etc, will probably be damaged, they'll still be threatened. + next if ($to_damage->get_type eq "space station"); # Since supply chains etc, will probably be damaged, they'll still be threatened. # damage planet out("Damaging planet ".$to_damage->name." at distance ".$to_damage->get_column('distance')); -- 2.51.2 From c54668ee58609094348d0b740b2022db9f604ced Mon Sep 17 00:00:00 2001 From: lemming552 Date: Tue, 27 Nov 2012 19:56:16 -0700 Subject: [PATCH 05/15] No fissures on starters. --- lib/Lacuna/RPC/Building/BlackHoleGenerator.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm index a420941e..e210513f 100644 --- a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm +++ b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm @@ -1118,6 +1118,7 @@ sub bhg_random_fissure { { zone => $body->zone, empire_id => undef, class => { like => 'Lacuna::DB::Result::Map::Body::Planet::P%' }, + usable_as_starter_enabled => 0, }, {rows => 1, order_by => 'rand()' } )->single; -- 2.51.2 From 62b85c9c359fbfbde97a0793eea928e392a9bb69 Mon Sep 17 00:00:00 2001 From: Daniel Crisman Date: Wed, 28 Nov 2012 19:46:07 -0500 Subject: [PATCH 06/15] Make sure x,y for a build/move building are integers --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 8 ++++++-- lib/Lacuna/RPC/Body.pm | 4 ++-- lib/Lacuna/RPC/Building.pm | 5 ++++- t/090_Build.t | 6 ++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index f4c45962..0650019c 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -700,7 +700,9 @@ has embassy => ( ); sub is_space_free { - my ($self, $x, $y) = @_; + my ($self, $unclean_x, $unclean_y) = @_; + my $x = int( $unclean_x ); + my $y = int( $unclean_y ); my $count = grep {$_->x == $x and $_->y == $y} @{$self->building_cache}; return 0 if $count > 0; return 1; @@ -732,7 +734,9 @@ sub find_free_space { } sub check_for_available_build_space { - my ($self, $x, $y) = @_; + my ($self, $unclean_x, $unclean_y) = @_; + my $x = int( $unclean_x ); + my $y = int( $unclean_y ); if ($x > 5 || $x < -5 || $y > 5 || $y < -5) { confess [1009, "That's not a valid space for a building.", [$x, $y]]; } diff --git a/lib/Lacuna/RPC/Body.pm b/lib/Lacuna/RPC/Body.pm index e7cb9dd1..ab6f5037 100644 --- a/lib/Lacuna/RPC/Body.pm +++ b/lib/Lacuna/RPC/Body.pm @@ -123,8 +123,8 @@ sub rearrange_buildings { my @miss_in_new; my @miss_in_cur; for my $building (@$arrangement) { my $id = $building->{id}; - my $x = $building->{x}; - my $y = $building->{y}; + my $x = int( $building->{x} ); + my $y = int( $building->{y} ); $new_ids{$id} = { x => $x, y => $y, diff --git a/lib/Lacuna/RPC/Building.pm b/lib/Lacuna/RPC/Building.pm index 4a501b7f..71f655e1 100644 --- a/lib/Lacuna/RPC/Building.pm +++ b/lib/Lacuna/RPC/Building.pm @@ -137,10 +137,13 @@ sub view { } sub build { - my ($self, $session_id, $body_id, $x, $y) = @_; + my ($self, $session_id, $body_id, $unclean_x, $unclean_y) = @_; my $empire = $self->get_empire_by_session($session_id); my $body = $self->get_body($empire, $body_id); + my $x = int( $unclean_x ); + my $y = int( $unclean_y ); + if ($x eq '' || $y eq '' || $x < -5 || $y < -5 || $x > 5 || $y > 5) { confess [1009, "You must specify an x,y coordinate to place the building that is between -5 and 5.", [$x, $y]]; } diff --git a/t/090_Build.t b/t/090_Build.t index 9c990c3b..d01824e7 100644 --- a/t/090_Build.t +++ b/t/090_Build.t @@ -202,6 +202,12 @@ $water1->finish_upgrade; $water2->finish_upgrade; $water3->finish_upgrade; +# Make sure non-integer coordinates don't work +$result = $tester->post('waterpurification', 'build', [$session_id, $home_planet, '3.1', -3]); +ok(exists $result->{error}, 'non-integer string attack thwarted!'); +$result = $tester->post('waterpurification', 'build', [$session_id, $home_planet, 3.2, -3]); +ok(exists $result->{error}, 'non-integer number attack thwarted!'); + $home->add_plan('Lacuna::DB::Result::Building::SpacePort',1,4); $home->add_plan('Lacuna::DB::Result::Building::SpacePort',1); $home->add_plan('Lacuna::DB::Result::Building::SpacePort',1,3); -- 2.51.2 From f428505526d92af48050d71f7eaad73ab09930e7 Mon Sep 17 00:00:00 2001 From: fireartist Date: Thu, 29 Nov 2012 20:49:48 +0000 Subject: [PATCH 07/15] don't pass DateTime object to DBIC->search() - use storage formatter --- lib/Lacuna/DB/Result/Building/Module/PoliceStation.pm | 6 +++++- lib/Lacuna/DB/Result/Building/Security.pm | 6 +++++- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 10 ++++++---- lib/Lacuna/RPC/Building/SpacePort.pm | 5 ++++- lib/Lacuna/Role/TraderRpc.pm | 5 ++++- lib/Lacuna/Web/ApiKey.pm | 3 ++- lib/Lacuna/Web/MissionCurator.pm | 4 +++- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Module/PoliceStation.pm b/lib/Lacuna/DB/Result/Building/Module/PoliceStation.pm index efb65bfa..b3485b6f 100644 --- a/lib/Lacuna/DB/Result/Building/Module/PoliceStation.pm +++ b/lib/Lacuna/DB/Result/Building/Module/PoliceStation.pm @@ -26,6 +26,10 @@ sub foreign_spies { sub prisoners { my $self = shift; + + my $dt_parser = Lacuna->db->storage->datetime_parser; + my $now = $dt_parser->format_datetime( DateTime->now ); + return Lacuna ->db ->resultset('Lacuna::DB::Result::Spies') @@ -33,7 +37,7 @@ sub prisoners { { on_body_id => $self->body_id, task => { 'in' => [ 'Captured', 'Prisoner Transport' ] }, - available_on=> { '>' => DateTime->now }, + available_on=> { '>' => $now }, } ); } diff --git a/lib/Lacuna/DB/Result/Building/Security.pm b/lib/Lacuna/DB/Result/Building/Security.pm index 34c7d34f..467f43ea 100644 --- a/lib/Lacuna/DB/Result/Building/Security.pm +++ b/lib/Lacuna/DB/Result/Building/Security.pm @@ -57,6 +57,10 @@ sub foreign_spies { sub prisoners { my $self = shift; + + my $dt_parser = Lacuna->db->storage->datetime_parser; + my $now = $dt_parser->format_datetime( DateTime->now ); + return Lacuna ->db ->resultset('Lacuna::DB::Result::Spies') @@ -64,7 +68,7 @@ sub prisoners { { on_body_id => $self->body_id, task => { 'in' => [ 'Captured', 'Prisoner Transport' ] }, - available_on=> { '>' => DateTime->now }, + available_on=> { '>' => $now }, } ); } diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 0650019c..76b9f371 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -374,16 +374,17 @@ around get_status => sub { $out->{skip_incoming_ships} = $empire->skip_incoming_ships; if (1) { # if (not $empire->skip_incoming_ships) { - my $now = time; - my $foreign_bodies; # Process all ships that have already arrived + my $dt_parser = Lacuna->db->storage->datetime_parser; + my $now = $dt_parser->format_datetime( DateTime->now ); + my $incoming_rs = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({ foreign_body_id => $self->id, direction => 'out', task => 'Travelling', - date_available => {'<' => DateTime->now.''}, + date_available => {'<' => $now}, }); while (my $ship = $incoming_rs->next) { $foreign_bodies->{$ship->body_id} = 1; @@ -1313,6 +1314,7 @@ sub tick { my $now = DateTime->now; my $now_epoch = $now->epoch; + my $dt_parser = Lacuna->db->storage->datetime_parser; my %todo; my $i; # in case 2 things finish at exactly the same time @@ -1341,7 +1343,7 @@ sub tick { # get ship tasks my $ships = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({ body_id => $self->id, - date_available => { '<=' => $now }, + date_available => { '<=' => $dt_parser->format_datetime($now) }, task => { '!=' => 'Docked' }, }); while (my $ship = $ships->next ) { diff --git a/lib/Lacuna/RPC/Building/SpacePort.pm b/lib/Lacuna/RPC/Building/SpacePort.pm index 5a74d3dd..7967bd1e 100644 --- a/lib/Lacuna/RPC/Building/SpacePort.pm +++ b/lib/Lacuna/RPC/Building/SpacePort.pm @@ -609,6 +609,9 @@ sub prepare_fetch_spies { while (my $ship = $ships->next) { push @ships, $ship->get_status($on_body); } + + my $dt_parser = Lacuna->db->storage->datetime_parser; + my $now = $dt_parser->format_datetime( DateTime->now ); my $spies = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search( { @@ -618,7 +621,7 @@ sub prepare_fetch_spies { task => { in => [ 'Idle', 'Counter Espionage' ], }, -and => [ task => { in => [ 'Unconscious', 'Debriefing' ], }, - available_on => { '<' => '\NOW()' }, + available_on => { '<' => $now }, ], ], }, diff --git a/lib/Lacuna/Role/TraderRpc.pm b/lib/Lacuna/Role/TraderRpc.pm index 7d182fd2..337944ab 100644 --- a/lib/Lacuna/Role/TraderRpc.pm +++ b/lib/Lacuna/Role/TraderRpc.pm @@ -152,8 +152,11 @@ sub get_prisoners { my ($self, $session_id, $building_id) = @_; my $empire = $self->get_empire_by_session($session_id); my $building = $self->get_building($empire, $building_id); + my $dt_parser = Lacuna->db->storage->datetime_parser; + my $now = $dt_parser->format_datetime( DateTime->now ); + my $prisoners = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search( - { on_body_id => $building->body_id, task => 'Captured', available_on => { '>' => DateTime->now } }, + { on_body_id => $building->body_id, task => 'Captured', available_on => { '>' => $now } }, {order_by => [ 'name' ]} ); my @out; diff --git a/lib/Lacuna/Web/ApiKey.pm b/lib/Lacuna/Web/ApiKey.pm index 3d152193..88e496e3 100644 --- a/lib/Lacuna/Web/ApiKey.pm +++ b/lib/Lacuna/Web/ApiKey.pm @@ -18,7 +18,8 @@ sub www_view_stats { my $row = sub { return ''.$_[0].''.$_[1].''.$_[2].''; }; - my $thirty_days_ago = DateTime->now->subtract(days=>30); + my $dt_parser = Lacuna->db->storage->datetime_parser; + my $thirty_days_ago = $dt_parser->format_datetime( DateTime->now->subtract(days=>30) ); my $out = "

Stats for $name

"; my $login = Lacuna->db->resultset('Lacuna::DB::Result::Log::Login')->search({api_key => $pair->public_key}); $out .= $row->('Empires Using', diff --git a/lib/Lacuna/Web/MissionCurator.pm b/lib/Lacuna/Web/MissionCurator.pm index b3ece5a4..ef21b8f1 100644 --- a/lib/Lacuna/Web/MissionCurator.pm +++ b/lib/Lacuna/Web/MissionCurator.pm @@ -34,7 +34,9 @@ sub www_add_essentia { body => 'I have approved a mission pack for '.$empire->name.'.', tags => ['Mission','Correspondence'], ); - my $recent = Lacuna->db->resultset('Lacuna::DB::Result::Log::Essentia')->search({ empire_id => $curator->id, description => 'Mission Curator', date_stamp => { '>' => DateTime->now->subtract(days => 7)}})->count; + my $dt_parser = Lacuna->db->storage->datetime_parser; + my $seven_days_ago = $dt_parser->format_datetime( DateTime->now->subtract(days => 7) ); + my $recent = Lacuna->db->resultset('Lacuna::DB::Result::Log::Essentia')->search({ empire_id => $curator->id, description => 'Mission Curator', date_stamp => { '>' => $seven_days_ago}})->count; $curator->add_essentia(100, 'Mission Curator')->update unless $recent; return $self->www_default($request, 'Essentia Added'); } -- 2.51.2 From 77f2cb2e468c22f13f11a66ccd69d39cac72c1cc Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 17:04:01 -0700 Subject: [PATCH 08/15] Adding fissure healing ship. --- lib/Lacuna/Constants.pm | 2 +- lib/Lacuna/DB/Result/Medals.pm | 1 + lib/Lacuna/DB/Result/Ships.pm | 1 + lib/Lacuna/DB/Result/Ships/Fissurehealer.pm | 28 +++++++++++ lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 55 +++++++++++++++++++++ var/messages/our_ship_hit_fissure.txt | 7 +++ var/www/public/resources.json | 1 + 7 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 lib/Lacuna/DB/Result/Ships/Fissurehealer.pm create mode 100644 lib/Lacuna/Role/Ship/Arrive/SealFissure.pm create mode 100644 var/messages/our_ship_hit_fissure.txt diff --git a/lib/Lacuna/Constants.pm b/lib/Lacuna/Constants.pm index 669fca12..5694a988 100644 --- a/lib/Lacuna/Constants.pm +++ b/lib/Lacuna/Constants.pm @@ -114,7 +114,7 @@ use constant SHIP_TYPES => (qw( probe short_range_colony_ship colony_ship spy_po supply_pod supply_pod2 supply_pod3 supply_pod4 drone fighter spy_shuttle observatory_seeker security_ministry_seeker spaceport_seeker excavator detonator scanner barge hulk hulk_fast hulk_huge galleon stake - placebo placebo2 placebo3 placebo4 placebo5 placebo6 bleeder sweeper + placebo placebo2 placebo3 placebo4 placebo5 placebo6 bleeder sweeper fissure_healer )); use constant SHIP_TRADE_TYPES => (qw( cargo_ship smuggler_ship freighter dory barge galleon hulk hulk_huge hulk_fast diff --git a/lib/Lacuna/DB/Result/Medals.pm b/lib/Lacuna/DB/Result/Medals.pm index 3256d596..be46f7a1 100644 --- a/lib/Lacuna/DB/Result/Medals.pm +++ b/lib/Lacuna/DB/Result/Medals.pm @@ -67,6 +67,7 @@ use constant MEDALS => { spy_shuttle => 'Built Spy Shuttle', observatory_seeker => 'Built Observatory Seeker', security_ministry_seeker => 'Built Security Ministry Seeker', + fissure_healer => 'Built Fissure Healer', spaceport_seeker => 'Built SpacePort Seeker', excavator => 'Built Excavator', detonator => 'Built Detonator', diff --git a/lib/Lacuna/DB/Result/Ships.pm b/lib/Lacuna/DB/Result/Ships.pm index 1c4653f8..6e2445f4 100644 --- a/lib/Lacuna/DB/Result/Ships.pm +++ b/lib/Lacuna/DB/Result/Ships.pm @@ -89,6 +89,7 @@ __PACKAGE__->typecast_map(type => { 'observatory_seeker' => 'Lacuna::DB::Result::Ships::ObservatorySeeker', 'spaceport_seeker' => 'Lacuna::DB::Result::Ships::SpacePortSeeker', 'security_ministry_seeker' => 'Lacuna::DB::Result::Ships::SecurityMinistrySeeker', + 'fissure_healer' => 'Lacuna::DB::Result::Ships::FissureHealer', }); with 'Lacuna::Role::Container'; diff --git a/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm b/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm new file mode 100644 index 00000000..216c6e9f --- /dev/null +++ b/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm @@ -0,0 +1,28 @@ +package Lacuna::DB::Result::Ships::ColonyShip; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Ships'; + +use constant prereq => [ { class=> 'Lacuna::DB::Result::Building::Observatory', level => 15 } ]; +use constant base_food_cost => 15_000; +use constant base_water_cost => 30_000; +use constant base_energy_cost => 90_000; +use constant base_ore_cost => 500_000; +use constant base_time_cost => 60 * 60 * 24 * 2; +use constant base_waste_cost => 50_000; +use constant base_combat => 0; +use constant base_speed => 250; +use constant base_stealth => 0; +use constant base_hold_size => 0; +use constant pilotable => 0; +use constant build_tags => ['Exploration']; + +with "Lacuna::Role::Ship::Send::Planet"; +with "Lacuna::Role::Ship::Send::Uninhabited"; +with "Lacuna::Role::Ship::Send::IsHostile"; +with "Lacuna::Role::Ship::Arrive::SealFissure"; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm new file mode 100644 index 00000000..e6a1b90a --- /dev/null +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -0,0 +1,55 @@ +package Lacuna::Role::Ship::Arrive::DamageBuilding; + +use strict; +use Moose::Role; +use Lacuna::Util qw(randint); +use DateTime; + +after handle_arrival_procedures => sub { + my ($self) = @_; + + # we're coming home + return if ($self->direction eq 'in'); + + # Turn around if occupied + return if ($self->foreign_body->empire_id); + + # determine target building + my $building; + my $body_hit = $self->foreign_body; + my ($fissure) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::Fissure'} @{$body_hit->building_cache}; + return if not defined $fissure; + + $body_hit->add_news(70, sprintf('An attempt to fix the fissure on %s happened today.', $body_hit->name)); + + # handle fissure + if (defined $fissure) { + my $curr_eff = $fissure->efficiency + randint(1,7); + $curr_eff = 100 if $curr_eff > 100; + $curr_lev = $fissure->level; + + if ( int(5.5 + $curr_eff/10) > randint(0,99) ) { + $curr_lev--; + } + if ($curr_lev < 1) { + $fissure->delete; + } + else { + $fissure->level($curr_lev); + $fissure->efficiency($curr_eff); + $fissure->update; + } + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'our_ship_hit_fissure.txt', + params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name, $curr_lev, $curr_eff ], + ); + $self->delete; + $body_hit->needs_surface_refresh(1); + $body_hit->update; + } + + confess [-1]; +}; + +1; diff --git a/var/messages/our_ship_hit_fissure.txt b/var/messages/our_ship_hit_fissure.txt new file mode 100644 index 00000000..8e9a6a6e --- /dev/null +++ b/var/messages/our_ship_hit_fissure.txt @@ -0,0 +1,7 @@ +Fissure Hit +~~~ +Our %s reached {Starmap %s %s %s} and left the fissure at level %s and %s%% efficiency. + +Regards, + +Your Humble Assistant diff --git a/var/www/public/resources.json b/var/www/public/resources.json index 54761f2e..05c1d6a5 100644 --- a/var/www/public/resources.json +++ b/var/www/public/resources.json @@ -192,6 +192,7 @@ "hulk" : { "description" : "Extra large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, "hulk_fast" : { "description" : "Extra large transport ship slightly bigger and much faster than a Hulk. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, "hulk_huge" : { "description" : "Incredibly large and very slow transport ship, useful for supply chains. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, + "fissure_healer" : { "description" : "Large slow ship, used to attempt sealing fissures on uninhabited planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/fissure-healer" }, "freighter" : { "description" : "Large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/freighter" }, "snark" : { "description" : "Robotic bombardment weapon, that can be used to destroy buildings on remote planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/snark" }, "snark2" : { "description" : "An improved version of the Snark, which has a splash damage radius of 1.", "wiki" : "http://community.lacunaexpanse.com/wiki/snark" }, -- 2.51.2 From f9832cb2700fc82d01c2f64ab8f763f46e4f578d Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 17:29:10 -0700 Subject: [PATCH 09/15] Couple needed fixes. --- lib/Lacuna/DB/Result/Ships/Fissurehealer.pm | 2 +- lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm b/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm index 216c6e9f..b1a755ab 100644 --- a/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm +++ b/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm @@ -1,4 +1,4 @@ -package Lacuna::DB::Result::Ships::ColonyShip; +package Lacuna::DB::Result::Ships::FissureHealer; use Moose; use utf8; diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index e6a1b90a..40598b41 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -1,4 +1,4 @@ -package Lacuna::Role::Ship::Arrive::DamageBuilding; +package Lacuna::Role::Ship::Arrive::SealFissure; use strict; use Moose::Role; -- 2.51.2 From 109d95cd6fe8dff85a09bfc8f39636a789f6d068 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 18:06:01 -0700 Subject: [PATCH 10/15] fix fix fix --- .../DB/Result/Ships/{Fissurehealer.pm => FissureHealer.pm} | 0 lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/Lacuna/DB/Result/Ships/{Fissurehealer.pm => FissureHealer.pm} (100%) diff --git a/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm b/lib/Lacuna/DB/Result/Ships/FissureHealer.pm similarity index 100% rename from lib/Lacuna/DB/Result/Ships/Fissurehealer.pm rename to lib/Lacuna/DB/Result/Ships/FissureHealer.pm diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 40598b41..847cb7fd 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -26,7 +26,7 @@ after handle_arrival_procedures => sub { if (defined $fissure) { my $curr_eff = $fissure->efficiency + randint(1,7); $curr_eff = 100 if $curr_eff > 100; - $curr_lev = $fissure->level; + my $curr_lev = $fissure->level; if ( int(5.5 + $curr_eff/10) > randint(0,99) ) { $curr_lev--; -- 2.51.2 From 59676b64546904932a9a913b84daab1d6c9badb3 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 20:17:39 -0700 Subject: [PATCH 11/15] Refinements. --- lib/Lacuna/DB/Result/Ships/FissureHealer.pm | 1 - lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 22 ++++++++++++++------- var/messages/we_destroyed_a_fissure.txt | 7 +++++++ var/www/public/changes.txt | 1 + 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 var/messages/we_destroyed_a_fissure.txt diff --git a/lib/Lacuna/DB/Result/Ships/FissureHealer.pm b/lib/Lacuna/DB/Result/Ships/FissureHealer.pm index b1a755ab..f380e2de 100644 --- a/lib/Lacuna/DB/Result/Ships/FissureHealer.pm +++ b/lib/Lacuna/DB/Result/Ships/FissureHealer.pm @@ -21,7 +21,6 @@ use constant build_tags => ['Exploration']; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Uninhabited"; -with "Lacuna::Role::Ship::Send::IsHostile"; with "Lacuna::Role::Ship::Arrive::SealFissure"; no Moose; diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 847cb7fd..7e81dd39 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -24,26 +24,34 @@ after handle_arrival_procedures => sub { # handle fissure if (defined $fissure) { - my $curr_eff = $fissure->efficiency + randint(1,7); + my $curr_eff = $fissure->efficiency + randint(1,5); $curr_eff = 100 if $curr_eff > 100; my $curr_lev = $fissure->level; - if ( int(5.5 + $curr_eff/10) > randint(0,99) ) { + my $down_chance = $curr_eff; + $down_chance = 5 if ($down_chance < 5); + $down_chance = 95 if ($down_chance > 95); + + if ( $down_chance > randint(0,99) ) { $curr_lev--; } if ($curr_lev < 1) { $fissure->delete; + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'we_destroyed_a_fissure.txt', + params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name ], } else { $fissure->level($curr_lev); $fissure->efficiency($curr_eff); $fissure->update; + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'our_ship_hit_fissure.txt', + params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name, $curr_lev, $curr_eff ], + ); } - $self->body->empire->send_predefined_message( - tags => ['Alert'], - filename => 'our_ship_hit_fissure.txt', - params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name, $curr_lev, $curr_eff ], - ); $self->delete; $body_hit->needs_surface_refresh(1); $body_hit->update; diff --git a/var/messages/we_destroyed_a_fissure.txt b/var/messages/we_destroyed_a_fissure.txt new file mode 100644 index 00000000..7af588b5 --- /dev/null +++ b/var/messages/we_destroyed_a_fissure.txt @@ -0,0 +1,7 @@ +Fissure Destroyed +~~~ +Our %s reached {Starmap %s %s %s} and destroyed a fissure. + +Regards, + +Your Humble Assistant diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 0825a970..ae06d609 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 3.0874: - Mod: Fissures have an interesting effect on gas giants. + - Add: Fissure Healer Ship added. 3.0873: - Mod: Observatory can only abandon a probe it controls. -- 2.51.2 From 163f86546ae26646b3a0dbb0c4152b45c8b35707 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 22:48:00 -0700 Subject: [PATCH 12/15] Using ore amount for sealing. --- lib/Lacuna/Constants.pm | 2 +- lib/Lacuna/DB/Result/Medals.pm | 2 +- lib/Lacuna/DB/Result/Ships.pm | 2 +- .../{FissureHealer.pm => FissureSealer.pm} | 4 +- lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 41 ++++++++++++++++++- var/www/public/resources.json | 2 +- 6 files changed, 46 insertions(+), 7 deletions(-) rename lib/Lacuna/DB/Result/Ships/{FissureHealer.pm => FissureSealer.pm} (90%) diff --git a/lib/Lacuna/Constants.pm b/lib/Lacuna/Constants.pm index 5694a988..e7749f4f 100644 --- a/lib/Lacuna/Constants.pm +++ b/lib/Lacuna/Constants.pm @@ -114,7 +114,7 @@ use constant SHIP_TYPES => (qw( probe short_range_colony_ship colony_ship spy_po supply_pod supply_pod2 supply_pod3 supply_pod4 drone fighter spy_shuttle observatory_seeker security_ministry_seeker spaceport_seeker excavator detonator scanner barge hulk hulk_fast hulk_huge galleon stake - placebo placebo2 placebo3 placebo4 placebo5 placebo6 bleeder sweeper fissure_healer + placebo placebo2 placebo3 placebo4 placebo5 placebo6 bleeder sweeper fissure_sealer )); use constant SHIP_TRADE_TYPES => (qw( cargo_ship smuggler_ship freighter dory barge galleon hulk hulk_huge hulk_fast diff --git a/lib/Lacuna/DB/Result/Medals.pm b/lib/Lacuna/DB/Result/Medals.pm index be46f7a1..5c079228 100644 --- a/lib/Lacuna/DB/Result/Medals.pm +++ b/lib/Lacuna/DB/Result/Medals.pm @@ -67,7 +67,7 @@ use constant MEDALS => { spy_shuttle => 'Built Spy Shuttle', observatory_seeker => 'Built Observatory Seeker', security_ministry_seeker => 'Built Security Ministry Seeker', - fissure_healer => 'Built Fissure Healer', + fissure_sealer => 'Built Fissure Sealer', spaceport_seeker => 'Built SpacePort Seeker', excavator => 'Built Excavator', detonator => 'Built Detonator', diff --git a/lib/Lacuna/DB/Result/Ships.pm b/lib/Lacuna/DB/Result/Ships.pm index 6e2445f4..ec985c55 100644 --- a/lib/Lacuna/DB/Result/Ships.pm +++ b/lib/Lacuna/DB/Result/Ships.pm @@ -89,7 +89,7 @@ __PACKAGE__->typecast_map(type => { 'observatory_seeker' => 'Lacuna::DB::Result::Ships::ObservatorySeeker', 'spaceport_seeker' => 'Lacuna::DB::Result::Ships::SpacePortSeeker', 'security_ministry_seeker' => 'Lacuna::DB::Result::Ships::SecurityMinistrySeeker', - 'fissure_healer' => 'Lacuna::DB::Result::Ships::FissureHealer', + 'fissure_sealer' => 'Lacuna::DB::Result::Ships::FissureSealer', }); with 'Lacuna::Role::Container'; diff --git a/lib/Lacuna/DB/Result/Ships/FissureHealer.pm b/lib/Lacuna/DB/Result/Ships/FissureSealer.pm similarity index 90% rename from lib/Lacuna/DB/Result/Ships/FissureHealer.pm rename to lib/Lacuna/DB/Result/Ships/FissureSealer.pm index f380e2de..cb8f1f08 100644 --- a/lib/Lacuna/DB/Result/Ships/FissureHealer.pm +++ b/lib/Lacuna/DB/Result/Ships/FissureSealer.pm @@ -9,13 +9,13 @@ use constant prereq => [ { class=> 'Lacuna::DB::Result::Building use constant base_food_cost => 15_000; use constant base_water_cost => 30_000; use constant base_energy_cost => 90_000; -use constant base_ore_cost => 500_000; +use constant base_ore_cost => 100_000; use constant base_time_cost => 60 * 60 * 24 * 2; use constant base_waste_cost => 50_000; use constant base_combat => 0; use constant base_speed => 250; use constant base_stealth => 0; -use constant base_hold_size => 0; +use constant base_hold_size => 50_000; use constant pilotable => 0; use constant build_tags => ['Exploration']; diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 7e81dd39..d780ca0b 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -4,6 +4,7 @@ use strict; use Moose::Role; use Lacuna::Util qw(randint); use DateTime; +use Lacuna::Constants qw(FOOD_TYPES ORE_TYPES); after handle_arrival_procedures => sub { my ($self) = @_; @@ -14,6 +15,13 @@ after handle_arrival_procedures => sub { # Turn around if occupied return if ($self->foreign_body->empire_id); + my $amount = 0; + my $payload = $self->payload; + foreach my $type (ORE_TYPES) { + if (defined($payload->{resources}{$type})) { + $amount += $payload->{resources}{$type}; + } + } # determine target building my $building; my $body_hit = $self->foreign_body; @@ -24,7 +32,7 @@ after handle_arrival_procedures => sub { # handle fissure if (defined $fissure) { - my $curr_eff = $fissure->efficiency + randint(1,5); + my $curr_eff = $fissure->efficiency + randint(1,5) + int($amount/1_000_000); $curr_eff = 100 if $curr_eff > 100; my $curr_lev = $fissure->level; @@ -34,6 +42,7 @@ after handle_arrival_procedures => sub { if ( $down_chance > randint(0,99) ) { $curr_lev--; + $curr_eff = 10; } if ($curr_lev < 1) { $fissure->delete; @@ -41,6 +50,7 @@ after handle_arrival_procedures => sub { tags => ['Alert'], filename => 'we_destroyed_a_fissure.txt', params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name ], + ); } else { $fissure->level($curr_lev); @@ -60,4 +70,33 @@ after handle_arrival_procedures => sub { confess [-1]; }; +after send => sub { + my $self = shift; + my $part = $self->hold_size; + my $ore = $part; + my $body = $self->body; + my $payload; + my $ore_stored = 0; + my $ore_type_count = 0; + for my $type (ORE_TYPES) { + my $stored = $body->type_stored($type); + $ore_stored += $stored; + $ore_type_count++ if ($stored); + } + $ore = $ore_stored if ($ore > $ore_stored); + foreach my $type (ORE_TYPES) { + my $stored = $body->type_stored($type); + if ($stored) { + my $amt = int(($ore * $stored)/$ore_stored) - 100; + if ( $amt > 0 ) { + $body->spend_type($type, $amt); + $payload->{resources}{$type} = $amt; + } + } + } + $self->payload($payload); + $self->update; + $body->update; +}; + 1; diff --git a/var/www/public/resources.json b/var/www/public/resources.json index 05c1d6a5..60b9491f 100644 --- a/var/www/public/resources.json +++ b/var/www/public/resources.json @@ -192,7 +192,7 @@ "hulk" : { "description" : "Extra large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, "hulk_fast" : { "description" : "Extra large transport ship slightly bigger and much faster than a Hulk. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, "hulk_huge" : { "description" : "Incredibly large and very slow transport ship, useful for supply chains. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, - "fissure_healer" : { "description" : "Large slow ship, used to attempt sealing fissures on uninhabited planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/fissure-healer" }, + "fissure_sealer" : { "description" : "Large slow ship, used to attempt sealing fissures on uninhabited planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/fissure-sealer" }, "freighter" : { "description" : "Large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/freighter" }, "snark" : { "description" : "Robotic bombardment weapon, that can be used to destroy buildings on remote planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/snark" }, "snark2" : { "description" : "An improved version of the Snark, which has a splash damage radius of 1.", "wiki" : "http://community.lacunaexpanse.com/wiki/snark" }, -- 2.51.2 From a809b3a7bc53482e7d3c4ec0a15e9a26cae81841 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 23:21:25 -0700 Subject: [PATCH 13/15] Fix and seal. --- lib/Lacuna/DB/Result/Ships/FissureSealer.pm | 4 ++-- lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Lacuna/DB/Result/Ships/FissureSealer.pm b/lib/Lacuna/DB/Result/Ships/FissureSealer.pm index cb8f1f08..28abe2d8 100644 --- a/lib/Lacuna/DB/Result/Ships/FissureSealer.pm +++ b/lib/Lacuna/DB/Result/Ships/FissureSealer.pm @@ -1,4 +1,4 @@ -package Lacuna::DB::Result::Ships::FissureHealer; +package Lacuna::DB::Result::Ships::FissureSealer; use Moose; use utf8; @@ -15,7 +15,7 @@ use constant base_waste_cost => 50_000; use constant base_combat => 0; use constant base_speed => 250; use constant base_stealth => 0; -use constant base_hold_size => 50_000; +use constant base_hold_size => 100_000; use constant pilotable => 0; use constant build_tags => ['Exploration']; diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index d780ca0b..7a8f8ffb 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -32,7 +32,7 @@ after handle_arrival_procedures => sub { # handle fissure if (defined $fissure) { - my $curr_eff = $fissure->efficiency + randint(1,5) + int($amount/1_000_000); + my $curr_eff = $fissure->efficiency + int($amount/1_000_000) + 1; $curr_eff = 100 if $curr_eff > 100; my $curr_lev = $fissure->level; -- 2.51.2 From a0a3a90de2613164940f78d53517e8266dd29647 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Fri, 30 Nov 2012 13:12:46 -0700 Subject: [PATCH 14/15] Message to send added. --- bin/util/fissure_sealer_message.pl | 76 ++++++++++++++++++++++ lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 4 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 bin/util/fissure_sealer_message.pl diff --git a/bin/util/fissure_sealer_message.pl b/bin/util/fissure_sealer_message.pl new file mode 100644 index 00000000..ccb0c634 --- /dev/null +++ b/bin/util/fissure_sealer_message.pl @@ -0,0 +1,76 @@ +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; +our $all; +GetOptions( + 'quiet' => \$quiet, + 'all' => \$all, +); + + +out('Started'); +my $start = time; + +out('Loading DB'); +our $db = Lacuna->db; +my $empires = $db->resultset('Lacuna::DB::Result::Empire'); + +my $lec = $empires->find(1); + +if (not $all) { + $empires = $empires->search({ is_admin => 1 }); +} + +$empires = $empires->search({ id => {'>' => 1}}); + +my $message = q{Despite our warnings about using Black Hole Generators and how they can cause unstable conditions on planets, your scientists have found more uses for them. Our instruments have noticed more fissures forming recently on unoccupied worlds. + +Since we can't seem to get most of you to stop using the Black Hole Generators, our scientists have come up with a way to seal these fissures though it only works on uninhabited planets. + +These Fissure Sealers do need to be sent with a quantity of ore, but still have a chance to help seal a fissure even if empty. In most cases, it will take multiple applications to fully seal a fissure. + +We have noticed that some of your scientists have come up with a method to neutralize Black Hole Generators by putting out a field from your Space Stations. We are glad that some of you have listened to us. + +Your Trading Partner, + +Tou Re Ell + +Lacuna Expanse Corp}; + +out('Sending Messages'); +while (my $empire = $empires->next) { + my $home = $empire->home_planet; + next unless defined $home; + out('Sending message to '.$empire->name); + $empire->send_message( + tag => 'Correspondence', + subject => 'A new device', + from => $lec, + body => $message, + ); + +} + +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/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 7a8f8ffb..e5eeaaa0 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -10,7 +10,9 @@ after handle_arrival_procedures => sub { my ($self) = @_; # we're coming home - return if ($self->direction eq 'in'); + if ($self->direction eq 'in') { + $self->unload($self->body); + } # Turn around if occupied return if ($self->foreign_body->empire_id); -- 2.51.2 From 21e339fe0f10c9c7162e031ef05c3a577bb52808 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Fri, 30 Nov 2012 15:42:11 -0700 Subject: [PATCH 15/15] n19 and asteroid mining medal fix. --- lib/Lacuna/DB/Result/Building/Network19.pm | 5 +++++ lib/Lacuna/DB/Result/Medals.pm | 4 ++++ var/www/public/changes.txt | 2 ++ 3 files changed, 11 insertions(+) diff --git a/lib/Lacuna/DB/Result/Building/Network19.pm b/lib/Lacuna/DB/Result/Building/Network19.pm index 5fcfbb61..f14accef 100644 --- a/lib/Lacuna/DB/Result/Building/Network19.pm +++ b/lib/Lacuna/DB/Result/Building/Network19.pm @@ -49,5 +49,10 @@ sub happiness_consumption { return ($self->body->restrict_coverage) ? 30 : 0; } +before delete => sub { + my ($self) = @_; + $self->body->restrict_coverage(0); +}; + no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Medals.pm b/lib/Lacuna/DB/Result/Medals.pm index 5c079228..84c3c055 100644 --- a/lib/Lacuna/DB/Result/Medals.pm +++ b/lib/Lacuna/DB/Result/Medals.pm @@ -180,6 +180,10 @@ use constant MEDALS => { A19 => 'Mined A19 Type Asteroid', A20 => 'Mined A20 Type Asteroid', A21 => 'Mined Debris Field', + A22 => 'Mined A22 Type Asteroid', + A23 => 'Mined A23 Type Asteroid', + A24 => 'Mined A24 Type Asteroid', + A25 => 'Mined A25 Type Asteroid', building1 => 'Built Level 1 Building', building2 => 'Built Level 2 Building', building3 => 'Built Level 3 Building', diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index ae06d609..27252e31 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,6 +1,8 @@ 3.0874: - Mod: Fissures have an interesting effect on gas giants. - Add: Fissure Healer Ship added. + - Fix: N19 coverage restriction turned off if N19 demolished on body. + - Fix: Corrected emails for deploying mining platforms A22-A25. 3.0873: - Mod: Observatory can only abandon a probe it controls. -- 2.51.2
StatisticPast 30 DaysAll Time