Branch Coverage

lib/Settlers/Game.pm
Criterion Covered Total %
branch 242 416 58.1


line true false branch
60 0 1 unless @_ <= 2
0 1 unless @_ >= 1
0 1 @_ >= 2 ? :
90 0 240 unless @_ <= 2
0 240 unless @_ >= 2
99 0 240 if (not $code && $value or ref $value ne 'HASH' or not $sender) { }
0 240 elsif (exists $value->{'player'} and $sender ne 'A' and $value->{'player'} ne $sender) { }
1 239 elsif (not exists $events{$code}) { }
132 231 187 if ($first) { }
158 8 231 if $@
164 0 30 unless @_ <= 2
0 30 unless @_ >= 2
169 0 30 unless $player_number and $location
172 0 30 unless $self->is_players_turn($player_number)
175 0 30 unless $self->phase =~ /^(?:Deployment|Play)$/u
181 0 8 if $self->phase eq 'Deployment' and $self->round == 2 and scalar @{$self->player->settlements;} == 1
183 0 30 if $self->player->has_built_road and $self->phase eq 'Deployment'
188 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
190 0 30 if $self->robber->active
193 0 30 unless my $path = $self->map->find_path($location)
198 0 120 if grep $path->is_colliding($_->location), @{$player->roads;}
202 12 18 $self->phase eq 'Deployment' || defined $self->{'road_building'} && $self->{'road_building'}->can_build_road ? :
211 0 43 unless @_ <= 1
0 43 unless @_ >= 1
230 104 68 if ($have_tested_leading_road) { }
2 77 elsif (@players == 1 and $road_length >= 5 and not $player->longest_road) { }
232 1 103 if $player->longest_road
243 0 43 if (my $game_over = $self->game_over)
250 0 46 unless @_ <= 1
0 46 unless @_ >= 1
252 1 45 if (my $player = $self->player_victory_check)
258 0 15 unless @_ <= 2
0 15 unless @_ >= 2
263 0 15 unless $self->phase =~ /^(?:Deployment|Play)$/u
266 0 15 unless $player_number and $location
269 1 14 unless $self->is_players_turn($player_number)
272 0 14 unless $self->phase eq 'Deployment' or $self->player->has_rolled_dice
275 1 13 if $self->player->has_built_settlement and $self->phase eq 'Deployment'
278 0 13 if $self->robber->active
281 0 13 unless my $intersection = $self->map->find_intersection($location)
287 0 52 unless 0 == grep(($intersection->is_colliding($_->location) || $intersection->is_adjacent($_->location)), @{$player->properties;})
290 8 5 $self->phase eq 'Deployment' ? :
296 4 9 if ($self->phase eq 'Deployment' and $self->round == 2)
304 0 6 unless @_ <= 2
0 6 unless @_ >= 2
309 0 6 unless $self->phase =~ /^(?:Deployment|Play)$/u
312 0 6 unless $player_number and $location
315 0 6 unless $self->is_players_turn($player_number)
318 0 6 unless $self->player->has_rolled_dice
321 0 6 if $self->robber->active
324 0 6 unless my $intersection = $self->map->find_intersection($location)
330 0 8 unless @_ <= 2
0 8 unless @_ >= 2
335 0 8 unless $self->phase =~ /^(?:Deployment|Play)$/u
338 0 8 unless $player_number
341 0 8 unless $self->player->number == $player_number
344 0 8 unless $self->player->has_rolled_dice
347 0 8 if $self->robber->active
354 0 8 unless @_ <= 2
0 8 unless @_ >= 2
359 0 8 unless $player_number and $type
362 0 8 unless $self->phase eq 'Play'
365 0 8 unless $self->is_players_turn($player_number)
368 0 8 if $self->player->has_played_dc
371 0 8 if $self->robber->active
379 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') { }
425 9 3 if ($have_tested_leaders) { }
1 4 elsif (@players == 1 and $knights_played >= 3 and not $player->largest_army) { }
427 0 9 if $player->largest_army
439 1 2 if (my $game_over = $self->game_over)
446 0 1 unless @_ <= 2
0 1 unless @_ >= 2
451 0 1 unless $player_number and $code
454 0 1 unless $self->is_players_turn($player_number)
458 0 1 unless defined $self->{'monopoly'}
460 0 1 if $self->robber->active
469 0 1 unless @_ <= 2
0 1 unless @_ >= 2
474 0 1 unless $player_number and $resources and ref $resources eq 'HASH'
477 0 1 unless $self->is_players_turn($player_number)
481 0 1 unless defined $self->{'year_of_plenty'}
492 0 4 unless @_ <= 2
0 4 unless @_ >= 1
1 3 @_ >= 2 ? :
494 0 4 if $self->{'phase_index'} == $#phases
505 1 3 if ($new_phase eq 'Deployment') { }
1 2 elsif ($new_phase eq 'Play') { }
516 0 0 unless @_ <= 2
0 0 unless @_ >= 2
525 0 0 unless $player and $resources and ref $resources eq 'HASH' and 1 == keys %$resources and exists $resources->{$player_number}
528 0 0 unless &all(sub { $_ < 0; } , values %{$$resources{$player_number};})
531 0 0 unless $self->phase eq 'Play' and 1 == grep(($player_number == $_->{'player'}->number), @{$self->robber->check_players_to_concede;})
546 0 0 if $msg
551 0 9 unless @_ <= 2
0 9 unless @_ >= 2
557 0 9 unless $player_number eq 'A' || grep(($player_number eq $_->number), @{$self->players;}) and $msg
562 0 1 unless @_ <= 2
0 1 unless @_ >= 1
0 1 @_ >= 2 ? :
568 0 8 unless @_ <= 2
0 8 unless @_ >= 1
8 0 @_ >= 2 ? :
572 5 3 $args->{'from_7'} ? :
580 0 8 if $msg
584 0 7 unless @_ <= 2
0 7 unless @_ >= 1
0 7 @_ >= 2 ? :
591 0 6 unless @_ <= 2
0 6 unless @_ >= 2
597 0 6 unless $player and $target_player
600 0 6 unless $self->is_players_turn($player->number)
614 0 7 unless @_ <= 2
0 7 unless @_ >= 2
619 0 7 unless $player_number and $location
622 0 7 unless $player_number == $self->player->number
632 2 5 unless $self->robber->can_steal
636 0 3 unless @_ <= 2
0 3 unless @_ >= 1
1 2 @_ >= 2 ? :
639 1 2 if ($self->phase eq 'Setup') { }
1 1 elsif ($self->phase eq 'Deployment') { }
1 0 elsif ($self->phase eq 'Play') { }
641 0 1 unless defined $self->map
645 0 1 unless @{$self->players;} >= 3
650 0 1 unless $self->round == 2 and $self->player->number eq '1'
655 0 1 unless defined $self->player_victory_check
662 0 17 unless @_ <= 2
0 17 unless @_ >= 1
0 17 @_ >= 2 ? :
667 0 16 unless @_ <= 2
0 16 unless @_ >= 1
0 16 @_ >= 2 ? :
672 1 15 if ($self->phase eq 'Deployment' and $self->round == 2)
679 0 65 unless @_ <= 2
0 65 unless @_ >= 1
0 65 @_ >= 2 ? :
681 0 65 if $self->phase eq 'Setup'
683 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;}) { }
718 0 66 unless @_ <= 2
0 66 unless @_ >= 1
66 0 @_ >= 2 ? :
722 0 66 unless $self->is_players_turn($player_number)
725 1 65 unless $self->phase eq 'Deployment' or $self->player->has_rolled_dice
728 1 64 if $self->phase eq 'Deployment' and not $self->player->has_built_road && $self->player->has_built_settlement
734 0 64 if ($self->robber->active)
736 0 0 if $self->robber->can_steal
752 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;}) { }
771 0 47 unless @_ <= 2
0 47 unless @_ >= 1
0 47 @_ >= 2 ? :
776 2 45 if $players_by_vps[0]->victory_points_count >= 10
779 0 5 unless @_ <= 2
0 5 unless @_ >= 1
5 0 @_ >= 2 ? :
781 0 5 unless $self->phase eq 'Setup'
783 1 4 unless $self->{'max_players'} > @{$self->players;}
791 0 56 unless @_ <= 2
0 56 unless @_ >= 2
795 0 56 unless $self->is_players_turn($player_number)
798 0 56 if $self->player->has_rolled_dice
805 5 51 if ($dice_roll == 7) { }
816 0 51 unless @_ <= 2
0 51 unless @_ >= 2
824 9 76 if $self->robber->location->uuid eq $tile->uuid
830 120 692 if ($property->location->is_adjacent($tile))
833 94 26 $property->isa('Settlers::Asset::Settlement') ? :
834 0 120 unless my $resource = $tile->yields($amount)
842 77 127 if (exists $resources{$player->number})
857 0 4 unless @_ <= 2
0 4 unless @_ >= 2
866 0 12 unless $resource
875 0 10 unless @_ <= 2
0 10 unless @_ >= 2
881 0 10 unless $self->phase eq 'Play'
884 0 10 unless grep(($self->player->number == $_), keys %$details)
887 0 10 unless grep(($offering_player == $_), keys %$details)
890 0 10 unless $self->player->has_rolled_dice
893 0 10 if exists $self->trades->{$uuid}
905 0 5 unless @_ <= 2
0 5 unless @_ >= 2
910 0 5 unless grep(($self->player->number == $_), keys %$details) and $player_number == $self->player->number
919 0 10 unless @_ <= 2
0 10 unless @_ >= 2
924 0 64 unless @_ <= 1
0 64 unless @_ >= 1
931 0 9 unless @_ <= 2
0 9 unless @_ >= 2
940 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)
951 0 1 unless @_ <= 2
0 1 unless @_ >= 2
960 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)
966 0 3 unless @_ <= 2
0 3 unless @_ >= 2
968 0 3 unless $self->phase eq 'Setup'
984 0 12 unless @_ <= 2
0 12 unless @_ >= 2
986 0 12 unless $number
988 0 12 unless @player
992 0 189 unless @_ <= 2
0 189 unless @_ >= 2
994 0 189 unless $number
1001 0 240 unless $msgs and ref $msgs eq 'ARRAY'