Skip to content

Commit

Permalink
Further tweaks, adding dump to Distribution Center.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemming552 committed May 15, 2016
1 parent b199923 commit e96aee2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
25 changes: 18 additions & 7 deletions lib/Lacuna/DB/Result/Building/ThemePark.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building';
use DateTime;
use Lacuna::Constants qw(FOOD_TYPES);
use Lacuna::Constants qw(FOOD_TYPES GROWTH_F INFLATION_F CONSUME_F WASTE_F HAPPY_F TINFLATE_F);

use constant prod_rate => GROWTH_F;
use constant consume_rate => CONSUME_F;
use constant cost_rate => INFLATION_F;
use constant waste_prod_rate => WASTE_F;
use constant happy_prod_rate => HAPPY_F;
use constant time_inflation => TINFLATE_F;


around 'build_tags' => sub {
my ($orig, $class) = @_;
Expand Down Expand Up @@ -37,33 +45,36 @@ use constant max_instances_per_planet => 2;

sub food_consumption {
my $self = shift;
return ($self->is_working) ? 125 : 5;
return ($self->is_working) ? 300 : 5;
}

sub energy_consumption {
my $self = shift;
return ($self->is_working) ? 130 : 5;
return ($self->is_working) ? 500 : 5;
}

sub ore_consumption {
my $self = shift;
return ($self->is_working) ? 15 : 5;
return ($self->is_working) ? 100 : 5;
}

sub water_consumption {
my $self = shift;
return ($self->is_working) ? 150 : 5;
return ($self->is_working) ? 500 : 5;
}

sub waste_production {
my $self = shift;
return ($self->is_working) ? 115 : 5;
if ($self->is_working) {
return $self->work->{food_type_count} * 35;
}
return 2;
}

sub happiness_production {
my $self = shift;
if ($self->is_working) {
return $self->work->{food_type_count} * 25;
return $self->work->{food_type_count} * 35;
}
return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Lacuna/DB/Result/Building/Waste/Exchanger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building::Waste';

use Lacuna::Constants qw(GROWTH_F INFLATION_F CONSUME_N WASTE_S WASTE_F);
use Lacuna::Constants qw(GROWTH_F INFLATION_F CONSUME_N WASTE_S WASTE_F TINFLATE_F);

use constant controller_class => 'Lacuna::RPC::Building::WasteExchanger';

Expand All @@ -18,6 +18,7 @@ use constant consume_rate => CONSUME_N;
use constant cost_rate => INFLATION_F;
use constant waste_prod_rate => WASTE_S;
use constant waste_consume_rate => WASTE_F;
use constant time_inflation => TINFLATE_F;

use constant energy_production => 100;
use constant ore_production => 100;
Expand All @@ -33,7 +34,7 @@ use constant time_to_build => 670;
use constant food_consumption => 8;
use constant waste_consumption => 300;

use constant waste_storage => 1000;
use constant waste_storage => 1500;

use constant max_instances_per_planet => 2;

Expand Down
19 changes: 18 additions & 1 deletion lib/Lacuna/RPC/Building/DistributionCenter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,24 @@ sub release_reserve {
return $self->view($session, $building);
}

__PACKAGE__->register_rpc_method_names(qw(reserve release_reserve get_stored_resources));
sub dump {
my ($self, $session_id, $building_id, $type, $amount) = @_;
if ($amount <= 0) {
confess [1009, 'You must specify an amount greater than 0.'];
}
my $session = $self->get_session({session_id => $session_id, building_id => $building_id });
my $empire = $session->current_empire;
my $building = $session->current_building;
my $body = $building->body;
$body->spend_type($type, $amount);
$body->add_type('waste', $amount);
$body->update;
return {
status => $self->format_status($session, $body),
};
}

__PACKAGE__->register_rpc_method_names(qw(dump reserve release_reserve get_stored_resources));


no Moose;
Expand Down

0 comments on commit e96aee2

Please sign in to comment.