| 1 | package Game::Schnapsen::Terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Digest::SHA (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Game::Schnapsen (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Game::Schnapsen::Bot (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | 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 | 6 | ▶ | use Game::Schnapsen::Declare qw(marriages_in); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Game::Schnapsen::Variant (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use Game::Terminal::Kit::Keys (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use Game::Terminal::Kit::Log (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | ▶ | use Game::Terminal::Kit::Picker (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | ▶ | use Game::Terminal::Kit::Run (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | ▶ | use Game::Terminal::Kit::Screen (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | our %FRAME = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | plain => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | wide => [ "\x{250C}", "\x{2510}", "\x{2514}", "\x{2518}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | "\x{2500}", "\x{2502}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ascii => [ '+', '+', '+', '+', '-', '|' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | fresh => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | wide => [ "\x{2554}", "\x{2557}", "\x{255A}", "\x{255D}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | "\x{2550}", "\x{2551}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ascii => [ '#', '#', '#', '#', '=', '#' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | cursor => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | wide => [ "\x{250F}", "\x{2513}", "\x{2517}", "\x{251B}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | "\x{2501}", "\x{2503}" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ascii => [ '+', '+', '+', '+', '=', '!' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | our %MARK_INK = (fresh => '1;32', cursor => '1;7'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | our %RANK_TEXT = (T => '10'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | my %SUIT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | S => { wide => "\x{2660}", ascii => 'S', colour => '37' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | H => { wide => "\x{2665}", ascii => 'H', colour => '31' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | D => { wide => "\x{2666}", ascii => 'D', colour => '31' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | C => { wide => "\x{2663}", ascii => 'C', colour => '37' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | has game => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | has out => (is => 'ro', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | has in => (is => 'ro', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | has mode => (is => 'ro', isa => Str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | has level => (is => 'ro', isa => Int); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | has seat => (is => 'ro', isa => Str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | has variant => (is => 'ro', isa => Str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | has ascii => (is => 'ro', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | has colour => (is => 'ro', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 42 | ▶ | has marks => (is => 'rw', isa => HashRef, default => sub { {} }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 6 | has keysource => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 42 | ▶ | has pending => (is => 'rw', isa => ArrayRef, default => sub { [] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 6 | has keyboard => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 6 | has screen => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 6 | has log => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 6 | has quit => (is => 'rw', isa => Any, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 6 | has _picking => (is => 'rw', isa => Any, init_arg => 'picking'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 6 | has _staring => (is => 'rw', isa => Any, init_arg => 'interactive'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 6 | has _framed => (is => 'rw', isa => Any); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 85 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 55 | ▶ | sub _in { return $_[0]->in || \*STDIN } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]->in || \*STDIN
MC/DC100%1/1
$_[0]->in || \*STDIN
$_[0]->in
Truth table100%2/2
A
A= $_[0]->in
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 944 | ▶ | sub _ascii { return $_[0]->ascii ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ascii: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 60 | ▶ | sub other { return $_[0] eq 'p1' ? 'p2' : 'p1' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
other: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 42 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=11 SCAR=28.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 42 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 42 | my $out = $self->_out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 42 | ▶ | $self->keyboard(Game::Terminal::Kit::Keys->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | in => $self->_in, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | pending => $self->pending, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | (defined $self->keysource ? (keysource => $self->keysource) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | )) unless $self->keyboard; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $self->screen(Game::Terminal::Kit::Screen->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | out => $out, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | interactive => $self->interactive, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | colour => defined $self->colour ? ($self->colour ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | : ((eval { -t $out } && !Game::Terminal::Kit::Screen::no_colour()) ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
eval {
do {
-t $out
}
} and not Game::Terminal::Kit::Screen::no_colour()
MC/DC0%0/2
eval {
do {
-t $out
}
} and not Game::Terminal::Kit::Screen::no_colour()
eval {
do {
-t $out
}
}
not Game::Terminal::Kit::Screen::no_colour()
Truth table0%0/3
A and not(B)
A= eval {
do {
-t $out
}
}B= not Game::Terminal::Kit::Screen::no_colour()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ascii => $self->_ascii, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | )) unless $self->screen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 42 | ▶ | $self->log(Game::Terminal::Kit::Log->new(keep => 12)) unless $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 42 | $self->screen->utf8->flush_on; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | . Game::Schnapsen::Bot->levels . ', not ' . $self->_level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | unless $self->_level >= 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | && $self->_level <= Game::Schnapsen::Bot->levels; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 41 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | sub _colour { return $_[0]->screen->colour ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_colour: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1342 | ▶ | sub paint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1342 | my ($self, $text, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1342 | return $self->screen->paint($text, $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 954 | ▶ | sub say_to { my ($self, @what) = @_; $self->screen->say(join '', @what); return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 707 | ▶ | sub tell { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tell: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 707 | my ($self, @what) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 707 | $self->say_to(@what); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 707 | $self->log->record(join '', @what); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 707 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 13 | ▶ | sub ask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ask: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 13 | my ($self, $prompt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 13 | my $fh = $self->_out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 13 | print {$fh} $prompt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 13 | my $in = $self->_in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 13 | my $line = <$in>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 13 | ▶ | return undef unless defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 10 | print {$fh} "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 10 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 10 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 764 | ▶ | sub rank_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rank_text: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 764 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 764 | my $rank = rank_of($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 650 | ▶ | sub plain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plain: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 650 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 650 | ▶ | return '-' unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 650 | my $suit = $SUIT{ suit_of($id) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 650 | ▶ | return $self->rank_text($id) . $suit->{ $self->_ascii ? 'ascii' : 'wide' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 539 | ▶ | sub pretty { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pretty: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 539 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 539 | ▶ | return '-' unless defined $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 538 | return $self->paint($self->plain($id), $SUIT{ suit_of($id) }{colour}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 113 | ▶ | sub _card_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_card_rows: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 113 | my ($self, $id, $mark) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 113 | my $rank = $self->rank_text($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 113 | my $suit = $SUIT{ suit_of($id) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 113 | ▶ | my $pip = $suit->{ $self->_ascii ? 'ascii' : 'wide' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | my ($tl, $tr, $bl, $br, $h, $v) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 113 | ▶ | = @{ $FRAME{$style}{ $self->_ascii ? 'ascii' : 'wide' } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | return ([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | $tl . ($h x 7) . $tr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | $v . sprintf('%-7s', $rank) . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | $v . (' ' x 7) . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | $v . ' ' . $pip . ' ' . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | $v . (' ' x 7) . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | $v . sprintf('%7s', $rank) . $v, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $bl . ($h x 7) . $br, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 113 | ], $suit->{colour}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 113 | ▶ | sub card_art { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_art: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 113 | my ($self, $id, $mark) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 113 | my ($rows, $colour) = $self->_card_rows($id, $mark); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 113 | return [ map { $self->paint($_, $ink) } @$rows ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | ▶ | sub card_back { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_back: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | my ($tl, $tr, $bl, $br, $h, $v, $fill) = $self->_ascii | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | ? ('+', '+', '+', '+', '-', '|', '#') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | : ("\x{250C}", "\x{2510}", "\x{2514}", "\x{2518}", "\x{2500}", "\x{2502}", "\x{2592}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | return [ map { $self->paint($_, '90') } ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $tl . ($h x 7) . $tr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | (map { $v . ($fill x 7) . $v } 1 .. 5), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | $bl . ($h x 7) . $br, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 23 | ▶ | sub fan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fan: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 23 | my ($self, $cards, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 23 | ▶ | return [ ('') x 7 ] unless @$cards; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 23 | ▶ | $marks ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$marks ||= {}
MC/DC100%1/1
$marks ||= {}
$marks
Truth table100%2/2
A
A= $marks
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 23 | my @rows = ('') x 7; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 23 | for my $i (0 .. $#$cards) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 112 | my $art = $self->card_art($cards->[$i], $marks->{ $cards->[$i] }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 112 | $rows[$_] .= $art->[$_] . ' ' for 0 .. 6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 23 | s/\s+\z// for @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 23 | return \@rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 27 | ▶ | sub score_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
score_line: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 27 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 27 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 27 | my $v = $g->variant; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 27 | my $up = Game::Schnapsen::Variant::match_direction($v) > 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 27 | my $s = $g->scores; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | return sprintf('%s you %d them %d (%s, %s)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $up ? 'Game points' : 'Game points left', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 27 | ▶ | $s->{ $self->_seat }, $s->{ other($self->_seat) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | $up ? 'first to 7' : 'down to zero', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | $v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 25 | ▶ | sub table_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_lines: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 25 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 25 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 25 | my $d = $g->deal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 25 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | push @out, sprintf('Deal %d trump %s talon %d%s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | $g->number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 25 | ▶ | $SUIT{ $d->trump }{ $self->_ascii ? 'ascii' : 'wide' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | $d->talon_left, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | $d->closed ? ' (closed)' : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 25 | push @out, sprintf('Card points you %d them %d', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $d->points_of($seat), $d->points_of(other($seat))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 23 | push @out, 'Turn-up: ' . $self->pretty($d->turn_up); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 25 | ▶ | if (defined $d->lead) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 5 | push @out, 'Led: ' . $self->pretty($d->lead); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | elsif (my $t = $d->last_trick) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | push @out, sprintf('Last trick: %s and %s to %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | $self->pretty($t->{lead}), $self->pretty($t->{follow}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 3 | ▶ | $t->{winner} eq $seat ? 'you' : 'them'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 25 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 22 | ▶ | sub hand_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hand_lines: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 22 | my ($self, $seat, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 22 | my $d = $self->game->deal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 22 | my $cards = $d->hand_of($seat)->sorted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | my $labels = join ' ', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 22 | my $pad = 7 - length $self->plain($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 111 | ▶ | $self->pretty($_) . ' ' x ($pad > 0 ? $pad : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } @$cards; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 22 | $labels =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 22 | push @out, $labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 22 | my $m = marriages_in($cards, $d->trump); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 22 | ▶ | push @out, 'Marriages: ' . join(', ', map { $_->{suit} . ' for ' . $_->{value} } @$m) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | if @$m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 22 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 21 | ▶ | sub render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 21 | my ($self, $seat, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 21 | my @out = ('', $self->score_line, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 21 | push @out, @{ $self->table_lines($seat) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 21 | push @out, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 21 | push @out, @{ $self->hand_lines($seat, $marks) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 21 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 13 | ▶ | sub show { my ($self, $seat) = @_; $self->say_to($_) for @{ $self->render($seat) }; return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 497 | ▶ | sub describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 497 | my ($self, $move, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 497 | ▶ | my $who = $seat eq $self->_seat ? 'You' : 'They'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 497 | my $k = $move->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 497 | ▶ | return "$who led " . $self->pretty($move->{card}) if $k eq 'lead'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 303 | ▶ | return "$who played " . $self->pretty($move->{card}) if $k eq 'follow'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 113 | ▶ | return "$who declared a marriage in $move->{suit}" if $k eq 'marriage'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 87 | ▶ | return "$who exchanged for the trump card" if $k eq 'exchange'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 70 | ▶ | return "$who closed the talon" if $k eq 'close'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 62 | ▶ | return "$who claimed 66" if $k eq 'claim'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 37 | ▶ | return "$who drew" if $k eq 'draw'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | return "$who did something"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 15 | ▶ | sub card_named { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_named: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 15 | my ($self, $text, $cards) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 14 | (my $want = uc $text) =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 14 | $want =~ s/\A10/T/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 14 | for my $card (@$cards) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 29 | ▶ | return $card if uc(name_of($card)) eq $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 4 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | ▶ | sub options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: called CC=2 SCAR=12.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | ▶ | return $self->_launcher_options unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $legal = $self->game->legal($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my @kinds = grep { !$seen{$_}++ } map { $_->{kind} } @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | return \@kinds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 984 | ▶ | sub is_human { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_human: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 984 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 984 | my $mode = $self->_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 984 | ▶ | return 0 if $mode eq 'watch'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 10 | ▶ | return 1 if $mode eq 'hotseat'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 10 | ▶ | return $seat eq $self->_seat ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 491 | ▶ | sub bot_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bot_move: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 491 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 491 | my $bot = Game::Schnapsen::Bot->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | level => $self->_level, seed => $self->game->seed . $seat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 491 | return $bot->choose($self->game, $seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 48 | ▶ | sub interactive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interactive: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 48 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 48 | my $want = $self->_staring; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 48 | ▶ | return $want ? 1 : 0 if defined $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 30 | ▶ | return (eval { -t $self->_out }) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 11 | ▶ | sub picking { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
picking: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 11 | my ($self, @set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 11 | ▶ | $self->_picking($set[0] ? 1 : 0) if @set; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 11 | ▶ | return $self->_picking ? 1 : 0 if defined $self->_picking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 6 | return $self->keys_available; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub raw { return $_[0]->keyboard->raw } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 7 | ▶ | sub keys_available { return $_[0]->keyboard->keys_available } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keys_available: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 5 | ▶ | sub enter_raw { return $_[0]->keyboard->enter_raw ? $_[0] : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enter_raw: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 6 | ▶ | sub leave_raw { $_[0]->keyboard->leave_raw; return $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leave_raw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 25 | ▶ | sub read_key { return $_[0]->keyboard->read_key } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 3 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 3 | $self->screen->clear(scrollback => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 492 | ▶ | sub remember { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remember: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 492 | my ($self, $seat, $held) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 492 | ▶ | my $hand = eval { $self->game->deal->hand_of($seat) } or return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 492 | my %mark; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 492 | for my $card (@{ $hand->sorted }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 2245 | ▶ | $mark{$card} = 'fresh' unless $held->{$card}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 492 | $self->marks(\%mark); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 492 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 7 | ▶ | sub card_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
card_line: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 7 | my ($self, $seat, $card) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 7 | my $d = $self->game->deal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 7 | my $name = $self->pretty($card); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 7 | my $lead = $d->lead; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 7 | ▶ | return "$name: you lead it" unless defined $lead; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | my $winner = Game::Schnapsen::Trick::winner_of($lead, $card, $d->trump); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | my $worth = Game::Schnapsen::Trick::value_of($lead, $card); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | my $mine = $d->points_of($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | ▶ | return sprintf '%s: %s the trick, %d %s%s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | ($winner == $card ? 'takes' : 'loses'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | $worth, ($worth == 1 ? 'point' : 'points'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ($winner == $card | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | ? sprintf(', which puts you on %d', $mine + $worth) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub pick_help { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pick_help: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | 'left and right walk your hand, home and end go to its ends,', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 'enter plays the card under the cursor.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 'the line under it says what that card would do to the trick.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 'x exchanges, c closes, m declares a marriage, o claims 66, d draws.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 't goes back to typing, q stops.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 6 | my %WALK = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | qw(left right up down tab back_tab home end page_up page_down); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 6 | my %SPECIAL = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | x => 'exchange', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | c => 'close', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | o => 'claim', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | d => 'draw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | ▶ | sub pick_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pick_move: called CC=19 SCAR=37.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 3 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 3 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | my $legal = $g->legal($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | ▶ | return undef unless @$legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | my %by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 3 | push @{ $by{ $_->{kind} } }, $_ for @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 15 | my @cards = map { $_->{card} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 3 | grep { defined $_->{card} } @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 3 | my %playable = map { $_ => 1 } @cards; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 3 | my @order = grep { $playable{$_} } @{ $g->deal->hand_of($seat)->sorted }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 3 | my $picker = Game::Terminal::Kit::Picker->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | items => [@order], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | numbered => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | game_keys => { %SPECIAL, m => 'marriage', t => 'type', '?' => 'help' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | screen => $self->screen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | my $log = $self->log; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 3 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 6 | $self->_pick_frame($seat, $picker, \%by); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 6 | my $key = $self->read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 6 | my ($event, $value) = $picker->step($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 6 | ▶ | if ($event eq 'quit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 2 | $self->quit(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 4 | ▶ | next if $event eq 'moved'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 3 | ▶ | if ($event eq 'chosen') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 1 | ▶ | my ($pick) = grep { defined $_->{card} && $_->{card} == $value } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $_->{'card'} && $_->{'card'} == $value
MC/DC100%2/2
defined $_->{'card'} && $_->{'card'} == $value
defined $_->{'card'}
$_->{'card'} == $value
Truth table100%3/3
A && B
A= defined $_->{'card'}B= $_->{'card'} == $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | @$legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 1 | ▶ | return $pick if $pick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $log->note('you cannot play that one'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | ▶ | if ($event ne 'key') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | $log->note('that key does nothing here. ? for the ones that do') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | ▶ | unless @order && $WALK{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@order and $WALK{$key}
MC/DC0%0/2
@order and $WALK{$key}
@order
$WALK{$key}
Truth table33%1/3
A and B
A= @orderB= $WALK{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | if ($value eq 'help') { $log->note($self->pick_help); next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 1 | ▶ | if ($value eq 'type') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $self->picking(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $self->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | return $self->typed_move($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | ▶ | if ($value eq 'marriage') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | my $m = $by{marriage}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | if (!$m) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $log->note('you have no marriage to declare'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | return $m->[0] if @$m == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | $log->note('which marriage? ' . join(' ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | map { lc $_->{suit} } @$m) . ' as a letter'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $self->_pick_frame($seat, $picker, \%by); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my $suit = $self->read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | return $pick if $pick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $log->note('you do not hold that marriage'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | ▶ | return $by{$value}[0] if $by{$value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | $log->note("you cannot $value here"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 6 | ▶ | sub _pick_frame { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pick_frame: called CC=6 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 6 | my ($self, $seat, $picker, $by) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 6 | my $card = $picker->current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 6 | my $log = $self->log; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 6 | ▶ | my %mark = (%{ $self->marks }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | defined $card ? ($card => 'cursor') : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 6 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | push @lines, map { s/\A\s+//r } map { @$_ } @{ $log->recent } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | if $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 6 | push @lines, @{ $self->render($seat, \%mark) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 6 | ▶ | push @lines, ' ' . $self->card_line($seat, $card) if defined $card; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 6 | my $offers = $self->_offers($by); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 6 | ▶ | push @lines, ' ' . $offers if length $offers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 6 | push @lines, map { ' ' . $_ } @{ $log->notes }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 6 | push @lines, ' ' . $self->paint( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 'arrows to choose, enter to play, ? for the keys', '90'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 6 | ▶ | $self->clear unless $self->_framed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 6 | $self->_framed(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 6 | $self->screen->show(\@lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 6 | $log->shown; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 6 | ▶ | sub _offers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_offers: called CC=7 SCAR=20.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 6 | my ($self, $by) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 6 | my @say; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 6 | ▶ | push @say, 'x exchange' if $by->{exchange}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 6 | ▶ | push @say, 'c close' if $by->{close}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 6 | ▶ | push @say, 'm marriage' if $by->{marriage}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 6 | ▶ | push @say, 'o claim 66' if $by->{claim}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 6 | ▶ | push @say, 'd draw' if $by->{draw}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 6 | ▶ | return @say ? 'also: ' . join(' ', @say) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 8 | ▶ | sub human_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
human_move: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 8 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 8 | ▶ | if ($self->picking) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | ▶ | return $self->pick_move($seat) if $self->enter_raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | $self->picking(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 8 | return $self->typed_move($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 8 | ▶ | sub typed_move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
typed_move: called CC=18 SCAR=34.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 8 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 8 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 8 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 13 | my $legal = $g->legal($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 13 | ▶ | return undef unless @$legal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 13 | my %by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 13 | push @{ $by{ $_->{kind} } }, $_ for @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 13 | my @words = sort keys %by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 13 | $self->show($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 13 | my $line = $self->ask('> '); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 13 | ▶ | return undef unless defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 10 | $line =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 10 | ▶ | if ($line =~ /\A(?:\?|h|help)\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 2 | $self->say_to('You may: ' . join(', ', @words)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 2 | $self->say_to('Name a card to play it (KH, 10H, TH). Or: ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | . 'm SUIT to declare a marriage, x to exchange, ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | . 'c to close, out to claim 66, d to draw.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | my $suit = uc $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my ($pick) = grep { $_->{suit} eq $suit } @{ $by{marriage} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | return $pick if $pick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $self->say_to('You do not hold that marriage.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 5 | my @playable = grep { defined $_->{card} } @$legal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 5 | my $card = $self->card_named($line, [ map { $_->{card} } @playable ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 5 | ▶ | if (defined $card) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 2 | my ($pick) = grep { $_->{card} == $card } @playable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | ▶ | return $pick if $pick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 3 | $self->say_to("I did not follow that. You may: " . join(', ', @words) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | . '. Type ? for help.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 733 | ▶ | sub announce { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
announce: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 733 | my ($self, $event) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 733 | my $k = $event->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 733 | ▶ | if ($k eq 'trick') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 190 | ▶ | return $self->tell(' ' . ($event->{winner} eq $self->_seat ? 'You take it.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | : 'They take it.')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 543 | ▶ | if ($k eq 'deal_end') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 26 | return $self->tell($self->deal_result_line($event)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 517 | ▶ | if ($k eq 'deal') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 22 | return $self->say_to(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 495 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 33 | ▶ | sub deal_result_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deal_result_line: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 33 | my ($self, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 33 | ▶ | return 'The deal is drawn. Nobody scores, and it is dealt again.' if $r->{drawn}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 32 | my %how = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | claim => 'the deal, claiming 66', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | closed_out => 'the deal, having closed the talon', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | false_claim => 'the deal: the claim was false', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | beat_closer => 'the deal, beating the closer to it', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | failed_close => 'the deal: the close failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | last_trick => 'the deal on the last trick', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | return sprintf('%s %s, for %d game point%s.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | $who, $how{ $r->{how} } // 'the deal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 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"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 8 | ▶ | sub result_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result_line: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 8 | my $g = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 8 | ▶ | my $r = $g->result or return ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 8 | my $s = $g->scores; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 8 | my $mine = $s->{ $self->_seat }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 8 | my $theirs = $s->{ other($self->_seat) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 8 | my $won = $r->{winner} eq $self->_seat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | return sprintf('%s the match, %d to %d, over %d deals.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | $won ? 'You win' : 'They win', $mine, $theirs, $r->{deals}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 8 | ▶ | if Game::Schnapsen::Variant::match_direction($g->variant) > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | return sprintf('%s the match over %d deals, with %d still to find %s.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | $won ? 'You win' : 'They win', $r->{deals}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 5 | ▶ | $won ? $theirs : $mine, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | $won ? 'against you' : 'from you'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 8 | ▶ | sub play { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play: called CC=17 SCAR=30.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 8 | my ($self, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 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))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 8 | my $bad = Game::Schnapsen::Variant::check_variant($variant); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 8 | ▶ | if ($bad) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 2 | $self->say_to('Cannot start: ' . $bad->message | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | . ' (schnapsen or sixtysix, and there is no default)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 2 | return $bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | my $g = Game::Schnapsen->build( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | variant => $variant, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | seed => $seed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 6 | ▶ | if (ref $g eq 'Game::Schnapsen::Error') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $self->say_to('Cannot start: ' . $g->message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | return $g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 6 | $self->game($g); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 6 | my $guard = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 493 | ▶ | my $seat = $g->turn or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 493 | ▶ | my $move = $self->is_human($seat) ? $self->human_move($seat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | : $self->bot_move($seat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 493 | ▶ | last unless $move; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | if ($self->is_human($seat)) { $self->log->forget } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 491 | else { $self->tell($self->describe($move, $seat)) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 491 | my $mine = $self->_seat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 491 | my %held = eval { map { $_ => 1 } @{ $g->deal->hand_of($mine)->sorted } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 491 | my @out = $g->apply($seat, $move); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $self->tell($out[0]->message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 491 | $self->remember($mine, \%held); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 491 | $self->announce($_) for @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 6 | $self->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 6 | $self->say_to(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 6 | ▶ | $self->say_to($self->result_line) if $g->over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 6 | return $g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 12 | ▶ | sub _usage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_usage: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 12 | return <<'USAGE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | schnapsen - Schnapsen and Sixty-Six at a prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | schnapsen --variant schnapsen the Austrian game, 20 cards, 7 down to 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | schnapsen --variant sixtysix the German parent, 24 cards, 0 up to 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | --seat p2 play the bot as p2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | --mode hotseat two people at one keyboard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | --mode watch two bots, and you read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | --level 1 a weaker opponent (1 or 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | --seed tuesday deal the same match every time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | --ascii letters instead of the suit pips | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | --nocolour no colour (NO_COLOR does the same) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | --nopick type the cards out instead of pointing at them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | --variant has no default, because the two are different games and picking one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | silently would make the other an afterthought. They differ in thirteen places: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | the pack, the card that exchanges for the trump, whether a marriage may be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | declared late, what the last trick is worth, which way the score runs, and more. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | At the prompt, name a card to play it: KH, TH, or 10H for the same card. Then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | m H declare a marriage in hearts, and lead one of the two | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | x exchange your lowest trump for the turn-up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | c close the talon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | out claim 66 and end the deal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | d draw (sixtysix, where you may close before drawing instead) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | ? what is legal right now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | Claiming is typed in full. A claim that turns out to be false loses the deal, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | the screen already shows you your own count, so it is not put a keystroke away | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | from anything else. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | On a terminal the left and right keys walk your own hand instead, and the line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | under it says what the card under the cursor would do to the trick: whether it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | takes it, what the trick is worth, and what that puts you on. Enter plays it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | The moves that are not cards keep their own keys, x c m o d, because a card is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | a thing in your hand and those are not. t goes back to typing, ? lists the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | keys. Needs Term::ReadKey; without it the cards are typed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | The card you drew at the end of the last trick is drawn in a heavier frame, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | you can see what is new without counting the hand. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | Exit status is 0 if you won, or if nobody was playing a seat, 1 if you lost or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | stopped early, and 2 for an option the game will not take. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | USAGE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 2 | ▶ | sub _launcher_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_launcher_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2 | { name => 'mode', type => 'enum', choices => [qw(bot hotseat watch)], help => 'you against the bot, two people, or two bots' }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | { name => 'level', type => 'int', min => 1, max => 2, help => "the bot's strength" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | { name => 'seat', type => 'enum', choices => [qw(p1 p2)], help => 'your seat' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | { name => 'seed', type => 'str', help => 'deal the same match every time' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 14 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=22 SCAR=38.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 14 | my ($class, @argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 14 | my %o = (mode => 'bot', level => 2, seat => 'p1'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 14 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 14 | ▶ | local $SIG{__WARN__} = sub { print STDERR "schnapsen: $_[0]" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | Getopt::Long::GetOptionsFromArray(\@argv, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 'variant=s' => \$o{variant}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 'mode=s' => \$o{mode}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 'level=i' => \$o{level}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 'seat=s' => \$o{seat}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 'seed=s' => \$o{seed}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 'ascii' => \$o{ascii}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 'pick!' => \$o{pick}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 'colour!' => \$o{colour}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 'color!' => \$o{colour}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 'help' => \$o{help}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 14 | ▶ | if (!$ok) { print STDERR _usage(); return 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 13 | ▶ | if ($o{help}) { print _usage(); return 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | if (@argv) { print STDERR "schnapsen: not an option: $argv[0]\n", _usage(); return 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 3 | my $levels = Game::Schnapsen::Bot->levels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | my $refused | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | = !(defined $o{variant} && $o{variant} =~ /\A(?:schnapsen|sixtysix)\z/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | ? '--variant must be schnapsen or sixtysix' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | : $o{mode} !~ /\A(?:bot|hotseat|watch)\z/ ? 'mode must be bot, hotseat or watch' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | : $o{seat} !~ /\A p[12] \z/x ? 'seat must be p1 or p2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 3 | ▶ | : !($o{level} =~ /\A\d+\z/ && $o{level} >= 1 && $o{level} <= $levels) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition44%4/9
defined $o{'variant'} && $o{'variant'} =~ /\A(?:schnapsen|sixtysix)\z/
$o{'level'} =~ /\A\d+\z/ && $o{'level'} >= 1 && $o{'level'} <= $levels
$o{"level"} =~ /\A\d+\z/ and $o{"level"} >= 1
MC/DC50%1/2
defined $o{'variant'} && $o{'variant'} =~ /\A(?:schnapsen|sixtysix)\z/
defined $o{'variant'}
$o{'variant'} =~ /\A(?:schnapsen|sixtysix)\z/
MC/DC0%0/3
$o{'level'} =~ /\A\d+\z/ && $o{'level'} >= 1 && $o{'level'} <= $levels
$o{"level"} =~ /\A\d+\z/
$o{"level"} >= 1
$o{'level'} <= $levels
Truth table66%2/3
A && B
A= defined $o{'variant'}B= $o{'variant'} =~ /\A(?:schnapsen|sixtysix)\z/
Truth table25%1/4
A and B && C
A= $o{"level"} =~ /\A\d+\z/B= $o{"level"} >= 1C= $o{'level'} <= $levels
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | ? "level must be 1 to $levels" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 3 | ▶ | if (defined $refused) { print STDERR "schnapsen: $refused\n", _usage(); return 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 2 | ▶ | my $seed = defined $o{seed} ? Digest::SHA::sha256($o{seed}) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | my $ui = $class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | variant => $o{variant}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | mode => $o{mode}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | level => $o{level}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | seat => $o{seat}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | ($o{ascii} ? (ascii => 1) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | (defined $o{colour} ? (colour => $o{colour}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 2 | ▶ | (defined $o{pick} ? (picking => $o{pick} ? 1 : 0) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | my $game = Game::Terminal::Kit::Run::guard( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 2 | ▶ | sub { $ui->play(defined $seed ? (seed => $seed) : ()) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 2 | $ui->keyboard, $ui->screen, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 2 | ▶ | return 1 unless ref $game && $game->over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $game and $game->over
MC/DC0%0/2
ref $game and $game->over
ref $game
$game->over
Truth table33%1/3
A and B
A= ref $gameB= $game->over
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 2 | ▶ | return 0 if $o{mode} ne 'bot'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | return 0 if ($game->winner // '') eq $o{seat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$game->winner // ""
MC/DC0%0/1
$game->winner // ""
$game->winner
Truth table0%0/2
A
A= $game->winner
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||