| 1 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | package Games::Goban::Board; | ||||||||||||||||||||
| 5 | { | ||||||||||||||||||||
| 6 | 2 | $Games::Goban::Board::VERSION = '1.102'; | |||||||||||||||||||
| 7 | } | ||||||||||||||||||||
| 8 | 2 | ▶ | use parent qw(Games::Board::Grid); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | # ABSTRACT: a go board built from Games::Board | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 2 | my $origin = ord('a'); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 2 | ▶ | sub piececlass { 'Games::Goban::Piece' } | ||||||||||||||||||
|
Subroutine
piececlass: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | sub new { | ||||||||||||||||||||
| 18 | 2 | ▶ | my ($self, %opts) = @_; | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 2 | my $board = $self->SUPER::new(%opts); | |||||||||||||||||||
| 21 | 2 | ▶ | $board->{skip_i} = defined $opts{skip_i} ? $opts{skip_i} : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 2 | $board; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | sub index2id { | ||||||||||||||||||||
| 27 | 728 | ▶ | my ($self, $loc) = @_; | ||||||||||||||||||
|
Subroutine
index2id: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 728 | my $id = chr($origin + $loc->[0]) . chr($origin + $loc->[1]); | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 728 | ▶ | $id =~ tr/[i-s]/[j-t]/ if $self->{skip_i}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 728 | $id; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | sub id2index { | ||||||||||||||||||||
| 37 | 7 | ▶ | my ($self, $id) = @_; | ||||||||||||||||||
|
Subroutine
id2index: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 7 | ▶ | $id =~ tr/[j-t]/[i-s]/ if $self->{skip_i}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 7 | my @loc = split //, $id; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 7 | $_ = ord($_) - $origin for @loc; | |||||||||||||||||||
| 44 | 7 | \@loc; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | package Games::Goban::Piece; | ||||||||||||||||||||
| 48 | { | ||||||||||||||||||||
| 49 | 2 | $Games::Goban::Piece::VERSION = '1.102'; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | 2 | ▶ | use base qw(Games::Board::Piece); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 2 | my $next_id = 0; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | sub new { | ||||||||||||||||||||
| 56 | 2 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
| |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 2 | ▶ | $args{id} ||= ++$next_id; | ||||||||||||||||||
|
Condition33%1/3
$args{"id"} ||= ++$next_id
MC/DC0%0/2
$args{"id"} ||= ++$next_id
$args{"id"}
++$next_id
Truth table33%1/3
A ||= B
A= $args{"id"}B= ++$next_id
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 2 | my $self = $class->SUPER::new(%args); | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 2 | $self->{color} = $args{color}; | |||||||||||||||||||
| 63 | 2 | $self->{notes} = $args{notes}; | |||||||||||||||||||
| 64 | 2 | $self->{move} = $args{move}; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 2 | bless $self => $class; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | sub notes { (shift)->{notes} } | ||||||||||||||||||
|
Subroutine
notes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 70 | 4 | ▶ | sub position { (shift)->current_space_id } | ||||||||||||||||||
|
Subroutine
position: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 2 | ▶ | sub moved_on { (shift)->{move} } | ||||||||||||||||||
|
Subroutine
moved_on: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 2 | ▶ | sub color { my $self = shift; $self->{color} } | ||||||||||||||||||
|
Subroutine
color: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 75 | 2 | ▶ | sub colour { my $self = shift; $self->{color} } | ||||||||||||||||||
|
Subroutine
colour: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 2 | 1; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||||