From d145026a46f345b935f03bf2ffce3f313d6df320 Mon Sep 17 00:00:00 2001 From: Mark Lemming Date: Sun, 29 Dec 2013 21:38:56 -0700 Subject: [PATCH] Citadel work and mass_scuttle_ship --- docs/SpacePort.pod | 18 ++++++++ lib/Lacuna/DB/Result/Building.pm | 4 +- .../DB/Result/Ships/ObservatorySeeker.pm | 5 ++- .../DB/Result/Ships/SecurityMinistrySeeker.pm | 5 ++- lib/Lacuna/RPC/Building/SpacePort.pm | 24 ++++++++++- lib/Lacuna/Role/Ship/Arrive/DamageBuilding.pm | 41 ++++++++++++++----- var/messages/citadel_repelled_ship.txt | 7 ++++ var/messages/ship_repelled_by_citadel.txt | 7 ++++ var/www/public/changes.txt | 4 ++ 9 files changed, 101 insertions(+), 14 deletions(-) create mode 100644 var/messages/citadel_repelled_ship.txt create mode 100644 var/messages/ship_repelled_by_citadel.txt diff --git a/docs/SpacePort.pod b/docs/SpacePort.pod index edee7d27..45c5718c 100644 --- a/docs/SpacePort.pod +++ b/docs/SpacePort.pod @@ -842,6 +842,24 @@ The unique id for the space port. The unique id of the ship you want to destroy. + +=head2 mass_scuttle_ship ( session_id, building_id, ship_ids ) + +Destroy a ship that you no longer need. It must be docked to scuttle it. + +=head3 session_id + +A session id. + +=head3 building_id + +The unique id for the space port. + +=head3 ship_ids + +Reference to an array of ship ids + + =head2 view_ships_travelling ( session_id, building_id, [ page_number ]) diff --git a/lib/Lacuna/DB/Result/Building.pm b/lib/Lacuna/DB/Result/Building.pm index 1fcef68c..6acf71d7 100755 --- a/lib/Lacuna/DB/Result/Building.pm +++ b/lib/Lacuna/DB/Result/Building.pm @@ -795,7 +795,9 @@ sub cost_to_upgrade { } my $oversight_reduction = 1; if (defined $self->body->oversight) { - $oversight_reduction = (100 - ($self->body->oversight->level * 3)) / 100; + my $om_level = ($self->body->oversight->level > $self->body->empire->university_level + 1) ? + $self->body->empire->university_level + 1 : $self->body->oversight->level; + $oversight_reduction = (100 - ($om_level * 3)) / 100; } my $time_inflator = ($self->level * 2) - 1; $time_inflator = 1 if ($time_inflator < 1); diff --git a/lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm b/lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm index 96c694f9..f012c113 100644 --- a/lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm +++ b/lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm @@ -15,7 +15,10 @@ use constant base_waste_cost => 40000; use constant base_speed => 1000; use constant base_combat => 2500; use constant base_stealth => 2700; -use constant target_building => ['Lacuna::DB::Result::Building::Observatory']; +use constant target_building => ['Lacuna::DB::Result::Building::Observatory', + 'Lacuna::DB::Result::Building::Permanent::TempleOfTheDrajilites', + 'Lacuna::DB::Result::Building::Permanent::OracleOfAnid', + ]; use constant build_tags => ['War']; with "Lacuna::Role::Ship::Send::NeutralArea"; diff --git a/lib/Lacuna/DB/Result/Ships/SecurityMinistrySeeker.pm b/lib/Lacuna/DB/Result/Ships/SecurityMinistrySeeker.pm index 100b0286..74a56dcf 100644 --- a/lib/Lacuna/DB/Result/Ships/SecurityMinistrySeeker.pm +++ b/lib/Lacuna/DB/Result/Ships/SecurityMinistrySeeker.pm @@ -15,7 +15,10 @@ use constant base_waste_cost => 40000; use constant base_speed => 1000; use constant base_combat => 3500; use constant base_stealth => 2700; -use constant target_building => ['Lacuna::DB::Result::Building::Security','Lacuna::DB::Result::Building::Module::PoliceStation']; +use constant target_building => ['Lacuna::DB::Result::Building::Security', + 'Lacuna::DB::Result::Building::Module::PoliceStation', + 'Lacuna::DB::Result::Building::Permanent::GratchsGauntlet', + ]; use constant build_tags => ['War']; with "Lacuna::Role::Ship::Send::NeutralArea"; diff --git a/lib/Lacuna/RPC/Building/SpacePort.pm b/lib/Lacuna/RPC/Building/SpacePort.pm index 95c4f8d3..f3c6a86c 100644 --- a/lib/Lacuna/RPC/Building/SpacePort.pm +++ b/lib/Lacuna/RPC/Building/SpacePort.pm @@ -1049,6 +1049,28 @@ sub scuttle_ship { }; } +sub mass_scuttle_ship { + my ($self, $session_id, $building_id, $ship_ids) = @_; + my $empire = $self->get_empire_by_session($session_id); + my $building = $self->get_building($empire, $building_id); + + if (scalar @{$ship_ids} > 6000) { + confess [ 1099, "More ships than can be docked on one planet!" ]; + } + my %shash = map { $_ => 1 } grep { !($_ =~ m/\D/) } @{$ship_ids}; + my @ship_ids = sort keys %shash; + Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search( + {id => { in => \@ship_ids }, + task =>'Docked', + body_id => $building->body_id, + } + )->delete; + + return { + status => $self->format_status($empire, $building->body), + }; +} + sub view_battle_logs { my ($self, $session_id, $building_id, $page_number) = @_; my $empire = $self->get_empire_by_session($session_id); @@ -1102,7 +1124,7 @@ around 'view' => sub { return $out; }; -__PACKAGE__->register_rpc_method_names(qw(send_ship_types get_fleet_for view_foreign_ships get_ships_for send_ship send_fleet recall_ship recall_all recall_spies scuttle_ship name_ship prepare_fetch_spies fetch_spies prepare_send_spies send_spies view_ships_orbiting view_ships_travelling view_all_ships view_battle_logs)); +__PACKAGE__->register_rpc_method_names(qw(send_ship_types get_fleet_for view_foreign_ships get_ships_for send_ship send_fleet recall_ship recall_all recall_spies scuttle_ship name_ship prepare_fetch_spies fetch_spies prepare_send_spies send_spies view_ships_orbiting view_ships_travelling view_all_ships view_battle_logs mass_scuttle_ship)); no Moose; __PACKAGE__->meta->make_immutable; diff --git a/lib/Lacuna/Role/Ship/Arrive/DamageBuilding.pm b/lib/Lacuna/Role/Ship/Arrive/DamageBuilding.pm index 78f94ec9..0f8fed71 100644 --- a/lib/Lacuna/Role/Ship/Arrive/DamageBuilding.pm +++ b/lib/Lacuna/Role/Ship/Arrive/DamageBuilding.pm @@ -75,18 +75,38 @@ after handle_arrival_procedures => sub { # let everyone know what's going on unless ($body_attacked->empire->skip_attack_messages) { - $body_attacked->empire->send_predefined_message( - tags => ['Attack','Alert'], - filename => 'ship_hit_building.txt', - params => [$self->type_formatted, $building->name, $body_attacked->id, $body_attacked->name, $self->body->empire_id, $self->body->empire->name], - ); + if (defined $citadel) { + $body_attacked->empire->send_predefined_message( + tags => ['Attack','Alert'], + filename => 'citadel_repelled_ship.txt', + params => [$self->type_formatted, $body_attacked->id, $body_attacked->name], + ); + } + else { + $body_attacked->empire->send_predefined_message( + tags => ['Attack','Alert'], + filename => 'ship_hit_building.txt', + params => [$self->type_formatted, $building->name, $body_attacked->id, + $body_attacked->name, $self->body->empire_id, $self->body->empire->name], + ); + } } unless ($self->body->empire->skip_attack_messages) { - $self->body->empire->send_predefined_message( - tags => ['Attack','Alert'], - filename => 'our_ship_hit_building.txt', - params => [$self->type_formatted, $body_attacked->x, $body_attacked->y, $body_attacked->name, $building->name, $amount], - ); + if (defined $citadel) { + $self->body->empire->send_predefined_message( + tags => ['Attack','Alert'], + filename => 'our_ship_hit_building.txt', + params => [$self->type_formatted, $body_attacked->x, $body_attacked->y, + $body_attacked->name, $building->name, $amount], + ); + } + else { + $self->body->empire->send_predefined_message( + tags => ['Attack','Alert'], + filename => 'ship_repelled_by_citadel.txt', + params => [$self->type_formatted, $body_attacked->x, $body_attacked->y, $body_attacked->name], + ); + } } $body_attacked->add_news(70, sprintf('An attack ship screamed out of the sky and damaged the %s on %s.',$building->name, $body_attacked->name)); @@ -127,6 +147,7 @@ after handle_arrival_procedures => sub { # Repel the ship at quarter speed $self->turn_around(int($self->speed / 4)); $self->update; + $log->insert; confess [-1]; } else { diff --git a/var/messages/citadel_repelled_ship.txt b/var/messages/citadel_repelled_ship.txt new file mode 100644 index 00000000..16ea44e5 --- /dev/null +++ b/var/messages/citadel_repelled_ship.txt @@ -0,0 +1,7 @@ +Citadel Reppeled Ship +~~~ +We just tracked a %s as it broke through the atmosphere on {Planet %s %s}. Our Citadel of Knope repelled it and sent it back from where it came from. + +Regards, + +Your Humble Assistant diff --git a/var/messages/ship_repelled_by_citadel.txt b/var/messages/ship_repelled_by_citadel.txt new file mode 100644 index 00000000..03c73d4e --- /dev/null +++ b/var/messages/ship_repelled_by_citadel.txt @@ -0,0 +1,7 @@ +Ship Repelled by Citadel +~~~ +Our %s reached {Starmap %s %s %s}, but was repelled by their Citadel of Knope. + +Regards, + +Your Humble Assistant diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index f41d8ba4..0df60262 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -3,6 +3,10 @@ - Fix: GG & Terra Platforms ignore University Level. - Fix: Archeology Level is limited by University Level. - Fix: The Dillon Forge is limited by University Level. + - Fix: Oversight Ministry is limited by University Level. + - Fix: Citadels now generate Battle Log reports and better email. + - Mod: Security Ministry Seekers also hit Gratch's Gauntlet. + - Mod: Observatory Seekers also hit Oracle of Anid and Temple of the Drajilites. 3.0897: - Fix: SupplyPods ignore University Level. -- 2.51.2