Skip to content

Commit

Permalink
Comma-fy the scow waste.
Browse files Browse the repository at this point in the history
Found out that when a ship is sent to itself, the after method modifier
for send doesn't trigger - beanstalk processes it too fast.  Introduce a
minimum 1-second timer for sending ships, that way the after method modifier
can trigger, setting the payload, before the beanstalk process picks it up.
  • Loading branch information
dmcbride authored and icydee committed Jul 4, 2014
1 parent 2a7c37c commit a364c0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/Lacuna/DB/Result/Ships.pm
Expand Up @@ -546,6 +546,7 @@ sub travel_time {
$speed ||= 1;
my $hours = $distance / $speed;
my $seconds = 60 * 60 * $hours;
$seconds = 1 if $seconds < 1;
return sprintf('%.0f', $seconds);
}

Expand Down
6 changes: 4 additions & 2 deletions lib/Lacuna/Role/Ship/Arrive/DumpWaste.pm
Expand Up @@ -2,6 +2,7 @@ package Lacuna::Role::Ship::Arrive::DumpWaste;

use strict;
use Moose::Role;
use Lacuna::Util qw(commify);

after handle_arrival_procedures => sub {
my ($self) = @_;
Expand Down Expand Up @@ -30,20 +31,21 @@ after handle_arrival_procedures => sub {
}
$body_attacked->add_waste($waste_dumped);
$body_attacked->update;
$waste_dumped = commify($waste_dumped); # commify so emails look nicer

unless ($self->body->empire->skip_attack_messages) {
$self->body->empire->send_predefined_message(
tags => ['Attack','Alert'],
filename => 'our_scow_hit.txt',
params => [$body_attacked->x, $body_attacked->y, $body_attacked->name, $self->hold_size],
params => [$body_attacked->x, $body_attacked->y, $body_attacked->name, $waste_dumped],
);
}

unless ($body_attacked->empire->skip_attack_messages) {
$body_attacked->empire->send_predefined_message(
tags => ['Attack','Alert'],
filename => 'hit_by_scow.txt',
params => [$self->body->empire_id, $self->body->empire->name, $body_attacked->id, $body_attacked->name, $self->hold_size],
params => [$self->body->empire_id, $self->body->empire->name, $body_attacked->id, $body_attacked->name, $waste_dumped],
);
}

Expand Down

0 comments on commit a364c0e

Please sign in to comment.