diff --git a/bin/clean_up_empires.pl b/bin/clean_up_empires.pl index c0f41cd2..29d035ff 100644 --- a/bin/clean_up_empires.pl +++ b/bin/clean_up_empires.pl @@ -86,7 +86,7 @@ while (my $empire = $inactives->next) { out('Updating Viral Log'); my $viral_log = $db->resultset('Lacuna::DB::Result::Log::Viral'); -my $add_deletes = $viral_log->search({date_stamp => format_date($start,'%F')},{rows=>1})->single; +my $add_deletes = $viral_log->search({date_stamp => format_date($start,'%F')})->first; unless (defined $add_deletes) { $add_deletes = $viral_log->new({date_stamp => format_date($start,'%F')})->insert; } @@ -98,7 +98,7 @@ $add_deletes->update({ }); my $cache = Lacuna->cache; my $create_date = format_date($start->clone->subtract(hours => 1),'%F'); -my $add_creates = $viral_log->search({date_stamp => $create_date},{rows=>1})->single; +my $add_creates = $viral_log->search({date_stamp => $create_date})->first; unless (defined $add_deletes) { $add_creates = $viral_log->new({date_stamp => $create_date})->insert; } diff --git a/bin/cult/add_colonies.pl b/bin/cult/add_colonies.pl index 195a3638..b68f05b4 100644 --- a/bin/cult/add_colonies.pl +++ b/bin/cult/add_colonies.pl @@ -49,7 +49,7 @@ if ($respawn) { my $test; do { $test = $db->resultset('Lacuna::DB::Result::Map::Body')->search({ - name => $pname })->single; + name => $pname })->first; if ($test) { $orbit++; $pname = $planet->star->name." ".$orbit; diff --git a/bin/delambert/add_colonies.pl b/bin/delambert/add_colonies.pl index ff74fcda..589eeec8 100644 --- a/bin/delambert/add_colonies.pl +++ b/bin/delambert/add_colonies.pl @@ -176,7 +176,7 @@ for my $level(@build_levels) { class => {-like => ['%Planet::GasGiant::G%','%:Planet::P%']}, -and => [size => {'>=' => $sizes->{$level}[0]}, size => {'<' => $sizes->{$level}[1] }], orbit => {'<' => 8}, - },{rows=>1})->single; + })->first; next STAR if not $body; out("Putting colony in star system ".$star->name); last STAR; @@ -240,7 +240,7 @@ sub create_empire { size => { '>=' => 110}, zone => $zone, empire_id => undef, - },{rows=>1})->single; + })->first; $empire->insert; $home->delete_buildings(@{$home->building_cache}); diff --git a/bin/draw_star_map.pl b/bin/draw_star_map.pl index a25a85a2..66bfffe7 100644 --- a/bin/draw_star_map.pl +++ b/bin/draw_star_map.pl @@ -9,7 +9,7 @@ my $bodies = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body'); for (my $y = 15; $y > -15; $y--) { foreach (my $x = 15; $x > -15; $x--) { my $star = $stars->search({x=>$x, y=>$y})->count; - my $body = $bodies->search({x=>$x, y=>$y},{rows=>1})->single; + my $body = $bodies->search({x=>$x, y=>$y})->first; if ($star) { print "*"; } diff --git a/bin/lacuna.psgi b/bin/lacuna.psgi index 37c15ee9..18f179a2 100644 --- a/bin/lacuna.psgi +++ b/bin/lacuna.psgi @@ -243,7 +243,7 @@ my $app = 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; + my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name => $username, is_admin => 1})->first; return 0 unless defined $empire; return $empire->is_password_valid($password); }; @@ -254,7 +254,7 @@ my $app = 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; + my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name => $username, is_mission_curator => 1})->first; return 0 unless defined $empire; return $empire->is_password_valid($password); }; diff --git a/bin/mission_check.pl b/bin/mission_check.pl index ebbf5e57..2e188a36 100644 --- a/bin/mission_check.pl +++ b/bin/mission_check.pl @@ -34,7 +34,7 @@ use utf8; out('Loading DB'); our $db = Lacuna->db; - my $emp = $db->resultset('Empire')->search({id => $empire_id})->single; + my $emp = $db->resultset('Empire')->find($empire_id); die "No empire with id:$empire_id found\n" unless $emp; diff --git a/bin/saben/create_colony.pl b/bin/saben/create_colony.pl index 784f612a..fedcfbe1 100644 --- a/bin/saben/create_colony.pl +++ b/bin/saben/create_colony.pl @@ -34,9 +34,8 @@ die 'Could not find target player.' unless defined $target_player; out('Finding colony...'); my $body = $db->resultset('Lacuna::DB::Result::Map::Body')->search( - { zone => $target_player->home_planet->zone, empire_id => undef, size => { between => [30,35]}}, - { rows => 1 } - )->single; + { zone => $target_player->home_planet->zone, empire_id => undef, size => { between => [30,35]}} + )->first; die 'Could not find a colony to occupy.' unless defined $body; say $body->name; diff --git a/bin/saben/create_colony2.pl b/bin/saben/create_colony2.pl index 29d56258..b59e3fc3 100644 --- a/bin/saben/create_colony2.pl +++ b/bin/saben/create_colony2.pl @@ -36,9 +36,8 @@ out('Finding colony...'); my $bodies = $db->resultset('Lacuna::DB::Result::Map::Body'); my $target_home = $target_player->home_planet; my $body = $bodies->search( - { x => {between => [ $target_home->x - 25, $target_home->x + 25 ]}, y => { between => [ $target_home->y - 25, $target_home->y + 25 ] }, empire_id => undef, size => { between => [30,35]}}, - { rows => 1 } - )->single; + { x => {between => [ $target_home->x - 25, $target_home->x + 25 ]}, y => { between => [ $target_home->y - 25, $target_home->y + 25 ] }, empire_id => undef, size => { between => [30,35]}} + )->first; die 'Could not find a colony to occupy.' unless defined $body; say $body->name; diff --git a/bin/saben/create_colony3.pl b/bin/saben/create_colony3.pl index 66f536d2..f8b31320 100644 --- a/bin/saben/create_colony3.pl +++ b/bin/saben/create_colony3.pl @@ -36,9 +36,8 @@ out('Finding colony...'); my $bodies = $db->resultset('Lacuna::DB::Result::Map::Body'); my $target_home = $target_player->home_planet; my $body = $bodies->search( - { x => {between => [ $target_home->x - 25, $target_home->x + 25 ]}, y => { between => [ $target_home->y - 25, $target_home->y + 25 ] }, empire_id => undef, size => { between => [30,35]}}, - { rows => 1 } - )->single; + { x => {between => [ $target_home->x - 25, $target_home->x + 25 ]}, y => { between => [ $target_home->y - 25, $target_home->y + 25 ] }, empire_id => undef, size => { between => [30,35]}} + )->first; die 'Could not find a colony to occupy.' unless defined $body; say $body->name; diff --git a/bin/saben/create_empire.pl b/bin/saben/create_empire.pl index b0a8cbfa..bf8df964 100644 --- a/bin/saben/create_empire.pl +++ b/bin/saben/create_empire.pl @@ -49,7 +49,7 @@ my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->new({ out('Find home planet...'); my $bodies = $db->resultset('Lacuna::DB::Result::Map::Body'); my $zone = $bodies->get_column('zone')->max; -my $home = $bodies->search({size => 35, zone => $zone },{rows=>1})->single; +my $home = $bodies->search({size => 35, zone => $zone })->first; $empire->insert; $empire->found($home); diff --git a/bin/saben/orig_send_attack.pl b/bin/saben/orig_send_attack.pl index 551a56ad..93f33858 100644 --- a/bin/saben/orig_send_attack.pl +++ b/bin/saben/orig_send_attack.pl @@ -130,7 +130,7 @@ sub start_attack { ); return $attack, $timer; } - my $probe = $ships->search({body_id => $saben_colony->id, type => 'probe', task=>'Docked'},{rows => 1})->single; + my $probe = $ships->search({body_id => $saben_colony->id, type => 'probe', task=>'Docked'})->first; if (defined $probe) { out('Has a probe to launch for '.$target_colony->name.'...'); $probe->send(target => $target_colony->star); diff --git a/bin/summarize_economy.pl b/bin/summarize_economy.pl index 18d8ad50..258fa166 100644 --- a/bin/summarize_economy.pl +++ b/bin/summarize_economy.pl @@ -55,12 +55,12 @@ out((($finish - $start->epoch)/60)." minutes have elapsed"); sub summarize { my $date = shift; out('Summarizing Economy For '.$date->ymd); - my $today = $economy_log->search({date_stamp => $date->ymd},{rows=>1})->single; + my $today = $economy_log->search({date_stamp => $date->ymd})->first; if (defined $today) { $today->delete; } $today = $economy_log->new({ date_stamp => $date->ymd }); - my $viral = $viral_log->search({date_stamp => $date->ymd},{rows=>1})->single; + my $viral = $viral_log->search({date_stamp => $date->ymd})->first; if (defined $viral) { $today->total_users($viral->total_users); } diff --git a/bin/summarize_server.pl b/bin/summarize_server.pl index e5571eca..b03470d6 100644 --- a/bin/summarize_server.pl +++ b/bin/summarize_server.pl @@ -262,7 +262,7 @@ sub summarize_alliances { $alliance_data{offense_success_rate} /= $alliance_data{member_count}; $alliance_data{defense_success_rate} /= $alliance_data{member_count}; } - my $log = $logs->search({alliance_id => $alliance->id},{rows=>1})->single; + my $log = $logs->search({alliance_id => $alliance->id})->first; if (defined $log) { if ($alliance_data{member_count}) { $log->update(\%alliance_data); @@ -367,7 +367,7 @@ sub summarize_empires { {defense_success_rate} = $empire_data{defense_success_rate} / $empire_data{colony_count}; } $empire_data{empire_size} = $empire_data{colony_count} * $empire_data{population}; - my $log = $logs->search({empire_id => $empire->id},{rows=>1})->single; + my $log = $logs->search({empire_id => $empire->id})->first; if (defined $log) { $empire_data{colony_count_delta} = $empire_data{colony_count} - $log->colony_count + $log->colony_count_delta; $empire_data{empire_size_delta} = ($empire_data{colony_count_delta}) ? $empire_data{colony_count_delta} * $empire_data{population_delta} : $empire_data{population_delta}; @@ -423,7 +423,7 @@ sub summarize_colonies { my $spy_logs = $db->resultset('Log::Spies'); while (my $planet = $planets->next) { out($planet->name); - my $log = $logs->search({planet_id => $planet->id},{rows=>1})->single; + my $log = $logs->search({planet_id => $planet->id})->first; my %colony_data = ( date_stamp => DateTime->now, planet_name => $planet->name, diff --git a/bin/summarize_spies.pl b/bin/summarize_spies.pl index 780f8250..3d604777 100644 --- a/bin/summarize_spies.pl +++ b/bin/summarize_spies.pl @@ -142,7 +142,7 @@ sub summarize_spies { my $logs = $db->resultset('Lacuna::DB::Result::Log::Spies'); while (my $spy = $spies->next) { out($spy->id.":".$spy->name); - my $log = $logs->search({ spy_id => $spy->id },{ rows => 1 } )->single; + my $log = $logs->search({ spy_id => $spy->id } )->first; my $offense_success_rate = ($spy->offense_mission_count) ? 100 * $spy->offense_mission_successes / $spy->offense_mission_count : 0; my $defense_success_rate = ($spy->defense_mission_count) ? 100 * $spy->defense_mission_successes / $spy->defense_mission_count : 0; my $success_rate = $offense_success_rate + $defense_success_rate; diff --git a/bin/trelvestian/add_colonies.pl b/bin/trelvestian/add_colonies.pl index 08eebc1d..a83b1b8e 100644 --- a/bin/trelvestian/add_colonies.pl +++ b/bin/trelvestian/add_colonies.pl @@ -37,10 +37,10 @@ if ($tournament) { my @colonies; if ($server_url =~ /us2/) { - push @colonies, $viable->search({ x => { '>' => 150}, y => { '>' => 150} },{rows=>1})->single; - push @colonies, $viable->search({ x => { '<' => -150}, y => { '>' => 150} },{rows=>1})->single; - push @colonies, $viable->search({ x => { '<' => -150}, y => { '<' => -150} },{rows=>1})->single; - push @colonies, $viable->search({ x => { '>' => 150}, y => { '<' => -150} },{rows=>1})->single; + push @colonies, $viable->search({ x => { '>' => 150}, y => { '>' => 150} })->first; + push @colonies, $viable->search({ x => { '<' => -150}, y => { '>' => 150} })->first; + push @colonies, $viable->search({ x => { '<' => -150}, y => { '<' => -150} })->first; + push @colonies, $viable->search({ x => { '>' => 150}, y => { '<' => -150} })->first; } elsif ($server_url =~ /us1/) { # four planets in 2|2 diff --git a/bin/util/move_plans_glyphs.pl b/bin/util/move_plans_glyphs.pl index 07e3139d..e758edbd 100644 --- a/bin/util/move_plans_glyphs.pl +++ b/bin/util/move_plans_glyphs.pl @@ -36,8 +36,8 @@ use utf8; out('Loading DB'); our $db = Lacuna->db; - my $body_from = $db->resultset('Map::Body')->search({id => $from})->single; - my $body_dest = $db->resultset('Map::Body')->search({id => $to})->single; + my $body_from = $db->resultset('Map::Body')->find($from); + my $body_dest = $db->resultset('Map::Body')->find($to); out(sprintf("%30s -> %30s", $body_from->name, $body_dest->name)); diff --git a/bin/util/revamp_map.pl b/bin/util/revamp_map.pl index 529e55b4..c2a17ac3 100644 --- a/bin/util/revamp_map.pl +++ b/bin/util/revamp_map.pl @@ -32,7 +32,7 @@ my @asteroid_types = qw(A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 my @habital_types = qw(P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 P26 P27 P28 P29 P30 P31 P32 P33 P34 P35 P36 P37 P38 P39 P40); my @gas_giant_types = qw(G1 G2 G3 G4 G5); -my $revamp_x = $db_config->search({name => 'revamp_x'})->single; +my $revamp_x = $db_config->search({name => 'revamp_x'})->first; my $x_min = int($config->get('map_size/x')->[0]); my $x_max = int($config->get('map_size/x')->[1]); diff --git a/bin/util/seed_fissures.pl b/bin/util/seed_fissures.pl index 2360ad34..1dc58ab5 100644 --- a/bin/util/seed_fissures.pl +++ b/bin/util/seed_fissures.pl @@ -47,8 +47,8 @@ my $placed = 0; while ($placed < $number) { my $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search( $search, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; unless (defined $target) { print "No body found\n"; $placed++; diff --git a/bin/util/swap_bodies.pl b/bin/util/swap_bodies.pl index 95e3c355..602fcd93 100644 --- a/bin/util/swap_bodies.pl +++ b/bin/util/swap_bodies.pl @@ -33,8 +33,8 @@ use utf8; out('Loading DB'); our $db = Lacuna->db; - my $body_from = $db->resultset('Map::Body')->search({id => $from})->single; - my $body_dest = $db->resultset('Map::Body')->search({id => $to})->single; + my $body_from = $db->resultset('Map::Body')->find($from); + my $body_dest = $db->resultset('Map::Body')->find($to); out(sprintf("%s at %d/%d -> %s at %d/%d", $body_from->name, $body_from->x, $body_from->y, diff --git a/bin/weekly_medals.pl b/bin/weekly_medals.pl index e367675b..55ef33f1 100644 --- a/bin/weekly_medals.pl +++ b/bin/weekly_medals.pl @@ -40,11 +40,11 @@ sub colonies { my $colonies = $db->resultset('Lacuna::DB::Result::Log::Colony'); # fastest growing - my $colony = $colonies->search(undef, {order_by => [{ -desc => 'population_delta'},'rand()'], rows => 1})->single; + my $colony = $colonies->search(undef, {order_by => [{ -desc => 'population_delta'},'rand()']})->first; add_medal($colony->empire_id,'fastest_growing_colony'); # largest - $colony = $colonies->search(undef, {order_by => [{ -desc => 'population'},'rand()'], rows => 1})->single; + $colony = $colonies->search(undef, {order_by => [{ -desc => 'population'},'rand()']})->first; add_medal($colony->empire_id,'largest_colony'); # reset deltas @@ -57,35 +57,35 @@ sub empires { my $empires = $db->resultset('Lacuna::DB::Result::Log::Empire'); # best attacker in the game - my $empire_log = $empires->search(undef, {order_by => [{ -desc => 'offense_success_rate'},'rand()'], rows => 1})->single; + my $empire_log = $empires->search(undef, {order_by => [{ -desc => 'offense_success_rate'},'rand()']})->first; add_medal($empire_log->empire_id,'best_attacker_in_the_game'); # best attacker of the week - $empire_log = $empires->search(undef, {order_by => [{ -desc => 'offense_success_rate_delta'},'rand()'], rows => 1})->single; + $empire_log = $empires->search(undef, {order_by => [{ -desc => 'offense_success_rate_delta'},'rand()']})->first; add_medal($empire_log->empire_id, 'best_attacker_of_the_week'); # best defender in the game - $empire_log = $empires->search(undef, {order_by => [{ -desc => 'defense_success_rate'},'rand()'], rows => 1})->single; + $empire_log = $empires->search(undef, {order_by => [{ -desc => 'defense_success_rate'},'rand()']})->first; add_medal($empire_log->empire_id, 'best_defender_in_the_game'); # best defender of the week - $empire_log = $empires->search(undef, {order_by => [{ -desc => 'defense_success_rate_delta'},'rand()'], rows => 1})->single; + $empire_log = $empires->search(undef, {order_by => [{ -desc => 'defense_success_rate_delta'},'rand()']})->first; add_medal($empire_log->empire_id,'best_defender_of_the_week'); # dirtiest player in the game - $empire_log = $empires->search(undef, {order_by => [{ -desc => 'dirtiest'},'rand()'], rows => 1})->single; + $empire_log = $empires->search(undef, {order_by => [{ -desc => 'dirtiest'},'rand()']})->first; add_medal($empire_log->empire_id,'dirtiest_empire_in_the_game'); # dirtiest player of the week - $empire_log = $empires->search(undef, {order_by => [{ -desc => 'dirtiest_delta'},'rand()'], rows => 1})->single; + $empire_log = $empires->search(undef, {order_by => [{ -desc => 'dirtiest_delta'},'rand()']})->first; add_medal($empire_log->empire_id,'dirtiest_empire_of_the_week'); # fastest growing empire - $empire_log = $empires->search(undef, {order_by => [{ -desc => 'empire_size_delta'},'rand()'], rows => 1})->single; + $empire_log = $empires->search(undef, {order_by => [{ -desc => 'empire_size_delta'},'rand()']})->first; add_medal($empire_log->empire_id,'fastest_growing_empire'); # largest empire - $empire_log = $empires->search(undef, {order_by => [{ -desc => 'empire_size'},'rand()'], rows => 1})->single; + $empire_log = $empires->search(undef, {order_by => [{ -desc => 'empire_size'},'rand()']})->first; add_medal($empire_log->empire_id,'largest_empire'); # reset deltas @@ -98,39 +98,39 @@ sub spies { my $spies = $db->resultset('Lacuna::DB::Result::Log::Spies'); # best in the game - my $spy = $spies->search(undef,{order_by => [{ -desc => 'success_rate'}, 'rand()'], rows=>1})->single; + my $spy = $spies->search(undef,{order_by => [{ -desc => 'success_rate'}, 'rand()']})->first; add_medal($spy->empire_id,'best_spy_in_the_game'); # best of the week - $spy = $spies->search(undef,{order_by => [{ -desc => 'success_rate_delta'},'rand()'], rows=>1})->single; + $spy = $spies->search(undef,{order_by => [{ -desc => 'success_rate_delta'},'rand()']})->first; add_medal($spy->empire_id,'best_spy_of_the_week'); # best offender in the game - $spy = $spies->search(undef,{order_by => [{ -desc => 'offense_success_rate'},'rand()'], rows=>1})->single; + $spy = $spies->search(undef,{order_by => [{ -desc => 'offense_success_rate'},'rand()']})->first; add_medal($spy->empire_id,'best_offensive_spy_in_the_game'); # best offender of the week - $spy = $spies->search(undef,{order_by => [{ -desc => 'offense_success_rate_delta'},'rand()'], rows=>1})->single; + $spy = $spies->search(undef,{order_by => [{ -desc => 'offense_success_rate_delta'},'rand()']})->first; add_medal($spy->empire_id,'best_offensive_spy_of_the_week'); # best defender in the game - $spy = $spies->search(undef,{order_by => [{ -desc => 'defense_success_rate'},'rand()'], rows=>1})->single; + $spy = $spies->search(undef,{order_by => [{ -desc => 'defense_success_rate'},'rand()']})->first; add_medal($spy->empire_id,'best_defensive_spy_in_the_game'); # best defender of the week - $spy = $spies->search(undef,{order_by => [{ -desc => 'defense_success_rate_delta'},'rand()'], rows=>1})->single; + $spy = $spies->search(undef,{order_by => [{ -desc => 'defense_success_rate_delta'},'rand()']})->first; add_medal($spy->empire_id,'best_defensive_spy_of_the_week'); # dirtiest in the game - $spy = $spies->search(undef,{order_by => [{ -desc => 'dirtiest'},'rand()'], rows=>1})->single; + $spy = $spies->search(undef,{order_by => [{ -desc => 'dirtiest'},'rand()']})->first; add_medal($spy->empire_id,'dirtiest_spy_in_the_game'); # dirtiest of the week - $spy = $spies->search(undef,{order_by => [{ -desc => 'dirtiest_delta'},'rand()'], rows=>1})->single; + $spy = $spies->search(undef,{order_by => [{ -desc => 'dirtiest_delta'},'rand()']})->first; add_medal($spy->empire_id,'dirtiest_spy_of_the_week'); # most improved of the week - $spy = $spies->search(undef,{order_by => [{ -desc => 'level_delta'},'rand()'], rows=>1})->single; + $spy = $spies->search(undef,{order_by => [{ -desc => 'level_delta'},'rand()']})->first; add_medal($spy->empire_id,'most_improved_spy_of_the_week'); # reset deltas diff --git a/lib/Lacuna/AI.pm b/lib/Lacuna/AI.pm index 4dfacf10..614cf285 100644 --- a/lib/Lacuna/AI.pm +++ b/lib/Lacuna/AI.pm @@ -40,7 +40,7 @@ has scratch => ( sub next_viable_colony { my $self = shift; - return $self->viable_colonies->search(undef, { rows => 1, order_by => 'rand()' })->single; + return $self->viable_colonies->search(undef, { order_by => 'rand()' })->first; } sub create_empire { @@ -57,8 +57,8 @@ sub create_empire { my $db = Lacuna->db; my $empire = $db->resultset('Lacuna::DB::Result::Empire')->new(\%attributes)->insert; # my $zone = $db->resultset('Lacuna::DB::Result::Map::Body')->get_column('zone')->max; -# my $home = $self->viable_colonies->search({zone => $zone},{rows=>1})->single; - my $home = $self->viable_colonies->search(undef,{rows=>1})->single; +# my $home = $self->viable_colonies->search({zone => $zone})->first; + my $home = $self->viable_colonies->search(undef,{ order_by => 'rand()'})->first; my @to_demolish = @{$home->building_cache}; $home->delete_buildings(\@to_demolish); $empire->found($home); @@ -560,7 +560,7 @@ sub start_attack { say ' Has one at star already...'; $seconds = 1; } - my $probe = $db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $attacking_colony->id, type => 'probe', task=>'Docked'},{rows => 1})->single; + my $probe = $db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $attacking_colony->id, type => 'probe', task=>'Docked'})->first; if (defined $probe and $seconds == 0) { say ' Has a probe to launch for '.$target_colony->name.'...'; $probe->send(target => $target_colony->star); diff --git a/lib/Lacuna/DB/Result.pm b/lib/Lacuna/DB/Result.pm index 6a692229..d72b88e7 100644 --- a/lib/Lacuna/DB/Result.pm +++ b/lib/Lacuna/DB/Result.pm @@ -26,7 +26,7 @@ sub new { sub random { my $self = shift; - return $self->search( undef, { rows => 1, order_by => 'rand()' })->single; + return $self->search( undef, { order_by => 'rand()' })->first; } diff --git a/lib/Lacuna/DB/Result/Building/Archaeology.pm b/lib/Lacuna/DB/Result/Building/Archaeology.pm index 9ebfa850..7cadc274 100644 --- a/lib/Lacuna/DB/Result/Building/Archaeology.pm +++ b/lib/Lacuna/DB/Result/Building/Archaeology.pm @@ -689,7 +689,7 @@ sub make_plan { my $glyph = Lacuna->db->resultset('Lacuna::DB::Result::Glyph')->search({ type => $type, body_id => $self->body_id, - })->single; + })->first; unless (defined($glyph)) { confess [ 1002, "You don't have any glyphs of type $type."]; } diff --git a/lib/Lacuna/DB/Result/Building/Intelligence.pm b/lib/Lacuna/DB/Result/Building/Intelligence.pm index 450dbe63..c0b29b84 100644 --- a/lib/Lacuna/DB/Result/Building/Intelligence.pm +++ b/lib/Lacuna/DB/Result/Building/Intelligence.pm @@ -76,10 +76,9 @@ has latest_spy => ( task => 'Training', }, { - order_by => { -desc => 'available_on' }, - rows => 1, + order_by => { -desc => 'available_on' } } - )->single; + )->first; }, ); diff --git a/lib/Lacuna/DB/Result/Building/MercenariesGuild.pm b/lib/Lacuna/DB/Result/Building/MercenariesGuild.pm index a51489d4..17d976ee 100644 --- a/lib/Lacuna/DB/Result/Building/MercenariesGuild.pm +++ b/lib/Lacuna/DB/Result/Building/MercenariesGuild.pm @@ -112,7 +112,7 @@ sub next_available_trade_ship { return $self->trade_ships->find($ship_id); } else { - return $self->trade_ships->search(undef, {rows => 1})->single; + return $self->trade_ships->search(undef)->first; } } diff --git a/lib/Lacuna/DB/Result/Building/Shipyard.pm b/lib/Lacuna/DB/Result/Building/Shipyard.pm index 2bd48aac..1509825e 100644 --- a/lib/Lacuna/DB/Result/Building/Shipyard.pm +++ b/lib/Lacuna/DB/Result/Building/Shipyard.pm @@ -158,7 +158,7 @@ sub build_ship { $ship->berth_level($ship->base_berth_level); $self->set_ship_stealth($ship); $time ||= $self->get_ship_costs($ship)->{seconds}; - my $latest = $self->building_ships->search(undef, { order_by => { -desc => 'date_available' }, rows => 1})->single; + my $latest = $self->building_ships->search(undef, { order_by => { -desc => 'date_available' })->first; my $date_completed; my $is_working; if (defined $latest) { diff --git a/lib/Lacuna/DB/Result/Building/SpacePort.pm b/lib/Lacuna/DB/Result/Building/SpacePort.pm index e901bd86..f8e059b0 100644 --- a/lib/Lacuna/DB/Result/Building/SpacePort.pm +++ b/lib/Lacuna/DB/Result/Building/SpacePort.pm @@ -95,7 +95,7 @@ sub is_full { sub find_ship { my ($self, $type) = @_; - my $ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $self->body_id, task => 'Docked', type => $type}, {rows=>1})->single; + my $ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $self->body_id, task => 'Docked', type => $type} )->first; unless (defined $ship ) { $type =~ s/_/ /g; confess [ 1002, 'You do not have enough '.$type.'s.']; diff --git a/lib/Lacuna/DB/Result/Building/Trade.pm b/lib/Lacuna/DB/Result/Building/Trade.pm index 450c4e41..0fe8e04b 100644 --- a/lib/Lacuna/DB/Result/Building/Trade.pm +++ b/lib/Lacuna/DB/Result/Building/Trade.pm @@ -400,7 +400,7 @@ sub next_available_trade_ship { return $self->trade_ships->find($ship_id); } else { - return $self->trade_ships->search(undef, {rows => 1})->single; + return $self->trade_ships->search(undef)->first; } } diff --git a/lib/Lacuna/DB/Result/Building/University.pm b/lib/Lacuna/DB/Result/Building/University.pm index 7e754fef..1ba4fb90 100644 --- a/lib/Lacuna/DB/Result/Building/University.pm +++ b/lib/Lacuna/DB/Result/Building/University.pm @@ -51,7 +51,7 @@ after finish_upgrade => sub { $empire->university_level(++$tech_lvl); $empire->update; if ($tech_lvl > 4) { - my $invite = Lacuna->db->resultset('Lacuna::DB::Result::Invite')->search({invitee_id => $empire->id},{rows=>1})->single; + my $invite = Lacuna->db->resultset('Lacuna::DB::Result::Invite')->search({invitee_id => $empire->id})->first; if (defined $invite) { my $inviter = $invite->inviter; if (defined $inviter) { diff --git a/lib/Lacuna/DB/Result/Empire.pm b/lib/Lacuna/DB/Result/Empire.pm index ad58a82e..886ff298 100644 --- a/lib/Lacuna/DB/Result/Empire.pm +++ b/lib/Lacuna/DB/Result/Empire.pm @@ -249,7 +249,7 @@ sub get_species_stats { sub has_medal { my ($self, $type) = @_; - return Lacuna->db->resultset('Medals')->search({empire_id => $self->id, type => $type},{rows=>1})->single; + return Lacuna->db->resultset('Medals')->search({empire_id => $self->id, type => $type})->first; } sub add_medal { @@ -408,8 +408,7 @@ sub get_latest_message_id { has_read => 0, },{ order_by => { -desc => 'date_sent' }, - rows => 1, - })->single; + })->first; my $message_id = defined $message ? $message->id : 0; return $message_id; } @@ -514,9 +513,8 @@ sub attach_invite_code { my $invites = Lacuna->db->resultset('Invite'); if (defined $invite_code && $invite_code ne '') { my $invite = $invites->search( - {code => $invite_code }, - {rows => 1} - )->single; + {code => $invite_code } + )->first; if (defined $invite) { if ($invite->invitee_id) { $invite = $invite->copy({invitee_id => $self->id, email => $self->email, accept_date => DateTime->now}); @@ -687,7 +685,7 @@ sub find_home_planet { } # determine search area - my $invite = Lacuna->db->resultset('Invite')->search({invitee_id => $self->id},{rows=>1})->single; + my $invite = Lacuna->db->resultset('Invite')->search({invitee_id => $self->id})->first; if (defined $invite) { $search{zone} = $invite->zone; delete $search{x}; @@ -750,7 +748,7 @@ sub get_invite_friend_url { my ($self) = @_; my $code = create_uuid_as_string(UUID_MD5, $self->id); my $invites = Lacuna->db->resultset('Invite'); - my $invite = $invites->search({code => $code},{rows=>1})->single; + my $invite = $invites->search({code => $code})->first; unless (defined $invite) { $invites->new({ inviter_id => $self->id, @@ -1081,7 +1079,7 @@ sub redeem_essentia_code { sub pay_taxes { my ($self, $station_id, $amount) = @_; - my $taxes = Lacuna->db->resultset('Taxes')->search({empire_id=>$self->id,station_id=>$station_id})->single; + my $taxes = Lacuna->db->resultset('Taxes')->search({empire_id=>$self->id,station_id=>$station_id})->first; if (defined $taxes) { $taxes->{paid_0} += $amount; $taxes->update; diff --git a/lib/Lacuna/DB/Result/Log/Battles.pm b/lib/Lacuna/DB/Result/Log/Battles.pm index 16106724..5e4b5989 100644 --- a/lib/Lacuna/DB/Result/Log/Battles.pm +++ b/lib/Lacuna/DB/Result/Log/Battles.pm @@ -50,10 +50,7 @@ after insert => sub { my $ai_battle_summary = $summary_rs->search({ attacking_empire_id => $self->attacking_empire_id, defending_empire_id => $self->defending_empire_id, - }, - { - rows => 1, - })->single; + })->first; if (not $ai_battle_summary) { $ai_battle_summary = $summary_rs->create({ attacking_empire_id => $self->attacking_empire_id, diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 609d044c..765b3c80 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -183,7 +183,7 @@ sub add_glyph { my $glyph = Lacuna->db->resultset('Lacuna::DB::Result::Glyph')->search({ type => $type, body_id => $self->id, - })->single; + })->first; if (defined($glyph)) { my $sum = $num_add + $glyph->quantity; $glyph->quantity($sum); @@ -205,7 +205,7 @@ sub use_glyph { my $glyph = Lacuna->db->resultset('Lacuna::DB::Result::Glyph')->search({ type => $type, body_id => $self->id, - })->single; + })->first; return 0 unless defined($glyph); if ($glyph->quantity > $num_used) { my $sum = $glyph->quantity - $num_used; diff --git a/lib/Lacuna/DB/Result/Mission.pm b/lib/Lacuna/DB/Result/Mission.pm index 3603d5dc..343757c7 100644 --- a/lib/Lacuna/DB/Result/Mission.pm +++ b/lib/Lacuna/DB/Result/Mission.pm @@ -31,7 +31,7 @@ has params => ( sub log { my $self = shift; my $logs = Lacuna->db->resultset('Lacuna::DB::Result::Log::Mission'); - my $log = $logs->search({filename => $self->mission_file_name},{rows => 1})->single; + my $log = $logs->search({filename => $self->mission_file_name})->first; unless (defined $log) { $log = $logs->new({filename => $self->mission_file_name})->insert; } @@ -281,7 +281,7 @@ sub check_objectives { my $glyph_on_body = Lacuna->db->resultset('Lacuna::DB::Result::Glyph')->search({ type => $glyph->{type}, body_id => $body->id, - })->single; + })->first; unless (defined($glyph_on_body)) { confess [ 1002, "You don't have any glyphs of ".$glyph->{type}."."]; } @@ -628,7 +628,7 @@ sub find_body_target { $body = $body->search({ empire_id => undef }); } - return $body->search(undef,{rows => 1, order_by => 'rand()'})->get_column('id')->single; + return $body->search(undef,{order_by => 'rand()'})->get_column('id')->first; } sub find_star_target { @@ -648,7 +648,7 @@ sub find_star_target { $star = $star->search({ color => $movement->{target}{color} }); } - return $star->search(undef,{rows => 1, order_by => 'rand()'})->get_column('id')->single; + return $star->search(undef,{ order_by => 'rand()'})->get_column('id')->first; } no Moose; diff --git a/lib/Lacuna/DB/Result/Propositions.pm b/lib/Lacuna/DB/Result/Propositions.pm index 60cf2925..be3ee470 100644 --- a/lib/Lacuna/DB/Result/Propositions.pm +++ b/lib/Lacuna/DB/Result/Propositions.pm @@ -183,7 +183,7 @@ sub get_status { }, }; if (defined $empire) { - my $vote = $self->votes->search({ empire_id => $empire->id},{rows=>1})->single; + my $vote = $self->votes->search({ empire_id => $empire->id})->first; if (defined $vote) { $out->{my_vote} = $vote->vote; } diff --git a/lib/Lacuna/DB/Result/Propositions/InductMember.pm b/lib/Lacuna/DB/Result/Propositions/InductMember.pm index 5dadc5f6..c810b88e 100644 --- a/lib/Lacuna/DB/Result/Propositions/InductMember.pm +++ b/lib/Lacuna/DB/Result/Propositions/InductMember.pm @@ -27,7 +27,7 @@ before pass => sub { my $embassy = Lacuna->db->resultset('Lacuna::DB::Result::Building')->search( { body_id => { in => \@planet_ids }, class => 'Lacuna::DB::Result::Building::Embassy' }, { order_by => { -desc => 'level' } } - )->single; + )->first; my $max_members = ( $building->level >= $embassy->level ) ? 2 * $building->level : 2 * $embassy->level; if ($count < $max_members ) { diff --git a/lib/Lacuna/DB/Result/Propositions/RenameStar.pm b/lib/Lacuna/DB/Result/Propositions/RenameStar.pm index c77aed98..2f5c10f8 100644 --- a/lib/Lacuna/DB/Result/Propositions/RenameStar.pm +++ b/lib/Lacuna/DB/Result/Propositions/RenameStar.pm @@ -19,7 +19,7 @@ before pass => sub { else { $star->name($name); $star->update; - my $elaw = $station->laws->search({type => 'Jurisdiction', star_id => $star->id})->single; + my $elaw = $station->laws->search({type => 'Jurisdiction', star_id => $star->id})->first; if ($elaw) { $elaw->name('Seize '.$name); $elaw->description('Seize control of {Starmap '.$star->x.' '.$star->y.' '.$name.'} by {Planet '.$station->id.' '. diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index cadf3049..991229bf 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -1069,8 +1069,8 @@ sub get_defender { { on_body_id => $self->on_body_id, task => { 'in' => \@tasks }, empire_id => { 'not_in' => \@member_ids } }, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; if (defined $defender) { $defender->on_body($self->on_body); weaken($defender->{_relationship_data}{on_body}); @@ -1098,9 +1098,9 @@ sub get_attacker { ->search( { on_body_id => $self->on_body_id, task => { in => \@tasks }, empire_id => { 'not in' => \@member_ids } }, - { rows => 1, order_by => 'rand()' } + { order_by => 'rand()' } ) - ->single; + ->first; if (defined $attacker) { $attacker->on_body($self->on_body); weaken($attacker->{_relationship_data}{on_body}); @@ -1827,10 +1827,10 @@ sub can_conduct_advanced_missions { confess [1010, 'You cannot attack your alliance mates.']; } my $ranks = Lacuna->db->resultset('Log::Empire'); - my $defender_rank = $ranks->search( { empire_id => $self->on_body->empire_id }, - {rows => 1})->get_column('empire_size_rank')->single; + my $defender_rank = $ranks->search( { empire_id => $self->on_body->empire_id } + )->get_column('empire_size_rank')->first; my $attacker_rank = $ranks->search( {empire_id => $self->empire_id }, - {rows => 1})->get_column('empire_size_rank')->single; + )->get_column('empire_size_rank')->first; unless ($attacker_rank + 100 > $defender_rank ) { # remember that the rank is inverted 1 is higher than 2. confess [1010, 'This empire is more than 100 away from you in empire rank, and is therefore immune to this attack.']; } @@ -2280,8 +2280,8 @@ sub abduct_operative { foreign_body_id => $self->on_body->id, task => 'Orbiting', type => 'spy_shuttle'}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; unless (defined($ship)) { foreach my $type (SHIP_TYPES) { my $ship = $ships->new({type => $type}); @@ -2293,8 +2293,8 @@ sub abduct_operative { {body_id => $self->on_body->id, task => 'Docked', hold_size => { '>=' => 700 }, type => {'in' => \@types}}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; } return $self->ship_not_found->id unless (defined $ship); return $self->no_contact->id unless (defined $defender); @@ -2354,10 +2354,7 @@ sub thwart_rebel { sub destroy_infrastructure { my ($self, $defender) = @_; - my ($building) = sort { - rand() <=> rand() - } - grep { + my ($building) = shuffle grep { $_->efficiency > 0 and $_->class ne 'Lacuna::DB::Result::Building::PlanetaryCommand' and $_->class ne 'Lacuna::DB::Result::Building::Module::StationCommand' and @@ -2401,8 +2398,8 @@ sub destroy_defense_ship { 'drone', ]}, }, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->ship_not_found->id unless (defined $ship); $self->things_destroyed( $self->things_destroyed + 1 ); @@ -2434,8 +2431,8 @@ sub destroy_ship { my ($self, $defender) = @_; my $ship = $self->on_body->ships->search( {task => 'Docked'}, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->ship_not_found->id unless (defined $ship); $self->things_destroyed( $self->things_destroyed + 1 ); $self->on_body->empire->send_predefined_message( @@ -2502,7 +2499,7 @@ sub destroy_plan { sub destroy_glyph { my ($self, $defender) = @_; - my $glyph = $self->on_body->glyph->search(undef, {rows => 1, order_by => 'rand()'})->single; + my $glyph = $self->on_body->glyph->search(undef, { order_by => 'rand()'})->first; return $self->mission_objective_not_found('glyph')->id unless defined $glyph; $self->things_destroyed( $self->things_destroyed + 1 ); my $stolen = $glyph->type.' glyph'; @@ -2564,8 +2561,8 @@ sub destroy_chain_ship { my $ship = Lacuna->db->resultset('Ships')->search( {body_id => $self->on_body->id, task => {'in' => ['Supply Chain', 'Waste Chain'] }}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->ship_not_found->id unless $ship; my $stype = "supply chain"; if ($ship->task eq "Waste Chain") { @@ -2603,8 +2600,8 @@ sub destroy_mining_ship { return $self->building_not_found->id unless defined $ministry; my $ship = Lacuna->db->resultset('Ships')->search( {body_id => $self->on_body->id, task => 'Mining'}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->ship_not_found->id unless $ship; $ship->delete; $ministry->recalc_ore_production; @@ -2676,8 +2673,8 @@ sub steal_resources { 'hulk_huge', 'dory', 'barge']}}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->ship_not_found->id unless defined $ship; my $space = $ship->hold_size; my @types = shuffle (FOOD_TYPES, ORE_TYPES); @@ -2756,8 +2753,8 @@ sub steal_glyph { 'hulk_fast', 'hulk_huge', 'barge']}}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->ship_not_found->id unless defined $ship; my @glyphs = $on_body->glyph; @@ -2813,8 +2810,8 @@ sub steal_ships { } my $ship = $ships->search( {body_id => $self->on_body->id, task => 'Docked', type => {'in' => \@types}}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->ship_not_found->id unless (defined $ship); $ship->body($self->from_body); weaken($ship->{_relationship_data}{body}); @@ -2847,10 +2844,7 @@ sub steal_ships { sub steal_building { my ($self, $defender) = @_; my $on_body = $self->on_body; - my ($building) = sort { - rand() <=> rand() - } - grep { + my ($building) = shuffle grep { ($_->level > 1) and ($_->class ne 'Lacuna::DB::Result::Building::Permanent::EssentiaVein') and ($_->class ne 'Lacuna::DB::Result::Building::Permanent::TheDillonForge') and @@ -2952,10 +2946,7 @@ sub thwart_thief { sub shut_down_defenses { my ($self, $defender) = @_; - my ($building) = sort { - rand() <=> rand() - } - grep { + my ($building) = shuffle grep { ($_->efficiency > 0) and ( $_->class eq 'Lacuna::DB::Result::Building::SAW' or $_->class eq 'Lacuna::DB::Result::Building::Shipyard' or @@ -2992,10 +2983,7 @@ sub shut_down_defenses { sub shut_down_building { my ($self, $defender) = @_; - my ($building) = sort { - rand() <=> rand() - } - grep { + my ($building) = shuffle grep { ($_->efficiency > 0) and ( $_->class eq 'Lacuna::DB::Result::Building::Archaeology' or $_->class eq 'Lacuna::DB::Result::Building::Development' or @@ -3047,8 +3035,8 @@ sub take_control_of_probe { my $probe = Lacuna->db ->resultset('Probes') ->search_observatory({body_id => $self->on_body_id }, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->probe_not_found->id unless defined $probe; $self->things_stolen( $self->things_stolen + 1 ); $self->on_body->empire->send_predefined_message( @@ -3088,8 +3076,8 @@ sub destroy_excavator { my $excavator = Lacuna->db ->resultset('Excavators') ->search({planet_id => $self->on_body->id}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->mission_objective_not_found('excavator')->id unless defined $excavator; my $body = $excavator->body; return $self->mission_objective_not_found('excavator')->id unless defined $body; @@ -3123,8 +3111,8 @@ sub kill_contact_with_mining_platform { my $platform = Lacuna->db ->resultset('MiningPlatforms') ->search({planet_id => $self->on_body->id}, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->mission_objective_not_found('mining platform')->id unless defined $platform; my $asteroid = $platform->asteroid; return $self->mission_objective_not_found('mining platform')->id unless defined $asteroid; @@ -3157,8 +3145,8 @@ sub hack_observatory_probes { my $probe = Lacuna->db ->resultset('Probes') ->search_observatory({body_id => $self->on_body->id }, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->probe_not_found->id unless defined $probe; $self->things_destroyed( $self->things_destroyed + 1 ); my $message = $self->empire->send_predefined_message( @@ -3201,8 +3189,8 @@ sub hack_offending_probes { ->resultset('Probes') ->search_observatory({star_id => $self->on_body->star_id, empire_id => {'not in' => \@safe} }, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->probe_not_found->id unless defined $probe; $defender->things_destroyed( $defender->things_destroyed + 1 ); $defender->empire->send_predefined_message( @@ -3238,8 +3226,8 @@ sub hack_local_probes { ->resultset('Probes') ->search_observatory( {star_id => $self->on_body->star_id, empire_id => $self->on_body->empire_id }, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; return $self->probe_not_found->id unless defined $probe; $self->things_destroyed( $self->things_destroyed + 1 ); $self->on_body->empire->send_predefined_message( diff --git a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm index b25ff366..29c7ac7b 100644 --- a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm +++ b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm @@ -91,9 +91,8 @@ sub find_target { $target = Lacuna->db ->resultset('Lacuna::DB::Result::Map::Body') ->search( - { name => $target_params->{body_name} }, - {rows=>1} - )->single; + { name => $target_params->{body_name} } + )->first; if (defined $target) { $target_type = $target->get_type; } @@ -103,16 +102,14 @@ sub find_target { $target = Lacuna->db ->resultset('Lacuna::DB::Result::Map::Body') ->search( - { x => $target_params->{x}, y => $target_params->{y} }, - {rows=>1} - )->single; + { x => $target_params->{x}, y => $target_params->{y} } + )->first; unless (defined $target) { $target = Lacuna->db ->resultset('Lacuna::DB::Result::Map::Star') ->search( - { x => $target_params->{x}, y => $target_params->{y} }, - {rows=>1} - )->single; + { x => $target_params->{x}, y => $target_params->{y} } + )->first; $target_type = "star" if (defined $target); } else { @@ -130,9 +127,8 @@ sub find_target { y => { '>=' => ($target_params->{y} -2), '<=' => ($target_params->{y} +2) } - }, - {rows=>1} - )->single; + } + )->first; if (defined $star) { my $sx = $star->x; my $sy = $star->y; my $tx = $target_params->{x}; my $ty = $target_params->{y}; @@ -209,9 +205,8 @@ sub find_target { elsif (exists $target_params->{star_name}) { $target = Lacuna->db-> resultset('Lacuna::DB::Result::Map::Star')->search( - { name => $target_params->{star_name} }, - {rows=>1} - )->single; + { name => $target_params->{star_name} } + )->first; $target_type = "star"; } elsif (exists $target_params->{star_id}) { @@ -775,8 +770,8 @@ sub generate_singularity { { on_body_id => $body->id, empire_id => { '!=' => $body->empire_id }, task => 'Sabotage BHG' }, - { rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; if (defined $lock_down) { my $power = $lock_down->mayhem_xp + $lock_down->offense; my $defense = 0; @@ -1520,8 +1515,8 @@ sub bhg_random_make { my $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body') ->search( {zone => $body->zone, empire_id => undef, }, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; my $btype = $target->get_type; my ($throw, $reason) = check_bhg_neutralized($target); if ($throw > 0) { @@ -1560,8 +1555,8 @@ sub bhg_random_type { my $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body') ->search( {zone => $body->zone, empire_id => undef, }, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; my $btype = $target->get_type; my ($throw, $reason) = check_bhg_neutralized($target); if ($throw > 0) { @@ -1597,8 +1592,8 @@ sub bhg_random_size { my $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body') ->search( {zone => $body->zone, id => { '!=' => $body->id } }, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; my $return; my $btype = $target->get_type; my ($throw, $reason) = check_bhg_neutralized($target); @@ -1633,8 +1628,8 @@ sub bhg_random_resource { my $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body') ->search( {zone => $body->zone, empire_id => { '!=' => undef} }, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; my $return; my $btype = $target->get_type; my ($throw, $reason) = check_bhg_neutralized($target); @@ -1671,8 +1666,8 @@ sub bhg_random_fissure { class => { like => 'Lacuna::DB::Result::Map::Body::Planet::P%' }, usable_as_starter_enabled => 0, }, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; my $btype = $target->get_type; my $return = { id => $target->id, @@ -1751,8 +1746,8 @@ sub bhg_random_decor { my $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body') ->search( {zone => $body->zone }, - {rows => 1, order_by => 'rand()' } - )->single; + { order_by => 'rand()' } + )->first; my $btype = $target->get_type; my $return = { id => $target->id, diff --git a/lib/Lacuna/RPC/Building/MiningMinistry.pm b/lib/Lacuna/RPC/Building/MiningMinistry.pm index ed2ae0d2..99aa5776 100644 --- a/lib/Lacuna/RPC/Building/MiningMinistry.pm +++ b/lib/Lacuna/RPC/Building/MiningMinistry.pm @@ -147,7 +147,7 @@ sub remove_cargo_ship_from_fleet { unless ($ship->body_id eq $building->body_id) { confess [1013, "You can't manage a ship that is not yours."]; } - my $platform = $building->platforms->search(undef, {rows => 1})->single; + my $platform = $building->platforms->search(undef)->first; if (defined $platform) { my $from = $platform->asteroid; unless (defined $from) { diff --git a/lib/Lacuna/RPC/Building/Observatory.pm b/lib/Lacuna/RPC/Building/Observatory.pm index f41b6018..8a4bc757 100644 --- a/lib/Lacuna/RPC/Building/Observatory.pm +++ b/lib/Lacuna/RPC/Building/Observatory.pm @@ -24,9 +24,8 @@ sub abandon_probe { my $probe = $building->probes->search( { star_id => $star->id, - }, - {rows => 1} - )->single; + } + )->first; if (defined $probe) { $probe->delete; } diff --git a/lib/Lacuna/RPC/Building/Parliament.pm b/lib/Lacuna/RPC/Building/Parliament.pm index 8e91cc91..90cfc3df 100644 --- a/lib/Lacuna/RPC/Building/Parliament.pm +++ b/lib/Lacuna/RPC/Building/Parliament.pm @@ -27,7 +27,7 @@ sub max_members { my $embassy = Lacuna->db->resultset('Lacuna::DB::Result::Building')->search( { body_id => { in => \@planet_ids }, class => 'Lacuna::DB::Result::Building::Embassy' }, { order_by => { -desc => 'level' } } - )->single; + )->first; return ( $building->level >= $embassy->level ) ? 2 * $building->level : 2 * $embassy->level; } diff --git a/lib/Lacuna/RPC/Building/SpacePort.pm b/lib/Lacuna/RPC/Building/SpacePort.pm index bee81300..89bdb400 100644 --- a/lib/Lacuna/RPC/Building/SpacePort.pm +++ b/lib/Lacuna/RPC/Building/SpacePort.pm @@ -28,18 +28,18 @@ sub find_target { $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Star')->find($target_params->{star_id}); } elsif (exists $target_params->{star_name}) { - $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Star')->search({ name => $target_params->{star_name} }, {rows=>1})->single; + $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Star')->search({ name => $target_params->{star_name} })->first; } if (exists $target_params->{body_id}) { $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->find($target_params->{body_id}); } elsif (exists $target_params->{body_name}) { - $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({ name => $target_params->{body_name} }, {rows=>1})->single; + $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({ name => $target_params->{body_name} })->first; } elsif (exists $target_params->{x}) { - $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({ x => $target_params->{x}, y => $target_params->{y} }, {rows=>1})->single; + $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({ x => $target_params->{x}, y => $target_params->{y} })->first; unless (defined $target) { - $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Star')->search({ x => $target_params->{x}, y => $target_params->{y} }, {rows=>1})->single; + $target = Lacuna->db->resultset('Lacuna::DB::Result::Map::Star')->search({ x => $target_params->{x}, y => $target_params->{y} })->first; } } unless (defined $target) { @@ -774,13 +774,13 @@ sub view_ships_travelling { sub _ship_paging_options { my ($self, $paging) = @_; - for my $key ( keys %{ $paging } ) { - # Throw away bad keys - unless ($key ~~ [qw(page_number items_per_page no_paging)]) { - delete $paging->{$key}; - next; - } - } +# for my $key ( keys %{ $paging } ) { +# # Throw away bad keys +# unless ($key ~~ [qw(page_number items_per_page no_paging)]) { +# delete $paging->{$key}; +# next; +# } +# } if ($paging->{no_paging}) { $paging = {}; } diff --git a/lib/Lacuna/RPC/Building/Trade.pm b/lib/Lacuna/RPC/Building/Trade.pm index cb07a1ca..b714cb1f 100644 --- a/lib/Lacuna/RPC/Building/Trade.pm +++ b/lib/Lacuna/RPC/Building/Trade.pm @@ -123,7 +123,7 @@ sub remove_supply_ship_from_fleet { confess [1013, "You can't manage a ship that is not yours."]; } - my $supply_chain = $building->supply_chains->search({},{rows => 1})->single; + my $supply_chain = $building->supply_chains->search({})->first; if (defined $supply_chain) { my $from = $supply_chain->target; $building->send_supply_ship_home($from, $ship); @@ -155,7 +155,7 @@ sub remove_waste_ship_from_fleet { confess [1013, "You can't manage a ship that is not yours."]; } - my $waste_chain = $building->waste_chains->search({},{rows => 1})->single; + my $waste_chain = $building->waste_chains->search({})->first; if (defined $waste_chain) { my $from = $building->body->star; $building->send_waste_ship_home($from, $ship); diff --git a/lib/Lacuna/RPC/Empire.pm b/lib/Lacuna/RPC/Empire.pm index fa061fc4..a0f38a56 100644 --- a/lib/Lacuna/RPC/Empire.pm +++ b/lib/Lacuna/RPC/Empire.pm @@ -219,10 +219,10 @@ sub send_password_reset_message { $empire = $empires->find($options{empire_id}); } elsif (exists $options{empire_name}) { - $empire = $empires->search({ name => $options{empire_name} }, { rows => 1 })->single; + $empire = $empires->search({ name => $options{empire_name} })->first; } elsif (exists $options{email}) { - $empire = $empires->search({ email => $options{email} }, { rows => 1 })->single; + $empire = $empires->search({ email => $options{email} })->first; } unless (defined $empire) { confess [1002, 'Empire not found.']; @@ -251,7 +251,7 @@ sub reset_password { unless (defined $key && $key ne '') { confess [1002, 'You need a key to reset a password.']; } - my $empire = Lacuna->db->resultset('Empire')->search({password_recovery_key => $key}, { rows=>1 })->single; + my $empire = Lacuna->db->resultset('Empire')->search({password_recovery_key => $key})->first; unless (defined $empire) { confess [1002, 'The key you provided is invalid. Password not reset.']; } diff --git a/lib/Lacuna/RPC/EssentiaCode.pm b/lib/Lacuna/RPC/EssentiaCode.pm index 824f1b36..3f16a2fb 100644 --- a/lib/Lacuna/RPC/EssentiaCode.pm +++ b/lib/Lacuna/RPC/EssentiaCode.pm @@ -15,7 +15,7 @@ sub verify_key { sub spend { my ($self, $key, $code_string) = @_; confess [401, 'Invalid key.'] unless $self->verify_key($key); - my $code = Lacuna->db->resultset('Lacuna::DB::Result::EssentiaCode')->search({code => $code_string}, {rows=>1})->single; + my $code = Lacuna->db->resultset('Lacuna::DB::Result::EssentiaCode')->search({code => $code_string})->first; confess [1002, 'The essentia code you specified is invalid.'] unless (defined $code); confess [1010, 'The essentia code you specified has already been redeemed.'] if ($code->used); $code->used(1); diff --git a/lib/Lacuna/RPC/Inbox.pm b/lib/Lacuna/RPC/Inbox.pm index 16f79232..26f18cc6 100644 --- a/lib/Lacuna/RPC/Inbox.pm +++ b/lib/Lacuna/RPC/Inbox.pm @@ -247,7 +247,7 @@ sub send_message { } } else { - my $user = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name => $name},{rows => 1})->single; + my $user = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name => $name})->first; if (defined $user) { push @sent, $user->name; push @to, $user; diff --git a/lib/Lacuna/RPC/Map.pm b/lib/Lacuna/RPC/Map.pm index 80f879ce..fa7e2143 100644 --- a/lib/Lacuna/RPC/Map.pm +++ b/lib/Lacuna/RPC/Map.pm @@ -13,7 +13,7 @@ sub check_star_for_incoming_probe { my $empire = $self->get_empire_by_session($session_id); my $date = 0; my @bodies = $empire->planets->get_column('id')->all; - my $incoming = Lacuna->db->resultset('Ships')->search({foreign_star_id=>$star_id, task=>'Travelling', type=>'probe', body_id => {in => \@bodies }}, {rows=>1})->single; + my $incoming = Lacuna->db->resultset('Ships')->search({foreign_star_id=>$star_id, task=>'Travelling', type=>'probe', body_id => {in => \@bodies }})->first; if (defined $incoming) { $date = $incoming->date_available_formatted; } @@ -91,7 +91,7 @@ sub get_star { sub get_star_by_name { my ($self, $session_id, $star_name) = @_; my $empire = $self->get_empire_by_session($session_id); - my $star = Lacuna->db->resultset('Map::Star')->search({name => $star_name}, {rows=>1})->single; + my $star = Lacuna->db->resultset('Map::Star')->search({name => $star_name})->first; unless (defined $star) { confess [1002, "Couldn't find a star."]; } @@ -101,7 +101,7 @@ sub get_star_by_name { sub get_star_by_xy { my ($self, $session_id, $x, $y) = @_; my $empire = $self->get_empire_by_session($session_id); - my $star = Lacuna->db->resultset('Map::Star')->search({x=>$x, y=>$y}, {rows=>1})->single; + my $star = Lacuna->db->resultset('Map::Star')->search({x=>$x, y=>$y})->first; unless (defined $star) { confess [1002, "Couldn't find a star."]; } diff --git a/lib/Lacuna/Role/Navigation.pm b/lib/Lacuna/Role/Navigation.pm index cc944c0a..1f2c95d0 100644 --- a/lib/Lacuna/Role/Navigation.pm +++ b/lib/Lacuna/Role/Navigation.pm @@ -14,18 +14,18 @@ sub find_target { $target = Lacuna->db->resultset('Map::Star')->find($target_params->{star_id}); } elsif (exists $target_params->{star_name}) { - $target = Lacuna->db->resultset('Map::Star')->search({ name => $target_params->{star_name} }, {rows=>1})->single; + $target = Lacuna->db->resultset('Map::Star')->search({ name => $target_params->{star_name} })->first; } if (exists $target_params->{body_id}) { $target = Lacuna->db->resultset('Map::Body')->find($target_params->{body_id}); } elsif (exists $target_params->{body_name}) { - $target = Lacuna->db->resultset('Map::Body')->search({ name => $target_params->{body_name} }, {rows=>1})->single; + $target = Lacuna->db->resultset('Map::Body')->search({ name => $target_params->{body_name} })->first; } elsif (exists $target_params->{x}) { - $target = Lacuna->db->resultset('Map::Body')->search({ x => $target_params->{x}, y => $target_params->{y} }, {rows=>1})->single; + $target = Lacuna->db->resultset('Map::Body')->search({ x => $target_params->{x}, y => $target_params->{y} })->first; unless (defined $target) { - $target = Lacuna->db->resultset('Map::Star')->search({ x => $target_params->{x}, y => $target_params->{y} }, {rows=>1})->single; + $target = Lacuna->db->resultset('Map::Star')->search({ x => $target_params->{x}, y => $target_params->{y} })->first; } } unless (defined $target) { diff --git a/lib/Lacuna/Role/Trader.pm b/lib/Lacuna/Role/Trader.pm index 398783e1..4b1ff9ef 100644 --- a/lib/Lacuna/Role/Trader.pm +++ b/lib/Lacuna/Role/Trader.pm @@ -50,7 +50,7 @@ sub check_payload { my $glyph = Lacuna->db->resultset('Lacuna::DB::Result::Glyph')->search({ type => $item->{name}, body_id => $self->body_id, - })->single; + })->first; my $gquant = 0; if (defined $glyph) { $gquant = $glyph->quantity; diff --git a/lib/Lacuna/Web/Admin.pm b/lib/Lacuna/Web/Admin.pm index 36a43576..cab15edd 100644 --- a/lib/Lacuna/Web/Admin.pm +++ b/lib/Lacuna/Web/Admin.pm @@ -947,7 +947,7 @@ sub www_view_empire { $invites_sent->all; $out .= ''; $out .= 'Invite Accepted From'; - my $invite_accepted = Lacuna->db->resultset('Lacuna::DB::Result::Invite')->search({invitee_id => $empire->id},{rows=>1})->single; + my $invite_accepted = Lacuna->db->resultset('Lacuna::DB::Result::Invite')->search({invitee_id => $empire->id})->first; if ( $invite_accepted && $invite_accepted->inviter_id ) { my $inviter = $invite_accepted->inviter; $out .= sprintf('%s', $inviter->id, $inviter->name); diff --git a/lib/Lacuna/Web/ApiKey.pm b/lib/Lacuna/Web/ApiKey.pm index 88e496e3..c092ae27 100644 --- a/lib/Lacuna/Web/ApiKey.pm +++ b/lib/Lacuna/Web/ApiKey.pm @@ -9,7 +9,7 @@ use Email::Stuff; sub www_view_stats { my ($self, $request) = @_; - my $pair = Lacuna->db->resultset('Lacuna::DB::Result::ApiKey')->search({ private_key => $request->param('private_key')}, {rows=>1})->single; + my $pair = Lacuna->db->resultset('Lacuna::DB::Result::ApiKey')->search({ private_key => $request->param('private_key')})->first; unless (defined $pair) { confess [404, 'That private key could not be found']; } diff --git a/lib/Lacuna/Web/Facebook.pm b/lib/Lacuna/Web/Facebook.pm index 0ec245d1..9cbb89bf 100644 --- a/lib/Lacuna/Web/Facebook.pm +++ b/lib/Lacuna/Web/Facebook.pm @@ -31,7 +31,7 @@ sub www_postback { return $self->format_error('Could not authenticate your Facebook account. Please close this window and try again.'); } - my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({facebook_uid => $user->{id} }, { rows => 1 })->single; + my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({facebook_uid => $user->{id} })->first; my $uri = Lacuna->config->get('server_url'); if (defined $empire && $empire->stage eq 'founded') { $empire->facebook_token($fb->access_token); @@ -109,7 +109,7 @@ sub www_my_empire { return $self->format_error(q{The bad thing that should never happen just happened. Facebook doesn't remember who you are!}); } - my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({facebook_uid => $user->{id} }, { rows => 1 })->single; + my $empire = Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({facebook_uid => $user->{id} })->first; my $out; unless (defined $empire) { $out = q{

Join thousands of other players online now in this strategic browser game. No downloads required. Play for free.

diff --git a/lib/Lacuna/Web/MissionCurator.pm b/lib/Lacuna/Web/MissionCurator.pm index 7411d177..de32b0d3 100644 --- a/lib/Lacuna/Web/MissionCurator.pm +++ b/lib/Lacuna/Web/MissionCurator.pm @@ -19,7 +19,7 @@ sub www_add_essentia { unless (defined $empire) { confess [404, 'Empire not found.']; } - my $curator = $empires->search({name=>$request->user},{rows=>1})->single; + my $curator = $empires->search({name=>$request->user})->first; my $jt = $empires->find(2); $empire->add_essentia({ amount => 100, diff --git a/lib/Lacuna/Web/Pay.pm b/lib/Lacuna/Web/Pay.pm index 05877274..1254aaa1 100644 --- a/lib/Lacuna/Web/Pay.pm +++ b/lib/Lacuna/Web/Pay.pm @@ -82,9 +82,8 @@ sub www_jambool_postback { return ['Not a valid socialgold_transaction_id.', { status => 402 }]; } my $transaction = Lacuna->db->resultset('Lacuna::DB::Result::Log::Essentia')->search( - { transaction_id => $transaction_id }, - { rows => 1 } - )->single; + { transaction_id => $transaction_id } + )->first; if (defined $transaction) { return ['Already processed this transaction.', { status => 200 }]; } @@ -140,9 +139,8 @@ sub www_jambool_reversal { my $transaction = Lacuna->db->resultset('Lacuna::DB::Result::Log::Essentia')->search( { transaction_id => $transaction_id, - }, - { rows => 1 } - )->single; + } + )->first; unless (defined $transaction) { return ['No record of this transaction.', { status => 402 }]; } @@ -704,9 +702,8 @@ sub www_buy_currency_cc { return ['Not a valid iTransact AuthCode.', { status => 402 }]; } my $transaction = Lacuna->db->resultset('Lacuna::DB::Result::Log::Essentia')->search( - { transaction_id => $transaction_id }, - { rows => 1 } - )->single; + { transaction_id => $transaction_id } + )->first; if (defined $transaction) { return ['Already processed this transaction.', { status => 200 }]; } @@ -871,9 +868,8 @@ sub www_paypal_ec_checkout { return ['Not a valid PayPal TransactionID.', { status => 402 }]; } my $transaction = Lacuna->db->resultset('Lacuna::DB::Result::Log::Essentia')->search( - { transaction_id => $transaction_id }, - { rows => 1 } - )->single; + { transaction_id => $transaction_id } + )->first; if (defined $transaction) { return ['Already processed this transaction.', { status => 200 }]; } diff --git a/t/010_Empire.t b/t/010_Empire.t index 66fb78ca..e3e5d8bd 100644 --- a/t/010_Empire.t +++ b/t/010_Empire.t @@ -234,7 +234,7 @@ is($result->{result}{species}{name}, 'The BORGinator', 'get renamed species name is($result->{result}{status}{empire}{essentia}, '100.0', 'essentia spent'); # as far as I can tell, we don't create an EssentiaCode in this test. -#my $code = Lacuna->db->resultset('Lacuna::DB::Result::EssentiaCode')->search({description=>'essentia code deleted'},{rows=>1})->single; +#my $code = Lacuna->db->resultset('Lacuna::DB::Result::EssentiaCode')->search({description=>'essentia code deleted'})->first; #is($result->{result}{status}{empire}{essentia}, $code->amount, 'you get a proper essentia code'); END { diff --git a/t/220_Parliament.t b/t/220_Parliament.t index b961562a..b7315a30 100644 --- a/t/220_Parliament.t +++ b/t/220_Parliament.t @@ -39,7 +39,7 @@ ok $empire->alliance_id, 'empire has alliance'; $friend->empire->alliance_id($empire->alliance_id); $friend->empire->update; -my $station = Lacuna->db->resultset('Map::Body')->search({class => {like => 'Lacuna::DB::Result::Map::Body::Planet::P%'}, empire_id => undef},{rows=>1})->single; +my $station = Lacuna->db->resultset('Map::Body')->search({class => {like => 'Lacuna::DB::Result::Map::Body::Planet::P%'}, empire_id => undef})->first; $station->convert_to_station($empire); $station->discard_changes; # just in case diff --git a/t/310_SpacePort.t b/t/310_SpacePort.t index 2fe70178..d29fe362 100644 --- a/t/310_SpacePort.t +++ b/t/310_SpacePort.t @@ -147,9 +147,9 @@ my $spy_id = $result->{result}{spies}[0]{id}; $result = $tester->post('spaceport', 'send_spies', [$session_id, $home->id, $enemy->empire->home_planet->id, $spy_pod->id, [ $spy_id ] ]); ok($result->{result}{ship}{date_arrives}, "spy pod sent"); -$spy_pod = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_pod->id},{rows=>1})->single; # pull the latest data on this ship +$spy_pod = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_pod->id})->first; # pull the latest data on this ship $spy_pod->arrive; -$spy = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({id=>$spy_id},{rows=>1})->single; +$spy = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({id=>$spy_id})->first; $spy->available_on($finish); $spy->task('Idle'); $spy->update; @@ -184,13 +184,13 @@ my $spies = $result->{result}{spies}; $result = $tester->post('spaceport', 'send_spies', [$session_id, $home->id, $enemy->empire->home_planet->id, $spy_shuttle->id, $spies ] ); ok($result->{result}{ship}{date_arrives}, "spy shuttle sent to orbit"); -$spy_shuttle = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_shuttle->id},{rows=>1})->single; # pull the latest data on this ship +$spy_shuttle = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_shuttle->id})->first; # pull the latest data on this ship $spy_shuttle->arrive; -$spy_shuttle = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_shuttle->id},{rows=>1})->single; # pull the latest data on this ship +$spy_shuttle = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_shuttle->id})->first; # pull the latest data on this ship for my $spy_id ( @$spies ) { - $spy = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({id=>$spy_id},{rows=>1})->single; + $spy = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search({id=>$spy_id})->first; $spy->available_on($finish); $spy->task('Idle'); $spy->update; @@ -202,10 +202,10 @@ is(ref $result->{result}{orbiting}, 'ARRAY', "can see what ships are available t $result = $tester->post('spaceport', 'prepare_fetch_spies', [$session_id, $enemy->empire->home_planet->id, $home->id ]); is( ref $result->{result}{ships}, 'ARRAY', "can prepare for fetch spies"); -$spy_shuttle = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_shuttle->id},{rows=>1})->single; # pull the latest data on this ship +$spy_shuttle = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_shuttle->id})->first; # pull the latest data on this ship $result = $tester->post('spaceport', 'recall_ship', [$session_id, $spaceport->id, $spy_shuttle->id]); ok($result->{result}{ship}{date_arrives}, "spy shuttle recalled"); -$spy_shuttle = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_shuttle->id},{rows=>1})->single; # pull the latest data on this ship +$spy_shuttle = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$spy_shuttle->id})->first; # pull the latest data on this ship $spy_shuttle->arrive; $result = $tester->post('spaceport', 'view_all_ships', diff --git a/t/320_AlliedDefense.t b/t/320_AlliedDefense.t index 8a649156..175b03c8 100644 --- a/t/320_AlliedDefense.t +++ b/t/320_AlliedDefense.t @@ -228,42 +228,42 @@ for my $i ( 0 .. 1 ) { my $planet = $tester{planet}; # Send a probe to the enemy's star - my $probe = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'probe'},{rows=>1})->single; + my $probe = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'probe'})->first; diag "Sending ship ", $probe->id, " type ", $probe->type, " to star_id ", $enemy{home}->star_id; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $probe->id, {star_id=>$enemy{home}->star_id}]); diag "Probe arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "probe sent"); - $probe = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$probe->id},{rows=>1})->single; # pull the latest data on this ship + $probe = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$probe->id})->first; # pull the latest data on this ship $probe->arrive; # Send a mining platform ship to the closest asteroid - my $miningship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'mining_platform_ship'},{rows=>1})->single; + my $miningship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'mining_platform_ship'})->first; diag "Sending ship ", $miningship->id, " type ", $miningship->type, " to ", $asteroid->{x}, ",", $asteroid->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $miningship->id, {x=>$asteroid->{x},y=>$asteroid->{y}}]); diag "Mining Platform Ship arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "mining platform ship sent"); - $miningship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$miningship->id},{rows=>1})->single; # pull the latest data on this ship + $miningship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$miningship->id})->first; # pull the latest data on this ship $miningship->arrive; # Send a fighter to defend the closest asteroid - my $fighter = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'fighter', task=>'Docked'},{rows=>1})->single; + my $fighter = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'fighter', task=>'Docked'})->first; diag "Sending ship ", $fighter->id, " type ", $fighter->type, " to ", $asteroid->{x}, ",", $asteroid->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $fighter->id, { x => $asteroid->{x}, y => $asteroid->{y} }]); diag "Fighter arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "fighter sent"); - $fighter = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter->id},{rows=>1})->single; # pull the latest data on this ship + $fighter = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter->id})->first; # pull the latest data on this ship $fighter->arrive; $result = $tester->post('spaceport', 'get_ships_for', [$tester{session_id}, $tester{home}->id, { x => $asteroid->{x}, y => $asteroid->{y} } ]); is( @{ $result->{result}{orbiting} }, 1, 'one ship is orbiting' ); # Send a fighter to defend the closest planet - my $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'fighter', task=>'Docked'},{rows=>1})->single; + my $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'fighter', task=>'Docked'})->first; diag "Sending ship ", $fighter2->id, " type ", $fighter2->type, " to ", $planet->{x}, ",", $planet->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $fighter2->id, { x => $planet->{x}, y => $planet->{y} }]); diag "Fighter arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "fighter2 sent"); - $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter2->id},{rows=>1})->single; # pull the latest data on this ship + $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter2->id})->first; # pull the latest data on this ship $fighter2->arrive; $tester->{fighter2} = $fighter2->id; @@ -321,12 +321,12 @@ for my $i ( 0 .. 1 ) { my $planet = $enemy{planet}; # Send a sweeper to the enemy's asteroid - my $sweeper = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'sweeper'},{rows=>1})->single; + my $sweeper = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'sweeper'})->first; diag "Sending ship ", $sweeper->id, " type ", $sweeper->type, " to ", $asteroid->{x}, ",", $asteroid->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $sweeper->id, { x => $asteroid->{x}, y => $asteroid->{y} }]); diag "Sweeper arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "sweeper sent"); - $sweeper = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$sweeper->id},{rows=>1})->single; # pull the latest data on this ship + $sweeper = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$sweeper->id})->first; # pull the latest data on this ship $sweeper->arrive; $result = $tester->post('spaceport', 'view_all_ships', [$tester{session_id}, $tester->{spaceport_id}]); @@ -338,12 +338,12 @@ for my $i ( 0 .. 1 ) { is( $ships{sweeper}, 1, 'One sweeper left' ); # Send a fighter to enemy asteroid - my $fighter3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'fighter', task=>'Docked'},{rows=>1})->single; + my $fighter3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'fighter', task=>'Docked'})->first; diag "Sending ship ", $fighter3->id, " type ", $fighter3->type, " to ", $asteroid->{x}, ",", $asteroid->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $fighter3->id, { x => $asteroid->{x}, y => $asteroid->{y} }]); diag "Fighter arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "fighter3 sent"); - $fighter3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter3->id},{rows=>1})->single; # pull the latest data on this ship + $fighter3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter3->id})->first; # pull the latest data on this ship $fighter3->arrive; $result = $tester->post('spaceport', 'view_all_ships', [$tester{session_id}, $tester->{spaceport_id}]); @@ -357,29 +357,29 @@ for my $i ( 0 .. 1 ) { } # Recall it - $fighter3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter3->id},{rows=>1})->single; # pull the latest data on this ship + $fighter3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter3->id})->first; # pull the latest data on this ship $result = $tester->post('spaceport', 'recall_ship', [$tester{session_id}, $tester->{spaceport_id}, $fighter3->id]); diag "Fighter arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "fighter recalled"); - $fighter3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter3->id},{rows=>1})->single; # pull the latest data on this ship + $fighter3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$fighter3->id})->first; # pull the latest data on this ship $fighter3->arrive; # Send a mining platform ship to the enemy asteroid - my $miningship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'mining_platform_ship'},{rows=>1})->single; + my $miningship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'mining_platform_ship'})->first; diag "Sending ship ", $miningship->id, " type ", $miningship->type, " to ", $asteroid->{x}, ",", $asteroid->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $miningship->id, {x=>$asteroid->{x},y=>$asteroid->{y}}]); diag "Mining Platform Ship arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "mining platform ship sent"); - $miningship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$miningship->id},{rows=>1})->single; # pull the latest data on this ship + $miningship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$miningship->id})->first; # pull the latest data on this ship $miningship->arrive; - my $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$enemy->{fighter2}},{rows=>1})->single; + my $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$enemy->{fighter2}})->first; diag "Enemy fighter 2 is at ", $fighter2->foreign_body_id, " task ", $fighter2->task, " combat ", $fighter2->combat; $result = $tester->post('spaceport', 'view_all_ships', [$enemy{session_id}, $enemy->{spaceport_id}]); # Send a stake to the enemy's closest planet - my $stake = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'stake'},{rows=>1})->single; + my $stake = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'stake'})->first; diag "Sending ship ", $stake->id, " type ", $stake->type, " to ", $planet->{x}, ",", $planet->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $stake->id, {x=>$planet->{x},y=>$planet->{y}}]); # Cannot send a stake to an inhabited planet @@ -389,12 +389,12 @@ for my $i ( 0 .. 1 ) { is( $result->{result}{status}{empire}{most_recent_message}{subject}, "Ship Shot Down", 'Stake shot down' ); # Accelerate reset period - $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$enemy->{fighter2}},{rows=>1})->single; + $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$enemy->{fighter2}})->first; diag "Enemy fighter 2 is at ", $fighter2->foreign_body_id, " task ", $fighter2->task, " combat ", $fighter2->combat; $fighter2->arrive; - $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$enemy->{fighter2}},{rows=>1})->single; + $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$enemy->{fighter2}})->first; $fighter2->arrive; - $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$enemy->{fighter2}},{rows=>1})->single; + $fighter2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$enemy->{fighter2}})->first; diag "Enemy fighter 2 is at ", $fighter2->foreign_body_id, " task ", $fighter2->task, " combat ", $fighter2->combat; $result = $tester->post('spaceport', 'view_all_ships', [$enemy{session_id}, $enemy->{spaceport_id}]); @@ -403,12 +403,12 @@ for my $i ( 0 .. 1 ) { $tester{home}->update; # Send a colony ship to the enemy's closest planet - my $colony_ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'colony_ship'},{rows=>1})->single; + my $colony_ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'colony_ship'})->first; diag "Sending ship ", $colony_ship->id, " type ", $colony_ship->type, " to ", $planet->{x}, ",", $planet->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $colony_ship->id, {x=>$planet->{x},y=>$planet->{y}}]); diag "Colony ship arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "colony ship sent"); - $colony_ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$colony_ship->id},{rows=>1})->single; # pull the latest data on this ship + $colony_ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$colony_ship->id})->first; # pull the latest data on this ship $colony_ship->arrive; $result = $tester->post('spaceport', 'view_all_ships', [$tester{session_id}, $tester->{spaceport_id}]); @@ -422,23 +422,23 @@ for my $i ( 0 .. 1 ) { } is( $result->{result}{status}{empire}{most_recent_message}{subject}, "Colony Founded", 'Colony founded' ); - my $detonator = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'detonator'},{rows=>1})->single; + my $detonator = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'detonator'})->first; diag "Sending ship ", $detonator->id, " type ", $detonator->type, " to star_id ", $enemy{home}->star_id; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $detonator->id, {star_id=>$enemy{home}->star_id}]); diag "Detonator arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "Detonator sent"); - $detonator = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$detonator->id},{rows=>1})->single; # pull the latest data on this ship + $detonator = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$detonator->id})->first; # pull the latest data on this ship $detonator->arrive; $result = $tester->post('spaceport', 'view', [$tester{session_id}, $tester->{spaceport_id}]); is( $result->{result}{status}{empire}{most_recent_message}{subject}, "Detonator Report", 'Detonator took out probes' ); - my $detonator2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'detonator'},{rows=>1})->single; + my $detonator2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $tester{home}->id, type=>'detonator'})->first; diag "Sending ship ", $detonator2->id, " type ", $detonator2->type, " to ", $asteroid->{x}, ",", $asteroid->{y}; $result = $tester->post('spaceport', 'send_ship', [$tester{session_id}, $detonator2->id, {x=>$asteroid->{x},y=>$asteroid->{y}}]); diag "Detonator arrives ", $result->{result}{ship}{date_arrives}; ok($result->{result}{ship}{date_arrives}, "Detonator sent"); - $detonator2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$detonator2->id},{rows=>1})->single; # pull the latest data on this ship + $detonator2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$detonator2->id})->first; # pull the latest data on this ship $detonator2->arrive; $result = $tester->post('spaceport', 'view', [$tester{session_id}, $tester->{spaceport_id}]); diff --git a/t/340_Observatory.t b/t/340_Observatory.t index 6cbf118f..07aae16d 100644 --- a/t/340_Observatory.t +++ b/t/340_Observatory.t @@ -59,11 +59,11 @@ $tester->finish_ships( $shipyard->id ); $result = $tester->post('spaceport', 'view', [$session_id, $spaceport->id]); is($result->{result}{docked_ships}{probe}, 2, "we have 2 probes built"); -my $ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $home->id, type=>'probe'}, {rows=>1})->single; +my $ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({body_id => $home->id, type=>'probe'})->first; $result = $tester->post('spaceport', 'send_ship', [$session_id, $ship->id, {star_id=>6}]); ok($result->{result}{ship}{date_arrives}, "probe sent"); -$ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$ship->id}, {rows=>1})->single; +$ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$ship->id})->first; $ship->arrive; $empire = $tester->empire(Lacuna->db->resultset('Lacuna::DB::Result::Empire')->find($empire->id)); diff --git a/t/360_Scows.t b/t/360_Scows.t index 730cf6de..35aa3005 100644 --- a/t/360_Scows.t +++ b/t/360_Scows.t @@ -92,7 +92,7 @@ Lacuna->cache->set('captcha', $session_id, { guid => 1111, solution => 1111 }, 6 $result = $tester->post('spaceport', 'send_ship', [$session_id, $scow->id, { star_id => $home->star_id } ] ); ok($result->{result}{ship}{date_arrives}, "scow sent to star id " . $home_star_id); -$scow = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow->id},{rows=>1})->single; # pull the latest data on this ship +$scow = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow->id})->first; # pull the latest data on this ship is( $scow->foreign_star_id, $home->star_id, 'scow is headed to the correct foreign star id' ); is( $scow->foreign_body_id, undef, 'scow does not have a foreign body id' ); @@ -101,7 +101,7 @@ $scow->arrive; is( $scow->task, 'Travelling', 'scow is travelling' ); is( $scow->direction, 'in', 'scow is headed home' ); -$scow = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow->id},{rows=>1})->single; # pull the latest data on this ship +$scow = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow->id})->first; # pull the latest data on this ship $scow->arrive; is( $scow->task, 'Docked', 'scow is docked' ); cmp_deeply( $scow->payload, {}, 'no payload' ); @@ -111,13 +111,13 @@ is($result->{result}, 1, 'Solved captcha'); $result = $tester->post('spaceport', 'send_ship', [$session_id, $scow2->id, { body_id => $enemy->empire->home_planet->id } ] ); ok($result->{result}{ship}{date_arrives}, "scow sent to planet id " . $enemy->empire->home_planet->id); -$scow2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow2->id},{rows=>1})->single; # pull the latest data on this ship +$scow2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow2->id})->first; # pull the latest data on this ship is( $scow2->foreign_star_id, undef, 'scow2 does not have a foreign star id' ); is( $scow2->foreign_body_id, $enemy->empire->home_planet->id, 'scow2 is headed to the correct foreign body id' ); $scow2->arrive; -$scow2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow2->id},{rows=>1})->single; # pull the latest data on this ship +$scow2 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow2->id})->first; # pull the latest data on this ship $result = $tester->post('spaceport', 'view', [$session_id, $spaceport->id]); is( $result->{result}{status}{empire}{most_recent_message}{subject}, "Ship Shot Down", 'Ship Shot Down' ); @@ -136,8 +136,8 @@ Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({shipyard_id=>$shipya $result = $tester->post('spaceport', 'view', [$session_id, $spaceport->id]); -$scow3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow3->id},{rows=>1})->single; # pull the latest data on this ship -$scow4 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow4->id},{rows=>1})->single; # pull the latest data on this ship +$scow3 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow3->id})->first; # pull the latest data on this ship +$scow4 = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({id=>$scow4->id})->first; # pull the latest data on this ship $result = $tester->post('spaceport', 'send_fleet', [$session_id, [$scow3->id, $scow4->id], { star_id => $home->star_id }]); is(scalar @{$result->{result}{fleet}}, 2, 'fleet sent'); diff --git a/t/430_Supply_Chain.t b/t/430_Supply_Chain.t index ca454520..916aaf42 100644 --- a/t/430_Supply_Chain.t +++ b/t/430_Supply_Chain.t @@ -23,17 +23,13 @@ diag("Create a station"); my $station = Lacuna->db->resultset('Map::Body')->search({ class => 'Lacuna::DB::Result::Map::Body::Planet::Station', empire_id => $empire->id, - },{ - rows=>1, -})->single; + })->first; if (not $station) { $station = Lacuna->db->resultset('Map::Body')->search({ class => {like => 'Lacuna::DB::Result::Map::Body::Planet::P%'}, empire_id => undef, - },{ - rows=>1, - })->single; + })->first; $station->convert_to_station($empire); $station = $station->discard_changes; # just in case @@ -52,9 +48,7 @@ $station->tick; my $trade = Lacuna->db->resultset('Building')->search({ class => 'Lacuna::DB::Result::Building::Trade', body_id => $home->id, - },{ - rows => 1, -})->single; + })->first; # remove any existing ships from the supply chain $result = $tester->post('trade','get_supply_ships', [$session_id, $trade->id]); diff --git a/t/440_fleets.t b/t/440_fleets.t index 787056fe..a62528b2 100644 --- a/t/440_fleets.t +++ b/t/440_fleets.t @@ -21,9 +21,7 @@ my $result; my $space_port = Lacuna->db->resultset('Building')->search({ class => 'Lacuna::DB::Result::Building::SpacePort', body_id => $home->id, - },{ - rows => 1, -})->single; + })->first; $result = $tester->post('spaceport','get_fleet_for', [$session_id, $home->id, {body_name => 'DeLambert-5-28'}]); diff --git a/t/TestHelper.pm b/t/TestHelper.pm index d345f512..b19b973f 100644 --- a/t/TestHelper.pm +++ b/t/TestHelper.pm @@ -30,7 +30,7 @@ has empire_password => ( has empire => ( is => 'rw', lazy => 1, - default => sub { my $self = shift; return Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name=>$self->empire_name}, {rows=>1})->single; }, + default => sub { my $self = shift; return Lacuna->db->resultset('Lacuna::DB::Result::Empire')->search({name=>$self->empire_name})->first; }, ); has session => (