Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
icydee committed Aug 30, 2012
2 parents c3f563a + 4b89900 commit 0fb11b7
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 49 deletions.
2 changes: 1 addition & 1 deletion lib/Lacuna.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Config::JSON;

useall __PACKAGE__;

our $VERSION = 3.0865;
our $VERSION = 3.0866;

my $config = Config::JSON->new('/data/Lacuna-Server/etc/lacuna.conf');
my $db = Lacuna::DB->connect($config->get('db/dsn'),$config->get('db/username'),$config->get('db/password'), { mysql_enable_utf8 => 1});
Expand Down
14 changes: 10 additions & 4 deletions lib/Lacuna/DB/Result/Building/IntelTraining.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,21 @@ sub training_costs {
};
if ($spy_id) {
my $spy = $self->get_spy($spy_id);
$costs->{time} = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
my $train_time = sprintf('%.0f', 3600 * $spy->level *
((100 - (5 * $self->body->empire->management_affinity)) / 100));
$train_time = 3600 if ($train_time < 3600);
$costs->{time} = $train_time;
}
else {
my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } });
while (my $spy = $spies->next) {
my $train_time = sprintf('%.0f', 3600 * $spy->level *
((100 - (5 * $self->body->empire->management_affinity)) / 100));
$train_time = 3600 if ($train_time < 3600);
push @{$costs->{time}}, {
spy_id => $spy->id,
name => $spy->name,
time => sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)),
time => $train_time,
};
}
}
Expand Down Expand Up @@ -136,8 +142,8 @@ sub train_spy {
my ($self, $spy_id, $time_to_train) = @_;
my $empire = $self->body->empire;
my $spy = $self->get_spy($spy_id);
unless ($time_to_train) {
$time_to_train = $self->training_costs($spy)->{time};
unless (defined $time_to_train) {
$time_to_train = $self->training_costs($spy_id)->{time};
}
unless ($spy->task ~~ ['Counter Espionage','Idle']) {
confess [1011, 'Spy must be idle to train.'];
Expand Down
12 changes: 8 additions & 4 deletions lib/Lacuna/DB/Result/Building/MayhemTraining.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,19 @@ sub training_costs {
};
if ($spy_id) {
my $spy = $self->get_spy($spy_id);
$costs->{time} = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
$train_time = 3600 if ($train_time < 3600);
$costs->{time} = $train_time;
}
else {
my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } });
while (my $spy = $spies->next) {
my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
$train_time = 3600 if ($train_time < 3600);
push @{$costs->{time}}, {
spy_id => $spy->id,
name => $spy->name,
time => sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)),
time => $train_time,
};
}
}
Expand Down Expand Up @@ -139,8 +143,8 @@ sub train_spy {
my ($self, $spy_id, $time_to_train) = @_;
my $empire = $self->body->empire;
my $spy = $self->get_spy($spy_id);
unless ($time_to_train) {
$time_to_train = $self->training_costs($spy)->{time};
unless (defined $time_to_train) {
$time_to_train = $self->training_costs($spy_id)->{time};
}
unless ($spy->task ~~ ['Counter Espionage','Idle']) {
confess [1011, 'Spy must be idle to train.'];
Expand Down
6 changes: 4 additions & 2 deletions lib/Lacuna/DB/Result/Building/Permanent/BlackHoleGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ after finish_upgrade => sub {

sub can_build_on {
my $self = shift;
unless ($self->body->isa('Lacuna::DB::Result::Map::Body::Planet') &&
!$self->body->isa('Lacuna::DB::Result::Map::Body::Planet::GasGiant')) {

if ( !$self->body->isa('Lacuna::DB::Result::Map::Body::Planet') ||
$self->body->isa('Lacuna::DB::Result::Map::Body::Planet::Station') ||
$self->body->isa('Lacuna::DB::Result::Map::Body::Planet::Gas Giant')) {
confess [1009, 'Can only be built on habitable planets.'];
}
return 1;
Expand Down
12 changes: 8 additions & 4 deletions lib/Lacuna/DB/Result/Building/PoliticsTraining.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,19 @@ sub training_costs {
};
if ($spy_id) {
my $spy = $self->get_spy($spy_id);
$costs->{time} = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
$train_time = 3600 if ($train_time < 3600);
$costs->{time} = $train_time;
}
else {
my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } });
while (my $spy = $spies->next) {
my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
$train_time = 3600 if ($train_time < 3600);
push @{$costs->{time}}, {
spy_id => $spy->id,
name => $spy->name,
time => sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)),
time => $train_time,
};
}
}
Expand Down Expand Up @@ -136,8 +140,8 @@ sub train_spy {
my ($self, $spy_id, $time_to_train) = @_;
my $empire = $self->body->empire;
my $spy = $self->get_spy($spy_id);
unless ($time_to_train) {
$time_to_train = $self->training_costs($spy)->{time};
unless (defined $time_to_train) {
$time_to_train = $self->training_costs($spy_id)->{time};
}
unless ($spy->task ~~ ['Counter Espionage','Idle']) {
confess [1011, 'Spy must be idle to train.'];
Expand Down
12 changes: 8 additions & 4 deletions lib/Lacuna/DB/Result/Building/TheftTraining.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,19 @@ sub training_costs {
};
if ($spy_id) {
my $spy = $self->get_spy($spy_id);
$costs->{time} = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
$train_time = 3600 if ($train_time < 3600);
$costs->{time} = $train_time;
}
else {
my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } });
while (my $spy = $spies->next) {
my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100));
$train_time = 3600 if ($train_time < 3600);
push @{$costs->{time}}, {
spy_id => $spy->id,
name => $spy->name,
time => sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)),
time => $train_time,
};
}
}
Expand Down Expand Up @@ -136,8 +140,8 @@ sub train_spy {
my ($self, $spy_id, $time_to_train) = @_;
my $empire = $self->body->empire;
my $spy = $self->get_spy($spy_id);
unless ($time_to_train) {
$time_to_train = $self->training_costs($spy)->{time};
unless (defined $time_to_train) {
$time_to_train = $self->training_costs($spy_id)->{time};
}
unless ($spy->task ~~ ['Counter Espionage','Idle']) {
confess [1011, 'Spy must be idle to train.'];
Expand Down
18 changes: 10 additions & 8 deletions lib/Lacuna/DB/Result/Map/Body/Planet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -899,20 +899,22 @@ sub is_plot_locked {
}

sub build_building {
my ($self, $building, $in_parallel) = @_;
unless ($building->isa('Lacuna::DB::Result::Building::Permanent')) {
$self->building_count( $self->building_count + 1 );
$self->plots_available( $self->plots_available - 1 );
$self->update;
}
my ($self, $building, $in_parallel, $no_upgrade) = @_;
$building->date_created(DateTime->now);
$building->body_id($self->id);
$building->level(0) unless $building->level;
$building->insert;
$building->body($self);
weaken($building->{_relationship_data}{body});
$building->start_upgrade(undef, $in_parallel);
unless ($no_upgrade) {
$building->start_upgrade(undef, $in_parallel);
}
$self->building_cache([@{$self->building_cache}, $building]);
unless ($building->isa('Lacuna::DB::Result::Building::Permanent')) {
$self->building_count( $self->building_count + 1 );
$self->plots_available( $self->plots_available - 1 );
$self->update;
}
}

sub found_colony {
Expand Down Expand Up @@ -1409,7 +1411,7 @@ sub tick_to {
}
# Process excavator sites
if ( my $arch = $self->archaeology) {
if ($arch->efficiency == 100) {
if ($arch->efficiency == 100 and $arch->level > 0) {
my $dig_sec = $now->epoch - $arch->last_check->epoch;
if ($dig_sec >= 3600) {
my $dig_hours = int($dig_sec/3600);
Expand Down
46 changes: 24 additions & 22 deletions lib/Lacuna/RPC/Building/BlackHoleGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -484,24 +484,26 @@ sub bhg_swap {
});

unless ($new_data->{type} eq "empty") {
$target->update({
needs_recalc => 1,
x => $old_data->{x},
y => $old_data->{y},
zone => $old_data->{zone},
star_id => $old_data->{star_id},
orbit => $old_data->{orbit},
});
my $target_waste = Lacuna->db->resultset('Lacuna::DB::Result::WasteChain')
->search({ planet_id => $target->id });
if ($target_waste->count > 0) {
while (my $chain = $target_waste->next) {
$chain->update({
star_id => $old_data->{star_id}
});
$target->update({
needs_recalc => 1,
x => $old_data->{x},
y => $old_data->{y},
zone => $old_data->{zone},
star_id => $old_data->{star_id},
orbit => $old_data->{orbit},
});
if ($new_data->{type} ne 'asteroid') {
my $target_waste = Lacuna->db->resultset('Lacuna::DB::Result::WasteChain')
->search({ planet_id => $target->id });
if ($target_waste->count > 0) {
while (my $chain = $target_waste->next) {
$chain->update({
star_id => $old_data->{star_id}
});
}
}
$target->recalc_chains; # Recalc all chains
}
}
$target->recalc_chains; # Recalc all chains
}

my $waste_chain = Lacuna->db->resultset('Lacuna::DB::Result::WasteChain')
Expand Down Expand Up @@ -787,18 +789,18 @@ sub bhg_decor {
}
$max_level = 30 if $max_level > 30;
my $planted = 0;
my $now = DateTime->now;
foreach my $cnt (1..$plant) {
my ($x, $y) = eval { $body->find_free_space};
unless ($@) {
my $deployed = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({
date_created => $now,
class => random_element(\@decor),
my $building = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({
x => $x,
y => $y,
level => randint(1, $max_level),
body_id => $body->id,
})->insert;
body => $body,
class => random_element(\@decor),
});
$body->build_building($building, undef, 1);
$planted++;
}
else {
Expand Down
6 changes: 6 additions & 0 deletions var/www/public/changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.0866:
- Fix: Freshly built ArchMin were returning results before completing their build.
- Fix: No longer will recalculate a supply chain on an asteroid.
- Fix: Minimum training times in spy training buildings.
- Fix: Can no longer place a useless BHG on a space station.

3.0865:
- Mod: Removed option to disable display of incoming ships. (To see if it fixes some resource issues)
- Mod: Attempt to make Counter Espionage tutorial message clearer since people don't read the entire email.
Expand Down

0 comments on commit 0fb11b7

Please sign in to comment.