forked from plainblack/Lacuna-Server-Open
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
2,064 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,21 @@ | ||
package Lacuna::Role::Fleet::Arrive::AddGasGiantPlatform; | ||
|
||
use strict; | ||
use Moose::Role; | ||
|
||
after handle_arrival_procedures => sub { | ||
my ($self) = @_; | ||
|
||
# we're coming home | ||
return if ($self->direction eq 'in'); | ||
|
||
# Add one plan for each ship in the fleet | ||
my $lab = $self->body->get_building_of_class('Lacuna::DB::Result::Building::GasGiantLab'); | ||
$self->foreign_body->add_plan('Lacuna::DB::Result::Building::Permanent::GasGiantPlatform', 1, (defined $lab) ? $lab->level : 0, $self->quantity); | ||
|
||
$self->delete; | ||
confess [-1]; | ||
}; | ||
|
||
|
||
1; |
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,21 @@ | ||
package Lacuna::Role::Fleet::Arrive::AddTerraformingPlatform; | ||
|
||
use strict; | ||
use Moose::Role; | ||
|
||
after handle_arrival_procedures => sub { | ||
my ($self) = @_; | ||
|
||
# we're coming home | ||
return if ($self->direction eq 'in'); | ||
|
||
# add one plan for each ship in the fleet | ||
my $lab = $self->body->get_building_of_class('Lacuna::DB::Result::Building::TerraformingLab'); | ||
$self->foreign_body->add_plan('Lacuna::DB::Result::Building::Permanent::TerraformingPlatform', 1, (defined $lab) ? $lab->level : 0, $self->quantity); | ||
|
||
$self->delete; | ||
confess [-1]; | ||
}; | ||
|
||
|
||
1; |
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,69 @@ | ||
package Lacuna::Role::Fleet::Arrive::CaptureWithSpies; | ||
|
||
use strict; | ||
use Moose::Role; | ||
|
||
after handle_arrival_procedures => sub { | ||
my ($self) = @_; | ||
# we don't capture when coming in to our own planet | ||
return if $self->direction eq 'in'; | ||
|
||
# we don't capture if there are no spies | ||
return unless ( | ||
(exists $self->payload->{spies} && scalar(@{$self->payload->{spies}})) | ||
|| (exists $self->payload->{fetch_spies} && scalar(@{$self->payload->{fetch_spies}})) | ||
); | ||
|
||
# we don't capture if it is from our empire | ||
my $body = $self->foreign_body; | ||
return if ($body->empire_id == $self->body->empire_id); | ||
|
||
# do nothing, because it is uninhabited | ||
return if (!$body->empire_id); | ||
|
||
# we don't capture if it is an ally | ||
return if ($body->empire->alliance_id && $self->body->empire->alliance_id | ||
&& $body->empire->alliance_id == $self->body->empire->alliance_id); | ||
|
||
# set last attack status | ||
$body->set_last_attacked_by($self->body->id); | ||
|
||
my $building = 'Security'; | ||
if ($body->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) { | ||
$building = 'Module::PoliceStation'; | ||
} | ||
my $security = $body->get_building_of_class('Lacuna::DB::Result::Building::'.$building); | ||
return unless defined $security && $security->efficiency > 0; | ||
|
||
# lets see if we can detect the ship | ||
my $security_detection = ($security->level * 700) * ( $security->efficiency / 100 ); | ||
if ($body->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) { | ||
$security_detection *= 1.5; | ||
} | ||
return unless $security_detection > $self->stealth; | ||
|
||
# ship detected, time to go kaboom | ||
my $spies = Lacuna->db->resultset('Spies'); | ||
foreach my $id ((@{$self->payload->{spies}}, @{$self->payload->{fetch_spies}})) { | ||
next unless $id; | ||
my $spy = $spies->find($id); | ||
next unless defined $spy; | ||
$spy->go_to_jail; | ||
$spy->update; | ||
} | ||
$self->body->empire->send_predefined_message( | ||
tags => ['Spies','Alert'], | ||
filename => 'ship_captured_with_spies.txt', | ||
params => [$self->name, $body->x, $body->y, $body->name], | ||
); | ||
$body->empire->send_predefined_message( | ||
tags => ['Spies','Alert'], | ||
filename => 'we_captured_ship_with_spies.txt', | ||
params => [$body->id, $body->name, $self->body->empire->id, $self->body->empire->name], | ||
); | ||
$self->delete; | ||
confess [-1]; | ||
}; | ||
|
||
1; | ||
|
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,30 @@ | ||
package Lacuna::Role::Fleet::Arrive::CargoExchange; | ||
|
||
use strict; | ||
use Moose::Role; | ||
|
||
after handle_arrival_procedures => sub { | ||
my ($self) = @_; | ||
|
||
if ($self->direction eq 'out' and $self->foreign_body->empire_id) { | ||
if ($self->foreign_body->isa('Lacuna::DB::Result::Map::Body::Planet::Station')) { | ||
my $amount = 0; | ||
my $payload = $self->payload; | ||
if (exists $payload->{resources}) { | ||
my %resources = %{$payload->{resources}}; | ||
foreach my $type (keys %resources) { | ||
$amount += $resources{$type}; | ||
} | ||
} | ||
if ($amount > 0) { | ||
$self->body->empire->pay_taxes($self->foreign_body->id, $amount); | ||
} | ||
} | ||
$self->unload($self->foreign_body); | ||
} | ||
elsif ($self->direction eq 'in') { | ||
$self->unload($self->body); | ||
} | ||
}; | ||
|
||
1; |
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,79 @@ | ||
package Lacuna::Role::Fleet::Arrive::Colonize; | ||
|
||
use strict; | ||
use Moose::Role; | ||
|
||
after handle_arrival_procedures => sub { | ||
my ($self) = @_; | ||
|
||
# we're coming home | ||
return if ($self->direction eq 'in'); | ||
|
||
# can't colonize because it's already taken | ||
my $empire = $self->body->empire; | ||
my $planet = $self->foreign_body; | ||
|
||
if ($planet->isa('Lacuna::DB::Result::Map::Body::Planet::GasGiant') && $empire->university_level < 19) { | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'cannot_colonize_gg.txt', | ||
params => [$planet->x, $planet->y, $planet->name, $planet->name], | ||
); | ||
} | ||
elsif ($planet->isa('Lacuna::DB::Result::Map::Body::Asteroid')) { | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'cannot_colonize_asteroid.txt', | ||
params => [$planet->x, $planet->y, $planet->name, $planet->name], | ||
); | ||
} | ||
elsif ($planet->is_locked || $planet->empire_id) { | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'cannot_colonize.txt', | ||
params => [$planet->x, $planet->y, $planet->name, $planet->name], | ||
); | ||
} | ||
|
||
# can't colonize because it's claimed | ||
elsif ($planet->is_claimed && $planet->is_claimed != $empire->id) { | ||
my $claimer = $planet->claimed_by; | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'cannot_colonize_staked.txt', | ||
params => [$planet->x, $planet->y, $planet->name, $claimer->id, $claimer->name, $planet->name], | ||
); | ||
} | ||
|
||
# let's claim this for our very own! | ||
else { | ||
$planet->lock; | ||
$planet->found_colony($empire); | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'colony_founded.txt', | ||
params => [$planet->id, $planet->name, $planet->name], | ||
); | ||
$empire->is_isolationist(0); | ||
$empire->update; | ||
$self->delete; | ||
confess [-1]; | ||
} | ||
}; | ||
|
||
after can_send_to_target => sub { | ||
my ($self, $target) = @_; | ||
my $empire = $self->body->empire; | ||
confess [1009, 'Can only be sent to habitable planets.'] if ($target->isa('Lacuna::DB::Result::Map::Body::Planet::GasGiant') && $empire->university_level < 19); | ||
confess [ 1009, 'Your species cannot survive on that planet.' ] if ($empire->university_level < 18 && ($target->orbit > $empire->max_orbit || $target->orbit < $empire->min_orbit)); | ||
if ($target->star->station_id) { | ||
if ($target->star->station->laws->search({type => 'MembersOnlyColonization'})->count) { | ||
unless ($target->star->station->alliance_id == $self->body->empire->alliance_id) { | ||
confess [1010, 'Only '.$target->star->station->alliance->name.' members can colonize planets in the jurisdiction of the space station.']; | ||
} | ||
} | ||
} | ||
return 1; | ||
}; | ||
|
||
1; |
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,59 @@ | ||
package Lacuna::Role::Fleet::Arrive::ConvertToStation; | ||
|
||
use strict; | ||
use Moose::Role; | ||
|
||
after handle_arrival_procedures => sub { | ||
my ($self) = @_; | ||
|
||
# we're coming home | ||
return if ($self->direction eq 'in'); | ||
|
||
# can't convert because it's already taken | ||
my $empire = $self->body->empire; | ||
my $planet = $self->foreign_body; | ||
if ($planet->is_locked || $planet->empire_id) { | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'cannot_convert_to_station.txt', | ||
params => [$planet->x, $planet->y, $planet->name, $planet->name], | ||
); | ||
} | ||
|
||
# can't convert because it's claimed | ||
elsif ($planet->is_claimed && $planet->is_claimed != $empire->id) { | ||
my $claimer = $planet->claimed_by; | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'cannot_convert_to_station_staked.txt', | ||
params => [$planet->x, $planet->y, $planet->name, $claimer->id, $claimer->name, $planet->name], | ||
); | ||
} | ||
|
||
# can't convert because not in an alliance | ||
elsif (!$empire->alliance_id) { | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'cannot_convert_to_station_no_alliance.txt', | ||
params => [$planet->x, $planet->y, $planet->name, $planet->name], | ||
); | ||
} | ||
|
||
# let's claim this for our very own! | ||
else { | ||
$planet->lock; | ||
$planet->convert_to_station($empire); | ||
$empire->send_predefined_message( | ||
tags => ['Colonization','Alert'], | ||
filename => 'station_founded.txt', | ||
params => [$planet->id, $planet->name, $planet->name], | ||
); | ||
$empire->is_isolationist(0); | ||
$empire->update; | ||
$self->delete; | ||
confess [-1]; | ||
} | ||
}; | ||
|
||
|
||
1; |
Oops, something went wrong.