forked from plainblack/Lacuna-Server-Open
/
Capitol.pm
79 lines (54 loc) · 2.01 KB
/
Capitol.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package Lacuna::DB::Result::Building::Capitol;
use Moose;
use utf8;
no warnings qw(uninitialized);
extends 'Lacuna::DB::Result::Building';
use Lacuna::Constants qw(INFLATION_F CONSUME_N WASTE_F HAPPY_F TINFLATE_F);
around 'build_tags' => sub {
my ($orig, $class) = @_;
return ($orig->($class), qw(Infrastructure Happiness Intelligence));
};
use constant consume_rate => CONSUME_N;
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;
use constant building_prereq => {'Lacuna::DB::Result::Building::PlanetaryCommand'=>10};
use constant max_instances_per_planet => 1;
use constant controller_class => 'Lacuna::RPC::Building::Capitol';
use constant image => 'capitol';
use constant name => 'Capitol';
use constant food_to_build => 350;
use constant energy_to_build => 350;
use constant ore_to_build => 350;
use constant water_to_build => 350;
use constant waste_to_build => 100;
use constant time_to_build => 230;
use constant food_consumption => 18;
use constant energy_consumption => 13;
use constant ore_consumption => 2;
use constant water_consumption => 20;
use constant waste_production => 5;
use constant happiness_production => 100;
before can_build => sub {
my $self = shift;
my @ids = $self->body->empire->planets->get_column('id')->all;
my $count = Lacuna->db->resultset('Lacuna::DB::Result::Building')->search({ class => __PACKAGE__, body_id => { in => \@ids } })->count;
if ($count) {
confess [1013, 'You can only have one Capitol.'];
}
};
after finish_upgrade => sub {
my $self = shift;
my $body = $self->body;
my $empire = $body->empire;
$empire->home_planet_id($body->id);
$empire->update;
$body->add_news(80, '%s have announced that their new capitol is %s.', $empire->name, $body->name);
};
sub rename_empire_cost {
my $self = shift;
return 30 - $self->effective_level;
}
no Moose;
__PACKAGE__->meta->make_immutable(inline_constructor => 0);