| 1 | package Game::Terminal::Kit::Zones; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | has zones => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | isa => ArrayRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | $self->zones([]) unless $self->zones; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 9 | ▶ | sub add { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 9 | my ($self, $name, $column, $row, $columns, $rows) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 9 | ▶ | die "Zones: a zone needs a name\n" unless defined $name && length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $name and length $name
MC/DC100%2/2
defined $name and length $name
defined $name
length $name
Truth table100%3/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | $self->remove($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 7 | ▶ | push @{ $self->zones }, [ $name, $column, $row, $columns // 1, $rows // 1 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$columns // 1
$rows // 1
MC/DC100%1/1
$columns // 1
$columns
MC/DC100%1/1
$rows // 1
$rows
Truth table100%2/2
A
A= $columns
Truth table100%2/2
A
A= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 9 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | $self->zones([ grep { $_->[0] ne $name } @{ $self->zones } ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | $self->zones([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | ▶ | sub names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | return map { $_->[0] } @{ $self->zones }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 17 | ▶ | sub at { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 17 | my ($self, $column, $row) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 17 | ▶ | return () unless defined $column && defined $row; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $column and defined $row
MC/DC50%1/2
defined $column and defined $row
defined $column
defined $row
Truth table66%2/3
A and B
A= defined $columnB= defined $row
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 16 | for my $zone (reverse @{ $self->zones }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 32 | my ($name, $left, $top, $columns, $rows) = @{$zone}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 32 | my ($across, $down) = ($column - $left, $row - $top); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 32 | ▶ | next if $across < 0 || $down < 0 || $across >= $columns || $down >= $rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$across < 0 or $down < 0 or $across >= $columns or $down >= $rows
$across < 0 or $down < 0 or $across >= $columns
$across < 0 or $down < 0
MC/DC100%4/4
$across < 0 or $down < 0 or $across >= $columns or $down >= $rows
$across < 0
$down < 0
$across >= $columns
$down >= $rows
Truth table100%5/5
A or B or C or D
A= $across < 0B= $down < 0C= $across >= $columnsD= $down >= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 9 | ▶ | return wantarray ? ($name, $across, $down) : $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 7 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||