| 1 | package Game::Backgammon::Terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Game::Backgammon; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Game::Backgammon::Board (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Game::Backgammon::Bot; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | my %CHECKER = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | white => { ascii => 'O', wide => "\x{25CB}", colour => '1;37', ink => '1;38;5;231' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | black => { ascii => 'X', wide => "\x{25CF}", colour => '1;36', ink => '1;38;5;16' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | my %SEQUENCE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 'A' => 'up', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 'B' => 'down', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 'C' => 'right', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 'D' => 'left', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 'H' => 'home', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 'F' => 'end', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | '1~' => 'home', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | '4~' => 'end', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | '5~' => 'page_up', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | '6~' => 'page_down', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | '7~' => 'home', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | '8~' => 'end', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | my %CONTROL = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | "\r" => 'enter', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | "\n" => 'enter', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | "\t" => 'tab', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | "\x7f" => 'backspace', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | "\x08" => 'backspace', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | "\x03" => 'interrupt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | "\x04" => 'eof', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | my %GROUND = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | light => '48;5;180', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | dark => '48;5;94', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | from => '48;5;136', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | to => '48;5;28', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | hit => '48;5;124', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | played => '48;5;24', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | ▶ | use constant ROWS => 5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | has game => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | isa => Object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | has out => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | isa => Any, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | default => sub { \*STDOUT } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | has in => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | isa => Any, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 18 | ▶ | default => sub { \*STDIN } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | has mode => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | default => 'bot' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | has level => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | default => 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | has seat => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | default => 'white' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | has view => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | default => '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | has ascii => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | has [qw/colour interactive picking/] => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | is => 'rw' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | has highlight => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 23 | ▶ | default => sub { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | has raw => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | has keysource => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | isa => CodeRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | has pending => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | isa => ArrayRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 23 | ▶ | default => sub { [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 23 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=10 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 23 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 23 | ▶ | $self->interactive(-t $self->in ? 1 : 0) unless defined $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 23 | ▶ | $self->colour($self->interactive && !$ENV{NO_COLOR} ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$self->interactive and not $ENV{"NO_COLOR"}
MC/DC0%0/2
$self->interactive and not $ENV{"NO_COLOR"}
$self->interactive
not $ENV{"NO_COLOR"}
Truth table33%1/3
A and not(B)
A= $self->interactiveB= not $ENV{"NO_COLOR"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | unless defined $self->colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 23 | ▶ | $self->picking($self->interactive ? 1 : 0) unless defined $self->picking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 23 | ▶ | $self->picking(0) unless $self->_keys_available; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 23 | ▶ | binmode $self->out, ':encoding(UTF-8)' unless $self->ascii; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 23 | my $previous = select $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 23 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 23 | select $previous; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 837 | ▶ | sub say_to { my ($self, @what) = @_; my $fh = $self->out; print {$fh} @what, "\n"; return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 221 | ▶ | sub board_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
board_lines: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 221 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 221 | ▶ | $view ||= $self->view || $self->game->turn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$view ||= $self->view || $self->game->turn
$self->view || $self->game->turn
MC/DC0%0/3
$view ||= $self->view || $self->game->turn
$view
$self->view
$self->game->turn
Truth table0%0/4
A ||= B || C
A= $viewB= $self->viewC= $self->game->turn
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 221 | my $board = $self->game->board; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 221 | my $other = Game::Backgammon::Board::other($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 221 | my @lines = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $self->_border(13 .. 24), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | $self->_half($view, [13 .. 24], 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ' |' . (' ' x 18) . '|' . $self->_label('BAR') . '|' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | . (' ' x 18) . '|' . $self->_label('OFF') . '|', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | $self->_half($view, [reverse 1 .. 12], 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | $self->_border(reverse 1 .. 12) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 221 | $lines[1] .= sprintf ' %-5s %3d pips', ucfirst $other, $board->pip_count($other); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 221 | $lines[11] .= sprintf ' %-5s %3d pips', ucfirst $view, $board->pip_count($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 221 | ▶ | if (my $last = $self->game->history->[-1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 195 | $lines[6] .= sprintf ' last: %s %s', $last->player, $last->notation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 221 | push @lines, sprintf ' the points are numbered from %s', $view; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 221 | return \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 215 | ▶ | sub render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 215 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 215 | return join "\n", @{ $self->board_lines($view) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 442 | ▶ | sub _border { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_border: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 442 | my ($self, @points) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 442 | my @cell = map { my $c = sprintf '%2d-', $_; $c =~ s/\A /-/; $c } @points; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 442 | return ' ' . $self->_label( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | '+' . join('', @cell[0 .. 5]) . '+---+' . join('', @cell[6 .. 11]) . '+---+' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 442 | ▶ | sub _half { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_half: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 442 | my ($self, $view, $points, $bottom) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 442 | my $board = $self->game->board; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 442 | my $other = Game::Backgammon::Board::other($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 442 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 442 | for my $row (0 .. ROWS - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2210 | ▶ | my $edge = $bottom ? ROWS - 1 - $row : $row; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2210 | ▶ | my $middle = $bottom ? $row : ROWS - 1 - $row; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2210 | my @cell; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2210 | for my $n (@$points) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 26520 | my ($mine, $theirs) = $board->point_for($view, $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 26520 | ▶ | push @cell, $mine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ? $self->_cell($view, $mine, $edge, $n) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | : $self->_cell($other, $theirs, $edge, $n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2210 | ▶ | my $bar = $bottom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ? $self->_cell($other, $board->bar($other), $middle) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | : $self->_cell($view, $board->bar($view), $middle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 2210 | ▶ | my $off = $bottom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ? $self->_cell($view, $board->off($view), $edge) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | : $self->_cell($other, $board->off($other), $edge); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2210 | push @lines, ' ' . $self->_label('|') . join('', @cell[0 .. 5]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | . $self->_label('|') . $bar . $self->_label('|') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | . join('', @cell[6 .. 11]) . $self->_label('|') . $off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | . $self->_label('|'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 442 | return @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 30940 | ▶ | sub _cell { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cell: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 30940 | my ($self, $player, $count, $edge, $point) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 30940 | ▶ | return $self->_ground($point, ' ') unless $count && $edge < ROWS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$count and $edge < 5
MC/DC50%1/2
$count and $edge < 5
$count
$edge < 5
Truth table66%2/3
A and B
A= $countB= $edge < 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 11450 | ▶ | return $self->_ground( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$edge == 4 and $count > 5
MC/DC100%2/2
$edge == 4 and $count > 5
$edge == 4
$count > 5
Truth table100%3/3
A and B
A= $edge == 4B= $count > 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | $point, $count > 9 ? "$count " : " $count ", $player | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | ) if $edge == ROWS - 1 && $count > ROWS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 11295 | ▶ | return $self->_ground($point, ' ') unless $edge < $count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | return $self->_ground( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 5883 | ▶ | $point, ' ' . $CHECKER{$player}{$self->ascii ? 'ascii' : 'wide'} . ' ', $player | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 30940 | ▶ | sub _ground { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ground: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 30940 | my ($self, $point, $text, $player) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | return $player | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ? $self->_paint($text, $CHECKER{$player}{colour}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 30940 | ▶ | : $text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$self->colour and defined $point
MC/DC100%2/2
$self->colour and defined $point
$self->colour
defined $point
Truth table100%3/3
A and B
A= $self->colourB= defined $point
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | unless $self->colour && defined $point; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 240 | my $mark = $self->highlight->{$point}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 240 | ▶ | $mark = $point % 2 ? 'dark' : 'light' unless $mark && $GROUND{$mark}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$mark and $GROUND{$mark}
MC/DC50%1/2
$mark and $GROUND{$mark}
$mark
$GROUND{$mark}
Truth table66%2/3
A and B
A= $markB= $GROUND{$mark}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 240 | my @code = ($GROUND{$mark}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 240 | ▶ | push @code, $CHECKER{$player}{ink} if $player; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 240 | return "\e[" . join(';', @code) . "m$text\e[0m"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 11934 | ▶ | sub _label { my ($self, $text) = @_; return $self->_paint($text, '2') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_label: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 17924 | ▶ | sub _paint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_paint: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 17924 | my ($self, $text, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 17924 | ▶ | return $text unless $self->colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 108 | return "\e[${code}m" . $text . "\e[0m"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 214 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=2 SCAR=10.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 214 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 214 | ▶ | return unless $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $fh = $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | print {$fh} "\e[2J\e[H"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 23 | ▶ | sub _keys_available { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keys_available: called CC=5 SCAR=21.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 23 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 23 | ▶ | return 1 if $self->keysource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 10 | ▶ | return 0 unless defined $self->in && -t $self->in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->in and -t $self->in
MC/DC0%0/2
defined $self->in and -t $self->in
defined $self->in
-t $self->in
Truth table33%1/3
A and B
A= defined $self->inB= -t $self->in
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | return eval { require Term::ReadKey; 1 } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 13 | ▶ | sub _enter_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_enter_raw: called CC=5 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 13 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 13 | ▶ | return $self if $self->raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 13 | ▶ | if ($self->keysource) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 13 | $self->raw(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | return undef unless $self->_keys_available; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | return undef unless eval { Term::ReadKey::ReadMode(3, $self->in); 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->raw(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 5 | ▶ | sub _leave_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_leave_raw: called CC=3 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 5 | ▶ | return $self unless $self->raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | eval { Term::ReadKey::ReadMode(0, $self->in) } unless $self->keysource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $self->raw(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 51 | ▶ | sub _read_char { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_char: called CC=6 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 51 | my ($self, $wait) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 51 | my $pending = $self->pending; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 51 | ▶ | return shift @$pending if @$pending; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 49 | ▶ | return $self->keysource->($wait) if $self->keysource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | my $char = Term::ReadKey::ReadKey($wait ? 0 : -1, $self->in); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | return $char if defined $char || $wait; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $char or $wait
MC/DC0%0/2
defined $char or $wait
defined $char
$wait
Truth table0%0/3
A or B
A= defined $charB= $wait
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | select undef, undef, undef, 0.05; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return Term::ReadKey::ReadKey(-1, $self->in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 31 | ▶ | sub _read_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_key: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 31 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 31 | my $char = $self->_read_char(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 31 | ▶ | return undef unless defined $char; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 29 | ▶ | return $CONTROL{$char} if $CONTROL{$char}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 15 | ▶ | return $self->_read_sequence if $char eq "\e"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | return $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 10 | ▶ | sub _read_sequence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_sequence: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 10 | my $opener = $self->_read_char(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 10 | ▶ | return 'escape' unless defined $opener; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 10 | ▶ | unless ($opener eq '[' || $opener eq 'O') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opener eq "[" or $opener eq "O"
MC/DC100%2/2
$opener eq "[" or $opener eq "O"
$opener eq "["
$opener eq "O"
Truth table100%3/3
A or B
A= $opener eq "["B= $opener eq "O"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | unshift @{ $self->pending }, $opener; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 2 | return 'escape'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 8 | my $tail = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 8 | ▶ | while (length $tail < 8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 10 | my $char = $self->_read_char(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 10 | ▶ | last unless defined $char; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 10 | $tail .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 10 | ▶ | last if $char =~ /[A-Za-z~]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 8 | ▶ | return $SEQUENCE{$tail} || 'escape'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$SEQUENCE{$tail} || 'escape'
MC/DC0%0/1
$SEQUENCE{$tail} || 'escape'
$SEQUENCE{$tail}
Truth table50%1/2
A
A= $SEQUENCE{$tail}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 197 | ▶ | sub step { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step: called CC=15 SCAR=34.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 197 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 197 | my $game = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 197 | ▶ | return 0 if $game->status ne 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 197 | my $who = $game->turn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 197 | ▶ | my $picking = $self->picking && $self->raw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition16%2/12
$self->picking && $self->raw && ($self->mode eq 'hotseat' || $self->mode eq 'bot' && $who eq $self->seat)
$self->picking and $self->raw
$self->mode eq "hotseat" or $self->mode eq "bot" and $who eq $self->seat
$self->mode eq "bot" and $who eq $self->seat
MC/DC0%0/5
$self->picking && $self->raw && ($self->mode eq 'hotseat' || $self->mode eq 'bot' && $who eq $self->seat)
$self->picking
$self->raw
$self->mode eq "hotseat"
$self->mode eq "bot"
$who eq $self->seat
Truth table16%1/6
A and B && C or D and E
A= $self->pickingB= $self->rawC= $self->mode eq "hotseat"D= $self->mode eq "bot"E= $who eq $self->seat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | && ($self->mode eq 'hotseat' || ($self->mode eq 'bot' && $who eq $self->seat)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 197 | ▶ | unless ($picking) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 197 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 197 | $self->say_to($self->render($who)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 197 | $self->say_to(sprintf ' %s to play %s', $who, join '-', @{ $game->dice }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 197 | my $turns = $game->legal_turns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 197 | ▶ | if ($turns->[0]->is_forfeit && @$turns == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$turns->[0]->is_forfeit and @$turns == 1
MC/DC50%1/2
$turns->[0]->is_forfeit and @$turns == 1
$turns->[0]->is_forfeit
@$turns == 1
Truth table66%2/3
A and B
A= $turns->[0]->is_forfeitB= @$turns == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 24 | ▶ | if ($picking) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $self->say_to($self->render($self->view || $who)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->view || $who
MC/DC0%0/2
$self->view || $who
$self->view
$who
Truth table0%0/3
A || B
A= $self->viewB= $who
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->say_to(sprintf ' %s to play %s', $who, join '-', @{ $game->dice }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 24 | $self->say_to(' no play'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 24 | $game->play($turns->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 24 | ▶ | return $game->status eq 'active' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 173 | my $turn = $self->_ask($who, $turns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 173 | ▶ | return 0 unless $turn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 171 | ▶ | $game->play($turn) or do { $self->say_to(' ' . $@->message); return 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 171 | $self->say_to(' ' . $turn->notation); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 171 | ▶ | return $game->status eq 'active' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 173 | ▶ | sub _ask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ask: called CC=13 SCAR=26.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 173 | my ($self, $who, $turns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 173 | ▶ | return Game::Backgammon::Bot->new(level => $self->level)->choose($self->game) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->mode eq "watch" or $self->mode eq "bot" and $who ne $self->seat
$self->mode eq "bot" and $who ne $self->seat
MC/DC66%2/3
$self->mode eq "watch" or $self->mode eq "bot" and $who ne $self->seat
$self->mode eq "watch"
$self->mode eq "bot"
$who ne $self->seat
Truth table75%3/4
A or B and C
A= $self->mode eq "watch"B= $self->mode eq "bot"C= $who ne $self->seat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | if $self->mode eq 'watch' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | || ($self->mode eq 'bot' && $who ne $self->seat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 46 | ▶ | if ($self->picking && $self->raw) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->picking and $self->raw
MC/DC0%0/2
$self->picking and $self->raw
$self->picking
$self->raw
Truth table33%1/3
A and B
A= $self->pickingB= $self->raw
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $turn = $self->_pick_turn($who, $turns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $self->highlight({}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return $turn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 46 | $self->say_to($_) for @{ $self->offer_lines($turns) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 46 | my $fh = $self->in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 46 | my $out = $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 46 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 49 | print {$out} " $who> "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 49 | my $line = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 49 | ▶ | return undef unless defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 48 | $line =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 48 | ▶ | return undef if $line eq 'q' || $line eq 'quit'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line eq "q" or $line eq "quit"
MC/DC50%1/2
$line eq "q" or $line eq "quit"
$line eq "q"
$line eq "quit"
Truth table66%2/3
A or B
A= $line eq "q"B= $line eq "quit"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 47 | ▶ | return $turns->[ $line - 1 ] if $line =~ /\A\d+\z/ && $line >= 1 && $line <= @$turns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$line =~ /\A\d+\z/ and $line >= 1 and $line <= @$turns
$line =~ /\A\d+\z/ and $line >= 1
MC/DC100%3/3
$line =~ /\A\d+\z/ and $line >= 1 and $line <= @$turns
$line =~ /\A\d+\z/
$line >= 1
$line <= @$turns
Truth table100%4/4
A and B and C
A= $line =~ /\A\d+\z/B= $line >= 1C= $line <= @$turns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 3 | $self->say_to(' pick a number from the list, or q to stop'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 30 | ▶ | sub _matching { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_matching: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 30 | my ($self, $turns, $chosen) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 30 | my @match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 30 | TURN: for my $turn (@$turns) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1061 | my $moves = $turn->moves; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1061 | ▶ | next TURN if @$moves < @$chosen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 1061 | for my $at (0 .. $#$chosen) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 765 | ▶ | next TURN if $moves->[$at]->notation ne $chosen->[$at]->notation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 391 | push @match, $turn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 30 | return \@match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 30 | ▶ | sub _next_moves { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_next_moves: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 30 | my ($self, $match, $chosen) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 30 | my (@move, %seen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 30 | for my $turn (@$match) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 474 | ▶ | my $move = $turn->moves->[ scalar @$chosen ] or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 467 | ▶ | next if $seen{ $move->notation }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 147 | push @move, $move; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 30 | return \@move; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 18 | ▶ | sub _complete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_complete: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 18 | my ($self, $match, $chosen) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 18 | for my $turn (@$match) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 141 | ▶ | return $turn if @{ $turn->moves } == @$chosen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 12 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 17 | ▶ | sub _move_marks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_move_marks: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 17 | my ($self, $view, $player, $chosen, $hover) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 17 | my %mark; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 42 | ▶ | my $seen = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 42 | my ($point) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 42 | ▶ | return undef if $point eq 'bar' || $point eq 'off'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$point eq "bar" or $point eq "off"
MC/DC100%2/2
$point eq "bar" or $point eq "off"
$point eq "bar"
$point eq "off"
Truth table100%3/3
A or B
A= $point eq "bar"B= $point eq "off"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 40 | ▶ | return $view eq $player ? $point : 25 - $point; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 17 | for my $move (@$chosen) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 5 | for my $end ($move->from, $move->to) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 10 | ▶ | my $point = $seen->($end) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 10 | $mark{$point} = 'played'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 17 | ▶ | if ($hover) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 16 | ▶ | if (my $to = $seen->($hover->to)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 15 | ▶ | $mark{$to} = $hover->hit ? 'hit' : 'to'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 16 | ▶ | if (my $from = $seen->($hover->from)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 15 | $mark{$from} = 'from'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 17 | return \%mark; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 5 | ▶ | sub _pick_turn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pick_turn: called CC=28 SCAR=40.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 5 | my ($self, $who, $turns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 5 | ▶ | return undef unless $self->raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 5 | ▶ | my $view = $self->view || $who; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->view || $who
MC/DC0%0/2
$self->view || $who
$self->view
$who
Truth table33%1/3
A || B
A= $self->viewB= $who
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 5 | my @chosen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 5 | my $at = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 5 | my @notice; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 5 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 15 | my $match = $self->_matching($turns, \@chosen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 15 | my $next = $self->_next_moves($match, \@chosen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 15 | my $done = $self->_complete($match, \@chosen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 15 | ▶ | return $done if $done && !@$next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$done and not @$next
MC/DC50%1/2
$done and not @$next
$done
not @$next
Truth table66%2/3
A and not(B)
A= $doneB= not @$next
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 12 | ▶ | $at = $#$next if $at > $#$next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 12 | ▶ | $at = 0 if $at < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 12 | $self->highlight( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | $self->_move_marks($view, $who, \@chosen, $next->[$at]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 12 | $self->_draw_choice($who, $view, $next, $at, \@chosen, $done, \@notice); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 12 | @notice = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 12 | my $key = $self->_read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 12 | ▶ | return undef if !defined $key || $key eq 'eof' || $key eq 'interrupt'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not defined $key or $key eq "eof" or $key eq "interrupt"
not defined $key or $key eq "eof"
MC/DC33%1/3
not defined $key or $key eq "eof" or $key eq "interrupt"
not defined $key
$key eq "eof"
$key eq "interrupt"
Truth table50%2/4
not(A) or B or C
A= not defined $keyB= $key eq "eof"C= $key eq "interrupt"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 11 | ▶ | if ($key eq 'up' || $key eq 'left' || $key eq 'k') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$key eq "up" or $key eq "left" or $key eq "k"
$key eq "up" or $key eq "left"
MC/DC0%0/3
$key eq "up" or $key eq "left" or $key eq "k"
$key eq "up"
$key eq "left"
$key eq "k"
Truth table25%1/4
A or B or C
A= $key eq "up"B= $key eq "left"C= $key eq "k"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $at = ($at - 1) % @$next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 11 | ▶ | if ($key eq 'down' || $key eq 'right' || $key eq 'tab' || $key eq 'j') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$key eq "down" or $key eq "right" or $key eq "tab" or $key eq "j"
$key eq "down" or $key eq "right" or $key eq "tab"
$key eq "down" or $key eq "right"
MC/DC25%1/4
$key eq "down" or $key eq "right" or $key eq "tab" or $key eq "j"
$key eq "down"
$key eq "right"
$key eq "tab"
$key eq "j"
Truth table40%2/5
A or B or C or D
A= $key eq "down"B= $key eq "right"C= $key eq "tab"D= $key eq "j"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 1 | $at = ($at + 1) % @$next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 10 | ▶ | if ($key eq 'enter' || $key eq ' ') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$key eq "enter" or $key eq " "
MC/DC50%1/2
$key eq "enter" or $key eq " "
$key eq "enter"
$key eq " "
Truth table66%2/3
A or B
A= $key eq "enter"B= $key eq " "
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 7 | push @chosen, $next->[$at]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 7 | $at = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 7 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 3 | ▶ | if ($key eq 'backspace') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 2 | ▶ | @notice = ('nothing taken back: no move chosen yet') unless @chosen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 2 | pop @chosen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 2 | $at = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 1 | ▶ | if ($key =~ /\A[1-9]\z/ && $key <= @$next) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$key =~ /\A[1-9]\z/ and $key <= @$next
MC/DC0%0/2
$key =~ /\A[1-9]\z/ and $key <= @$next
$key =~ /\A[1-9]\z/
$key <= @$next
Truth table33%1/3
A and B
A= $key =~ /\A[1-9]\z/B= $key <= @$next
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $at = $key - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | ▶ | if ($key eq 'f' && $done) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$key eq "f" and $done
MC/DC0%0/2
$key eq "f" and $done
$key eq "f"
$done
Truth table33%1/3
A and B
A= $key eq "f"B= $done
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | return $done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | ▶ | if ($key eq 'v') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $self->view($view = Game::Backgammon::Board::other($view)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 1 | ▶ | if ($key eq 'q') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 1 | $self->highlight({}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | if ($key eq '?') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | @notice = @{ $self->_key_lines }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | @notice = ('that key does nothing here, ? for the ones that do'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | sub _key_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key_lines: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | 'up and down choose a move, enter plays it', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 'backspace takes back the move chosen before it', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 'a digit jumps to that move, v turns the board round', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 'f finishes the turn where one can end, q stops the game', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 12 | ▶ | sub _draw_choice { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_draw_choice: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 12 | my ($self, $who, $view, $next, $at, $chosen, $done, $notice) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 12 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 12 | $self->say_to($self->render($view)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 12 | $self->say_to(sprintf ' %s to play %s', $who, join '-', @{ $self->game->dice }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | $self->say_to( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | @$chosen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 12 | ▶ | ? ' so far: ' . join ' ', map { $_->notation } @$chosen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | : ' nothing chosen yet' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 12 | $self->say_to(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 12 | $self->say_to($_) for @{ $self->_choice_lines($next, $at) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 12 | ▶ | if ($done) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $self->say_to(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $self->say_to(' f finishes the turn here'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 12 | $self->say_to(' ' . $_) for @$notice; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 12 | $self->say_to(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 12 | $self->say_to(' up and down to choose, enter to play it, ? for the keys'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 12 | ▶ | sub _choice_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_choice_lines: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 12 | my ($self, $next, $at) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 12 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 12 | for my $index (0 .. $#$next) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 55 | my $move = $next->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 55 | my $text = sprintf '%2d) %-9s %s', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | $index + 1, $move->notation, $self->_describe($move); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 55 | $text =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 55 | ▶ | push @lines, $index == $at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | ? ' ' . $self->_paint("> $text", '1;7') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | : ' ' . $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 12 | return \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 55 | ▶ | sub _describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_describe: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 55 | my ($self, $move) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 55 | my @note; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 55 | ▶ | push @note, 'from the bar' if $move->is_bar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 55 | ▶ | push @note, 'bears off' if $move->is_off; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 55 | ▶ | push @note, 'hits' if $move->hit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 55 | ▶ | push @note, sprintf 'with the %d', $move->die unless @note; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 55 | return join ', ', @note; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 48 | ▶ | sub offer_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offer_lines: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 48 | my ($self, $turns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 48 | my @item = map { sprintf '%2d) %s', $_ + 1, $turns->[$_]->notation } 0 .. $#$turns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 48 | my $width = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 48 | for my $item (@item) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 322 | ▶ | $width = length $item if length $item > $width; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 48 | ▶ | my $columns = int(74 / ($width + 2)) || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
int 74 / ($width + 2) || 1
MC/DC0%0/1
int 74 / ($width + 2) || 1
int 74 / ($width + 2)
Truth table50%1/2
A
A= int 74 / ($width + 2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 48 | ▶ | $columns = 4 if $columns > 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 48 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 48 | ▶ | while (@item) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 116 | my @row = splice @item, 0, $columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 116 | my $line = ' ' . join ' ', map { sprintf '%-*s', $width, $_ } @row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 116 | $line =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 116 | push @lines, $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 48 | return \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 5 | ▶ | sub start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=7 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 5 | ▶ | $self->game(Game::Backgammon->new(seed => $self->_seed)) unless $self->game; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 5 | ▶ | $self->picking(0) if $self->picking && !$self->_enter_raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->picking and not $self->_enter_raw
MC/DC0%0/2
$self->picking and not $self->_enter_raw
$self->picking
not $self->_enter_raw
Truth table33%1/3
A and not(B)
A= $self->pickingB= not $self->_enter_raw
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 5 | my $interrupt = $SIG{INT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | local $SIG{INT} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $self->_leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | $SIG{INT} = defined $interrupt ? $interrupt : 'DEFAULT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | kill 'INT', $$; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 5 | my $played = eval { $self->_turns; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 5 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 5 | $self->_leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 5 | ▶ | die $error unless $played; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 5 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 5 | $self->highlight({}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 5 | ▶ | $self->say_to($self->render($self->mode eq 'bot' ? $self->seat : undef)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 5 | my $r = $self->game->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 5 | ▶ | $self->say_to($r ? $r->stringify : 'stopped'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 5 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 5 | ▶ | sub _turns { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_turns: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 5 | my $guard = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 5 | ▶ | while ($self->step) { last if ++$guard > 10_000 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | sub _seed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_seed: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | require Digest::SHA; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | open my $ur, '<:raw', '/dev/urandom' or return Digest::SHA::sha256(rand() . $$ . time); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | read $ur, my $bytes, 32; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | close $ur; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | return length($bytes) == 32 ? $bytes : Digest::SHA::sha256(rand() . $$ . time); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | sub _usage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_usage: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | return <<'USAGE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | backgammon [--mode bot|hotseat|watch] [--level 1-3] [--seat white|black] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | [--view white|black] [--ascii] [--no-colour] [--no-pick] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | bot play the computer (the default) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | hotseat two people at one keyboard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | watch the computer against itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | --view pin the board to one side's numbering. By default it is drawn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | from the side on roll, because a turn is written in the mover's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | own numbers and the board should agree with the list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | --ascii O and X instead of the round checkers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | --no-pick choose a whole turn by number from the list, as 0.01 did, rather | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | than one checker at a time with the keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | --help this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | The board is the usual one: your home board is the bottom right quarter and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | you run into it anticlockwise, the bar is the middle column and the tray the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | one on the right. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | On a terminal a turn is built one checker at a time: the moves you can make | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | with the dice you have left are listed, up and down choose one and enter plays | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | it, backspace takes the last one back, and the board shows where the checker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | under the cursor is going. A roll that can be played three hundred ways is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | still only a handful of choices at each step. v turns the board round and q | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | stops. Without a terminal, or with --no-pick, every legal turn is numbered and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | you pick one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | Exit status is 0 when the game ended or was stopped, 2 for an option the game | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | will not take. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | USAGE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my ($class, @argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | my %o = (mode => 'bot', level => 3, seat => 'white', view => '', ascii => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my ($colour, $pick, $help); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | local $SIG{__WARN__} = sub { print STDERR "backgammon: $_[0]" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | Getopt::Long::GetOptionsFromArray(\@argv, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 'mode=s' => \$o{mode}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 'level=i' => \$o{level}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 'seat=s' => \$o{seat}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 'view=s' => \$o{view}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 'ascii' => \$o{ascii}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | 'colour!' => \$colour, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 'pick!' => \$pick, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 'help' => \$help, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | if (!$ok) { print STDERR _usage(); return 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | if ($help) { print _usage(); return 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | if (@argv) { print STDERR "backgammon: not an option: $argv[0]\n", _usage(); return 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my %refused = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | mode => [ qr/\A(?:bot|hotseat|watch)\z/, 'bot, hotseat or watch' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | seat => [ qr/\A(?:white|black)\z/, 'white or black' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | view => [ qr/\A(?:white|black|)\z/, 'white or black' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | level => [ qr/\A[123]\z/, '1 to 3' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | for my $k (qw(mode seat view level)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | next if $o{$k} =~ $refused{$k}[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | print STDERR "backgammon: --$k takes $refused{$k}[1], not '$o{$k}'\n", _usage(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | my $terminal = $class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | %o, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | (defined $colour ? (colour => $colour) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | (defined $pick ? (picking => $pick) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | local @SIG{qw(INT TERM HUP)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | for my $sig (qw(INT TERM HUP)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | $SIG{$sig} = sub { $terminal->_leave_raw; $SIG{$sig} = 'DEFAULT'; kill $sig, $$ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | my $played = eval { $result = $terminal->start; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | my $died = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $terminal->_leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | die $died unless $played; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | return 1 if $result && $terminal->mode eq 'bot' && $result->winner ne $terminal->seat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$result and $terminal->mode eq "bot" and $result->winner ne $terminal->seat
$result and $terminal->mode eq "bot"
MC/DC0%0/3
$result and $terminal->mode eq "bot" and $result->winner ne $terminal->seat
$result
$terminal->mode eq "bot"
$result->winner ne $terminal->seat
Truth table0%0/4
A and B and C
A= $resultB= $terminal->mode eq "bot"C= $result->winner ne $terminal->seat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||