Branch Coverage

lib/Catan/Game.pm
Criterion Covered Total %
branch 45 400 11.2


line true false branch
59 0 1 unless @_ <= 2
0 1 unless @_ >= 1
1 0 @_ >= 2 ? :
64 1 0 exists $args->{'log'} && ref $args->{'log'} eq 'GLOB' ? :
83 0 11 unless @_ <= 3
0 11 unless @_ >= 2
4 7 @_ >= 3 ? :
87 0 11 if (not $action_code) { }
10 1 elsif (exists $actions{$action_code}) { }
94 5 5 if $@
105 0 0 unless @_ <= 2
0 0 unless @_ >= 2
110 0 0 unless $player_number and $location
113 0 0 unless $self->is_players_turn($player_number)
116 0 0 unless $self->phase =~ /^(?:Deployment|Play)$/u
119 0 0 if $self->player->has_built_road and $self->phase eq 'Deployment'
124 0 0 unless $self->phase eq 'Deployment' or $self->player->has_rolled_dice or defined $self->{'road_building'} and $self->{'road_building'}->can_build_road
126 0 0 if $self->robber->active
129 0 0 unless my $path = $self->map->find_path($location)
134 0 0 if grep $path->is_colliding($_->location), @{$player->roads;}
138 0 0 $self->phase eq 'Deployment' || defined $self->{'road_building'} && $self->{'road_building'}->can_build_road ? :
147 0 0 unless @_ <= 1
0 0 unless @_ >= 1
166 0 0 if ($have_tested_leading_road) { }
0 0 elsif (@players == 1 and $road_length >= 6 and not $player->longest_road) { }
168 0 0 if $player->longest_road
179 0 0 if (my $game_over = $self->game_over)
186 0 0 unless @_ <= 1
0 0 unless @_ >= 1
188 0 0 if (my $player = $self->player_victory_check)
194 0 0 unless @_ <= 2
0 0 unless @_ >= 2
199 0 0 unless $self->phase =~ /^(?:Deployment|Play)$/u
202 0 0 unless $player_number and $location
205 0 0 unless $self->is_players_turn($player_number)
208 0 0 unless $self->phase eq 'Deployment' or $self->player->has_rolled_dice
211 0 0 if $self->player->has_built_settlement and $self->phase eq 'Deployment'
214 0 0 if $self->robber->active
217 0 0 unless my $intersection = $self->map->find_intersection($location)
223 0 0 unless 0 == grep(($intersection->is_colliding($_->location) || $intersection->is_adjacent($_->location)), @{$player->properties;})
226 0 0 $self->phase eq 'Deployment' ? :
232 0 0 if ($self->phase eq 'Deployment' and $self->round == 2)
240 0 0 unless @_ <= 2
0 0 unless @_ >= 2
245 0 0 unless $self->phase =~ /^(?:Deployment|Play)$/u
248 0 0 unless $player_number and $location
251 0 0 unless $self->is_players_turn($player_number)
254 0 0 unless $self->player->has_rolled_dice
257 0 0 if $self->robber->active
260 0 0 unless my $intersection = $self->map->find_intersection($location)
266 0 0 unless @_ <= 2
0 0 unless @_ >= 2
271 0 0 unless $self->phase =~ /^(?:Deployment|Play)$/u
274 0 0 unless $player_number
277 0 0 unless $self->player->number == $player_number
280 0 0 unless $self->player->has_rolled_dice
283 0 0 if $self->robber->active
290 0 0 unless @_ <= 2
0 0 unless @_ >= 2
295 0 0 unless $player_number and $type
298 0 0 unless $self->phase eq 'Play'
301 0 0 unless $self->is_players_turn($player_number)
304 0 0 if $self->player->has_played_dc
307 0 0 if $self->robber->active
315 0 0 if ($card->type eq 'KN') { }
0 0 elsif ($card->type eq 'YP') { }
0 0 elsif ($card->type eq 'MO') { }
0 0 elsif ($card->type eq 'RB') { }
361 0 0 if ($have_tested_leaders) { }
0 0 elsif (@players == 1 and $knights_played >= 3 and not $player->largest_army) { }
363 0 0 if $player->largest_army
375 0 0 if (my $game_over = $self->game_over)
382 0 0 unless @_ <= 2
0 0 unless @_ >= 2
387 0 0 unless $player_number and $code
390 0 0 unless $self->is_players_turn($player_number)
394 0 0 unless defined $self->{'monopoly'}
396 0 0 if $self->robber->active
405 0 0 unless @_ <= 2
0 0 unless @_ >= 2
410 0 0 unless $player_number and $resources and ref $resources eq 'HASH'
413 0 0 unless $self->is_players_turn($player_number)
417 0 0 unless defined $self->{'year_of_plenty'}
428 0 2 unless @_ <= 2
0 2 unless @_ >= 1
1 1 @_ >= 2 ? :
430 0 2 if $self->{'phase_index'} == $#phases
441 1 1 if ($new_phase eq 'Deployment') { }
0 1 elsif ($new_phase eq 'Play') { }
452 0 0 unless @_ <= 2
0 0 unless @_ >= 2
463 0 0 unless $player and $resources and ref $resources eq 'HASH' and 1 == keys %$resources and exists $resources->{$player_number} and &all(sub { $_ < 0; } , values %{$$resources{$player_number};}) and 1 == grep(($player_number == $_->{'player'}->number), @{$self->robber->check_players_to_concede;})
478 0 0 if $msg
483 0 6 unless @_ <= 2
0 6 unless @_ >= 2
488 0 6 unless $player_number eq 'A' || $self->is_player_number($player_number) and $msg
494 0 1 unless @_ <= 2
0 1 unless @_ >= 1
0 1 @_ >= 2 ? :
500 0 0 unless @_ <= 2
0 0 unless @_ >= 1
0 0 @_ >= 2 ? :
504 0 0 $args->{'from_7'} ? :
512 0 0 if $msg
516 0 0 unless @_ <= 2
0 0 unless @_ >= 1
0 0 @_ >= 2 ? :
523 0 0 unless @_ <= 2
0 0 unless @_ >= 2
529 0 0 unless $player and $target_player
532 0 0 unless $self->is_players_turn($player->number)
547 0 0 unless @_ <= 2
0 0 unless @_ >= 2
552 0 0 unless $player_number and $location
555 0 0 unless $player_number == $self->player->number
566 0 0 unless $self->robber->active
570 0 1 unless @_ <= 2
0 1 unless @_ >= 1
1 0 @_ >= 2 ? :
575 0 0 unless @_ <= 2
0 0 unless @_ >= 1
0 0 @_ >= 2 ? :
580 0 0 unless @_ <= 2
0 0 unless @_ >= 1
0 0 @_ >= 2 ? :
585 0 0 if ($self->phase eq 'Deployment' and $self->round == 2)
592 0 0 unless @_ <= 2
0 0 unless @_ >= 1
0 0 @_ >= 2 ? :
594 0 0 if $self->phase eq 'Setup'
596 0 0 if ($self->turn == 0) { }
0 0 elsif ($self->phase eq 'Deployment' and $self->turn == @{$self->players;} and @{$self->player->settlements;} == 1) { }
0 0 elsif ($self->phase eq 'Deployment' and @{$self->player->settlements;} == 2) { }
0 0 elsif ($self->phase eq 'Play' and $self->{'turn_index'} + 1 == @{$self->players;}) { }
631 0 0 unless @_ <= 2
0 0 unless @_ >= 1
0 0 @_ >= 2 ? :
635 0 0 unless $self->is_players_turn($player_number)
638 0 0 unless $self->phase eq 'Deployment' or $self->player->has_rolled_dice
641 0 0 if $self->phase eq 'Deployment' and not $self->player->has_built_road && $self->player->has_built_settlement
647 0 0 if ($self->robber->active)
664 0 0 if ($self->turn == @{$self->players;} and $self->phase eq 'Play' or $self->phase eq 'Deployment' and @{$self->player->properties;} == 2 and $self->turn == 1 or $self->phase eq 'Deployment' and @{$self->player->properties;} == 1 and $self->turn == @{$self->players;}) { }
683 0 0 unless @_ <= 2
0 0 unless @_ >= 1
0 0 @_ >= 2 ? :
688 0 0 if $players_by_vps[0]->victory_points_count >= 10
691 0 5 unless @_ <= 2
0 5 unless @_ >= 1
5 0 @_ >= 2 ? :
693 0 5 unless $self->phase eq 'Setup'
695 1 4 unless $self->{'max_players'} > @{$self->players;}
703 0 0 unless @_ <= 2
0 0 unless @_ >= 2
707 0 0 unless $self->is_players_turn($player_number)
714 0 0 if ($dice_roll == 7) { }
725 0 0 unless @_ <= 2
0 0 unless @_ >= 2
733 0 0 if $self->robber->location->uuid eq $tile->uuid
739 0 0 if ($property->location->is_adjacent($tile))
742 0 0 $property->isa('Catan::Asset::Settlement') ? :
743 0 0 unless my $resource = $tile->yields($amount)
751 0 0 if (exists $resources{$player->number})
766 0 0 unless @_ <= 2
0 0 unless @_ >= 2
775 0 0 unless $resource
784 0 0 unless @_ <= 2
0 0 unless @_ >= 2
790 0 0 unless grep(($self->player->number == $_), keys %$details)
793 0 0 unless grep(($offering_player == $_), keys %$details)
796 0 0 unless $self->player->has_rolled_dice
799 0 0 if exists $self->trades->{$uuid}
811 0 0 unless @_ <= 2
0 0 unless @_ >= 2
816 0 0 unless grep(($self->player->number == $_), keys %$details) and $player_number == $self->player->number
825 0 0 unless @_ <= 2
0 0 unless @_ >= 2
830 0 0 unless @_ <= 1
0 0 unless @_ >= 1
837 0 0 unless @_ <= 2
0 0 unless @_ >= 2
846 0 0 unless $player_number and $uuid and exists $self->trades->{$uuid} and $self->trades->{$uuid}{'player'} != $player_number and $self->trades->{$uuid}{'trade'}->resources($player_number)
857 0 0 unless @_ <= 2
0 0 unless @_ >= 2
866 0 0 unless $player_number and $uuid and exists $self->trades->{$uuid} and $self->trades->{$uuid}{'player'} == $player_number and $self->trades->{$uuid}{'trade'}->resources($player_number)
872 0 1 unless @_ <= 1
0 1 unless @_ >= 1
877 0 1 unless @_ <= 1
0 1 unless @_ >= 1
882 0 3 unless @_ <= 2
0 3 unless @_ >= 2
884 0 3 unless $self->phase eq 'Setup'
898 0 0 unless @_ <= 2
0 0 unless @_ >= 2
900 0 0 unless $number
902 0 0 unless @player
906 0 0 unless @_ <= 2
0 0 unless @_ >= 2
908 0 0 unless $number
915 0 11 unless $msgs and ref $msgs eq 'ARRAY'
916 0 11 unless my $fh = $self->{'log'}