Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic space station infrastructure
- Loading branch information
JT Smith
committed
Mar 9, 2011
1 parent
82e3720
commit 78a6ca7
Showing
26 changed files
with
511 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
=head1 Interstellar Broadcast System Methods | ||
|
||
Interstellar Broadcast System is accessible via the URL C</ibs>. | ||
|
||
The list of methods below represents changes and additions to the methods that all L<Modules> share. | ||
|
||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
=head1 Modules vs Buildings | ||
|
||
Modules are special types of L<Buildings> that can only be built on a space station. | ||
|
||
Modules produce no resources, and therefore may be built to consume resources beyond your production levels. | ||
|
||
Modules can only be built, repaired, upgraded, downgraded, and demolished via acts of L<Parliament>. Therefore modules don't inherit the C<build>, C<upgrade>, C<downgrade>, C<demolish>, and C<repair> methods from L<Buildings>. | ||
|
||
=head1 Module Types | ||
|
||
Below is a list of the different types of structures that can be built on space stations in Lacuna. | ||
|
||
=over | ||
|
||
=item L<IBS> | ||
|
||
=item L<Parliament> | ||
|
||
=item L<StationCommand> | ||
|
||
=item L<Warehouse> | ||
|
||
=back | ||
|
||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
=head1 Parliament Methods | ||
|
||
Parliament is accessible via the URL C</parliament>. | ||
|
||
The list of methods below represents changes and additions to the methods that all L<Modules> share. | ||
|
||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
=head1 Station Command Methods | ||
|
||
Station Command Center is accessible via the URL C</stationcommand>. | ||
|
||
The list of methods below represents changes and additions to the methods that all L<Modules> share. | ||
|
||
=head2 view ( session_id, building_id ) | ||
|
||
Command extends the view method to include a C<planet> section. | ||
|
||
{ | ||
"building" : { ... }, | ||
"status" : { ... }, | ||
"next_colony_cost" : 750000, # the amount of happiness required to settle your next colony | ||
"planet" : { | ||
"id" : "id-goes-here", | ||
"x" : -4, | ||
"y" : 10, | ||
"z" : 6, | ||
"star_id" : "id-goes-here", | ||
"orbit" : 3, | ||
"type" : "habitable planet", | ||
"name" : "Earth", | ||
"image" : "p13", | ||
"size" : 67, | ||
"water" : 900, | ||
"ore" : { | ||
"gold" : 3399, | ||
"bauxite" : 4000, | ||
... | ||
}, | ||
"building_count" : 7, | ||
"population" : 470000, | ||
"happiness" : 3939, | ||
"happiness_hour" : 25, | ||
"food_stored" : 33329, | ||
"food_capacity" : 40000, | ||
"food_hour" : 229, | ||
"energy_stored" : 39931, | ||
"energy_capacity" : 43000, | ||
"energy_hour" : 391, | ||
"ore_hour" 284, | ||
"ore_capacity" 35000, | ||
"ore_stored" 1901, | ||
"waste_hour" : 933, | ||
"waste_stored" : 9933, | ||
"waste_capacity" : 13000, | ||
"water_stored" : 9929, | ||
"water_hour" : 295, | ||
"water_capacity" : 51050 | ||
} | ||
} | ||
|
||
|
||
=head2 view_plans ( session_id, building_id ) | ||
|
||
Returns a list of all the plans you've collected through various means. | ||
|
||
{ | ||
"status" : { ... }, | ||
"plans" : [ | ||
{ | ||
"name" : "Malcud Fungus Farm", | ||
"level" : 1, | ||
"extra_build_level" : 5 | ||
}, | ||
... | ||
] | ||
} | ||
|
||
If the C<level> is 1, and there is an C<extra_build_level>, that means that the building will be built up to 1 plus the extra build level when complete. So in the example above, it would be a level 6 directly after being built. | ||
|
||
|
||
=head3 session_id | ||
|
||
A session id. | ||
|
||
=head3 building_id | ||
|
||
The unique id of the PCC. | ||
|
||
|
||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
=head1 Warehouse Methods | ||
|
||
Warehouse is accessible via the URL C</warehouse>. | ||
|
||
The list of methods below represents changes and additions to the methods that all L<Modules> share. | ||
|
||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package Lacuna::DB::Result::Building::Module; | ||
|
||
use Moose; | ||
use utf8; | ||
no warnings qw(uninitialized); | ||
extends 'Lacuna::DB::Result::Building'; | ||
|
||
around 'build_tags' => sub { | ||
my ($orig, $class) = @_; | ||
return ($orig->($class), qw(Infrastructure)); | ||
}; | ||
|
||
sub image_level { | ||
my $self = shift; | ||
return $self->image; | ||
} | ||
|
||
use constant energy_consumption => 200; | ||
use constant water_consumption => 100; | ||
use constant food_consumption => 100; | ||
use constant ore_consumption => 100; | ||
use constant energy_to_build => 500; | ||
use constant food_to_build => 100; | ||
use constant ore_to_build => 500; | ||
use constant water_to_build => 150; | ||
|
||
around spend_efficiency => sub { | ||
my ($orig, $self, $amount) = @_; | ||
if ($self->efficiency <= $amount) { | ||
if ($self->level <= 1 && eval{$self->can_demolish}) { | ||
$self->demolish; | ||
} | ||
elsif ($self->level > 1 && eval{$self->can_downgrade}) { | ||
$self->downgrade; | ||
} | ||
else { | ||
$orig->($self, $amount); | ||
} | ||
} | ||
else { | ||
$orig->($self, $amount); | ||
} | ||
return $self; | ||
}; | ||
|
||
sub cost_to_upgrade { | ||
return { | ||
food => 0, | ||
ore => 0, | ||
water => 0, | ||
energy => 0, | ||
waste => 0, | ||
time => 60, | ||
}; | ||
} | ||
|
||
around can_upgrade => sub { | ||
my ($orig, $self, $cost, $from_parliament) = @_; | ||
if ($from_parliament) { | ||
$orig->($self, $cost); | ||
} | ||
else { | ||
confess [1010, 'Space station modules can only be upgraded by an act of Parliament.']; | ||
} | ||
}; | ||
|
||
around can_downgrade => sub { | ||
my ($orig, $self, $cost, $from_parliament) = @_; | ||
if ($from_parliament) { | ||
$orig->($self, $cost); | ||
} | ||
else { | ||
confess [1010, 'Space station modules can only be downgraded by an act of Parliament.']; | ||
} | ||
}; | ||
|
||
around can_demolish => sub { | ||
my ($orig, $self, $cost, $from_parliament) = @_; | ||
if ($from_parliament) { | ||
$orig->($self, $cost); | ||
} | ||
else { | ||
confess [1010, 'Space station modules can only be demolished by an act of Parliament.']; | ||
} | ||
}; | ||
|
||
around can_build => sub { | ||
my ($orig, $self, $cost, $from_parliament) = @_; | ||
if ($from_parliament) { | ||
$orig->($self, $cost); | ||
} | ||
else { | ||
confess [1010, 'Space station modules can only be built by an act of Parliament.']; | ||
} | ||
}; | ||
|
||
around can_repair => sub { | ||
my ($orig, $self, $cost, $from_parliament) = @_; | ||
if ($from_parliament) { | ||
$orig->($self, $cost); | ||
} | ||
else { | ||
confess [1010, 'Space station modules can only be repaired by an act of Parliament.']; | ||
} | ||
}; | ||
|
||
sub can_build_on { | ||
my $self = shift; | ||
if ($self->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) { | ||
confess [1009, 'Can only be built on space stations.']; | ||
} | ||
return 1; | ||
} | ||
|
||
no Moose; | ||
__PACKAGE__->meta->make_immutable(inline_constructor => 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package Lacuna::DB::Result::Building::Module::IBS; | ||
|
||
use Moose; | ||
use utf8; | ||
no warnings qw(uninitialized); | ||
extends 'Lacuna::DB::Result::Building::Module'; | ||
|
||
use constant controller_class => 'Lacuna::RPC::Building::IBS'; | ||
use constant image => 'ibs'; | ||
use constant name => 'Interstellar Broadcast System'; | ||
use constant max_instances_per_planet => 1; | ||
|
||
|
||
no Moose; | ||
__PACKAGE__->meta->make_immutable(inline_constructor => 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package Lacuna::DB::Result::Building::Module::Parliament; | ||
|
||
use Moose; | ||
use utf8; | ||
no warnings qw(uninitialized); | ||
extends 'Lacuna::DB::Result::Building::Module'; | ||
|
||
use constant controller_class => 'Lacuna::RPC::Building::Parliament'; | ||
use constant image => 'parliament'; | ||
use constant name => 'Parliament'; | ||
use constant max_instances_per_planet => 1; | ||
|
||
|
||
|
||
no Moose; | ||
__PACKAGE__->meta->make_immutable(inline_constructor => 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package Lacuna::DB::Result::Building::Module::StationCommand; | ||
|
||
use Moose; | ||
use utf8; | ||
no warnings qw(uninitialized); | ||
extends 'Lacuna::DB::Result::Building::Module'; | ||
|
||
use constant controller_class => 'Lacuna::RPC::Building::StationCommand'; | ||
use constant image => 'stationcommand'; | ||
use constant name => 'Station Command Center'; | ||
use constant max_instances_per_planet => 1; | ||
|
||
|
||
no Moose; | ||
__PACKAGE__->meta->make_immutable(inline_constructor => 0); |
Oops, something went wrong.