File Coverage

lib/Catan/Event/RoadBuilding.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 0 2 0.0
total 28 34 82.3


line stmt bran cond sub pod time code
1             package Catan::Event::RoadBuilding;
2             $Catan::Event::RoadBuilding::VERSION = '0.03';
3 2     2   10 use strict;
  2     1   3  
  2         50  
  1         891  
  1         3  
  1         22  
4 2     2   10 use warnings;
  2     1   3  
  2         277  
  1         5  
  1         2  
  1         177  
5              
6             sub new
7             {
8 2     2 0 4 my ($class, $player) = @_;
9 2 50 33     9 die 'RoadBuilding requires a player object argument'
10             unless $player && $player->isa('Catan::Game::Player');
11              
12             bless {
13 2         4 starting_roads => scalar @{$player->roads},
  2         7  
14             player => $player,
15             }, $class;
16             }
17              
18             # has a player built 2 roads since activating road building
19             sub can_build_road
20             {
21 6     6 0 12 my $self = shift;
22 6 50       15 return $self->{starting_roads} - scalar @{$self->{player}->roads} < 2 ? 1 : 0;
  6         18  
23             }
24             1;
25              
26             __END__