Permalink
Browse files

Updated for auto succeed at an E cost. Named args needed for API.

  • Loading branch information...
1 parent 85ece35 commit e170a0d189bc378b9b22480b5cba884574e4ea92 @lemming552 lemming552 committed Sep 25, 2012
Showing with 31 additions and 17 deletions.
  1. +29 −16 examples/blackhole.pl
  2. +2 −1 lib/Games/Lacuna/Client/Buildings/BlackHoleGenerator.pm
View
@@ -34,6 +34,7 @@
'change_type=i',
'swap_places',
'subsidize_cool',
+ 'succeed',
'view',
'actions',
);
@@ -155,23 +156,34 @@
elsif ($opts{actions}) {
$bhg_out = $bhg->get_actions_for($target);
}
- elsif ($opts{make_planet}) {
- $bhg_out = $bhg->generate_singularity($target, "Make Planet");
- }
- elsif ($opts{make_asteroid}) {
- $bhg_out = $bhg->generate_singularity($target, "Make Asteroid");
- }
- elsif ($opts{increase_size}) {
- $bhg_out = $bhg->generate_singularity($target, "Increase Size");
- }
- elsif ($opts{change_type}) {
- $bhg_out = $bhg->generate_singularity($target, "Change Type", $params);
- }
- elsif ($opts{swap_places}) {
- $bhg_out = $bhg->generate_singularity($target, "Swap Places");
- }
else {
- die "Nothing to do!\n";
+ my $args = {};
+ if ($opts{make_planet}) {
+ $args->{task_name} = "Make Planet";
+ }
+ elsif ($opts{make_asteroid}) {
+ $args->{task_name} = "Make Asteroid";
+ }
+ elsif ($opts{increase_size}) {
+ $args->{task_name} = "Increase Size";
+ }
+ elsif ($opts{change_type}) {
+ $args->{task_name} = "Change Type";
+ $args->{params} = $params;
+ }
+ elsif ($opts{swap_places}) {
+ $args->{task_name} = "Swap Places";
+ }
+ else {
+ die "Nothing to do!\n";
+ }
+ if ($opts{succeed}) {
+ $args->{subsidize} = 1;
+ }
+ $args->{target} = $target;
+ $args->{session_id} = $glc->{session_id};
+ $args->{building_id} = $bhg_id;
+ $bhg_out = $bhg->generate_singularity($args);
}
print $ofh $json->pretty->canonical->encode($bhg_out);
@@ -233,6 +245,7 @@ sub usage {
--view View options
--actions View statistics for possible actions with designated target
--subsidize_cool Subsidize Cooldown of BHG costing 2e, but allowing immediate reuse.
+ --succeed Automatically succeed. Use --actions for E cost.
END_USAGE
@@ -11,7 +11,8 @@ our @ISA = qw(Games::Lacuna::Client::Buildings);
sub api_methods {
return {
- generate_singularity => { default_args => [qw(session_id building_id)] },
+# generate_singularity => { default_args => [qw(session_id building_id)] },
+ generate_singularity => { },
get_actions_for => { default_args => [qw(session_id building_id)] },
subsidize_cooldown => { default_args => [qw(session_id building_id)] },
};

0 comments on commit e170a0d

Please sign in to comment.