File Coverage

lib/Settlers/Map/Tile.pm
Criterion Covered Total %
statement 35 36 97.2
branch 1 2 50.0
condition 4 5 80.0
subroutine 14 15 93.3
pod 1 7 14.2
total 55 65 84.6


line stmt bran cond sub pod time code
1             package Settlers::Map::Tile;
2             $Settlers::Map::Tile::VERSION = '0.07';
3 3     3   13 use strict;
  3     1   5  
  3         71  
  1         880  
  1         2  
  1         24  
4 3     3   12 use warnings;
  3     1   6  
  3         71  
  1         5  
  1         2  
  1         26  
5 3     3   1268 use parent 'Math::HexGrid::Hex';
  3     1   624  
  3         17  
  1         6  
  1         2  
  1         6  
6              
7             use overload
8 3         13 '""' => 'uuid',
  1         6  
9 3     3   7131 fallback => 1;
  3     1   6  
  1         140  
  1         2  
10              
11             sub new
12             {
13 222     222 1 327 my ($class, $q, $r, $number) = @_;
14              
15 222         597 my $self = $class->SUPER::new($q, $r);
16              
17             # yielding tiles need a number
18 222 50 66     2737 die 'new() requires a number' if $class->yields && ! $number;
19              
20             # non resource-producing yield nothing
21 222   100     1722 $self->{number} = $number || 0;
22 222         493 return $self;
23             }
24              
25 363554     363554 0 956863 sub uuid { $_[0]->{id} }
26 1998     1998 0 6433 sub number { $_[0]->{number} }
27 114     114 0 296 sub yields { undef }
28 0     0 0 0 sub name { $_[0]->{name} }
29 74     74 0 243 sub code { $_[0]->{code} }
30              
31             sub tile_neighbor_uuid
32             {
33 2664     2664 0 3830 my ($self, $direction) = @_;
34 2664         6477 return $self->SUPER::hex_neighbor($direction)->id;
35             }
36             1;
37              
38             __END__