diff --git a/lib/Lacuna/DB/Result/Propositions/DemolishModule.pm b/lib/Lacuna/DB/Result/Propositions/DemolishModule.pm index 6f0122d4..6da9aa46 100644 --- a/lib/Lacuna/DB/Result/Propositions/DemolishModule.pm +++ b/lib/Lacuna/DB/Result/Propositions/DemolishModule.pm @@ -13,7 +13,7 @@ before pass => sub { $building->demolish; } else { - $self->pass_extra_message('Unfortunately by the time the proposition passed, the module had already been demolished, effectively nullifying the vote.'); + $self->pass_extra_message('Unfortunately, by the time the proposition passed, the module had already been demolished, effectively nullifying the vote.'); } }; diff --git a/lib/Lacuna/DB/Result/Propositions/DowngradeModule.pm b/lib/Lacuna/DB/Result/Propositions/DowngradeModule.pm index 327c89cd..7f468bcc 100644 --- a/lib/Lacuna/DB/Result/Propositions/DowngradeModule.pm +++ b/lib/Lacuna/DB/Result/Propositions/DowngradeModule.pm @@ -13,7 +13,7 @@ before pass => sub { $building->downgrade; } else { - $self->pass_extra_message('Unfortunately by the time the proposition passed, the module had been demolished, effectively nullifying the vote.'); + $self->pass_extra_message('Unfortunately, by the time the proposition passed, the module had been demolished, effectively nullifying the vote.'); } }; diff --git a/lib/Lacuna/DB/Result/Propositions/InstallModule.pm b/lib/Lacuna/DB/Result/Propositions/InstallModule.pm index e97e85e8..c30374ec 100644 --- a/lib/Lacuna/DB/Result/Propositions/InstallModule.pm +++ b/lib/Lacuna/DB/Result/Propositions/InstallModule.pm @@ -13,7 +13,7 @@ before pass => sub { $building->finish_upgrade; } else { - $self->pass_extra_message('Unfortunately by the time the proposition passed, the module had been demolished, effectively nullifying the vote.'); + $self->pass_extra_message('Unfortunately, by the time the proposition passed, the module had been demolished, effectively nullifying the vote.'); } }; diff --git a/lib/Lacuna/DB/Result/Propositions/RenameStation.pm b/lib/Lacuna/DB/Result/Propositions/RenameStation.pm index 4d22d34e..a8cdc2b5 100644 --- a/lib/Lacuna/DB/Result/Propositions/RenameStation.pm +++ b/lib/Lacuna/DB/Result/Propositions/RenameStation.pm @@ -10,7 +10,7 @@ before pass => sub { my $station = $self->station; my $name = $self->scratch->{name}; if (Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({name=>$name, 'id'=>{'!='=>$station->id}})->count) { - $self->pass_extra_message('Unfortunately by the time the proposition passed, the name *'.$name.'* had already taken, effectively nullifying the vote.'); + $self->pass_extra_message('Unfortunately, by the time the proposition passed, the name *'.$name.'* had already taken, effectively nullifying the vote.'); } else { $station->name($name); diff --git a/lib/Lacuna/DB/Result/Propositions/RepairModule.pm b/lib/Lacuna/DB/Result/Propositions/RepairModule.pm new file mode 100644 index 00000000..e4337cfd --- /dev/null +++ b/lib/Lacuna/DB/Result/Propositions/RepairModule.pm @@ -0,0 +1,27 @@ +package Lacuna::DB::Result::Propositions::RepairModule; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Propositions'; + +before pass => sub { + my ($self) = @_; + my $station = $self->station; + my $building = $station->buildings->find($self->scratch->{building_id}); + if (defined $building) { + my $costs = $building->get_repair_costs; + if (eval{$building->can_repair($costs)}) { + $building->repair($costs); + } + else { + $self->pass_extra_message('Unfortunately, by the time the proposition passed, there weren\'t enough resources in storage to repair the module, effectively nullifying the vote.'); + } + } + else { + $self->pass_extra_message('Unfortunately, by the time the proposition passed, the module had been demolished, effectively nullifying the vote.'); + } +}; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/RPC/Building.pm b/lib/Lacuna/RPC/Building.pm index e89e74cf..525daac6 100644 --- a/lib/Lacuna/RPC/Building.pm +++ b/lib/Lacuna/RPC/Building.pm @@ -305,6 +305,21 @@ sub repair { my $building = $self->get_building($empire, $building_id, skip_offline => 1); my $costs = $building->get_repair_costs; $building->can_repair($costs); + my $body = $building->body; + if ($body->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) { + my $name = $building->name.' ('.$building->x.','.$building->y.')'; + my $proposition = Lacuna->db->resultset('Lacuna::DB::Result::Propositions')->new({ + type => 'RepairModule', + name => 'Repair '.$name, + description => 'Repair '.$name.' on the station named "'.$body->name.'".', + scratch => { building_id => $building->id }, + proposed_by_id => $empire->id, + }); + $proposition->station($body); + $proposition->proposed_by($empire); + $proposition->insert; + confess [1017, 'The repair order has been delayed pending a parliamentary vote.']; + } $building->repair($costs); return $self->view($empire, $building); }