diff --git a/lib/Lacuna/DB/Result/Building/Archaeology.pm b/lib/Lacuna/DB/Result/Building/Archaeology.pm index 2b80c645..1a1f3ca3 100644 --- a/lib/Lacuna/DB/Result/Building/Archaeology.pm +++ b/lib/Lacuna/DB/Result/Building/Archaeology.pm @@ -54,7 +54,7 @@ sub can_search_for_glyph { confess [1010, 'The Archaeology Ministry is already searching for a glyph.']; } my $stored = $ore.'_stored'; - unless ($self->$stored >= 10_000) { + unless ($self->body->$stored >= 10_000) { confess [1011, 'Not enough '.$ore.' in storage. You need 10,000.']; } return 1; @@ -90,32 +90,32 @@ before finish_work => sub { my %recipies = ( # gypsum => { -# plan => 'Lacuna::DB::Building::Permanent::BeachA', +# plan => 'Lacuna::DB::Result::Building::Permanent::BeachA', # gypsum => { -# plan => 'Lacuna::DB::Building::Permanent::BeachB', +# plan => 'Lacuna::DB::Result::Building::Permanent::BeachB', # }, # }, magnetite => { uraninite => { - plan => 'Lacuna::DB::Building::Permanent::Volcano', + plan => 'Lacuna::DB::Result::Building::Permanent::Volcano', }, halite => { - plan => 'Lacuna::DB::Building::Permanent::NaturalSpring', + plan => 'Lacuna::DB::Result::Building::Permanent::NaturalSpring', } }, rutile => { - plan => 'Lacuna::DB::Building::Permanent::Crater', + plan => 'Lacuna::DB::Result::Building::Permanent::Crater', }, chalcopyrite=> { sulfur => { - plan => 'Lacuna::DB::Building::Permanent::GeoThermalVent', + plan => 'Lacuna::DB::Result::Building::Permanent::GeoThermalVent', }, }, sulfur => { methane => { galena => { anthracite => { - plan => 'Lacuna::DB::Building::Permanent::GasGiantPlatform', + plan => 'Lacuna::DB::Result::Building::Permanent::GasGiantPlatform', } } } @@ -123,28 +123,28 @@ my %recipies = ( methane => { zircon => { fluorite => { - plan => 'Lacuna::DB::Building::Permanent::InterDimensionalRift', + plan => 'Lacuna::DB::Result::Building::Permanent::InterDimensionalRift', }, magnetite => { beryl => { - plan => 'Lacuna::DB::Building::Permanent::TerraformingPlatform', + plan => 'Lacuna::DB::Result::Building::Permanent::TerraformingPlatform', } }, }, }, galena => { gold => { - plan => 'Lacuna::DB::Building::Permanent::KalavianRuins', + plan => 'Lacuna::DB::Result::Building::Permanent::KalavianRuins', }, }, goethite => { - plan => 'Lacuna::DB::Building::Permanent::Lake', + plan => 'Lacuna::DB::Result::Building::Permanent::Lake', }, chromite => { halite => { anthracite => { beryl => { - plan => 'Lacuna::DB::Building::Permanent::LibraryOfJith', + plan => 'Lacuna::DB::Result::Building::Permanent::LibraryOfJith', }, }, }, @@ -153,7 +153,7 @@ my %recipies = ( trona => { kerogen => { monazite => { - plan => 'Lacuna::DB::Building::Permanent::MassadsHenge', + plan => 'Lacuna::DB::Result::Building::Permanent::MassadsHenge', }, }, }, @@ -162,13 +162,13 @@ my %recipies = ( uraninite => { bauxite => { goethite => { - plan => 'Lacuna::DB::Building::Permanent::OracleOfAnid', + plan => 'Lacuna::DB::Result::Building::Permanent::OracleOfAnid', }, }, }, }, trona => { - plan => 'Lacuna::DB::Building::Permanent::RockyOutcrop', + plan => 'Lacuna::DB::Result::Building::Permanent::RockyOutcrop', }, kerogen => { rutile => { diff --git a/lib/Lacuna/RPC/Building/Archaeology.pm b/lib/Lacuna/RPC/Building/Archaeology.pm index e505a546..458218bf 100644 --- a/lib/Lacuna/RPC/Building/Archaeology.pm +++ b/lib/Lacuna/RPC/Building/Archaeology.pm @@ -12,11 +12,11 @@ sub model_class { } sub get_glyphs { - my ($self, $session_id, $building_id, $onoff) = @_; + my ($self, $session_id, $building_id) = @_; my $empire = $self->get_empire_by_session($session_id); my $building = $self->get_building($empire, $building_id); my @out; - my $glyphs = $building->glyphs; + my $glyphs = $building->body->glyphs; while (my $glyph = $glyphs->next) { push @out, { id => $glyph->id, diff --git a/t/Archaeology.t b/t/Archaeology.t new file mode 100644 index 00000000..12e4bb94 --- /dev/null +++ b/t/Archaeology.t @@ -0,0 +1,37 @@ +use lib '../lib'; +use Test::More tests => 4; +use Test::Deep; +use Data::Dumper; +use 5.010; +use DateTime; + +use TestHelper; +my $tester = TestHelper->new->generate_test_empire->build_infrastructure; +my $session_id = $tester->session->id; +my $empire = $tester->empire; +my $home = $empire->home_planet; + +my $result; + +$result = $tester->post('archaeology', 'build', [$session_id, $home->id, 0, 3]); +ok($result->{result}{building}{id}, "built an archaeology ministry"); +my $arch = $tester->get_building($result->{result}{building}{id}); +$arch->finish_upgrade; + +$result = $tester->post('archaeology', 'get_glyphs', [$session_id, $arch->id]); +ok(exists $result->{result}, 'can call get_glyphs when there are no glyphs'); + +$home->bauxite_stored(10000); + +$result = $tester->post('archaeology', 'search_for_glyph', [$session_id, $arch->id, 'bauxite']); +ok(exists $result->{result}, 'can search for glyphs'); + +my $glyph = $home->add_glyph('rutile'); + +$result = $tester->post('archaeology', 'assemble_glyphs', [$session_id, $arch->id, [$glyph->id]]); +ok(exists $result->{result}, 'can assemble glyphs into a plan'); + + +END { + $tester->cleanup; +}