| 1 | package Games::Go::Cinderblock::Delta; | ||||||||||
| 2 | 6 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | #use overload | ||||||||||
| 5 | # '!' => \&reverse, | ||||||||||
| 6 | |||||||||||
| 7 | 6 | has rulemap => ( | |||||||||
| 8 | isa => 'Games::Go::Cinderblock::Rulemap', | ||||||||||
| 9 | is => 'ro', #shouldn't change. | ||||||||||
| 10 | required => 1, | ||||||||||
| 11 | ); | ||||||||||
| 12 | #changes to board. | ||||||||||
| 13 | # format: {remove => {b => \@nodes}} | ||||||||||
| 14 | 6 | has _board => ( | |||||||||
| 15 | isa => 'HashRef', | ||||||||||
| 16 | is => 'ro', | ||||||||||
| 17 | required => 0, | ||||||||||
| 18 | predicate => 'diff_board', | ||||||||||
| 19 | ); | ||||||||||
| 20 | #changes to turn. | ||||||||||
| 21 | # format: {before=>'w', after=>'b'} | ||||||||||
| 22 | 6 | has _turn => ( | |||||||||
| 23 | isa => 'HashRef', | ||||||||||
| 24 | is => 'ro', | ||||||||||
| 25 | required => 0, | ||||||||||
| 26 | predicate => 'diff_turn', | ||||||||||
| 27 | ); | ||||||||||
| 28 | #changes to caps. | ||||||||||
| 29 | # format: {w => {before=>3, after=>5}} | ||||||||||
| 30 | 6 | has _captures => ( | |||||||||
| 31 | isa => 'HashRef', | ||||||||||
| 32 | is => 'ro', | ||||||||||
| 33 | required => 0, | ||||||||||
| 34 | predicate => 'diff_captures', | ||||||||||
| 35 | ); | ||||||||||
| 36 | |||||||||||
| 37 | 4 | ▶ | around BUILDARGS => sub { | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||
| 38 | 4 | my $orig = shift; | |||||||||
| 39 | 4 | my $class = shift; | |||||||||
| 40 | 4 | my %args = @_; | |||||||||
| 41 | 4 | ▶ | if($args{captures}){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 3 | $args{_captures} = delete $args{captures}; | |||||||||
| 43 | } | ||||||||||
| 44 | 4 | ▶ | if($args{turn}){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 4 | $args{_turn} = delete $args{turn}; | |||||||||
| 46 | } | ||||||||||
| 47 | 4 | ▶ | if($args{board}){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 4 | $args{_board} = delete $args{board}; | |||||||||
| 49 | } | ||||||||||
| 50 | 4 | return $class->$orig(%args); | |||||||||
| 51 | 6 | }; | |||||||||
| 52 | |||||||||||
| 53 | 2 | ▶ | sub board{ | ||||||||
|
Subroutine
board: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 54 | 2 | my $self = shift; | |||||||||
| 55 | 2 | ▶ | die 'no color' if shift; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 2 | return $self->_board; | |||||||||
| 57 | } | ||||||||||
| 58 | 3 | ▶ | sub turn{ | ||||||||
|
Subroutine
turn: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 59 | 3 | my $self = shift; | |||||||||
| 60 | 3 | ▶ | return {} unless $self->diff_turn; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 3 | return $self->_turn | |||||||||
| 62 | } | ||||||||||
| 63 | 2 | ▶ | sub captures{ | ||||||||
|
Subroutine
captures: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 64 | 2 | my ($self,$color) = @_; | |||||||||
| 65 | 2 | ▶ | return {} unless $self->diff_captures; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 2 | ▶ | if($color){ return $self->_captures->{$color} } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 1 | return $self->_captures; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 2 | ▶ | sub board_addition{ | ||||||||
|
Subroutine
board_addition: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 71 | 2 | my $self = shift; | |||||||||
| 72 | 2 | my $color = shift; | |||||||||
| 73 | 2 | ▶ | return {} unless $self->diff_board; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 2 | ▶ | if($color){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 1 | return $self->_board->{add}{$color} | |||||||||
| 76 | } | ||||||||||
| 77 | 1 | return $self->_board->{add}; | |||||||||
| 78 | } | ||||||||||
| 79 | 2 | ▶ | sub board_removal{ | ||||||||
|
Subroutine
board_removal: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 80 | 2 | my $self = shift; | |||||||||
| 81 | 2 | ▶ | return {} unless $self->diff_board; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | 2 | my $color = shift; | |||||||||
| 83 | 2 | ▶ | if($color){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 1 | return $self->_board->{remove}{$color} | |||||||||
| 85 | } | ||||||||||
| 86 | 1 | return $self->_board->{remove}; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | sub to_args{ | ||||||||
|
Subroutine
to_args: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 90 | 0 | my $self = shift; | |||||||||
| 91 | 0 | my %struct; | |||||||||
| 92 | 0 | ▶ | if($self->diff_board){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | 0 | $struct{board} = $self->_board; | |||||||||
| 94 | } | ||||||||||
| 95 | 0 | ▶ | if($self->diff_turn){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | 0 | $struct{turn} = $self->_turn; | |||||||||
| 97 | } | ||||||||||
| 98 | 0 | ▶ | if($self->diff_captures){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 0 | $struct{captures} = $self->_captures; | |||||||||
| 100 | } | ||||||||||
| 101 | 0 | return \%struct; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | 6 | 1; | |||||||||
| 105 | |||||||||||
| 106 | __END__ | ||||||||||