File Coverage

lib/Catan/Event/RoadBuilding.pm
Criterion Covered Total %
statement 12 19 63.1
branch 0 4 0.0
condition 0 3 0.0
subroutine 4 6 66.6
pod 0 2 0.0
total 16 34 47.0


line stmt bran cond sub pod time code
1             package Catan::Event::RoadBuilding;
2             $Catan::Event::RoadBuilding::VERSION = '0.02';
3 2     2   10 use strict;
  2     1   4  
  2         56  
  1         862  
  1         2  
  1         22  
4 2     2   11 use warnings;
  2     1   4  
  2         300  
  1         5  
  1         2  
  1         280  
5              
6             sub new
7             {
8 0     0 0   my ($class, $player) = @_;
9 0 0 0       die 'RoadBuilding requires a player object argument'
10             unless $player && $player->isa('Catan::Game::Player');
11              
12             bless {
13 0           starting_roads => scalar @{$player->roads},
  0            
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 0     0 0   my $self = shift;
22 0 0         return $self->{starting_roads} - scalar @{$self->{player}->roads} < 2 ? 1 : 0;
  0            
23             }
24             1;
25              
26             __END__