diff --git a/docs/SpacePort.pod b/docs/SpacePort.pod index 65aa6bf3..e41e55ad 100644 --- a/docs/SpacePort.pod +++ b/docs/SpacePort.pod @@ -173,6 +173,24 @@ Provides a list of incoming ships and ships that are available to send to a spec }, ... ], + "unavailable" : [ + { + "reason" : [1009, "You can't send a detonator to a star."], + "ship" : { + "id" : "id-goes-here", + "name" : "D13", + "type_human" : "Detonator", + "type" : "detonator", + "task" : "Docked", + "speed" : "700", + "stealth" : "0", + "hold_size" : "0", + "date_started" : "01 31 2010 13:09:05 +0600", + "date_available" : "01 31 2010 13:09:05 +0600" + } + }, + ... + ], "mining_platforms" : [ { empire_id => "id-goes-here", @@ -183,7 +201,7 @@ Provides a list of incoming ships and ships that are available to send to a spec "status" : { ... } } -The C block will be returned only if the target is an asteroid that has platforms on it. +The C block tells you about ships that are docked, but are for some reason not available to be used. The C block will be returned only if the target is an asteroid that has platforms on it. =head3 session_id diff --git a/lib/Lacuna/DB/Result/Ships.pm b/lib/Lacuna/DB/Result/Ships.pm index 9f8b732c..e6d4c25a 100644 --- a/lib/Lacuna/DB/Result/Ships.pm +++ b/lib/Lacuna/DB/Result/Ships.pm @@ -78,7 +78,7 @@ sub is_available { } sub can_send_to_target { - confess [1009, 'Cannot send that type of ship using this method.']; + confess [1009, 'Cannot be used in that manner.']; } sub type_formatted { diff --git a/lib/Lacuna/RPC/Building/SpacePort.pm b/lib/Lacuna/RPC/Building/SpacePort.pm index 94a3bcdc..cdccf248 100644 --- a/lib/Lacuna/RPC/Building/SpacePort.pm +++ b/lib/Lacuna/RPC/Building/SpacePort.pm @@ -68,19 +68,24 @@ sub get_ships_for { push @incoming, $ship->get_status; } + my @unavailable; my @available; my $available_rs = $ships->search({task => 'Docked'}); - while (my $ship = $incoming_rs->next) { + while (my $ship = $available_rs->next) { eval{ $ship->can_send_to_target($target) }; - next if $@; + if ($@) { + push @unavailable, { ship => $ship->get_status, reason => $@ }; + next; + } $ship->body($body); - push @incoming, $ship->get_status; + push @available, $ship->get_status; } my %out = ( status => $self->format_status($empire, $body), incoming => \@incoming, available => \@available, + unavailable => \@unavailable, ); if ($target->isa('Lacuna::DB::Result::Map::Body::Asteroid')) {