Branch Coverage

lib/Catan/Game.pm
Criterion Covered Total %
branch 241 414 58.2


line true false branch
60 0 1 unless @_ <= 2
0 1 unless @_ >= 1
1 0 @_ >= 2 ? :
65 1 0 exists $args->{'log'} && ref $args->{'log'} eq 'GLOB' ? :
84 0 239 unless @_ <= 3
0 239 unless @_ >= 2
232 7 @_ >= 3 ? :
88 0 239 if (not $action_code) { }
238 1 elsif (exists $actions{$action_code}) { }
95 8 230 if $@
106 0 30 unless @_ <= 2
0 30 unless @_ >= 2
111 0 30 unless $player_number and $location
114 0 30 unless $self->is_players_turn($player_number)
117 0 30 unless $self->phase =~ /^(?:Deployment|Play)$/u
120 0 30 if $self->player->has_built_road and $self->phase eq 'Deployment'
125 0 2 unless $self->phase eq 'Deployment' or $self->player->has_rolled_dice or defined $self->{'road_building'} and $self->{'road_building'}->can_build_road
127 0 30 if $self->robber->active
130 0 30 unless my $path = $self->map->find_path($location)
135 0 120 if grep $path->is_colliding($_->location), @{$player->roads;}
139 12 18 $self->phase eq 'Deployment' || defined $self->{'road_building'} && $self->{'road_building'}->can_build_road ? :
148 0 43 unless @_ <= 1
0 43 unless @_ >= 1
167 104 68 if ($have_tested_leading_road) { }
2 83 elsif (@players == 1 and $road_length >= 6 and not $player->longest_road) { }
169 1 103 if $player->longest_road
180 0 43 if (my $game_over = $self->game_over)
187 0 46 unless @_ <= 1
0 46 unless @_ >= 1
189 1 45 if (my $player = $self->player_victory_check)
195 0 15 unless @_ <= 2
0 15 unless @_ >= 2
200 0 15 unless $self->phase =~ /^(?:Deployment|Play)$/u
203 0 15 unless $player_number and $location
206 1 14 unless $self->is_players_turn($player_number)
209 0 14 unless $self->phase eq 'Deployment' or $self->player->has_rolled_dice
212 1 13 if $self->player->has_built_settlement and $self->phase eq 'Deployment'
215 0 13 if $self->robber->active
218 0 13 unless my $intersection = $self->map->find_intersection($location)
224 0 52 unless 0 == grep(($intersection->is_colliding($_->location) || $intersection->is_adjacent($_->location)), @{$player->properties;})
227 8 5 $self->phase eq 'Deployment' ? :
233 4 9 if ($self->phase eq 'Deployment' and $self->round == 2)
241 0 6 unless @_ <= 2
0 6 unless @_ >= 2
246 0 6 unless $self->phase =~ /^(?:Deployment|Play)$/u
249 0 6 unless $player_number and $location
252 0 6 unless $self->is_players_turn($player_number)
255 0 6 unless $self->player->has_rolled_dice
258 0 6 if $self->robber->active
261 0 6 unless my $intersection = $self->map->find_intersection($location)
267 0 8 unless @_ <= 2
0 8 unless @_ >= 2
272 0 8 unless $self->phase =~ /^(?:Deployment|Play)$/u
275 0 8 unless $player_number
278 0 8 unless $self->player->number == $player_number
281 0 8 unless $self->player->has_rolled_dice
284 0 8 if $self->robber->active
291 0 7 unless @_ <= 2
0 7 unless @_ >= 2
296 0 7 unless $player_number and $type
299 0 7 unless $self->phase eq 'Play'
302 0 7 unless $self->is_players_turn($player_number)
305 0 7 if $self->player->has_played_dc
308 0 7 if $self->robber->active
316 3 4 if ($card->type eq 'KN') { }
1 3 elsif ($card->type eq 'YP') { }
1 2 elsif ($card->type eq 'MO') { }
2 0 elsif ($card->type eq 'RB') { }
362 9 3 if ($have_tested_leaders) { }
1 4 elsif (@players == 1 and $knights_played >= 3 and not $player->largest_army) { }
364 0 9 if $player->largest_army
376 1 2 if (my $game_over = $self->game_over)
383 0 1 unless @_ <= 2
0 1 unless @_ >= 2
388 0 1 unless $player_number and $code
391 0 1 unless $self->is_players_turn($player_number)
395 0 1 unless defined $self->{'monopoly'}
397 0 1 if $self->robber->active
406 0 1 unless @_ <= 2
0 1 unless @_ >= 2
411 0 1 unless $player_number and $resources and ref $resources eq 'HASH'
414 0 1 unless $self->is_players_turn($player_number)
418 0 1 unless defined $self->{'year_of_plenty'}
429 0 4 unless @_ <= 2
0 4 unless @_ >= 1
0 4 @_ >= 2 ? :
431 0 4 if $self->{'phase_index'} == $#phases
442 1 3 if ($new_phase eq 'Deployment') { }
1 2 elsif ($new_phase eq 'Play') { }
453 0 0 unless @_ <= 2
0 0 unless @_ >= 2
464 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;})
479 0 0 if $msg
484 0 9 unless @_ <= 2
0 9 unless @_ >= 2
489 0 9 unless $player_number eq 'A' || $self->is_player_number($player_number) and $msg
495 0 1 unless @_ <= 2
0 1 unless @_ >= 1
0 1 @_ >= 2 ? :
501 0 8 unless @_ <= 2
0 8 unless @_ >= 1
8 0 @_ >= 2 ? :
505 5 3 $args->{'from_7'} ? :
513 0 8 if $msg
517 0 0 unless @_ <= 2
0 0 unless @_ >= 1
0 0 @_ >= 2 ? :
524 0 6 unless @_ <= 2
0 6 unless @_ >= 2
530 0 6 unless $player and $target_player
533 0 6 unless $self->is_players_turn($player->number)
548 0 7 unless @_ <= 2
0 7 unless @_ >= 2
553 0 7 unless $player_number and $location
556 0 7 unless $player_number == $self->player->number
567 0 7 unless $self->robber->active
571 0 3 unless @_ <= 2
0 3 unless @_ >= 1
1 2 @_ >= 2 ? :
574 1 2 if ($self->phase eq 'Setup') { }
1 1 elsif ($self->phase eq 'Deployment') { }
1 0 elsif ($self->phase eq 'Play') { }
576 0 1 unless defined $self->map
580 0 1 unless @{$self->players;} >= 3
585 0 1 unless $self->round == 2 and $self->player->number eq '1'
590 0 1 unless defined $self->player_victory_check
597 0 17 unless @_ <= 2
0 17 unless @_ >= 1
0 17 @_ >= 2 ? :
602 0 16 unless @_ <= 2
0 16 unless @_ >= 1
0 16 @_ >= 2 ? :
607 1 15 if ($self->phase eq 'Deployment' and $self->round == 2)
614 0 65 unless @_ <= 2
0 65 unless @_ >= 1
0 65 @_ >= 2 ? :
616 0 65 if $self->phase eq 'Setup'
618 2 63 if ($self->turn == 0) { }
1 62 elsif ($self->phase eq 'Deployment' and $self->turn == @{$self->players;} and @{$self->player->settlements;} == 1) { }
3 59 elsif ($self->phase eq 'Deployment' and @{$self->player->settlements;} == 2) { }
14 45 elsif ($self->phase eq 'Play' and $self->{'turn_index'} + 1 == @{$self->players;}) { }
653 0 67 unless @_ <= 2
0 67 unless @_ >= 1
67 0 @_ >= 2 ? :
657 1 66 unless $self->is_players_turn($player_number)
660 1 65 unless $self->phase eq 'Deployment' or $self->player->has_rolled_dice
663 1 64 if $self->phase eq 'Deployment' and not $self->player->has_built_road && $self->player->has_built_settlement
669 2 62 if ($self->robber->active)
686 16 48 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;}) { }
705 0 47 unless @_ <= 2
0 47 unless @_ >= 1
0 47 @_ >= 2 ? :
710 2 45 if $players_by_vps[0]->victory_points_count >= 10
713 0 5 unless @_ <= 2
0 5 unless @_ >= 1
5 0 @_ >= 2 ? :
715 0 5 unless $self->phase eq 'Setup'
717 1 4 unless $self->{'max_players'} > @{$self->players;}
725 0 56 unless @_ <= 2
0 56 unless @_ >= 2
729 0 56 unless $self->is_players_turn($player_number)
736 5 51 if ($dice_roll == 7) { }
747 0 51 unless @_ <= 2
0 51 unless @_ >= 2
755 17 68 if $self->robber->location->uuid eq $tile->uuid
761 108 600 if ($property->location->is_adjacent($tile))
764 88 20 $property->isa('Catan::Asset::Settlement') ? :
765 0 108 unless my $resource = $tile->yields($amount)
773 73 131 if (exists $resources{$player->number})
788 0 4 unless @_ <= 2
0 4 unless @_ >= 2
797 0 12 unless $resource
806 0 10 unless @_ <= 2
0 10 unless @_ >= 2
812 0 10 unless grep(($self->player->number == $_), keys %$details)
815 0 10 unless grep(($offering_player == $_), keys %$details)
818 0 10 unless $self->player->has_rolled_dice
821 0 10 if exists $self->trades->{$uuid}
833 0 5 unless @_ <= 2
0 5 unless @_ >= 2
838 0 5 unless grep(($self->player->number == $_), keys %$details) and $player_number == $self->player->number
847 0 10 unless @_ <= 2
0 10 unless @_ >= 2
852 0 64 unless @_ <= 1
0 64 unless @_ >= 1
859 0 9 unless @_ <= 2
0 9 unless @_ >= 2
868 0 9 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)
879 0 1 unless @_ <= 2
0 1 unless @_ >= 2
888 0 1 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)
894 0 1 unless @_ <= 1
0 1 unless @_ >= 1
899 0 1 unless @_ <= 1
0 1 unless @_ >= 1
904 0 3 unless @_ <= 2
0 3 unless @_ >= 2
906 0 3 unless $self->phase eq 'Setup'
920 0 12 unless @_ <= 2
0 12 unless @_ >= 2
922 0 12 unless $number
924 0 12 unless @player
928 0 189 unless @_ <= 2
0 189 unless @_ >= 2
930 0 189 unless $number
937 0 240 unless $msgs and ref $msgs eq 'ARRAY'
938 0 240 unless my $fh = $self->{'log'}