| 1 | package Game::Schnapsen::Terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Digest::SHA (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Game::Schnapsen (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Game::Schnapsen::Bot (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Game::Schnapsen::Card qw(rank_of suit_of points_of name_of id_of long_name_of); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Game::Schnapsen::Declare qw(marriages_in); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use Game::Schnapsen::Variant (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | our %FRAME = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | plain => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | wide => [ "\x{250C}", "\x{2510}", "\x{2514}", "\x{2518}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | "\x{2500}", "\x{2502}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ascii => [ '+', '+', '+', '+', '-', '|' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | fresh => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | wide => [ "\x{2554}", "\x{2557}", "\x{255A}", "\x{255D}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | "\x{2550}", "\x{2551}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ascii => [ '#', '#', '#', '#', '=', '#' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | cursor => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | wide => [ "\x{250F}", "\x{2513}", "\x{2517}", "\x{251B}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | "\x{2501}", "\x{2503}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ascii => [ '+', '+', '+', '+', '=', '!' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | our %MARK_INK = (fresh => '1;32', cursor => '1;7'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | our %RANK_TEXT = (T => '10'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | my %SUIT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | S => { wide => "\x{2660}", ascii => 'S', colour => '37' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | H => { wide => "\x{2665}", ascii => 'H', colour => '31' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | D => { wide => "\x{2666}", ascii => 'D', colour => '31' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | C => { wide => "\x{2663}", ascii => 'C', colour => '37' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 5 | has game => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 5 | has out => (is => 'ro', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | has in => (is => 'ro', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | has mode => (is => 'ro', isa => Str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | has level => (is => 'ro', isa => Int); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | has seat => (is => 'ro', isa => Str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | has variant => (is => 'ro', isa => Str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | has ascii => (is => 'ro', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | has colour => (is => 'ro', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | has _painting => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 42 | ▶ | has marks => (is => 'rw', isa => HashRef, default => sub { {} }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | has raw => (is => 'rw', isa => Any, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | has keysource => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 42 | ▶ | has pending => (is => 'rw', isa => ArrayRef, default => sub { [] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 5 | has quit => (is => 'rw', isa => Any, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | has _picking => (is => 'rw', isa => Any, init_arg => 'picking'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 5 | has _staring => (is => 'rw', isa => Any, init_arg => 'interactive'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | our %SEQUENCE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 'A' => 'up', 'B' => 'down', 'C' => 'right', 'D' => 'left', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'H' => 'home', 'F' => 'end', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | '1~' => 'home', '4~' => 'end', '5~' => 'page_up', '6~' => 'page_down', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | '7~' => 'home', '8~' => 'end', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | our %CONTROL = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | "\r" => 'enter', "\n" => 'enter', "\t" => 'tab', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | "\x7f" => 'backspace', "\x08" => 'backspace', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | "\x03" => 'interrupt', "\x04" => 'eof', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1123 | ▶ | sub _out { return $_[0]->out || \*STDOUT } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_out: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]->out || \*STDOUT
MC/DC100%1/1
$_[0]->out || \*STDOUT
$_[0]->out
Truth table100%2/2
A
A= $_[0]->out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 22 | ▶ | sub _in { return $_[0]->in || \*STDIN } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->in || \*STDIN
MC/DC0%0/1
$_[0]->in || \*STDIN
$_[0]->in
Truth table50%1/2
A
A= $_[0]->in
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 984 | ▶ | sub _mode { return $_[0]->mode || 'bot' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mode: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->mode || 'bot'
MC/DC0%0/1
$_[0]->mode || 'bot'
$_[0]->mode
Truth table50%1/2
A
A= $_[0]->mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 576 | ▶ | sub _level { return $_[0]->level || 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_level: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]->level || 2
MC/DC100%1/1
$_[0]->level || 2
$_[0]->level
Truth table100%2/2
A
A= $_[0]->level
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1298 | ▶ | sub _seat { return $_[0]->seat || 'p1' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_seat: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]->seat || 'p1'
MC/DC0%0/1
$_[0]->seat || 'p1'
$_[0]->seat
Truth table50%1/2
A
A= $_[0]->seat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 944 | ▶ | sub _ascii { return $_[0]->ascii ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ascii: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 60 | ▶ | sub other { return $_[0] eq 'p1' ? 'p2' : 'p1' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
other: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 42 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 42 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 42 | ▶ | binmode $self->_out, ':encoding(UTF-8)' unless $self->_ascii; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 42 | my $previous = select $self->_out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 42 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 42 | select $previous; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 42 | ▶ | die 'Game::Schnapsen::Terminal: the level is 1 to ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_level >= 1 and $self->_level <= "Game::Schnapsen::Bot"->levels
MC/DC50%1/2
$self->_level >= 1 and $self->_level <= "Game::Schnapsen::Bot"->levels
$self->_level >= 1
$self->_level <= "Game::Schnapsen::Bot"->levels
Truth table66%2/3
A and B
A= $self->_level >= 1B= $self->_level <= "Game::Schnapsen::Bot"->levels
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | . Game::Schnapsen::Bot->levels . ', not ' . $self->_level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | unless $self->_level >= 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | && $self->_level <= Game::Schnapsen::Bot->levels; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 41 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1343 | ▶ | sub _colour { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_colour: called CC=6 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1343 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1343 | my $on = $self->_painting; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1343 | ▶ | return $on if defined $on; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | $on = defined $self->colour ? ($self->colour ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 25 | ▶ | : ((eval { -t $self->_out } && !$ENV{NO_COLOR}) ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
eval {
do {
-t $self->_out
}
} and not $ENV{"NO_COLOR"}
MC/DC0%0/2
eval {
do {
-t $self->_out
}
} and not $ENV{"NO_COLOR"}
eval {
do {
-t $self->_out
}
}
not $ENV{"NO_COLOR"}
Truth table0%0/3
A and not(B)
A= eval {
do {
-t $self->_out
}
}B= not $ENV{"NO_COLOR"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 25 | $self->_painting($on); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 25 | return $on; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1342 | ▶ | sub paint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paint: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1342 | my ($self, $text, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1342 | ▶ | return $text unless $self->_colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | return "\e[${code}m" . $text . "\e[0m"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1068 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 13 | ▶ | sub ask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ask: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 13 | my ($self, $prompt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 13 | my $fh = $self->_out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 13 | print {$fh} $prompt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 13 | my $in = $self->_in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 13 | my $line = <$in>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 13 | ▶ | return undef unless defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 10 | print {$fh} "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 10 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 10 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 764 | ▶ | sub rank_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rank_text: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 764 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 764 | my $rank = rank_of($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 764 | ▶ | return $RANK_TEXT{$rank} // $rank; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$Game::Schnapsen::Terminal::RANK_TEXT{$rank} // $rank
MC/DC0%0/2
$Game::Schnapsen::Terminal::RANK_TEXT{$rank} // $rank
$Game::Schnapsen::Terminal::RANK_TEXT{$rank}
$rank
Truth table66%2/3
A // B
A= $Game::Schnapsen::Terminal::RANK_TEXT{$rank}B= $rank
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 650 | ▶ | sub plain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plain: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 650 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 650 | ▶ | return '-' unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 650 | my $suit = $SUIT{ suit_of($id) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 650 | ▶ | return $self->rank_text($id) . $suit->{ $self->_ascii ? 'ascii' : 'wide' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 539 | ▶ | sub pretty { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pretty: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 539 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 539 | ▶ | return '-' unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 538 | return $self->paint($self->plain($id), $SUIT{ suit_of($id) }{colour}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 113 | ▶ | sub _card_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_card_rows: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 113 | my ($self, $id, $mark) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 113 | my $rank = $self->rank_text($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 113 | my $suit = $SUIT{ suit_of($id) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 113 | ▶ | my $pip = $suit->{ $self->_ascii ? 'ascii' : 'wide' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 113 | ▶ | my $style = $mark && $FRAME{$mark} ? $mark : 'plain'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$mark and $Game::Schnapsen::Terminal::FRAME{$mark}
MC/DC50%1/2
$mark and $Game::Schnapsen::Terminal::FRAME{$mark}
$mark
$Game::Schnapsen::Terminal::FRAME{$mark}
Truth table66%2/3
A and B
A= $markB= $Game::Schnapsen::Terminal::FRAME{$mark}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | my ($tl, $tr, $bl, $br, $h, $v) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 113 | ▶ | = @{ $FRAME{$style}{ $self->_ascii ? 'ascii' : 'wide' } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | return ([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | $tl . ($h x 7) . $tr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | $v . sprintf('%-7s', $rank) . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | $v . (' ' x 7) . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | $v . ' ' . $pip . ' ' . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | $v . (' ' x 7) . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | $v . sprintf('%7s', $rank) . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | $bl . ($h x 7) . $br, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 113 | ], $suit->{colour}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 113 | ▶ | sub card_art { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_art: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 113 | my ($self, $id, $mark) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 113 | my ($rows, $colour) = $self->_card_rows($id, $mark); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 113 | ▶ | my $ink = $mark && $MARK_INK{$mark} ? $MARK_INK{$mark} : $colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$mark and $Game::Schnapsen::Terminal::MARK_INK{$mark}
MC/DC50%1/2
$mark and $Game::Schnapsen::Terminal::MARK_INK{$mark}
$mark
$Game::Schnapsen::Terminal::MARK_INK{$mark}
Truth table66%2/3
A and B
A= $markB= $Game::Schnapsen::Terminal::MARK_INK{$mark}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 113 | return [ map { $self->paint($_, $ink) } @$rows ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | ▶ | sub card_back { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_back: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | ▶ | my ($tl, $tr, $bl, $br, $h, $v, $fill) = $self->_ascii | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ? ('+', '+', '+', '+', '-', '|', '#') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | : ("\x{250C}", "\x{2510}", "\x{2514}", "\x{2518}", "\x{2500}", "\x{2502}", "\x{2592}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | return [ map { $self->paint($_, '90') } ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | $tl . ($h x 7) . $tr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | (map { $v . ($fill x 7) . $v } 1 .. 5), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | $bl . ($h x 7) . $br, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 23 | ▶ | sub fan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fan: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 23 | my ($self, $cards, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 23 | ▶ | return [ ('') x 7 ] unless @$cards; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 23 | ▶ | $marks ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$marks ||= {}
MC/DC100%1/1
$marks ||= {}
$marks
Truth table100%2/2
A
A= $marks
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 23 | my @rows = ('') x 7; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 23 | for my $i (0 .. $#$cards) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 112 | my $art = $self->card_art($cards->[$i], $marks->{ $cards->[$i] }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 112 | $rows[$_] .= $art->[$_] . ' ' for 0 .. 6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 23 | s/\s+\z// for @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 23 | return \@rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 27 | ▶ | sub score_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
score_line: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 27 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 27 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 27 | my $v = $g->variant; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 27 | my $up = Game::Schnapsen::Variant::match_direction($v) > 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 27 | my $s = $g->scores; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | return sprintf('%s you %d them %d (%s, %s)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | $up ? 'Game points' : 'Game points left', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 27 | ▶ | $s->{ $self->_seat }, $s->{ other($self->_seat) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | $up ? 'first to 7' : 'down to zero', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | $v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 25 | ▶ | sub table_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_lines: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 25 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 25 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 25 | my $d = $g->deal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 25 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | push @out, sprintf('Deal %d trump %s talon %d%s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | $g->number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 25 | ▶ | $SUIT{ $d->trump }{ $self->_ascii ? 'ascii' : 'wide' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | $d->talon_left, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | $d->closed ? ' (closed)' : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 25 | push @out, sprintf('Card points you %d them %d', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | $d->points_of($seat), $d->points_of(other($seat))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 25 | ▶ | if (defined $d->turn_up && !$d->closed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $d->turn_up and not $d->closed
MC/DC50%1/2
defined $d->turn_up and not $d->closed
defined $d->turn_up
not $d->closed
Truth table66%2/3
A and not(B)
A= defined $d->turn_upB= not $d->closed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 23 | push @out, 'Turn-up: ' . $self->pretty($d->turn_up); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 25 | ▶ | if (defined $d->lead) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 5 | push @out, 'Led: ' . $self->pretty($d->lead); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | elsif (my $t = $d->last_trick) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | push @out, sprintf('Last trick: %s and %s to %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | $self->pretty($t->{lead}), $self->pretty($t->{follow}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | $t->{winner} eq $seat ? 'you' : 'them'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 25 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 22 | ▶ | sub hand_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hand_lines: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 22 | my ($self, $seat, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 22 | my $d = $self->game->deal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 22 | my $cards = $d->hand_of($seat)->sorted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 22 | ▶ | my @out = @{ $self->fan($cards, $marks || $self->marks) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$marks || $self->marks
MC/DC0%0/2
$marks || $self->marks
$marks
$self->marks
Truth table66%2/3
A || B
A= $marksB= $self->marks
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | my $labels = join ' ', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 22 | my $pad = 7 - length $self->plain($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 111 | ▶ | $self->pretty($_) . ' ' x ($pad > 0 ? $pad : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } @$cards; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 22 | $labels =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 22 | push @out, $labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 22 | my $m = marriages_in($cards, $d->trump); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 22 | ▶ | push @out, 'Marriages: ' . join(', ', map { $_->{suit} . ' for ' . $_->{value} } @$m) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | if @$m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 22 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 21 | ▶ | sub render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 21 | my ($self, $seat, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 21 | ▶ | $seat //= $self->_seat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$seat //= $self->_seat
MC/DC0%0/2
$seat //= $self->_seat
$seat
$self->_seat
Truth table33%1/3
A //= B
A= $seatB= $self->_seat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 21 | my @out = ('', $self->score_line, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 21 | push @out, @{ $self->table_lines($seat) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 21 | push @out, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 21 | push @out, @{ $self->hand_lines($seat, $marks) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 21 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 13 | ▶ | sub show { my ($self, $seat) = @_; $self->say_to($_) for @{ $self->render($seat) }; return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 497 | ▶ | sub describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 497 | my ($self, $move, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 497 | ▶ | my $who = $seat eq $self->_seat ? 'You' : 'They'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 497 | my $k = $move->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 497 | ▶ | return "$who led " . $self->pretty($move->{card}) if $k eq 'lead'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 303 | ▶ | return "$who played " . $self->pretty($move->{card}) if $k eq 'follow'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 113 | ▶ | return "$who declared a marriage in $move->{suit}" if $k eq 'marriage'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 87 | ▶ | return "$who exchanged for the trump card" if $k eq 'exchange'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 70 | ▶ | return "$who closed the talon" if $k eq 'close'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 62 | ▶ | return "$who claimed 66" if $k eq 'claim'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 37 | ▶ | return "$who drew" if $k eq 'draw'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | return "$who did something"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 15 | ▶ | sub card_named { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_named: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 15 | my ($self, $text, $cards) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 15 | ▶ | return undef unless defined $text && length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $text and length $text
MC/DC50%1/2
defined $text and length $text
defined $text
length $text
Truth table66%2/3
A and B
A= defined $textB= length $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 14 | (my $want = uc $text) =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 14 | $want =~ s/\A10/T/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 14 | for my $card (@$cards) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 29 | ▶ | return $card if uc(name_of($card)) eq $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 4 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $legal = $self->game->legal($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my @kinds = grep { !$seen{$_}++ } map { $_->{kind} } @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | return \@kinds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 984 | ▶ | sub is_human { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_human: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 984 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 984 | my $mode = $self->_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 984 | ▶ | return 0 if $mode eq 'watch'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 10 | ▶ | return 1 if $mode eq 'hotseat'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 10 | ▶ | return $seat eq $self->_seat ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 491 | ▶ | sub bot_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bot_move: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 491 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 491 | my $bot = Game::Schnapsen::Bot->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | level => $self->_level, seed => $self->game->seed . $seat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 491 | return $bot->choose($self->game, $seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 6 | ▶ | sub interactive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interactive: called CC=4 SCAR=18.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 6 | my $want = $self->_staring; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 6 | ▶ | return $want ? 1 : 0 if defined $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | return (eval { -t $self->_out }) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 11 | ▶ | sub picking { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
picking: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 11 | my ($self, @set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 11 | ▶ | $self->_picking($set[0] ? 1 : 0) if @set; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 11 | ▶ | return $self->_picking ? 1 : 0 if defined $self->_picking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 6 | return $self->keys_available; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 9 | ▶ | sub keys_available { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keys_available: called CC=4 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 9 | ▶ | return 1 if $self->keysource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 9 | ▶ | return 0 unless eval { -t $self->_in }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | return eval { require Term::ReadKey; 1 } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 5 | ▶ | sub enter_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enter_raw: called CC=5 SCAR=20.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 5 | ▶ | return $self if $self->raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 5 | ▶ | if ($self->keysource) { $self->raw(1); return $self } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | ▶ | return undef unless $self->keys_available; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | return undef unless eval { Term::ReadKey::ReadMode(3, $self->_in); 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $self->raw(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 8 | ▶ | sub leave_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leave_raw: called CC=3 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 8 | ▶ | return $self unless $self->raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | eval { Term::ReadKey::ReadMode(0, $self->_in) } unless $self->keysource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $self->raw(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 45 | ▶ | sub read_char { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_char: called CC=6 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 45 | my ($self, $wait) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 45 | my $pending = $self->pending; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 45 | ▶ | return shift @$pending if @$pending; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 43 | ▶ | return $self->keysource->($wait) if $self->keysource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | my $char = Term::ReadKey::ReadKey($wait ? 0 : -1, $self->_in); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | select undef, undef, undef, 0.05; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | return Term::ReadKey::ReadKey(-1, $self->_in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 25 | ▶ | sub read_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_key: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 25 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 25 | my $char = $self->read_char(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 25 | ▶ | return undef unless defined $char; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 24 | ▶ | return $CONTROL{$char} if $CONTROL{$char}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 18 | ▶ | return $self->read_sequence if $char eq "\e"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 8 | return $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 10 | ▶ | sub read_sequence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_sequence: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 10 | my $opener = $self->read_char(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 10 | ▶ | return 'escape' unless defined $opener; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 2 | unshift @{ $self->pending }, $opener; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 2 | return 'escape'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 8 | my $tail = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 8 | ▶ | while (length $tail < 8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 10 | my $char = $self->read_char(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 10 | ▶ | last unless defined $char; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 10 | $tail .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 10 | ▶ | last if $char =~ /[A-Za-z~]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 8 | ▶ | return $SEQUENCE{$tail} || 'escape'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Game::Schnapsen::Terminal::SEQUENCE{$tail} || 'escape'
MC/DC0%0/1
$Game::Schnapsen::Terminal::SEQUENCE{$tail} || 'escape'
$Game::Schnapsen::Terminal::SEQUENCE{$tail}
Truth table50%1/2
A
A= $Game::Schnapsen::Terminal::SEQUENCE{$tail}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 6 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=2 SCAR=10.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 6 | ▶ | return $self unless $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $fh = $self->_out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | print {$fh} "\e[2J\e[3J\e[H"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 492 | ▶ | sub remember { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remember: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 492 | my ($self, $seat, $held) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 492 | ▶ | my $hand = eval { $self->game->deal->hand_of($seat) } or return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 492 | my %mark; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 492 | for my $card (@{ $hand->sorted }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 2245 | ▶ | $mark{$card} = 'fresh' unless $held->{$card}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 492 | $self->marks(\%mark); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 492 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 7 | ▶ | sub card_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_line: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 7 | my ($self, $seat, $card) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 7 | my $d = $self->game->deal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 7 | my $name = $self->pretty($card); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 7 | my $lead = $d->lead; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 7 | ▶ | return "$name: you lead it" unless defined $lead; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | my $winner = Game::Schnapsen::Trick::winner_of($lead, $card, $d->trump); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | my $worth = Game::Schnapsen::Trick::value_of($lead, $card); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | my $mine = $d->points_of($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | ▶ | return sprintf '%s: %s the trick, %d %s%s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | ($winner == $card ? 'takes' : 'loses'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | $worth, ($worth == 1 ? 'point' : 'points'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | ($winner == $card | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | ? sprintf(', which puts you on %d', $mine + $worth) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | sub pick_help { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pick_help: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | 'left and right walk your hand, enter plays the card under the cursor.', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 'the line under it says what that card would do to the trick.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 'x exchanges, c closes, m declares a marriage, o claims 66, d draws.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 't goes back to typing, q stops.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 5 | my %SPECIAL = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | x => 'exchange', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | c => 'close', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | o => 'claim', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | d => 'draw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 3 | ▶ | sub pick_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pick_move: called CC=33 SCAR=45.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 3 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 3 | my $legal = $g->legal($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 3 | ▶ | return undef unless @$legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 3 | my %by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 3 | push @{ $by{ $_->{kind} } }, $_ for @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 15 | my @cards = map { $_->{card} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 3 | grep { defined $_->{card} } @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 3 | my %playable = map { $_ => 1 } @cards; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | my @order = grep { $playable{$_} } @{ $g->deal->hand_of($seat)->sorted }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 3 | my $at = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 3 | my @notice; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 3 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 6 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 6 | ▶ | my %mark = (%{ $self->marks }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | @order ? ($order[$at] => 'cursor') : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 6 | $self->say_to($_) for @{ $self->render($seat, \%mark) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 6 | ▶ | $self->say_to(' ' . $self->card_line($seat, $order[$at])) if @order; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 6 | my $offers = $self->_offers(\%by); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 6 | ▶ | $self->say_to(' ' . $offers) if length $offers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 6 | $self->say_to(' ' . $_) for @notice; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 6 | @notice = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 6 | $self->say_to(' ' . $self->paint( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 'arrows to choose, enter to play, ? for the keys', '90')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 6 | my $key = $self->read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 6 | ▶ | if (!defined $key || $key eq 'eof' || $key eq 'interrupt' || $key eq 'q') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
not defined $key or $key eq "eof" or $key eq "interrupt" or $key eq "q"
not defined $key or $key eq "eof" or $key eq "interrupt"
not defined $key or $key eq "eof"
MC/DC25%1/4
not defined $key or $key eq "eof" or $key eq "interrupt" or $key eq "q"
not defined $key
$key eq "eof"
$key eq "interrupt"
$key eq "q"
Truth table40%2/5
not(A) or B or C or D
A= not defined $keyB= $key eq "eof"C= $key eq "interrupt"D= $key eq "q"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | $self->quit(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 4 | ▶ | if (@order && ($key eq 'left' || $key eq 'up')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@order and $key eq "left" || $key eq "up"
$key eq "left" or $key eq "up"
MC/DC0%0/3
@order and $key eq "left" || $key eq "up"
@order
$key eq "left"
$key eq "up"
Truth table25%1/4
A and B or C
A= @orderB= $key eq "left"C= $key eq "up"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $at = ($at - 1) % @order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 4 | ▶ | if (@order && ($key eq 'right' || $key eq 'down' || $key eq 'tab')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
@order and $key eq "right" || $key eq "down" || $key eq "tab"
$key eq "right" or $key eq "down" or $key eq "tab"
$key eq "right" or $key eq "down"
MC/DC25%1/4
@order and $key eq "right" || $key eq "down" || $key eq "tab"
@order
$key eq "right"
$key eq "down"
$key eq "tab"
Truth table40%2/5
A and B or C or D
A= @orderB= $key eq "right"C= $key eq "down"D= $key eq "tab"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 1 | $at = ($at + 1) % @order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | ▶ | if (@order && ($key eq 'enter' || $key eq ' ')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@order and $key eq "enter" || $key eq " "
$key eq "enter" or $key eq " "
MC/DC33%1/3
@order and $key eq "enter" || $key eq " "
@order
$key eq "enter"
$key eq " "
Truth table50%2/4
A and B or C
A= @orderB= $key eq "enter"C= $key eq " "
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 1 | ▶ | my ($pick) = grep { defined $_->{card} && $_->{card} == $order[$at] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $_->{'card'} && $_->{'card'} == $order[$at]
MC/DC100%2/2
defined $_->{'card'} && $_->{'card'} == $order[$at]
defined $_->{'card'}
$_->{'card'} == $order[$at]
Truth table100%3/3
A && B
A= defined $_->{'card'}B= $_->{'card'} == $order[$at]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | @$legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 1 | ▶ | return $pick if $pick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | @notice = ('you cannot play that one'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | ▶ | if (my $kind = $SPECIAL{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | ▶ | return $by{$kind}[0] if $by{$kind}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 1 | @notice = ("you cannot $kind here"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | ▶ | if ($key eq 'm') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | if (my $m = $by{marriage}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | return $m->[0] if @$m == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | @notice = ('which marriage? ' . join(' ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | map { lc $_->{suit} } @$m) . ' as a letter'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my $suit = $self->read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | my ($pick) = grep { lc $_->{suit} eq lc($suit // '') } @$m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$suit // ""
MC/DC0%0/1
$suit // ""
$suit
Truth table0%0/2
A
A= $suit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | return $pick if $pick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | @notice = ('you do not hold that marriage'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | @notice = ('you have no marriage to declare'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | ▶ | if ($key eq 't') { $self->picking(0); return $self->typed_move($seat) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 1 | ▶ | if ($key eq '?') { @notice = $self->pick_help; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 1 | @notice = ('that key does nothing here. ? for the ones that do'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 6 | ▶ | sub _offers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_offers: called CC=7 SCAR=20.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 6 | my ($self, $by) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 6 | my @say; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 6 | ▶ | push @say, 'x exchange' if $by->{exchange}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 6 | ▶ | push @say, 'c close' if $by->{close}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 6 | ▶ | push @say, 'm marriage' if $by->{marriage}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 6 | ▶ | push @say, 'o claim 66' if $by->{claim}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 6 | ▶ | push @say, 'd draw' if $by->{draw}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 6 | ▶ | return @say ? 'also: ' . join(' ', @say) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 8 | ▶ | sub human_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
human_move: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 8 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 8 | ▶ | if ($self->picking) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 2 | ▶ | return $self->pick_move($seat) if $self->enter_raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 2 | $self->picking(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 8 | return $self->typed_move($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 8 | ▶ | sub typed_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
typed_move: called CC=18 SCAR=34.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 8 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 8 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 8 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 13 | my $legal = $g->legal($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 13 | ▶ | return undef unless @$legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 13 | my %by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 13 | push @{ $by{ $_->{kind} } }, $_ for @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 13 | my @words = sort keys %by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 13 | $self->show($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 13 | my $line = $self->ask('> '); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 13 | ▶ | return undef unless defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 10 | $line =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 10 | ▶ | if ($line =~ /\A(?:\?|h|help)\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 2 | $self->say_to('You may: ' . join(', ', @words)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | $self->say_to('Name a card to play it (KH, 10H, TH). Or: ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | . 'm SUIT to declare a marriage, x to exchange, ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | . 'c to close, out to claim 66, d to draw.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 8 | ▶ | if ($line =~ /\Am\s*([SHDC])\z/i && $by{marriage}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$line =~ /\Am\s*([SHDC])\z/i and $by{"marriage"}
MC/DC0%0/2
$line =~ /\Am\s*([SHDC])\z/i and $by{"marriage"}
$line =~ /\Am\s*([SHDC])\z/i
$by{"marriage"}
Truth table33%1/3
A and B
A= $line =~ /\Am\s*([SHDC])\z/iB= $by{"marriage"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $suit = uc $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my ($pick) = grep { $_->{suit} eq $suit } @{ $by{marriage} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | return $pick if $pick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $self->say_to('You do not hold that marriage.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 8 | ▶ | if ($line =~ /\A(?:x|exchange)\z/i && $by{exchange}) { return $by{exchange}[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$line =~ /\A(?:x|exchange)\z/i and $by{"exchange"}
MC/DC0%0/2
$line =~ /\A(?:x|exchange)\z/i and $by{"exchange"}
$line =~ /\A(?:x|exchange)\z/i
$by{"exchange"}
Truth table33%1/3
A and B
A= $line =~ /\A(?:x|exchange)\z/iB= $by{"exchange"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 8 | ▶ | if ($line =~ /\A(?:c|close)\z/i && $by{close}) { return $by{close}[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$line =~ /\A(?:c|close)\z/i and $by{"close"}
MC/DC0%0/2
$line =~ /\A(?:c|close)\z/i and $by{"close"}
$line =~ /\A(?:c|close)\z/i
$by{"close"}
Truth table33%1/3
A and B
A= $line =~ /\A(?:c|close)\z/iB= $by{"close"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 8 | ▶ | if ($line =~ /\A(?:out|claim|66)\z/i && $by{claim}) { return $by{claim}[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line =~ /\A(?:out|claim|66)\z/i and $by{"claim"}
MC/DC50%1/2
$line =~ /\A(?:out|claim|66)\z/i and $by{"claim"}
$line =~ /\A(?:out|claim|66)\z/i
$by{"claim"}
Truth table66%2/3
A and B
A= $line =~ /\A(?:out|claim|66)\z/iB= $by{"claim"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 5 | ▶ | if ($line =~ /\A(?:d|draw)\z/i && $by{draw}) { return $by{draw}[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$line =~ /\A(?:d|draw)\z/i and $by{"draw"}
MC/DC0%0/2
$line =~ /\A(?:d|draw)\z/i and $by{"draw"}
$line =~ /\A(?:d|draw)\z/i
$by{"draw"}
Truth table33%1/3
A and B
A= $line =~ /\A(?:d|draw)\z/iB= $by{"draw"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 5 | my @playable = grep { defined $_->{card} } @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 5 | my $card = $self->card_named($line, [ map { $_->{card} } @playable ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 5 | ▶ | if (defined $card) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 2 | my ($pick) = grep { $_->{card} == $card } @playable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 2 | ▶ | return $pick if $pick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 3 | $self->say_to("I did not follow that. You may: " . join(', ', @words) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | . '. Type ? for help.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 733 | ▶ | sub announce { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
announce: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 733 | my ($self, $event) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 733 | my $k = $event->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 733 | ▶ | if ($k eq 'trick') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 190 | ▶ | return $self->say_to(' ' . ($event->{winner} eq $self->_seat ? 'You take it.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | : 'They take it.')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 543 | ▶ | if ($k eq 'deal_end') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 26 | return $self->say_to($self->deal_result_line($event)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 517 | ▶ | if ($k eq 'deal') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 22 | return $self->say_to(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 495 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 33 | ▶ | sub deal_result_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deal_result_line: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 33 | my ($self, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 33 | ▶ | return 'The deal is drawn. Nobody scores, and it is dealt again.' if $r->{drawn}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 32 | ▶ | my $who = ($r->{winner} // '') eq $self->_seat ? 'You win' : 'They win'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$r->{"winner"} // ""
MC/DC0%0/1
$r->{"winner"} // ""
$r->{"winner"}
Truth table50%1/2
A
A= $r->{"winner"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 32 | my %how = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | claim => 'the deal, claiming 66', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | closed_out => 'the deal, having closed the talon', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | false_claim => 'the deal: the claim was false', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | beat_closer => 'the deal, beating the closer to it', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | failed_close => 'the deal: the close failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | last_trick => 'the deal on the last trick', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | return sprintf('%s %s, for %d game point%s.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | $who, $how{ $r->{how} } // 'the deal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 32 | ▶ | $r->{game_points}, $r->{game_points} == 1 ? '' : 's'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$how{$r->{"how"}} // "the deal"
MC/DC0%0/1
$how{$r->{"how"}} // "the deal"
$how{$r->{"how"}}
Truth table50%1/2
A
A= $how{$r->{"how"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 8 | ▶ | sub result_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result_line: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 8 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 8 | ▶ | my $r = $g->result or return ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 8 | my $s = $g->scores; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 8 | my $mine = $s->{ $self->_seat }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 8 | my $theirs = $s->{ other($self->_seat) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 8 | my $won = $r->{winner} eq $self->_seat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | return sprintf('%s the match, %d to %d, over %d deals.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | $won ? 'You win' : 'They win', $mine, $theirs, $r->{deals}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 8 | ▶ | if Game::Schnapsen::Variant::match_direction($g->variant) > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | return sprintf('%s the match over %d deals, with %d still to find %s.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | $won ? 'You win' : 'They win', $r->{deals}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 5 | ▶ | $won ? $theirs : $mine, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | $won ? 'against you' : 'from you'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 8 | ▶ | sub play { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play: called CC=17 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 8 | my ($self, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 8 | ▶ | my $seed = $o{seed} // Digest::SHA::sha256(join ':', $$, time, rand); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$o{"seed"} // &Digest::SHA::sha256(join(":", $$, time, rand))
MC/DC0%0/2
$o{"seed"} // &Digest::SHA::sha256(join(":", $$, time, rand))
$o{"seed"}
&Digest::SHA::sha256(join(":", $$, time, rand))
Truth table33%1/3
A // B
A= $o{"seed"}B= &Digest::SHA::sha256(join(":", $$, time, rand))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 8 | ▶ | my $variant = $o{variant} // $self->variant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$o{"variant"} // $self->variant
MC/DC50%1/2
$o{"variant"} // $self->variant
$o{"variant"}
$self->variant
Truth table66%2/3
A // B
A= $o{"variant"}B= $self->variant
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 8 | my $bad = Game::Schnapsen::Variant::check_variant($variant); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 8 | ▶ | if ($bad) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 2 | $self->say_to('Cannot start: ' . $bad->message | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | . ' (schnapsen or sixtysix, and there is no default)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 2 | return $bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | my $g = Game::Schnapsen->build( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | variant => $variant, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | seed => $seed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 6 | ▶ | dealer => $o{dealer} || 'p1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$o{'dealer'} || 'p1'
MC/DC0%0/1
$o{'dealer'} || 'p1'
$o{'dealer'}
Truth table50%1/2
A
A= $o{'dealer'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 6 | ▶ | if (ref $g eq 'Game::Schnapsen::Error') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $self->say_to('Cannot start: ' . $g->message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | return $g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 6 | $self->game($g); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 6 | my $guard = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 6 | ▶ | while (!$g->over && !$self->quit && $guard++ < 10_000) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $g->over || $self->quit and $guard++ < 10000
$g->over || $self->quit
MC/DC33%1/3
not $g->over || $self->quit and $guard++ < 10000
$g->over
$self->quit
$guard++ < 10000
Truth table50%2/4
not(A || B) and C
A= $g->overB= $self->quitC= $guard++ < 10000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 493 | ▶ | my $seat = $g->turn or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 493 | ▶ | my $move = $self->is_human($seat) ? $self->human_move($seat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | : $self->bot_move($seat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 493 | ▶ | last unless $move; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 491 | ▶ | $self->say_to($self->describe($move, $seat)) unless $self->is_human($seat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 491 | my $mine = $self->_seat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 491 | my %held = eval { map { $_ => 1 } @{ $g->deal->hand_of($mine)->sorted } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 491 | my @out = $g->apply($seat, $move); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 491 | ▶ | if (@out == 1 && ref $out[0] eq 'Game::Schnapsen::Error') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@out == 1 and ref $out[0] eq "Game::Schnapsen::Error"
MC/DC0%0/2
@out == 1 and ref $out[0] eq "Game::Schnapsen::Error"
@out == 1
ref $out[0] eq "Game::Schnapsen::Error"
Truth table66%2/3
A and B
A= @out == 1B= ref $out[0] eq "Game::Schnapsen::Error"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | $self->say_to($out[0]->message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 491 | $self->remember($mine, \%held); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 491 | $self->announce($_) for @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 6 | $self->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 6 | $self->say_to(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 6 | ▶ | $self->say_to($self->result_line) if $g->over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 6 | return $g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||