From 352e7740aaae1968514f1d8b5ef73f0bc14391ef Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 18 Mar 2011 11:44:22 -0500 Subject: [PATCH] Slight change to the Space Station Lab API to accomodate displaying descriptions and images for the plans. --- docs/SpaceStationLab.pod | 11 ++++++++--- lib/Lacuna/DB/Result/Building/SSLa.pm | 11 ++++++++--- t/SpaceStationLab.t | 2 +- var/www/public/changes.txt | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/SpaceStationLab.pod b/docs/SpaceStationLab.pod index 445f4840..8798988e 100644 --- a/docs/SpaceStationLab.pod +++ b/docs/SpaceStationLab.pod @@ -14,10 +14,15 @@ This method is changed from the default because it adds a C element t "building" : { ... }, "status" : { ... }, "make_plan" : { - "types" : { - "ibs" : "Interstellar Broadcast Station", + "types" : [ + { + "type" : "ibs", + "name" : "Interstellar Broadcast Station", + "image" : "ibs", + "url" : "/ibs" + }, ... - }, + ], "level_costs" : [ { level => 1, diff --git a/lib/Lacuna/DB/Result/Building/SSLa.pm b/lib/Lacuna/DB/Result/Building/SSLa.pm index 03884d5c..5e54c0a4 100644 --- a/lib/Lacuna/DB/Result/Building/SSLa.pm +++ b/lib/Lacuna/DB/Result/Building/SSLa.pm @@ -69,12 +69,17 @@ sub makeable_plans { sub makeable_plans_formatted { my $self = shift; - my %out; + my @out; my $makeable_plans = $self->makeable_plans; while (my ($type, $class) = each %{$makeable_plans}) { - $out{$type} = $class->name; + push @out, { + image => $class->image, + name => $class->name, + url => $class->controller_class->app_url, + type => $type, + }; } - return \%out; + return \@out; } sub level_costs_formatted { diff --git a/t/SpaceStationLab.t b/t/SpaceStationLab.t index c1253f92..d3453f71 100644 --- a/t/SpaceStationLab.t +++ b/t/SpaceStationLab.t @@ -50,7 +50,7 @@ $result = $tester->post('ssla', 'view', [$session_id, $ssla->id]); is($result->{result}{make_plan}{subsidy_cost}, 2, 'got subsidy cost'); is(scalar(@{$result->{result}{make_plan}{level_costs}}), 1, 'got level costs'); ok($result->{result}{make_plan}{level_costs}[0]{food} > 1000, 'got good level costs'); -is($result->{result}{make_plan}{types}{ibs}, 'Interstellar Broadcast System', 'got types'); +ok(exists $result->{result}{make_plan}{types}[0]{url}, 'got types'); $home->ore_capacity(5_000_000); $home->water_capacity(5_000_000); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index d65757e8..a6a5e490 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,4 +1,5 @@ 3.0200 + - API: Slight change to the Space Station Lab API to accomodate displaying descriptions and images for the plans. - Fix: P16 type planets were being misidentified as P17 planets. 3.0100 -- 2.51.2