From f98c90e1ad3ea00367ed2b39313a0dce3a8e8912 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 7 Mar 2011 15:38:46 -0600 Subject: [PATCH 1/9] cleanup change log --- var/www/public/changes.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 15ee7e99..0b6c1bd5 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -2,14 +2,14 @@ - Rule: Spies now have a minimum recovery time of 1 hour. - Rule: Spies now retire after 150 offensive or defensive missions, which means they can perform 299 total missions if divided equally. - Rule: Trade accepted message now tells you who accepted the trade. + - Rule: Defender shot down messages have been added. + - Rule: Distribution Center building adds new storage possibilities. - API: The status for defending fighters will now include from and orbiting blocks (as returned by view_all_ships(), get_ships_for(), etc). The get_ships_for() now includes a recallable block when that lists the fighters that defending that body. - - API: Added Lacuna::RCP::Captcha with methods fetch() and solve(). + - API: Added /captcha RPC with methods fetch() and solve(). - API: Trade Ministry and Transporter's accept_from_market methods use the new captchas. - - Fix: Attacker shot down messages will once again show the proper Empire. - - Add: Defender shot down messages have been added. - Fix: Drones will once again defend properly - Fix: Ships defending other planets won't attack their own empire - - Add: Distribution Center building + - Fix: Attacker shot down messages will once again show the proper Empire. - Fix: Essentia veins higher than level 1 will properly produce essentia. - Fix: Missions won't repeatedly run against the same spy - Fix: Missions requiring multiple of the same glyph will no longer cause errors -- 2.51.2 From 8dd80c47fa068106e4cdd4c6c2fd55aa97681c5f Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 8 Mar 2011 12:17:36 -0600 Subject: [PATCH 2/9] added space station lab --- bin/lacuna.psgi | 5 ++ docs/Buildings.pod | 2 + docs/SpaceStationLab.pod | 10 ++++ lib/Lacuna.pm | 2 +- lib/Lacuna/Constants.pm | 4 ++ lib/Lacuna/DB/Result/Building.pm | 4 ++ lib/Lacuna/DB/Result/Building/SSLa.pm | 61 ++++++++++++++++++++++++ lib/Lacuna/DB/Result/Building/SSLb.pm | 65 ++++++++++++++++++++++++++ lib/Lacuna/DB/Result/Building/SSLc.pm | 65 ++++++++++++++++++++++++++ lib/Lacuna/DB/Result/Building/SSLd.pm | 56 ++++++++++++++++++++++ lib/Lacuna/DB/Result/Medals.pm | 4 ++ lib/Lacuna/RPC/Building/SSLa.pm | 22 +++++++++ lib/Lacuna/RPC/Building/SSLb.pm | 22 +++++++++ lib/Lacuna/RPC/Building/SSLc.pm | 22 +++++++++ lib/Lacuna/RPC/Building/SSLd.pm | 22 +++++++++ lib/Lacuna/RPC/Building/Transporter.pm | 16 +++---- var/www/public/changes.txt | 3 ++ var/www/public/resources.json | 4 ++ 18 files changed, 380 insertions(+), 9 deletions(-) create mode 100644 docs/SpaceStationLab.pod create mode 100644 lib/Lacuna/DB/Result/Building/SSLa.pm create mode 100644 lib/Lacuna/DB/Result/Building/SSLb.pm create mode 100644 lib/Lacuna/DB/Result/Building/SSLc.pm create mode 100644 lib/Lacuna/DB/Result/Building/SSLd.pm create mode 100644 lib/Lacuna/RPC/Building/SSLa.pm create mode 100644 lib/Lacuna/RPC/Building/SSLb.pm create mode 100644 lib/Lacuna/RPC/Building/SSLc.pm create mode 100644 lib/Lacuna/RPC/Building/SSLd.pm diff --git a/bin/lacuna.psgi b/bin/lacuna.psgi index 9f0cd8e1..f9e36dff 100644 --- a/bin/lacuna.psgi +++ b/bin/lacuna.psgi @@ -163,6 +163,11 @@ $urlmap->map(Lacuna::RPC::Building::AlgaePond->new->to_app_with_url); $urlmap->map(Lacuna::RPC::Building::LapisForest->new->to_app_with_url); $urlmap->map(Lacuna::RPC::Building::BeeldebanNest->new->to_app_with_url); $urlmap->map(Lacuna::RPC::Building::MalcudField->new->to_app_with_url); +$urlmap->map(Lacuna::RPC::Building::SSLa->new->to_app_with_url); +$urlmap->map(Lacuna::RPC::Building::SSLb->new->to_app_with_url); +$urlmap->map(Lacuna::RPC::Building::SSLc->new->to_app_with_url); +$urlmap->map(Lacuna::RPC::Building::SSLd->new->to_app_with_url); + # admin my $admin = builder { diff --git a/docs/Buildings.pod b/docs/Buildings.pod index f0a450bd..2f291e66 100644 --- a/docs/Buildings.pod +++ b/docs/Buildings.pod @@ -450,6 +450,8 @@ Below is a list of the different types of structures that can be built on planet =item L +=item L + =item L =item L diff --git a/docs/SpaceStationLab.pod b/docs/SpaceStationLab.pod new file mode 100644 index 00000000..32a7e472 --- /dev/null +++ b/docs/SpaceStationLab.pod @@ -0,0 +1,10 @@ +=head1 Space Station Lab Methods + +Space Station Lab is accessible via the URLs C, C, C, and C. The C URL controls all the actual functions of the lab, but you must build all four lab components to use the functions of SSL A. + +The list of methods below represents changes and additions to the methods that all L share. + + + + +=cut diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 3a2a6539..2015e380 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 2.4700; +our $VERSION = 2.4800; 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}); diff --git a/lib/Lacuna/Constants.pm b/lib/Lacuna/Constants.pm index e3565d9f..e6f3c98c 100644 --- a/lib/Lacuna/Constants.pm +++ b/lib/Lacuna/Constants.pm @@ -29,6 +29,10 @@ use constant FINDABLE_PLANS => (qw( Lacuna::DB::Result::Building::Permanent::AlgaePond )); use constant BUILDABLE_CLASSES => (qw( + Lacuna::RPC::Building::SSLa + Lacuna::RPC::Building::SSLb + Lacuna::RPC::Building::SSLc + Lacuna::RPC::Building::SSLd Lacuna::RPC::Building::DistributionCenter Lacuna::RPC::Building::AtmosphericEvaporator Lacuna::RPC::Building::MetalJunkArches diff --git a/lib/Lacuna/DB/Result/Building.pm b/lib/Lacuna/DB/Result/Building.pm index caed22cc..30213e54 100644 --- a/lib/Lacuna/DB/Result/Building.pm +++ b/lib/Lacuna/DB/Result/Building.pm @@ -1036,6 +1036,10 @@ sub spend_efficiency { 'Lacuna::DB::Result::Building::SupplyPod' => 'Lacuna::DB::Result::Building::SupplyPod', 'Lacuna::DB::Result::Building::SAW' => 'Lacuna::DB::Result::Building::SAW', 'Lacuna::DB::Result::Building::DistributionCenter' => 'Lacuna::DB::Result::Building::DistributionCenter', + 'Lacuna::DB::Result::Building::SSLa' => 'Lacuna::DB::Result::Building::SSLa', + 'Lacuna::DB::Result::Building::SSLb' => 'Lacuna::DB::Result::Building::SSLb', + 'Lacuna::DB::Result::Building::SSLc' => 'Lacuna::DB::Result::Building::SSLc', + 'Lacuna::DB::Result::Building::SSLd' => 'Lacuna::DB::Result::Building::SSLd', }); } diff --git a/lib/Lacuna/DB/Result/Building/SSLa.pm b/lib/Lacuna/DB/Result/Building/SSLa.pm new file mode 100644 index 00000000..4a748c9c --- /dev/null +++ b/lib/Lacuna/DB/Result/Building/SSLa.pm @@ -0,0 +1,61 @@ +package Lacuna::DB::Result::Building::SSLa; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Building'; + +around 'build_tags' => sub { + my ($orig, $class) = @_; + return ($orig->($class), qw(Construction Ships)); +}; + +use constant university_prereq => 20; +use constant max_instances_per_planet => 1; + +use constant controller_class => 'Lacuna::RPC::Building::SSLa'; + +use constant image => 'ssla'; + +use constant name => 'Space Station Lab (A)'; + +use constant food_to_build => 230; + +use constant energy_to_build => 350; + +use constant ore_to_build => 370; + +use constant water_to_build => 260; + +use constant waste_to_build => 100; + +use constant time_to_build => 60 * 2; + +use constant food_consumption => 5; + +use constant energy_consumption => 20; + +use constant ore_consumption => 15; + +use constant water_consumption => 6; + +use constant waste_production => 20; + + +before 'can_demolish' => sub { + my $self = shift; + my $sslb = $self->body->get_building_of_class('Lacuna::DB::Result::Building::SSLb'); + if (defined $sslb) { + confess [1013, 'You have to demolish your Space Station Lab (B) before you can demolish your Space Station Lab (A).']; + } +}; + +before can_build => sub { + my $self = shift; + if ($self->x == 5 || $self->y == 5 || (($self->y == -1 || $self->y == 0) && ($self->x == -1 && $self->x == 0))) { + confess [1009, 'Space Station Lab cannot be placed in that location.']; + } +}; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Building/SSLb.pm b/lib/Lacuna/DB/Result/Building/SSLb.pm new file mode 100644 index 00000000..e97bc0c0 --- /dev/null +++ b/lib/Lacuna/DB/Result/Building/SSLb.pm @@ -0,0 +1,65 @@ +package Lacuna::DB::Result::Building::SSLb; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Building'; + +around 'build_tags' => sub { + my ($orig, $class) = @_; + return ($orig->($class), qw(Construction Ships)); +}; + +use constant building_prereq => {'Lacuna::DB::Result::Building::SSLa'=>1}; +use constant max_instances_per_planet => 1; + +use constant controller_class => 'Lacuna::RPC::Building::SSLb'; + +use constant image => 'sslb'; + +use constant name => 'Space Station Lab (B)'; + +use constant food_to_build => 230; + +use constant energy_to_build => 350; + +use constant ore_to_build => 370; + +use constant water_to_build => 260; + +use constant waste_to_build => 100; + +use constant time_to_build => 60 * 2; + +use constant food_consumption => 5; + +use constant energy_consumption => 20; + +use constant ore_consumption => 15; + +use constant water_consumption => 6; + +use constant waste_production => 20; + + +before 'can_demolish' => sub { + my $self = shift; + my $sslc = $self->body->get_building_of_class('Lacuna::DB::Result::Building::SSLc'); + if (defined $sslc) { + confess [1013, 'You have to demolish your Space Station Lab (C) before you can demolish your Space Station Lab (B).']; + } +}; + +before can_build => sub { + my $self = shift; + my $ssla = $self->body->get_building_of_class('Lacuna::DB::Result::Building::SSLa'); + unless (defined $ssla) { + confess [1013, 'You must have a Space Station Lab (A) before you can build Space Station Lab (B).']; + } + unless ($self->x == $ssla->x + 1 && $self->y == $ssla->y) { + confess [1013, 'Space Station Lab (B) must be placed to the right of Space Station Lab (A).']; + } +}; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Building/SSLc.pm b/lib/Lacuna/DB/Result/Building/SSLc.pm new file mode 100644 index 00000000..c5ba22eb --- /dev/null +++ b/lib/Lacuna/DB/Result/Building/SSLc.pm @@ -0,0 +1,65 @@ +package Lacuna::DB::Result::Building::SSLc; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Building'; + +around 'build_tags' => sub { + my ($orig, $class) = @_; + return ($orig->($class), qw(Construction Ships)); +}; + +use constant building_prereq => {'Lacuna::DB::Result::Building::SSLb'=>1}; +use constant max_instances_per_planet => 1; + +use constant controller_class => 'Lacuna::RPC::Building::SSLc'; + +use constant image => 'sslc'; + +use constant name => 'Space Station Lab (C)'; + +use constant food_to_build => 230; + +use constant energy_to_build => 350; + +use constant ore_to_build => 370; + +use constant water_to_build => 260; + +use constant waste_to_build => 100; + +use constant time_to_build => 60 * 2; + +use constant food_consumption => 5; + +use constant energy_consumption => 20; + +use constant ore_consumption => 15; + +use constant water_consumption => 6; + +use constant waste_production => 20; + + +before 'can_demolish' => sub { + my $self = shift; + my $ssld = $self->body->get_building_of_class('Lacuna::DB::Result::Building::SSLd'); + if (defined $ssld) { + confess [1013, 'You have to demolish your Space Station Lab (D) before you can demolish your Space Station Lab (C).']; + } +}; + +before can_build => sub { + my $self = shift; + my $sslb = $self->body->get_building_of_class('Lacuna::DB::Result::Building::SSLb'); + unless (defined $sslb) { + confess [1013, 'You must have a Space Station Lab (B) before you can build Space Station Lab (C).']; + } + unless ($self->x == $sslb->x + 1 && $self->y == $sslb->y) { + confess [1013, 'Space Station Lab (C) must be placed below Space Station Lab (B).']; + } +}; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Building/SSLd.pm b/lib/Lacuna/DB/Result/Building/SSLd.pm new file mode 100644 index 00000000..199225fb --- /dev/null +++ b/lib/Lacuna/DB/Result/Building/SSLd.pm @@ -0,0 +1,56 @@ +package Lacuna::DB::Result::Building::SSLd; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Building'; + +around 'build_tags' => sub { + my ($orig, $class) = @_; + return ($orig->($class), qw(Construction Ships)); +}; + +use constant building_prereq => {'Lacuna::DB::Result::Building::SSLc'=>1}; +use constant max_instances_per_planet => 1; + +use constant controller_class => 'Lacuna::RPC::Building::SSLd'; + +use constant image => 'ssld'; + +use constant name => 'Space Station Lab (D)'; + +use constant food_to_build => 230; + +use constant energy_to_build => 350; + +use constant ore_to_build => 370; + +use constant water_to_build => 260; + +use constant waste_to_build => 100; + +use constant time_to_build => 60 * 2; + +use constant food_consumption => 5; + +use constant energy_consumption => 20; + +use constant ore_consumption => 15; + +use constant water_consumption => 6; + +use constant waste_production => 20; + +before can_build => sub { + my $self = shift; + my $sslc = $self->body->get_building_of_class('Lacuna::DB::Result::Building::SSLc'); + unless (defined $sslc) { + confess [1013, 'You must have a Space Station Lab (C) before you can build Space Station Lab (D).']; + } + unless ($self->x == $sslc->x + 1 && $self->y == $sslc->y) { + confess [1013, 'Space Station Lab (D) must be placed to the left of Space Station Lab (C).']; + } +}; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Medals.pm b/lib/Lacuna/DB/Result/Medals.pm index 1c2b1351..4b55e57c 100644 --- a/lib/Lacuna/DB/Result/Medals.pm +++ b/lib/Lacuna/DB/Result/Medals.pm @@ -223,6 +223,10 @@ use constant MEDALS => { EnergyReserve => 'Built Energy Reserve', Entertainment => 'Built Entertainment District', Espionage => 'Built Espionage Ministry', + SSLa => 'Built Space Station Lab (A)', + SSLb => 'Built Space Station Lab (B)', + SSLc => 'Built Space Station Lab (C)', + SSLd => 'Built Space Station Lab (D)', MalcudField => 'Discovered a Malcud Field', Ravine => 'Discovered a Ravine', AlgaePond => 'Discovered a Algae Pond', diff --git a/lib/Lacuna/RPC/Building/SSLa.pm b/lib/Lacuna/RPC/Building/SSLa.pm new file mode 100644 index 00000000..93b3f481 --- /dev/null +++ b/lib/Lacuna/RPC/Building/SSLa.pm @@ -0,0 +1,22 @@ +package Lacuna::RPC::Building::SSLa; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::RPC::Building'; + +sub app_url { + return '/ssla'; +} + +sub model_class { + return 'Lacuna::DB::Result::Building::SSLa'; +} + + +__PACKAGE__->register_rpc_method_names(qw()); + + +no Moose; +__PACKAGE__->meta->make_immutable; + diff --git a/lib/Lacuna/RPC/Building/SSLb.pm b/lib/Lacuna/RPC/Building/SSLb.pm new file mode 100644 index 00000000..a9c2d64f --- /dev/null +++ b/lib/Lacuna/RPC/Building/SSLb.pm @@ -0,0 +1,22 @@ +package Lacuna::RPC::Building::SSLb; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::RPC::Building'; + +sub app_url { + return '/sslb'; +} + +sub model_class { + return 'Lacuna::DB::Result::Building::SSLb'; +} + + +__PACKAGE__->register_rpc_method_names(qw()); + + +no Moose; +__PACKAGE__->meta->make_immutable; + diff --git a/lib/Lacuna/RPC/Building/SSLc.pm b/lib/Lacuna/RPC/Building/SSLc.pm new file mode 100644 index 00000000..2bb3fd53 --- /dev/null +++ b/lib/Lacuna/RPC/Building/SSLc.pm @@ -0,0 +1,22 @@ +package Lacuna::RPC::Building::SSLc; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::RPC::Building'; + +sub app_url { + return '/sslc'; +} + +sub model_class { + return 'Lacuna::DB::Result::Building::SSLc'; +} + + +__PACKAGE__->register_rpc_method_names(qw()); + + +no Moose; +__PACKAGE__->meta->make_immutable; + diff --git a/lib/Lacuna/RPC/Building/SSLd.pm b/lib/Lacuna/RPC/Building/SSLd.pm new file mode 100644 index 00000000..13ef7707 --- /dev/null +++ b/lib/Lacuna/RPC/Building/SSLd.pm @@ -0,0 +1,22 @@ +package Lacuna::RPC::Building::SSLd; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::RPC::Building'; + +sub app_url { + return '/ssld'; +} + +sub model_class { + return 'Lacuna::DB::Result::Building::SSLd'; +} + + +__PACKAGE__->register_rpc_method_names(qw()); + + +no Moose; +__PACKAGE__->meta->make_immutable; + diff --git a/lib/Lacuna/RPC/Building/Transporter.pm b/lib/Lacuna/RPC/Building/Transporter.pm index c7b12fad..e0b1891a 100644 --- a/lib/Lacuna/RPC/Building/Transporter.pm +++ b/lib/Lacuna/RPC/Building/Transporter.pm @@ -127,14 +127,14 @@ sub accept_from_market { } $empire->spend_essentia($trade->ask + 1, 'Trade Price and Transporter Cost')->update; $trade->body->empire->add_essentia($trade->ask, 'Trade Income')->update; - my $cargo_log = Lacuna->db->resultset('Lacuna::DB::Result::Log::Cargo'); - $cargo_log->new({ - message => 'transporter offer accepted', - body_id => $trade->body_id, - data => $trade->payload, - object_type => ref($trade), - object_id => $trade->id, - })->insert; + #my $cargo_log = Lacuna->db->resultset('Lacuna::DB::Result::Log::Cargo'); + #$cargo_log->new({ + # message => 'transporter offer accepted', + # body_id => $trade->body_id, + # data => $trade->payload, + # object_type => ref($trade), + # object_id => $trade->id, + #})->insert; $trade->body->empire->send_predefined_message( tags => ['Alert'], filename => 'trade_accepted.txt', diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 0b6c1bd5..763efbe7 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,6 @@ +2.4800 + - Rule: Added Space Station Lab building, which will eventually allow building space station modules. + 2.4700 - Rule: Spies now have a minimum recovery time of 1 hour. - Rule: Spies now retire after 150 offensive or defensive missions, which means they can perform 299 total missions if divided equally. diff --git a/var/www/public/resources.json b/var/www/public/resources.json index 697150b6..82d9e7b3 100644 --- a/var/www/public/resources.json +++ b/var/www/public/resources.json @@ -1,5 +1,9 @@ { "buildings" : { + "/ssla" : { "description" : "Allows the construction of Space Station Lab modules.", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, + "/sslb" : { "description" : "Infrastructure required to support Space Station Lab (A).", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, + "/sslc" : { "description" : "Infrastructure required to support Space Station Lab (A).", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, + "/ssld" : { "description" : "Infrastructure required to support Space Station Lab (A).", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, "/distributioncenter" : { "description" : "A tier two resource storage building. Allows keeping specific resources in reserve.", "wiki" : "http://community.lacunaexpanse.com/wiki/distribution-center" }, "/saw" : { "description" : "A railgun system used to protect your planet from enemy ships.", "wiki" : "http://community.lacunaexpanse.com/wiki/shield-against-weapons" }, "/atmosphericevaporator" : { "description" : "Produces water by condensing it from the air and soil.", "wiki" : "http://community.lacunaexpanse.com/wiki/atmospheric-evaporator" }, -- 2.51.2 From 235c4a6b803cc0626d477a847fd851dbb36179fd Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 8 Mar 2011 12:17:44 -0600 Subject: [PATCH 3/9] don't require captcha on api methods, and use more sensible approach to captcha error throwing --- bin/setup/install-pm.sh | 2 +- lib/Lacuna/DB/Result/Ships/Bleeder.pm | 1 - lib/Lacuna/DB/Result/Ships/ColonyShip.pm | 1 - lib/Lacuna/DB/Result/Ships/Detonator.pm | 1 - lib/Lacuna/DB/Result/Ships/Excavator.pm | 1 - lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm | 1 - lib/Lacuna/DB/Result/Ships/Scanner.pm | 1 - lib/Lacuna/DB/Result/Ships/Scow.pm | 1 - .../DB/Result/Ships/SecurityMinistrySeeker.pm | 1 - .../DB/Result/Ships/ShortRangeColonyShip.pm | 1 - lib/Lacuna/DB/Result/Ships/Snark.pm | 1 - lib/Lacuna/DB/Result/Ships/Snark2.pm | 1 - lib/Lacuna/DB/Result/Ships/Snark3.pm | 1 - lib/Lacuna/DB/Result/Ships/SpacePortSeeker.pm | 1 - lib/Lacuna/DB/Result/Ships/Stake.pm | 1 - lib/Lacuna/DB/Result/Ships/Surveyor.pm | 1 - lib/Lacuna/DB/Result/Ships/Sweeper.pm | 1 - lib/Lacuna/DB/Result/Ships/Thud.pm | 1 - lib/Lacuna/RPC/Building/Intelligence.pm | 3 +-- lib/Lacuna/RPC/Building/SpacePort.pm | 5 ++--- lib/Lacuna/RPC/Building/Trade.pm | 16 +++++++++------- lib/Lacuna/RPC/Building/Transporter.pm | 17 +++++++++-------- lib/Lacuna/Role/Ship/Send/LoadWithSpies.pm | 2 -- lib/Lacuna/Session.pm | 14 ++++++-------- t/Captcha.t | 8 ++++---- 25 files changed, 32 insertions(+), 52 deletions(-) diff --git a/bin/setup/install-pm.sh b/bin/setup/install-pm.sh index 0b4159e2..967839e3 100755 --- a/bin/setup/install-pm.sh +++ b/bin/setup/install-pm.sh @@ -1 +1 @@ -cpanm AnyEvent Email::Valid Chat::Envolve Text::CSV_XS Log::Log4perl UUID::Tiny DateTime::Format::MySQL DBIx::Class::TimeStamp JSON::XS JSON Config::JSON Starman JSON::RPC::Dispatcher Log::Any::Adapter Log::Any::Adapter::Log4perl String::Random List::Util::WeightedChoice List::Util List::MoreUtils DateTime Regexp::Common Pod::Simple::HTML File::Copy DateTime::Format::Duration XML::FeedPP SOAP::Amazon::S3 DBD::mysql DBIx::Class JSON::Any DBIx::Class::InflateColumn::Serializer DBIx::Class::DynamicSubclass Memcached::libmemcached Server::Starter IO::Socket::SSL Net::Server::SS::PreFork Email::Stuff Facebook::Graph File::Path namespace::autoclean Clone Plack::Middleware::CrossOrigin Net::Amazon::S3 Path::Class Git::Wrapper +cpanm AnyEvent Email::Valid Chat::Envolve Text::CSV_XS Log::Log4perl UUID::Tiny DateTime::Format::MySQL DBIx::Class::TimeStamp JSON::XS JSON Config::JSON Starman JSON::RPC::Dispatcher Log::Any::Adapter Log::Any::Adapter::Log4perl String::Random List::Util::WeightedChoice List::Util List::MoreUtils DateTime Regexp::Common Pod::Simple::HTML File::Copy DateTime::Format::Duration XML::FeedPP SOAP::Amazon::S3 DBD::mysql DBIx::Class JSON::Any DBIx::Class::InflateColumn::Serializer DBIx::Class::DynamicSubclass Memcached::libmemcached Server::Starter IO::Socket::SSL Net::Server::SS::PreFork Email::Stuff Facebook::Graph File::Path namespace::autoclean Clone Plack::Middleware::CrossOrigin Net::Amazon::S3 Path::Class Git::Wrapper Guard diff --git a/lib/Lacuna/DB/Result/Ships/Bleeder.pm b/lib/Lacuna/DB/Result/Ships/Bleeder.pm index ed2d6d17..fbe5ce19 100644 --- a/lib/Lacuna/DB/Result/Ships/Bleeder.pm +++ b/lib/Lacuna/DB/Result/Ships/Bleeder.pm @@ -18,7 +18,6 @@ use constant base_combat => 1700; use constant base_hold_size => 0; use constant build_tags => ['War']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Inhabited"; with "Lacuna::Role::Ship::Send::NotIsolationist"; diff --git a/lib/Lacuna/DB/Result/Ships/ColonyShip.pm b/lib/Lacuna/DB/Result/Ships/ColonyShip.pm index 121e1a9b..e2be787b 100644 --- a/lib/Lacuna/DB/Result/Ships/ColonyShip.pm +++ b/lib/Lacuna/DB/Result/Ships/ColonyShip.pm @@ -19,7 +19,6 @@ use constant base_hold_size => 0; use constant pilotable => 1; use constant build_tags => ['Colonization']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Uninhabited"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; diff --git a/lib/Lacuna/DB/Result/Ships/Detonator.pm b/lib/Lacuna/DB/Result/Ships/Detonator.pm index c2792fd9..0390cdd0 100644 --- a/lib/Lacuna/DB/Result/Ships/Detonator.pm +++ b/lib/Lacuna/DB/Result/Ships/Detonator.pm @@ -18,7 +18,6 @@ use constant base_stealth => 0; use constant base_hold_size => 0; use constant build_tags => ['War']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::AsteroidAndStar"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; with "Lacuna::Role::Ship::Arrive::DestroyProbes"; diff --git a/lib/Lacuna/DB/Result/Ships/Excavator.pm b/lib/Lacuna/DB/Result/Ships/Excavator.pm index 89f3594a..47c00d79 100644 --- a/lib/Lacuna/DB/Result/Ships/Excavator.pm +++ b/lib/Lacuna/DB/Result/Ships/Excavator.pm @@ -17,7 +17,6 @@ use constant base_stealth => 0; use constant base_hold_size => 0; use constant build_tags => ['Exploration']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Body"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; with "Lacuna::Role::Ship::Arrive::Excavate"; diff --git a/lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm b/lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm index ab24e481..ef4424aa 100644 --- a/lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm +++ b/lib/Lacuna/DB/Result/Ships/ObservatorySeeker.pm @@ -18,7 +18,6 @@ use constant base_stealth => 2700; use constant target_building => 'Lacuna::DB::Result::Building::Observatory'; use constant build_tags => ['War']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Inhabited"; with "Lacuna::Role::Ship::Send::NotIsolationist"; diff --git a/lib/Lacuna/DB/Result/Ships/Scanner.pm b/lib/Lacuna/DB/Result/Ships/Scanner.pm index a2f8a783..1be2dae8 100644 --- a/lib/Lacuna/DB/Result/Ships/Scanner.pm +++ b/lib/Lacuna/DB/Result/Ships/Scanner.pm @@ -18,7 +18,6 @@ use constant base_stealth => 1850; use constant base_hold_size => 0; use constant build_tags => [qw(Exploration Intelligence)]; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; with "Lacuna::Role::Ship::Arrive::ScanSurface"; diff --git a/lib/Lacuna/DB/Result/Ships/Scow.pm b/lib/Lacuna/DB/Result/Ships/Scow.pm index 8aaf87c3..0a40f5ff 100644 --- a/lib/Lacuna/DB/Result/Ships/Scow.pm +++ b/lib/Lacuna/DB/Result/Ships/Scow.pm @@ -18,7 +18,6 @@ use constant base_stealth => 0; use constant base_hold_size => 2100; use constant build_tags => [qw(War Trade)]; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::PlanetAndStar"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; with "Lacuna::Role::Ship::Arrive::DumpWaste"; diff --git a/lib/Lacuna/DB/Result/Ships/SecurityMinistrySeeker.pm b/lib/Lacuna/DB/Result/Ships/SecurityMinistrySeeker.pm index 664ec05c..066fc54d 100644 --- a/lib/Lacuna/DB/Result/Ships/SecurityMinistrySeeker.pm +++ b/lib/Lacuna/DB/Result/Ships/SecurityMinistrySeeker.pm @@ -18,7 +18,6 @@ use constant base_stealth => 2700; use constant target_building => 'Lacuna::DB::Result::Building::Security'; use constant build_tags => ['War']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Inhabited"; with "Lacuna::Role::Ship::Send::NotIsolationist"; diff --git a/lib/Lacuna/DB/Result/Ships/ShortRangeColonyShip.pm b/lib/Lacuna/DB/Result/Ships/ShortRangeColonyShip.pm index 5ca91002..3814885a 100644 --- a/lib/Lacuna/DB/Result/Ships/ShortRangeColonyShip.pm +++ b/lib/Lacuna/DB/Result/Ships/ShortRangeColonyShip.pm @@ -19,7 +19,6 @@ use constant base_hold_size => 0; use constant pilotable => 1; use constant build_tags => ['Colonization']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Uninhabited"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; diff --git a/lib/Lacuna/DB/Result/Ships/Snark.pm b/lib/Lacuna/DB/Result/Ships/Snark.pm index 92f01fde..dae24995 100644 --- a/lib/Lacuna/DB/Result/Ships/Snark.pm +++ b/lib/Lacuna/DB/Result/Ships/Snark.pm @@ -18,7 +18,6 @@ use constant base_combat => 2000; use constant base_hold_size => 0; use constant build_tags => ['War']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Inhabited"; with "Lacuna::Role::Ship::Send::NotIsolationist"; diff --git a/lib/Lacuna/DB/Result/Ships/Snark2.pm b/lib/Lacuna/DB/Result/Ships/Snark2.pm index fb1eb2ec..5597023b 100644 --- a/lib/Lacuna/DB/Result/Ships/Snark2.pm +++ b/lib/Lacuna/DB/Result/Ships/Snark2.pm @@ -20,7 +20,6 @@ use constant build_tags => ['War']; use constant type_formatted => 'Snark II'; use constant splash_radius => 1; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Inhabited"; with "Lacuna::Role::Ship::Send::NotIsolationist"; diff --git a/lib/Lacuna/DB/Result/Ships/Snark3.pm b/lib/Lacuna/DB/Result/Ships/Snark3.pm index e057dbe4..f044817f 100644 --- a/lib/Lacuna/DB/Result/Ships/Snark3.pm +++ b/lib/Lacuna/DB/Result/Ships/Snark3.pm @@ -20,7 +20,6 @@ use constant build_tags => ['War']; use constant type_formatted => 'Snark III'; use constant splash_radius => 2; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Inhabited"; with "Lacuna::Role::Ship::Send::NotIsolationist"; diff --git a/lib/Lacuna/DB/Result/Ships/SpacePortSeeker.pm b/lib/Lacuna/DB/Result/Ships/SpacePortSeeker.pm index 473ef5be..d5c3a0f6 100644 --- a/lib/Lacuna/DB/Result/Ships/SpacePortSeeker.pm +++ b/lib/Lacuna/DB/Result/Ships/SpacePortSeeker.pm @@ -18,7 +18,6 @@ use constant base_stealth => 2700; use constant target_building => 'Lacuna::DB::Result::Building::SpacePort'; use constant build_tags => ['War']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Inhabited"; with "Lacuna::Role::Ship::Send::NotIsolationist"; diff --git a/lib/Lacuna/DB/Result/Ships/Stake.pm b/lib/Lacuna/DB/Result/Ships/Stake.pm index 36bf2ef4..58612cfe 100644 --- a/lib/Lacuna/DB/Result/Ships/Stake.pm +++ b/lib/Lacuna/DB/Result/Ships/Stake.pm @@ -19,7 +19,6 @@ use constant base_hold_size => 0; use constant pilotable => 0; use constant build_tags => ['Colonization']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Uninhabited"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; diff --git a/lib/Lacuna/DB/Result/Ships/Surveyor.pm b/lib/Lacuna/DB/Result/Ships/Surveyor.pm index d7b98ae2..14579265 100644 --- a/lib/Lacuna/DB/Result/Ships/Surveyor.pm +++ b/lib/Lacuna/DB/Result/Ships/Surveyor.pm @@ -18,7 +18,6 @@ use constant base_stealth => 3000; use constant base_hold_size => 0; use constant build_tags => [qw(Exploration Intelligence)]; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; with "Lacuna::Role::Ship::Arrive::SurveySurface"; diff --git a/lib/Lacuna/DB/Result/Ships/Sweeper.pm b/lib/Lacuna/DB/Result/Ships/Sweeper.pm index f80bc88b..517660c1 100644 --- a/lib/Lacuna/DB/Result/Ships/Sweeper.pm +++ b/lib/Lacuna/DB/Result/Ships/Sweeper.pm @@ -18,7 +18,6 @@ use constant base_stealth => 2800; use constant pilotable => 1; use constant build_tags => ['War']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Body"; with "Lacuna::Role::Ship::Send::NotIsolationist"; with "Lacuna::Role::Ship::Arrive::TriggerDefense"; diff --git a/lib/Lacuna/DB/Result/Ships/Thud.pm b/lib/Lacuna/DB/Result/Ships/Thud.pm index e22cbdd2..737afdca 100644 --- a/lib/Lacuna/DB/Result/Ships/Thud.pm +++ b/lib/Lacuna/DB/Result/Ships/Thud.pm @@ -18,7 +18,6 @@ use constant base_combat => 2100; use constant base_hold_size => 0; use constant build_tags => ['War']; -with "Lacuna::Role::Captcha::Ships"; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Inhabited"; with "Lacuna::Role::Ship::Send::NotIsolationist"; diff --git a/lib/Lacuna/RPC/Building/Intelligence.pm b/lib/Lacuna/RPC/Building/Intelligence.pm index be9d4226..214a4c10 100644 --- a/lib/Lacuna/RPC/Building/Intelligence.pm +++ b/lib/Lacuna/RPC/Building/Intelligence.pm @@ -6,8 +6,6 @@ no warnings qw(uninitialized); extends 'Lacuna::RPC::Building'; use Lacuna::Util qw(randint); -with 'Lacuna::Role::Captcha::Spies'; - sub app_url { return '/intelligence'; } @@ -79,6 +77,7 @@ sub assign_spy { my ($self, $session_id, $building_id, $spy_id, $assignment) = @_; my $empire = $self->get_empire_by_session($session_id); my $building = $self->get_building($empire, $building_id); + $empire->current_session->check_captcha; my $spy = $building->get_spy($spy_id); unless (defined $spy) { confess [1002, "Spy not found."]; diff --git a/lib/Lacuna/RPC/Building/SpacePort.pm b/lib/Lacuna/RPC/Building/SpacePort.pm index ace947e2..f72969bf 100644 --- a/lib/Lacuna/RPC/Building/SpacePort.pm +++ b/lib/Lacuna/RPC/Building/SpacePort.pm @@ -129,6 +129,7 @@ sub send_ship { my ($self, $session_id, $ship_id, $target_params) = @_; my $empire = $self->get_empire_by_session($session_id); my $target = $self->find_target($target_params); + $empire->current_session->check_captcha; my $ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->find($ship_id); unless (defined $ship) { confess [1002, 'Could not locate that ship.']; @@ -150,13 +151,11 @@ sub send_fleet { my ($self, $session_id, $ship_ids, $target_params) = @_; my $empire = $self->get_empire_by_session($session_id); my $target = $self->find_target($target_params); + $empire->current_session->check_captcha; my $max_ships = Lacuna->config->get('ships_per_fleet') || 10; if (@$ship_ids > $max_ships) { confess [1009, 'Too many ships for a fleet.']; } - unless ($empire->current_session->check_captcha()) { - confess [1016, 'Needs to solve a captcha.']; - } my @fleet; my $speed = 999999999; for my $ship_id (@$ship_ids) { diff --git a/lib/Lacuna/RPC/Building/Trade.pm b/lib/Lacuna/RPC/Building/Trade.pm index a140878a..00d5bb62 100644 --- a/lib/Lacuna/RPC/Building/Trade.pm +++ b/lib/Lacuna/RPC/Building/Trade.pm @@ -4,6 +4,7 @@ use Moose; use utf8; no warnings qw(uninitialized); extends 'Lacuna::RPC::Building'; +use Guard; with 'Lacuna::Role::TraderRpc'; @@ -86,19 +87,18 @@ sub accept_from_market { confess [1013, 'Another buyer has placed an offer on this trade. Please wait a few moments and try again.']; } $cache->set('trade_lock',$trade_id,1,5); + my $guard = scope_guard { + $cache->delete('trade_lock',$trade_id); + }; + my $empire = $self->get_empire_by_session($session_id); my $building = $self->get_building($empire, $building_id); confess [1013, 'You cannot use a trade ministry that has not yet been built.'] unless $building->level > 0; - # Replacing the old captchas for all but empire creation - unless ($empire->current_session->check_captcha()) { - $cache->delete('trade_lock',$trade_id); - confess [1016, 'Needs to solve a captcha.']; - } + $empire->current_session->check_captcha; my $trade = $building->market->find($trade_id); unless (defined $trade) { - $cache->delete('trade_lock',$trade_id); confess [1002, 'Could not find that trade. Perhaps it has already been accepted.',$trade_id]; } my $offer_ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->find($trade->ship_id); @@ -109,9 +109,11 @@ sub accept_from_market { my $body = $building->body; unless ($empire->essentia >= $trade->ask) { - $cache->delete('trade_lock',$trade_id); confess [1011, 'You need at least '.$trade->ask.' essentia to make this trade.'] } + + $guard->cancel; + $empire->spend_essentia($trade->ask, 'Trade Price')->update; $trade->body->empire->add_essentia($trade->ask, 'Trade Income')->update; #my $cargo_log = Lacuna->db->resultset('Lacuna::DB::Result::Log::Cargo'); diff --git a/lib/Lacuna/RPC/Building/Transporter.pm b/lib/Lacuna/RPC/Building/Transporter.pm index a127a6ed..4afb5963 100644 --- a/lib/Lacuna/RPC/Building/Transporter.pm +++ b/lib/Lacuna/RPC/Building/Transporter.pm @@ -4,6 +4,7 @@ use Moose; use utf8; no warnings qw(uninitialized); extends 'Lacuna::RPC::Building'; +use Guard; with 'Lacuna::Role::TraderRpc'; @@ -101,30 +102,30 @@ sub accept_from_market { confess [1013, 'Another buyer has placed an offer on this trade. Please wait a few moments and try again.']; } $cache->set('trade_lock',$trade_id,1,5); + my $guard = scope_guard { + $cache->delete('trade_lock',$trade_id); + }; + my $empire = $self->get_empire_by_session($session_id); my $building = $self->get_building($empire, $building_id); confess [1013, 'You cannot use a transporter that has not yet been built.'] unless $building->level > 0; - # Replacing the old captchas for all but empire creation - unless ($empire->current_session->check_captcha()) { - $cache->delete('trade_lock',$trade_id); - confess [1016, 'Needs to solve a captcha.']; - } + $empire->current_session->check_captcha; my $trade = $building->market->find($trade_id); unless (defined $trade) { - $cache->delete('trade_lock',$trade_id); confess [1002, 'Could not find that trade. Perhaps it has already been accepted.', $trade_id]; } unless ($building->determine_available_cargo_space >= $trade->ask) { - $cache->delete('trade_lock',$trade_id); confess [1011, 'This transporter has a maximum load size of '.$building->determine_available_cargo_space.'.']; } my $body = $building->body; unless ($empire->essentia >= $trade->ask + 1) { - $cache->delete('trade_lock',$trade_id); confess [1011, 'You need '.($trade->ask + 1).' essentia to make this trade.'] } + + $guard->cancel; + $empire->spend_essentia($trade->ask + 1, 'Trade Price and Transporter Cost')->update; $trade->body->empire->add_essentia($trade->ask, 'Trade Income')->update; #my $cargo_log = Lacuna->db->resultset('Lacuna::DB::Result::Log::Cargo'); diff --git a/lib/Lacuna/Role/Ship/Send/LoadWithSpies.pm b/lib/Lacuna/Role/Ship/Send/LoadWithSpies.pm index 2b764970..57c42a29 100644 --- a/lib/Lacuna/Role/Ship/Send/LoadWithSpies.pm +++ b/lib/Lacuna/Role/Ship/Send/LoadWithSpies.pm @@ -3,8 +3,6 @@ package Lacuna::Role::Ship::Send::LoadWithSpies; use strict; use Moose::Role; -with 'Lacuna::Role::Captcha::Ships'; - after send => sub { my $self = shift; return if $self->payload->{spies}[0]; diff --git a/lib/Lacuna/Session.pm b/lib/Lacuna/Session.pm index 2ed12b00..fbf03f9f 100644 --- a/lib/Lacuna/Session.pm +++ b/lib/Lacuna/Session.pm @@ -64,14 +64,12 @@ has empire => ( ); sub check_captcha { - my $self = shift; - my $valid = Lacuna->cache->get('captcha_valid', $self->id); - if ( defined $valid && $valid ) { - return 1; - } - else { - return undef; - } + my $self = shift; + my $valid = Lacuna->cache->get('captcha_valid', $self->id); + if ( defined $valid && $valid ) { + return 1; + } + confess [1016,'Needs to solve a captcha.']; } sub extend { diff --git a/t/Captcha.t b/t/Captcha.t index 6d155a57..8c2b10a2 100644 --- a/t/Captcha.t +++ b/t/Captcha.t @@ -9,10 +9,10 @@ $tester->cleanup; my $session_id = $tester->session->id; my $home_planet = $tester->empire->home_planet_id; +Lacuna->cache->delete( 'captcha', $session_id ); + my $result; -unless ($tester->session->check_captcha()) { - ok( 'Needs to solve a captcha' ); -} +ok( ! eval { $tester->session->check_captcha }, "captcha required initially" ); $result = $tester->post('captcha','fetch', [ $session_id ]); ok( exists $result->{result}{guid}, 'Fetch captcha returned guid' ); @@ -23,7 +23,7 @@ Lacuna->cache->set( 'captcha', $session_id, { guid => 1111, solution => 1111 }, $result = $tester->post( 'captcha','solve', [ $session_id, 1111, 1111 ] ); is( $result->{result}, 1, 'Solved captcha' ); -is( $tester->empire->current_session->check_captcha(), 1, 'Captcha is valid' ); +ok ( eval {$tester->session->check_captcha } , 'Captcha is valid' ); END { $tester->cleanup; -- 2.51.2 From 94e8c88f4877ff0ba6234c5dae742026edc6f41f Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 8 Mar 2011 12:36:05 -0600 Subject: [PATCH 4/9] wrong cardinal coord --- lib/Lacuna/DB/Result/Building/SSLa.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/DB/Result/Building/SSLa.pm b/lib/Lacuna/DB/Result/Building/SSLa.pm index 4a748c9c..6ae00801 100644 --- a/lib/Lacuna/DB/Result/Building/SSLa.pm +++ b/lib/Lacuna/DB/Result/Building/SSLa.pm @@ -52,7 +52,7 @@ before 'can_demolish' => sub { before can_build => sub { my $self = shift; - if ($self->x == 5 || $self->y == 5 || (($self->y == -1 || $self->y == 0) && ($self->x == -1 && $self->x == 0))) { + if ($self->x == 5 || $self->y == 5 || (($self->y == 1 || $self->y == 0) && ($self->x == -1 && $self->x == 0))) { confess [1009, 'Space Station Lab cannot be placed in that location.']; } }; -- 2.51.2 From 9a84d63a22efe780195acc9b7f80302f5649ecb6 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 8 Mar 2011 12:44:59 -0600 Subject: [PATCH 5/9] && where || needed --- lib/Lacuna/DB/Result/Building/SSLa.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/DB/Result/Building/SSLa.pm b/lib/Lacuna/DB/Result/Building/SSLa.pm index 6ae00801..c1fa57bc 100644 --- a/lib/Lacuna/DB/Result/Building/SSLa.pm +++ b/lib/Lacuna/DB/Result/Building/SSLa.pm @@ -52,7 +52,7 @@ before 'can_demolish' => sub { before can_build => sub { my $self = shift; - if ($self->x == 5 || $self->y == 5 || (($self->y == 1 || $self->y == 0) && ($self->x == -1 && $self->x == 0))) { + if ($self->x == 5 || $self->y == 5 || (($self->y == 1 || $self->y == 0) && ($self->x == -1 || $self->x == 0))) { confess [1009, 'Space Station Lab cannot be placed in that location.']; } }; -- 2.51.2 From bb244b6dd7e72c35caeb966d81aea562d2430d5f Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 8 Mar 2011 12:47:33 -0600 Subject: [PATCH 6/9] better description --- var/www/public/resources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/var/www/public/resources.json b/var/www/public/resources.json index 82d9e7b3..f48401f7 100644 --- a/var/www/public/resources.json +++ b/var/www/public/resources.json @@ -1,6 +1,6 @@ { "buildings" : { - "/ssla" : { "description" : "Allows the construction of Space Station Lab modules.", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, + "/ssla" : { "description" : "Allows the construction of Space Station Lab modules. Requires four plots, and this is the top left corner of the building.", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, "/sslb" : { "description" : "Infrastructure required to support Space Station Lab (A).", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, "/sslc" : { "description" : "Infrastructure required to support Space Station Lab (A).", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, "/ssld" : { "description" : "Infrastructure required to support Space Station Lab (A).", "wiki" : "http://community.lacunaexpanse.com/wiki/space-station-lab" }, -- 2.51.2 From 9618fd3add331bb45ddf34fbbdb8ad3e097a42ed Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 8 Mar 2011 13:57:34 -0600 Subject: [PATCH 7/9] simplify lacuna.psgi --- bin/lacuna.psgi | 416 ++++++++++++++++++++++++------------------------ 1 file changed, 211 insertions(+), 205 deletions(-) diff --git a/bin/lacuna.psgi b/bin/lacuna.psgi index f9e36dff..83086270 100644 --- a/bin/lacuna.psgi +++ b/bin/lacuna.psgi @@ -6,6 +6,7 @@ use Log::Log4perl; use Log::Any::Adapter; use Lacuna; use Plack::Builder; +use JSON qw(encode_json); $|=1; @@ -16,216 +17,221 @@ use Log::Log4perl; Log::Log4perl::init('/data/Lacuna-Server/etc/log4perl.conf'); Log::Any::Adapter->set('Log::Log4perl'); -my $urlmap = Plack::App::URLMap->new; - -$urlmap->map('/starman_ping' => sub { [200, [ 'Content-Type' => 'text/plain'], [ 'pong' ]] } ); - -$urlmap->map("/map" => Lacuna::RPC::Map->new->to_app); -$urlmap->map("/body" => Lacuna::RPC::Body->new->to_app); -$urlmap->map("/empire" => Lacuna::RPC::Empire->new->to_app); -$urlmap->map("/alliance" => Lacuna::RPC::Alliance->new->to_app); -$urlmap->map("/inbox" => Lacuna::RPC::Inbox->new->to_app); -$urlmap->map("/stats" => Lacuna::RPC::Stats->new->to_app); -$urlmap->map("/pay" => Lacuna::Web::Pay->new->to_app); -$urlmap->map("/chat" => Lacuna::Web::Chat->new->to_app); -$urlmap->map("/chat/rpc" => Lacuna::RPC::Chat->new->to_app); -$urlmap->map("/entertainment/vote" => Lacuna::Web::EntertainmentVote->new->to_app); -$urlmap->map("/announcement" => Lacuna::Web::Announcement->new->to_app); -$urlmap->map("/facebook" => Lacuna::Web::Facebook->new->to_app); -$urlmap->map("/apikey" => Lacuna::Web::ApiKey->new->to_app); -$urlmap->map("/essentia-code" => Lacuna::RPC::EssentiaCode->new->to_app); -$urlmap->map("/captcha" => Lacuna::RPC::Captcha->new->to_app); - -# buildings -$urlmap->map(Lacuna::RPC::Building::DistributionCenter->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SAW->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::AtmosphericEvaporator->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::GreatBallOfJunk->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::JunkHengeSculpture->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::MetalJunkArches->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::PyramidJunkSculpture->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SpaceJunkPark->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::ThemePark->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::BlackHoleGenerator->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::TheDillonForge->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::HallsOfVrbansk->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::GratchsGauntlet->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::KasternsKeep->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SubspaceSupplyDepot->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SupplyPod->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::PantheonOfHagness->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Capitol->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Stockpile->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Algae->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Apple->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Bean->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beeldeban->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Bread->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Burger->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Cheese->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Chip->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Cider->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Corn->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::CornMeal->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::EssentiaVein->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Volcano->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::MassadsHenge->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::LibraryOfJith->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::NaturalSpring->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::OracleOfAnid->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::TempleOfTheDrajilites->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::GeoThermalVent->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::InterDimensionalRift->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::CitadelOfKnope->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::CrashedShipSite->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::KalavianRuins->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Grove->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Sand->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Lagoon->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Crater->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Dairy->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Denton->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Development->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Embassy->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::EnergyReserve->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Entertainment->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Espionage->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Fission->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::FoodReserve->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Fusion->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::DeployedBleeder->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::GasGiantLab->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::GasGiantPlatform->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Geo->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Hydrocarbon->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Intelligence->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Lapis->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Malcud->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Mine->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::MiningMinistry->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Network19->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Observatory->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::OreRefinery->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::OreStorage->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Pancake->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Park->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Pie->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::PlanetaryCommand->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Potato->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Propulsion->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Oversight->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::RockyOutcrop->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Lake->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Security->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Shake->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Shipyard->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Singularity->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Soup->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SpacePort->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Syrup->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::TerraformingLab->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::GeneticsLab->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Archaeology->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::TerraformingPlatform->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Trade->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Transporter->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::University->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WasteEnergy->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WasteRecycling->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WasteSequestration->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WasteDigester->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WasteTreatment->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WaterProduction->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WaterPurification->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WaterReclamation->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::WaterStorage->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Wheat->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach1->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach2->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach3->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach4->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach5->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach6->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach7->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach8->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach9->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach10->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach11->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach12->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Beach13->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::PilotTraining->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::MissionCommand->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::CloakingLab->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::MunitionsLab->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::LuxuryHousing->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::Ravine->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::AlgaePond->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::LapisForest->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::BeeldebanNest->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::MalcudField->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SSLa->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SSLb->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SSLc->new->to_app_with_url); -$urlmap->map(Lacuna::RPC::Building::SSLd->new->to_app_with_url); - - -# admin -my $admin = builder { - enable "Auth::Basic", authenticator => sub { - my ($username, $password) = @_; - return 0 unless $username; - my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name => $username, is_admin => 1},{rows=>1})->single; - return 0 unless defined $empire; - return $empire->is_password_valid($password); - }; - Lacuna::Web::Admin->new->to_app; -}; -$urlmap->map("/admin" => $admin); - -# mission curator -my $curator = builder { - enable "Auth::Basic", authenticator => sub { - my ($username, $password) = @_; - return 0 unless $username; - my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name => $username, is_mission_curator => 1},{rows=>1})->single; - return 0 unless defined $empire; - return $empire->is_password_valid($password); - }; - Lacuna::Web::MissionCurator->new->to_app; -}; -$urlmap->map("/missioncurator" => $curator); - -my $online = builder { +my $offline = [ 500, + [ 'Content-Type' => 'application/json-rpc' ], + [ encode_json( { + "jsonrpc" => "2.0", + "error" => { + "code" => -32000, + "message" => "The server is offline for maintenance.", + } + } ) ], +]; + +my $gameover = [ 500, + [ 'Content-Type' => 'application/json-rpc' ], + [ encode_json( { + "jsonrpc" => "2.0", + "error" => { + "code" => 1200, + "message" => "Game Over", + "data" => "http://community.lacunaexanse.com/wiki/hall-of-fame", + } + } ) ], +]; + +builder { enable 'CrossOrigin', origins => '*', methods => ['GET', 'POST'], max_age => 60*60*24*30, headers => '*'; - $urlmap->to_app; -}; - -my $offline = [ 500, - ['Content-Type' => 'application/json-rpc' ], - [ '{"jsonrpc" : "2.0", "error" : { "code" : "-32000", "message" : "The server is offline for maintenance." }}' ], - ]; -my $gameover = [ 1200, - ['Content-Type' => 'application/json-rpc' ], - [ '{"jsonrpc" : "2.0", "error" : { "code" : "1200", "message" : "Game Over", "data" : "http://community.lacunaexanse.com/wiki/hall-of-fame" }}' ], - ]; + enable sub { + my $app = shift; + return sub { + my ($env) = @_; + my $status = Lacuna->cache->get('server','status'); + if ($status eq 'Offline') { + return $offline; + } + elsif ($status eq 'Game Over') { + return $gameover; + } + $app->($env); + } + }; -print "Server Up\n"; -my $app = sub { - my @args = @_; - my $status = Lacuna->cache->get('server','status'); - if ($status eq 'Offline') { - return $offline; - } - elsif ($status eq 'Game Over') { - return $gameover; + mount '/starman_ping' => sub { [200, [ 'Content-Type' => 'text/plain'], [ 'pong' ]] }; + + mount "/map" => Lacuna::RPC::Map->new->to_app; + mount "/body" => Lacuna::RPC::Body->new->to_app; + mount "/empire" => Lacuna::RPC::Empire->new->to_app; + mount "/alliance" => Lacuna::RPC::Alliance->new->to_app; + mount "/inbox" => Lacuna::RPC::Inbox->new->to_app; + mount "/stats" => Lacuna::RPC::Stats->new->to_app; + mount "/pay" => Lacuna::Web::Pay->new->to_app; + mount "/chat" => Lacuna::Web::Chat->new->to_app; + mount "/chat/rpc" => Lacuna::RPC::Chat->new->to_app; + mount "/entertainment/vote" => Lacuna::Web::EntertainmentVote->new->to_app; + mount "/announcement" => Lacuna::Web::Announcement->new->to_app; + mount "/facebook" => Lacuna::Web::Facebook->new->to_app; + mount "/apikey" => Lacuna::Web::ApiKey->new->to_app; + mount "/essentia-code" => Lacuna::RPC::EssentiaCode->new->to_app; + mount "/captcha" => Lacuna::RPC::Captcha->new->to_app; + + for my $building (qw( + Lacuna::RPC::Building::DistributionCenter + Lacuna::RPC::Building::SAW + Lacuna::RPC::Building::AtmosphericEvaporator + Lacuna::RPC::Building::GreatBallOfJunk + Lacuna::RPC::Building::JunkHengeSculpture + Lacuna::RPC::Building::MetalJunkArches + Lacuna::RPC::Building::PyramidJunkSculpture + Lacuna::RPC::Building::SpaceJunkPark + Lacuna::RPC::Building::ThemePark + Lacuna::RPC::Building::BlackHoleGenerator + Lacuna::RPC::Building::TheDillonForge + Lacuna::RPC::Building::HallsOfVrbansk + Lacuna::RPC::Building::GratchsGauntlet + Lacuna::RPC::Building::KasternsKeep + Lacuna::RPC::Building::SubspaceSupplyDepot + Lacuna::RPC::Building::SupplyPod + Lacuna::RPC::Building::PantheonOfHagness + Lacuna::RPC::Building::Capitol + Lacuna::RPC::Building::Stockpile + Lacuna::RPC::Building::Algae + Lacuna::RPC::Building::Apple + Lacuna::RPC::Building::Bean + Lacuna::RPC::Building::Beeldeban + Lacuna::RPC::Building::Bread + Lacuna::RPC::Building::Burger + Lacuna::RPC::Building::Cheese + Lacuna::RPC::Building::Chip + Lacuna::RPC::Building::Cider + Lacuna::RPC::Building::Corn + Lacuna::RPC::Building::CornMeal + Lacuna::RPC::Building::EssentiaVein + Lacuna::RPC::Building::Volcano + Lacuna::RPC::Building::MassadsHenge + Lacuna::RPC::Building::LibraryOfJith + Lacuna::RPC::Building::NaturalSpring + Lacuna::RPC::Building::OracleOfAnid + Lacuna::RPC::Building::TempleOfTheDrajilites + Lacuna::RPC::Building::GeoThermalVent + Lacuna::RPC::Building::InterDimensionalRift + Lacuna::RPC::Building::CitadelOfKnope + Lacuna::RPC::Building::CrashedShipSite + Lacuna::RPC::Building::KalavianRuins + Lacuna::RPC::Building::Grove + Lacuna::RPC::Building::Sand + Lacuna::RPC::Building::Lagoon + Lacuna::RPC::Building::Crater + Lacuna::RPC::Building::Dairy + Lacuna::RPC::Building::Denton + Lacuna::RPC::Building::Development + Lacuna::RPC::Building::Embassy + Lacuna::RPC::Building::EnergyReserve + Lacuna::RPC::Building::Entertainment + Lacuna::RPC::Building::Espionage + Lacuna::RPC::Building::Fission + Lacuna::RPC::Building::FoodReserve + Lacuna::RPC::Building::Fusion + Lacuna::RPC::Building::DeployedBleeder + Lacuna::RPC::Building::GasGiantLab + Lacuna::RPC::Building::GasGiantPlatform + Lacuna::RPC::Building::Geo + Lacuna::RPC::Building::Hydrocarbon + Lacuna::RPC::Building::Intelligence + Lacuna::RPC::Building::Lapis + Lacuna::RPC::Building::Malcud + Lacuna::RPC::Building::Mine + Lacuna::RPC::Building::MiningMinistry + Lacuna::RPC::Building::Network19 + Lacuna::RPC::Building::Observatory + Lacuna::RPC::Building::OreRefinery + Lacuna::RPC::Building::OreStorage + Lacuna::RPC::Building::Pancake + Lacuna::RPC::Building::Park + Lacuna::RPC::Building::Pie + Lacuna::RPC::Building::PlanetaryCommand + Lacuna::RPC::Building::Potato + Lacuna::RPC::Building::Propulsion + Lacuna::RPC::Building::Oversight + Lacuna::RPC::Building::RockyOutcrop + Lacuna::RPC::Building::Lake + Lacuna::RPC::Building::Security + Lacuna::RPC::Building::Shake + Lacuna::RPC::Building::Shipyard + Lacuna::RPC::Building::Singularity + Lacuna::RPC::Building::Soup + Lacuna::RPC::Building::SpacePort + Lacuna::RPC::Building::Syrup + Lacuna::RPC::Building::TerraformingLab + Lacuna::RPC::Building::GeneticsLab + Lacuna::RPC::Building::Archaeology + Lacuna::RPC::Building::TerraformingPlatform + Lacuna::RPC::Building::Trade + Lacuna::RPC::Building::Transporter + Lacuna::RPC::Building::University + Lacuna::RPC::Building::WasteEnergy + Lacuna::RPC::Building::WasteRecycling + Lacuna::RPC::Building::WasteSequestration + Lacuna::RPC::Building::WasteDigester + Lacuna::RPC::Building::WasteTreatment + Lacuna::RPC::Building::WaterProduction + Lacuna::RPC::Building::WaterPurification + Lacuna::RPC::Building::WaterReclamation + Lacuna::RPC::Building::WaterStorage + Lacuna::RPC::Building::Wheat + Lacuna::RPC::Building::Beach1 + Lacuna::RPC::Building::Beach2 + Lacuna::RPC::Building::Beach3 + Lacuna::RPC::Building::Beach4 + Lacuna::RPC::Building::Beach5 + Lacuna::RPC::Building::Beach6 + Lacuna::RPC::Building::Beach7 + Lacuna::RPC::Building::Beach8 + Lacuna::RPC::Building::Beach9 + Lacuna::RPC::Building::Beach10 + Lacuna::RPC::Building::Beach11 + Lacuna::RPC::Building::Beach12 + Lacuna::RPC::Building::Beach13 + Lacuna::RPC::Building::PilotTraining + Lacuna::RPC::Building::MissionCommand + Lacuna::RPC::Building::CloakingLab + Lacuna::RPC::Building::MunitionsLab + Lacuna::RPC::Building::LuxuryHousing + Lacuna::RPC::Building::Ravine + Lacuna::RPC::Building::AlgaePond + Lacuna::RPC::Building::LapisForest + Lacuna::RPC::Building::BeeldebanNest + Lacuna::RPC::Building::MalcudField + Lacuna::RPC::Building::SSLa + Lacuna::RPC::Building::SSLb + Lacuna::RPC::Building::SSLc + Lacuna::RPC::Building::SSLd + )) { + mount $building->new->to_app_with_url; } - else { - return $online->(@args); - } -}; -$app; + mount '/admin' => builder { + enable "Auth::Basic", authenticator => sub { + my ($username, $password) = @_; + return 0 unless $username; + my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name => $username, is_admin => 1},{rows=>1})->single; + return 0 unless defined $empire; + return $empire->is_password_valid($password); + }; + Lacuna::Web::Admin->new->to_app; + }; + mount "/missioncurator" => builder { + enable "Auth::Basic", authenticator => sub { + my ($username, $password) = @_; + return 0 unless $username; + my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name => $username, is_mission_curator => 1},{rows=>1})->single; + return 0 unless defined $empire; + return $empire->is_password_valid($password); + }; + Lacuna::Web::MissionCurator->new->to_app; + }; +}; -- 2.51.2 From 468bfad7d700a8c45edbe0e8d2e9cda37802d673 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 8 Mar 2011 14:59:36 -0600 Subject: [PATCH 8/9] don't allow trading a fraction of a resource --- lib/Lacuna/Role/Trader.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Lacuna/Role/Trader.pm b/lib/Lacuna/Role/Trader.pm index 64f76613..efc9f52d 100644 --- a/lib/Lacuna/Role/Trader.pm +++ b/lib/Lacuna/Role/Trader.pm @@ -9,6 +9,7 @@ my $have_exception = [1011, 'You cannot offer to trade something you do not have my $cargo_exception = 'You need %s cargo space to trade that.'; my $offer_nothing_exception = [1013, 'It appears that you have offered nothing.']; my $ask_nothing_exception = [1013, 'It appears that you have asked for nothing.']; +my $fractional_offer_exception = [1013, 'You cannot offer a fraction of a resource.']; sub market { return Lacuna->db->resultset('Lacuna::DB::Result::Market'); @@ -44,6 +45,7 @@ sub check_payload { given($item->{type}) { when ([qw(water energy waste), ORE_TYPES, FOOD_TYPES]) { confess $offer_nothing_exception unless ($item->{quantity} > 0); + confess $fractional_offer_exception if ($item->{quantity} != int($item->{quantity})); confess $have_exception unless ($body->type_stored($item->{type}) >= $item->{quantity}); $space_used += $item->{quantity}; } -- 2.51.2 From b0e1548995240d0eb6ee81c890663cb5ad21e79e Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 8 Mar 2011 15:15:57 -0600 Subject: [PATCH 9/9] fix ship stealth calculation --- lib/Lacuna/DB/Result/Building/Shipyard.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Shipyard.pm b/lib/Lacuna/DB/Result/Building/Shipyard.pm index 9dfa4fb3..aa804191 100644 --- a/lib/Lacuna/DB/Result/Building/Shipyard.pm +++ b/lib/Lacuna/DB/Result/Building/Shipyard.pm @@ -274,8 +274,8 @@ sub set_ship_hold_size { sub set_ship_stealth { my ($self, $ship) = @_; - my $cloaking_level = (defined $self->cloaking_lab) ? $self->cloaking_lab->level : 1; - my $ptf = ($ship->pilotable && defined $self->pilot_training_facility) ? $self->pilot_training_facility->level : 1; + my $cloaking_level = (defined $self->cloaking_lab) ? $self->cloaking_lab->level : 0; + my $ptf = ($ship->pilotable && defined $self->pilot_training_facility) ? $self->pilot_training_facility->level : 0; my $css_level = (defined $self->crashed_ship_site) ? $self->crashed_ship_site->level : 0; my $improvement = 1 + ($self->level * 0.01) + ($ptf * 0.03) + ($cloaking_level * 0.05) + ($css_level * 0.05) + ($self->body->empire->deception_affinity * 0.03); $ship->stealth(sprintf('%.0f', $ship->base_stealth * $improvement )); -- 2.51.2