Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix bug post-release to do with BHG subsidy

  • Loading branch information...
commit 309246481601816036bd1c03178e301cd0492d19 1 parent b3bf5d6
Iain C Docherty authored September 23, 2012
2  lib/Lacuna/RPC/Building/BlackHoleGenerator.pm
@@ -458,6 +458,8 @@ sub generate_singularity {
458 458
     }
459 459
   }
460 460
   if ($subsidize) {
  461
+    $empire->spend_essentia($chance->{essentia_cost},'BHG perfection subsidy after the fact');
  462
+    $empire->update;
461 463
   }
462 464
 
463 465
   return {
51  t/490_bhg.pm
... ...
@@ -0,0 +1,51 @@
  1
+use lib '../lib';
  2
+
  3
+use strict;
  4
+use warnings;
  5
+
  6
+use Test::More tests => 3;
  7
+use Test::Deep;
  8
+use Test::Memory::Cycle;
  9
+use Data::Dumper;
  10
+use 5.010;
  11
+use DateTime;
  12
+use Lacuna;
  13
+use TestHelper;
  14
+
  15
+my $empire_name     = 'icydee';
  16
+my $planet_name     = 'iceburg';
  17
+my $target_name     = 'Aep Eewes Eerv 3';
  18
+
  19
+my $tester = TestHelper->new({empire_name => $empire_name})->use_existing_test_empire;
  20
+my $empire = $tester->empire;
  21
+my $session = $empire->start_session({api_key => 'tester'});
  22
+
  23
+diag("Empire ".$empire->name);
  24
+diag("Empire @{[$empire->name]}");
  25
+diag("Session @{[$tester->session]}");
  26
+
  27
+my $session_id = $tester->session->id;
  28
+
  29
+my ($planet) = Lacuna->db->resultset('Map::Body::Planet')->search({name => $planet_name});
  30
+my ($bhg)    = $planet->get_building_of_class('Lacuna::DB::Result::Building::Permanent::BlackHoleGenerator');
  31
+
  32
+diag("BHG = $bhg");
  33
+
  34
+my $result = $tester->post('blackholegenerator','get_actions_for', [$session_id, $bhg->id, {body_name => $target_name}]);
  35
+diag(Dumper($result->{result}{tasks}));
  36
+
  37
+$result = $tester->post('blackholegenerator','generate_singularity', [{
  38
+    session_id          => $session_id,
  39
+    building_id         => $bhg->id,
  40
+    target              => { body_name => $target_name },
  41
+    task_name           => "Swap Places",
  42
+    subsidize           => 1,
  43
+}]);
  44
+
  45
+diag(Dumper($result->{result}));
  46
+
  47
+$result = $tester->post('blackholegenerator','subsidize_cooldown', [$session_id, $bhg->id]);
  48
+
  49
+diag(Dumper($result->{result}{tasks}));
  50
+1;
  51
+

0 notes on commit 3092464

Please sign in to comment.
Something went wrong with that request. Please try again.