| 1 | package Game::Senet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 62 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 62 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 62 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 62 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 62 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 62 | ▶ | use Object::Proto::Sugar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 62 | ▶ | use Game::Senet::Engine qw(EMPTY LIGHT DARK SIDE_LIGHT SIDE_DARK piece_of); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 62 | ▶ | use Game::Senet::Rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 62 | ▶ | use Game::Senet::Variant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 62 | ▶ | use Game::Senet::Sticks (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 62 | ▶ | use Game::Senet::Notation (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 62 | ▶ | use Game::Senet::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 62 | ▶ | use Game::Senet::Result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 62 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 62 | my $E = 'Game::Senet::Engine'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 62 | my $X = 'Game::Senet::Error'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 62 | my (%SIDE_OF, %OTHER, %SEATS); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 62 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 62 | %SIDE_OF = (light => SIDE_LIGHT, dark => SIDE_DARK); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 62 | %OTHER = (light => 'dark', dark => 'light', p1 => 'p2', p2 => 'p1'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 62 | %SEATS = (p1 => 1, p2 => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 62 | has _light_seat => (is => 'ro', init_arg => 'light', private => 1, default => 'p1'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 62 | has _seed => (is => 'ro', init_arg => 'seed', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 62 | has _rules_given => (is => 'ro', init_arg => 'rules', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 62 | has _first_given => (is => 'ro', init_arg => 'first', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 62 | has _position_given => (is => 'ro', init_arg => 'position', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 62 | has _start => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 62 | has _script => (is => 'ro', init_arg => 'script', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 62 | has _variant => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 62 | has _game => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 62 | has _first => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 62 | has _throws => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 62 | has _roll => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 62 | has _sticks => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 62 | has _legal => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 62 | has _number => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 62 | has _log => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 62 | has _choices => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 62 | has _resigned => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 62 | has _error => (is => 'rw', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 7144 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=15 SCAR=27.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 7144 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 7144 | my ($seed, $script) = ($self->_seed, $self->_script); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 7144 | ▶ | Carp::croak('Game::Senet: a game wants a seed: some bytes that decide every throw of its sticks') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
defined $seed and not ref $seed and length $seed or ref $script eq "ARRAY"
defined $seed and not ref $seed and length $seed
defined $seed and not ref $seed
MC/DC50%2/4
defined $seed and not ref $seed and length $seed or ref $script eq "ARRAY"
defined $seed
not ref $seed
length $seed
ref $script eq "ARRAY"
Truth table42%3/7
A and not(B) and C or D
A= defined $seedB= not ref $seedC= length $seedD= ref $script eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | unless (defined $seed && !ref $seed && length $seed) || ref $script eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | Carp::croak("Game::Senet: light is played by seat 'p1' or 'p2'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 7143 | ▶ | unless defined $self->_light_seat && $SEATS{ $self->_light_seat }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->_light_seat and $SEATS{$self->_light_seat}
MC/DC50%1/2
defined $self->_light_seat and $SEATS{$self->_light_seat}
defined $self->_light_seat
$SEATS{$self->_light_seat}
Truth table66%2/3
A and B
A= defined $self->_light_seatB= $SEATS{$self->_light_seat}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 7142 | my $variant = Game::Senet::Variant->of($self->_rules_given); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 7142 | $self->_variant($variant); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 7142 | my $first = $self->_first_given; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | Carp::croak("Game::Senet: first is 'light' or 'dark'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 7142 | ▶ | if defined $first && !exists $SIDE_OF{$first}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $first and not exists $SIDE_OF{$first}
MC/DC100%2/2
defined $first and not exists $SIDE_OF{$first}
defined $first
not exists $SIDE_OF{$first}
Truth table100%3/3
A and not(B)
A= defined $firstB= not exists $SIDE_OF{$first}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 7141 | my $position = $self->_position_given; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 7141 | ▶ | if (defined $position) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 149 | my $code = Game::Senet::Notation::validate_position($position); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 149 | ▶ | Carp::croak("Game::Senet: the position was refused, code $code") if $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 149 | my ($pieces) = $position =~ / (\d)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 149 | ▶ | Carp::croak("Game::Senet: the position has $pieces pieces a side and the rules " . $variant->pieces) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | unless $pieces == $variant->pieces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 148 | ▶ | $position =~ s/ [ld] (\d)\z/' ' . substr($first, 0, 1) . " $1"/e if defined $first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 7140 | $self->_start($position); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 7140 | ▶ | my $game = Game::Senet::Rules->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$first // "light"
MC/DC100%1/1
$first // "light"
$first
Truth table100%2/2
A
A= $first
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | rules => $variant->as_hash, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | (defined $position ? (position => $position) : (first => $first // 'light')), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 7140 | $self->_game($game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 7140 | $self->_first($game->side); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7140 | $self->_throws(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 7140 | $self->_log([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 7140 | $self->_choices([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 7140 | $self->_settle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 7140 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 774983 | ▶ | sub _next_throw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_next_throw: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 774983 | my ($self, $number) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 774983 | ▶ | if (my $script = $self->_script) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 10387 | my $next = $script->[$number]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 10387 | ▶ | return unless defined $next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 10181 | ▶ | return (ref $next ? $next->{roll} : $next, ref $next ? $next->{sticks} : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 764596 | my $sticks = Game::Senet::Sticks::throw_for($self->_seed, $number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 764596 | return (Game::Senet::Sticks::roll_of(Game::Senet::Sticks::light_of($sticks)), join '', @$sticks); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 755273 | ▶ | sub _settle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_settle: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 755273 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 755273 | my $game = $self->_game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 755273 | $self->_roll(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 755273 | $self->_sticks(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 755273 | $self->_number(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 755273 | $self->_legal([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 755273 | ▶ | while (!$self->is_over) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 774983 | my $number = $self->_throws; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 774983 | my ($roll, $sticks) = $self->_next_throw($number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 774983 | ▶ | return unless defined $roll; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 774777 | $self->_throws($number + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 774777 | my @moves = $game->moves($roll); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 774777 | ▶ | if (@moves) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 753297 | $self->_legal(\@moves); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 753297 | $self->_roll($roll); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 753297 | $self->_sticks($sticks); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 753297 | $self->_number($number); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 753297 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 21480 | my $side = $game->side; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 21480 | my $ply = $game->ply; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 21480 | $game->forfeit($roll); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 21480 | ▶ | push @{ $self->_log }, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ply => $ply, side => $side, throw => $number, roll => $roll, sticks => $sticks, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | move => undef, again => ($game->side eq $side ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1770 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 85634 | ▶ | sub _refuse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refuse: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 85634 | my ($self, $code, %detail) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 85634 | $self->_error($X->of($code, %detail)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 85634 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 78735 | ▶ | sub _why_not { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_why_not: called CC=44 SCAR=38.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 78735 | my ($self, $from, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 78735 | my $game = $self->_game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 78735 | my $variant = $self->_variant; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 78735 | my $board = $game->board; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 78735 | my $roll = $self->_roll; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 78735 | my $side = $SIDE_OF{ $game->side }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 78735 | my $me = piece_of($side); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 78735 | ▶ | my $enemy = piece_of($side == SIDE_LIGHT ? SIDE_DARK : SIDE_LIGHT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 78735 | my $rules = $E->rules($variant->as_hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 78735 | my @legal = $game->moves($roll); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 78735 | my $piece = $board->at($from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 78735 | ▶ | return 'no_piece' if $piece == EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 15932 | ▶ | return 'not_your_piece' if $piece != $me; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 7590 | ▶ | return 'bound_piece' if $game->only && $from != $game->only; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$game->only and $from != $game->only
MC/DC50%1/2
$game->only and $from != $game->only
$game->only
$from != $game->only
Truth table66%2/3
A and B
A= $game->onlyB= $from != $game->only
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 7580 | ▶ | if ($from >= 26) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1211 | my @chain = @{ $rules->{exits}{$from}{$roll} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1211 | ▶ | return 'no_back' if $to ne 'off' && $to == $from - $roll; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$to ne "off" and $to == $from - $roll
MC/DC100%2/2
$to ne "off" and $to == $from - $roll
$to ne "off"
$to == $from - $roll
Truth table100%3/3
A and B
A= $to ne "off"B= $to == $from - $roll
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1169 | ▶ | return 'no_exit' if !@chain || $chain[0] eq 'stay'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not @chain or $chain[0] eq "stay"
MC/DC50%1/2
not @chain or $chain[0] eq "stay"
not @chain
$chain[0] eq "stay"
Truth table66%2/3
not(A) or B
A= not @chainB= $chain[0] eq "stay"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 675 | my %target; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 675 | for my $entry (@chain) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 675 | ▶ | if ($entry eq 'off') { $target{off} = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 113 | elsif ($entry eq 'walk') { $target{$_} = 1 for 1 .. 15 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 170 | elsif ($entry ne 'stay') { $target{$entry} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 675 | ▶ | return 'wrong_distance' unless $target{$to}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 59 | ▶ | return 'no_exit' unless grep { $_->from == $from } @legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 57 | ▶ | return 'own_piece' if $to ne 'off' && $board->at($to) == $me; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$to ne "off" and $board->at($to) == $me
MC/DC50%1/2
$to ne "off" and $board->at($to) == $me
$to ne "off"
$board->at($to) == $me
Truth table66%2/3
A and B
A= $to ne "off"B= $board->at($to) == $me
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 50 | ▶ | return 'safe_house' if $to ne 'off' && $board->at($to) == $enemy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$to ne "off" and $board->at($to) == $enemy
MC/DC50%1/2
$to ne "off" and $board->at($to) == $enemy
$to ne "off"
$board->at($to) == $enemy
Truth table66%2/3
A and B
A= $to ne "off"B= $board->at($to) == $enemy
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 43 | return 'wrong_distance'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 6369 | ▶ | my $any = $variant->reach26 eq 'any' && $from == 25; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$variant->reach26 eq 'any' && $from == 25
MC/DC100%2/2
$variant->reach26 eq 'any' && $from == 25
$variant->reach26 eq 'any'
$from == 25
Truth table100%3/3
A && B
A= $variant->reach26 eq 'any'B= $from == 25
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 6369 | my $forward = $from + $roll; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 6369 | my $back = $from - $roll; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 6369 | ▶ | return 'wrong_distance' if $to eq 'off'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 6173 | my $is_back = $to == $back; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 6173 | ▶ | return 'wrong_distance' unless $to == $forward || $is_back || ($any && $to == 26); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$to == $forward or $is_back or $any and $to == 26
$to == $forward or $is_back
$any and $to == 26
MC/DC50%2/4
$to == $forward or $is_back or $any and $to == 26
$to == $forward
$is_back
$any
$to == 26
Truth table80%4/5
A or B or C and D
A= $to == $forwardB= $is_backC= $anyD= $to == 26
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 218 | ▶ | if ($is_back) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 171 | ▶ | return 'forward_first' if grep { !$_->back } @legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | return 'no_back' unless $variant->backward; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | elsif ($to > 26) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 15 | return 'must_land_26'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 33 | ▶ | my ($lo, $hi) = $from < $to ? ($from, $to) : ($to, $from); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 33 | ▶ | if ($variant->blockade) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 33 | for my $x ($lo + 1 .. $hi - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 69 | ▶ | next unless $board->at($x) == $enemy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 19 | my ($first, $last) = ($x, $x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 19 | ▶ | $first-- while $first > 1 && $board->at($first - 1) == $enemy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$first > 1 and $board->at($first - 1) == $enemy
MC/DC50%1/2
$first > 1 and $board->at($first - 1) == $enemy
$first > 1
$board->at($first - 1) == $enemy
Truth table66%2/3
A and B
A= $first > 1B= $board->at($first - 1) == $enemy
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 19 | ▶ | $last++ while $last < 30 && $board->at($last + 1) == $enemy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$last < 30 and $board->at($last + 1) == $enemy
MC/DC50%1/2
$last < 30 and $board->at($last + 1) == $enemy
$last < 30
$board->at($last + 1) == $enemy
Truth table66%2/3
A and B
A= $last < 30B= $board->at($last + 1) == $enemy
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 19 | ▶ | return 'blockade' if $last - $first + 1 >= $variant->blockade; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 24 | my $there = $board->at($to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 24 | ▶ | return 'own_piece' if $there == $me; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | ▶ | if ($there == $enemy) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | ▶ | return 'safe_house' if grep { $_ == $to } @{ $rules->{safe} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | return 'protected'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return 'bad_move'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 833767 | ▶ | sub play { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 833767 | my ($self, $what) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 833767 | $self->_error(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 833767 | ▶ | return $self->_refuse('game_over') if $self->is_over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 833766 | my ($from, $to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 833766 | ▶ | my $object = Scalar::Util::blessed($what) && $what->isa('Game::Senet::Move'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($what) && $what->isa('Game::Senet::Move')
MC/DC50%1/2
builtin::blessed($what) && $what->isa('Game::Senet::Move')
builtin::blessed($what)
$what->isa('Game::Senet::Move')
Truth table66%2/3
A && B
A= builtin::blessed($what)B= $what->isa('Game::Senet::Move')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 833766 | ▶ | if ($object) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 216329 | ▶ | ($from, $to) = ($what->from, $what->off ? 'off' : $what->to); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 617437 | my ($parsed, $why) = Game::Senet::Notation::parse_move($what); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 617437 | ▶ | return $self->_refuse('bad_move', text => $what, why => $why) unless $parsed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 610540 | ($from, $to) = @{$parsed}{qw(from to)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 826869 | ▶ | return $self->_refuse('no_roll') unless defined $self->_roll; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 826868 | my $game = $self->_game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 826868 | my $roll = $self->_roll; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 826868 | my $wire = $from . '-' . $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 826868 | my ($move) = grep { Game::Senet::Notation::format_move($_) eq $wire } @{ $self->_legal }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 826868 | ▶ | $move = undef if $move && $object && ($what->roll != $roll || $what->side ne $game->side); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$move and $object and $what->roll != $roll || $what->side ne $game->side
$move and $object
$what->roll != $roll or $what->side ne $game->side
MC/DC75%3/4
$move and $object and $what->roll != $roll || $what->side ne $game->side
$move
$object
$what->roll != $roll
$what->side ne $game->side
Truth table80%4/5
A and B and C or D
A= $moveB= $objectC= $what->roll != $rollD= $what->side ne $game->side
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 826868 | ▶ | return $self->_refuse($self->_why_not($from, $to), from => $from, to => $to, roll => $roll) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | unless $move; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 748133 | push @{ $self->_choices }, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 748133 | depth => $game->depth, log => scalar @{ $self->_log }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | throws => $self->_throws, roll => $roll, sticks => $self->_sticks, number => $self->_number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 748133 | my $side = $game->side; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 748133 | my $ply = $game->ply; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 748133 | $game->apply($move); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 748133 | ▶ | push @{ $self->_log }, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $game->is_over and $game->side eq $side
MC/DC100%2/2
not $game->is_over and $game->side eq $side
not $game->is_over
$game->side eq $side
Truth table100%3/3
not(A) and B
A= not $game->is_overB= $game->side eq $side
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ply => $ply, side => $side, throw => $self->_number, roll => $roll, sticks => $self->_sticks, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | move => $wire, back => $move->back, swap => $move->swap, off => $move->off, walk => $move->walk, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | again => (!$game->is_over && $game->side eq $side ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 748133 | $self->_settle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 748133 | return $move; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1069 | ▶ | sub play_or_die { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play_or_die: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1069 | my ($self, $what) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1069 | my $move = $self->play($what); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1069 | ▶ | return $move if $move; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $error = $self->_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | Carp::croak('Game::Senet: ' . $error->code . ': ' . $error->message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 578 | ▶ | sub undo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undo: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 578 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 578 | $self->_error(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 578 | ▶ | if (defined $self->_resigned) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $self->_resigned(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 578 | ▶ | my $choice = pop @{ $self->_choices } or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 577 | my $game = $self->_game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 577 | ▶ | $game->undo while $game->depth > $choice->{depth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 577 | splice @{ $self->_log }, $choice->{log}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 577 | $self->_throws($choice->{throws}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 577 | $self->_roll($choice->{roll}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 577 | $self->_sticks($choice->{sticks}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 577 | $self->_number($choice->{number}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 577 | $self->_legal([ $game->moves($choice->{roll}) ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 577 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | ▶ | sub resign { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resign: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | my ($self, $side) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 8 | $self->_error(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 8 | ▶ | return 0 if $self->is_over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | ▶ | $side = $self->_game->side unless defined $side; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 8 | ▶ | Carp::croak("Game::Senet: a side is 'light' or 'dark'") unless exists $SIDE_OF{$side}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 8 | $self->_resigned($side); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 4943546 | ▶ | sub is_over { defined $_[0]->_resigned || $_[0]->_game->is_over ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_over: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
Condition100%3/3
defined $_[0]->_resigned or $_[0]->_game->is_over
MC/DC100%2/2
defined $_[0]->_resigned or $_[0]->_game->is_over
defined $_[0]->_resigned
$_[0]->_game->is_over
Truth table100%3/3
A or B
A= defined $_[0]->_resignedB= $_[0]->_game->is_over
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 10541 | ▶ | sub result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 10541 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 10541 | ▶ | return undef unless $self->is_over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1415 | my $game = $self->_game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1415 | my $resigned = $self->_resigned; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | return Game::Senet::Result->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1415 | ▶ | winner => (defined $resigned ? $OTHER{$resigned} : $game->winner), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | how => (defined $resigned ? 'resign' : $game->how), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | final => $game->position, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | home => { light => $game->home('light'), dark => $game->home('dark') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | plies => $game->ply, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | throws => $self->_throws, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 78759 | ▶ | sub error { $_[0]->_error } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 551161 | ▶ | sub side { $_[0]->is_over ? undef : $_[0]->_game->side } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
side: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1579235 | ▶ | sub roll { $_[0]->is_over ? undef : $_[0]->_roll } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
roll: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 92495 | ▶ | sub sticks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sticks: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 92495 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 92495 | ▶ | my $sticks = $self->is_over ? undef : $self->_sticks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 92495 | ▶ | return defined $sticks ? [ split //, $sticks ] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 9766 | ▶ | sub throw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 9766 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 9766 | my $roll = $self->roll; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 9766 | ▶ | return undef unless defined $roll; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 9766 | ▶ | return $roll == 5 ? 0 : $roll; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 403353 | ▶ | sub legal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
legal: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 403353 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 403353 | ▶ | return wantarray ? () : 0 unless defined $self->roll; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 403353 | my @legal = @{ $self->_legal }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 403353 | ▶ | return wantarray ? @legal : scalar @legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 225229 | ▶ | sub turn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
turn: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 225229 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 225229 | ▶ | return undef if $self->is_over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 224985 | my $side = $self->_game->side; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 224985 | my $segment = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 224985 | for my $entry (reverse @{ $self->_log }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 254947 | ▶ | last unless $entry->{side} eq $side && $entry->{again}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$entry->{"side"} eq $side and $entry->{"again"}
MC/DC50%1/2
$entry->{"side"} eq $side and $entry->{"again"}
$entry->{"side"} eq $side
$entry->{"again"}
Truth table66%2/3
A and B
A= $entry->{"side"} eq $sideB= $entry->{"again"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 103515 | $segment++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 224985 | my $roll = $self->_roll; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 224985 | ▶ | side => $side, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_game->only || undef
MC/DC100%1/1
$self->_game->only || undef
$self->_game->only
Truth table100%2/2
A
A= $self->_game->only
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | segment => $segment, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | bound => ($self->_game->only || undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | extra => (defined $roll ? Game::Senet::Sticks::extra_throw($roll) : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 6900 | ▶ | sub side_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
side_of: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 6900 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 6900 | ▶ | Carp::croak("Game::Senet: a seat is 'p1' or 'p2'") unless defined $seat && $SEATS{$seat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $seat and $SEATS{$seat}
MC/DC0%0/2
defined $seat and $SEATS{$seat}
defined $seat
$SEATS{$seat}
Truth table33%1/3
A and B
A= defined $seatB= $SEATS{$seat}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 6900 | ▶ | return $seat eq $self->_light_seat ? 'light' : 'dark'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 6899 | ▶ | sub seat_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seat_of: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 6899 | my ($self, $side) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 6899 | ▶ | Carp::croak("Game::Senet: a side is 'light' or 'dark'") unless defined $side && exists $SIDE_OF{$side}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $side and exists $SIDE_OF{$side}
MC/DC0%0/2
defined $side and exists $SIDE_OF{$side}
defined $side
exists $SIDE_OF{$side}
Truth table33%1/3
A and B
A= defined $sideB= exists $SIDE_OF{$side}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 6899 | ▶ | return $side eq 'light' ? $self->_light_seat : $OTHER{ $self->_light_seat }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 95439 | ▶ | sub variant { $_[0]->_variant } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
variant: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 6897 | ▶ | sub first { $_[0]->_first } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 6898 | ▶ | sub seed { $_[0]->_seed } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 90106 | ▶ | sub throws { $_[0]->_throws } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throws: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 90347 | ▶ | sub ply { $_[0]->_game->ply } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ply: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 88863 | ▶ | sub position { $_[0]->_game->position } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
position: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 90159 | ▶ | sub key { $_[0]->_game->key } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 12732 | ▶ | sub home { $_[0]->_game->home($_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
home: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 503340 | ▶ | sub at { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at: called CC=5 SCAR=16.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 503340 | my ($self, $house) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 503340 | ▶ | Carp::croak("Game::Senet: there is no house " . ($house // 'undef')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$house // "undef"
MC/DC0%0/1
$house // "undef"
$house
Truth table0%0/2
A
A= $house
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | unless Game::Senet::Notation::house_ok($house); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 503340 | my $piece = $self->_game->board->at($house); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 503340 | ▶ | return $piece == EMPTY ? undef : $piece == LIGHT ? 'light' : 'dark'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 2266 | ▶ | sub protected { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protected: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 2266 | my ($self, $house) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 2266 | ▶ | Carp::croak("Game::Senet: there is no house " . ($house // 'undef')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$house // "undef"
MC/DC0%0/1
$house // "undef"
$house
Truth table50%1/2
A
A= $house
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | unless Game::Senet::Notation::house_ok($house); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 2265 | return $self->_game->protected($house); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 4202 | ▶ | sub in_blockade { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
in_blockade: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 4202 | my ($self, $house) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 4202 | ▶ | Carp::croak("Game::Senet: there is no house " . ($house // 'undef')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$house // "undef"
MC/DC0%0/1
$house // "undef"
$house
Truth table0%0/2
A
A= $house
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | unless Game::Senet::Notation::house_ok($house); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 4202 | return $self->_game->in_blockade($house); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 3 | ▶ | sub rules_revision { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rules_revision: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 6897 | ▶ | sub chances { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chances: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 6897 | my ($roll, $weight, $denominator) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 34485 | ▶ | { roll => $roll, throw => ($roll == 5 ? 0 : $roll), weight => $weight, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | denominator => $denominator, extra => Game::Senet::Sticks::extra_throw($roll) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } $E->chances; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 12702 | ▶ | sub log { [ map { { %$_ } } @{ $_[0]->_log } ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 7131 | ▶ | sub forfeits_since { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forfeits_since: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 7131 | my ($self, $ply) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 7131 | ▶ | $ply = 0 unless defined $ply; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 7131 | ▶ | return map { { %$_ } } grep { !defined $_->{move} && $_->{ply} >= $ply } @{ $self->_log }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
!defined($_->{'move'}) && $_->{'ply'} >= $ply
MC/DC100%2/2
!defined($_->{'move'}) && $_->{'ply'} >= $ply
!defined($_->{'move'})
$_->{'ply'} >= $ply
Truth table100%3/3
not(A) && B
A= !defined($_->{'move'})B= $_->{'ply'} >= $ply
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 7094 | ▶ | sub to_record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_record: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 7094 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 7094 | my $variant = $self->_variant; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | my %record = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 42564 | variant => { name => $variant->exits, map { $_ => $variant->$_ } grep { $_ ne 'exits' } $variant->fields }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | first => $self->_first, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | plies => [ map { { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | side => $_->{side}, roll => $_->{roll}, move => $_->{move}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 704872 | ▶ | (defined $_->{sticks} ? (sticks => $_->{sticks}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 7094 | } } @{ $self->_log } ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 7094 | ▶ | $record{position} = $self->_start if defined $self->_start; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 7094 | ▶ | $record{seed} = unpack 'H*', $self->_seed if defined $self->_seed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 7094 | ▶ | if (my $result = $self->result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 871 | ▶ | $record{result} = { winner => ($result->is_draw ? 'draw' : $result->winner), how => $result->how }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 7094 | return Game::Senet::Notation::format_record(\%record); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 5667 | ▶ | sub replay { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replay: called CC=30 SCAR=35.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 5667 | my ($class, $record, %option) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 5667 | ▶ | my $bad = sub { return (undef, $X->of('bad_record', @_)) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 5667 | ▶ | if (!ref $record) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 5663 | my ($parsed, $problem) = Game::Senet::Notation::parse_record($record); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 5663 | ▶ | return $bad->(line => $problem->{line}, why => $problem->{error}) unless $parsed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 5622 | $record = $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 5626 | ▶ | my @plies = @{ $record->{plies} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$record->{'plies'} || []
MC/DC0%0/1
$record->{'plies'} || []
$record->{'plies'}
Truth table50%1/2
A
A= $record->{'plies'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 5626 | my %fields = %{ $record->{variant} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 5626 | my $exits = delete $fields{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 5626 | my $rules = $option{rules}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 5626 | ▶ | unless (defined $rules) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 5625 | ▶ | return $bad->(ply => 0, why => 'variant') unless grep { $_ eq $exits } Game::Senet::Variant->names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 5625 | $rules = Game::Senet::Variant->custom(exits => $exits, %fields); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | my $game = defined $record->{seed} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | ? $class->new(seed => pack('H*', $record->{seed}), rules => $rules, first => $record->{first}, (defined $record->{position} ? (position => $record->{position}) : ())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | ▶ | : $class->new(script => [ map { { roll => $_->{roll}, sticks => $_->{sticks} } } @plies ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 5626 | ▶ | rules => $rules, first => $record->{first}, (defined $record->{position} ? (position => $record->{position}) : ())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 5626 | for my $i (0 .. $#plies) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 535165 | my $ply = $plies[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 535165 | ▶ | if (my $made = $game->_log->[$i]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 3706 | ▶ | return $bad->(ply => $i, why => 'forfeit') if defined $ply->{move} || defined $made->{move}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ply->{"move"} or defined $made->{"move"}
MC/DC50%1/2
defined $ply->{"move"} or defined $made->{"move"}
defined $ply->{"move"}
defined $made->{"move"}
Truth table66%2/3
A or B
A= defined $ply->{"move"}B= defined $made->{"move"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 3705 | ▶ | return $bad->(ply => $i, why => 'side') unless $made->{side} eq $ply->{side}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 3705 | ▶ | return $bad->(ply => $i, why => 'roll') unless $made->{roll} == $ply->{roll}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 3705 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 531459 | ▶ | return $bad->(ply => $i, why => 'over') if $game->is_over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 531459 | ▶ | return $bad->(ply => $i, why => 'forfeit') unless defined $ply->{move}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 531459 | ▶ | return $bad->(ply => $i, why => 'side') unless $game->side eq $ply->{side}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 531459 | ▶ | return $bad->(ply => $i, why => 'roll') unless defined $game->roll && $game->roll == $ply->{roll}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $game->roll and $game->roll == $ply->{"roll"}
MC/DC50%1/2
defined $game->roll and $game->roll == $ply->{"roll"}
defined $game->roll
$game->roll == $ply->{"roll"}
Truth table66%2/3
A and B
A= defined $game->rollB= $game->roll == $ply->{"roll"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 531458 | ▶ | unless ($game->play($ply->{move})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 4 | my $error = $game->error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 4 | return (undef, $X->of($error->code, %{ $error->detail }, ply => $i)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 5620 | ▶ | return $bad->(ply => scalar @plies, why => 'length') if @{ $game->_log } > @plies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 5620 | ▶ | if (my $result = $record->{result}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 471 | ▶ | if ($result->{how} eq 'resign') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 4 | ▶ | return $bad->(ply => scalar @plies, why => 'result') if $game->is_over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 4 | $game->resign($OTHER{ $result->{winner} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 467 | my $ended = $game->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 467 | ▶ | my $winner = $ended ? ($ended->is_draw ? 'draw' : $ended->winner) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | return $bad->(ply => scalar @plies, why => 'result') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 467 | ▶ | unless $ended && $ended->how eq $result->{how} && $winner eq $result->{winner}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$ended and $ended->how eq $result->{"how"} and $winner eq $result->{"winner"}
$ended and $ended->how eq $result->{"how"}
MC/DC0%0/3
$ended and $ended->how eq $result->{"how"} and $winner eq $result->{"winner"}
$ended
$ended->how eq $result->{"how"}
$winner eq $result->{"winner"}
Truth table25%1/4
A and B and C
A= $endedB= $ended->how eq $result->{"how"}C= $winner eq $result->{"winner"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 5620 | return ($game, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 6251 | ▶ | sub to_text { $_[0]->to_record } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 5178 | ▶ | sub from_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_text: called CC=8 SCAR=33.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 5178 | my ($class, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 5178 | ▶ | Carp::croak('Game::Senet: from_text wants the text to_text wrote, and was given ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not defined $text or ref $text
MC/DC0%0/2
not defined $text or ref $text
not defined $text
ref $text
Truth table33%1/3
not(A) or B
A= not defined $textB= ref $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | . (defined $text ? 'a reference' : 'nothing')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | if !defined $text || ref $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 5178 | my ($game, $error) = $class->replay($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 5178 | ▶ | return $game if $game; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my $detail = $error->detail; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | my $where = $detail->{line} ? " at line $detail->{line}" : ' at ply ' . (($detail->{ply} // 0) + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$detail->{"ply"} // 0
MC/DC0%0/1
$detail->{"ply"} // 0
$detail->{"ply"}
Truth table0%0/2
A
A= $detail->{"ply"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | Carp::croak('Game::Senet: the text was refused' . $where . ': ' . $error->message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | . (defined $detail->{why} ? " ($detail->{why})" : '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 62 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||