| 1 | package Game::Dominoes::Terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 28 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 28 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 28 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 28 | ▶ | use Game::Dominoes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 28 | ▶ | use Game::Dominoes::Bot; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 28 | ▶ | use Game::Dominoes::Notation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 28 | ▶ | use Game::Dominoes::Rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 28 | ▶ | use Game::Dominoes::Scoring; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 28 | ▶ | use Game::Terminal::Kit::History; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 28 | ▶ | use Game::Terminal::Kit::Keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 28 | ▶ | use Game::Terminal::Kit::Log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 28 | ▶ | use Game::Terminal::Kit::Picker; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 28 | ▶ | use Game::Terminal::Kit::Replay; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 28 | ▶ | use Game::Terminal::Kit::Run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 28 | ▶ | use Game::Terminal::Kit::Save; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 28 | ▶ | use Game::Terminal::Kit::Screen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 28 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 28 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 28 | our @PIPS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | [[1, 1]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | [[0, 0], [2, 2]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | [[0, 0], [1, 1], [2, 2]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | [[0, 0], [0, 2], [2, 0], [2, 2]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | [[0, 0], [0, 2], [1, 1], [2, 0], [2, 2]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | [[0, 0], [0, 2], [1, 0], [1, 2], [2, 0], [2, 2]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 28 | our %CHARS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | wide => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | pip => "\x{25CF}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | h => "\x{2500}", v => "\x{2502}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | tl => "\x{250C}", tr => "\x{2510}", bl => "\x{2514}", br => "\x{2518}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | t => "\x{252C}", b => "\x{2534}", l => "\x{251C}", r => "\x{2524}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ascii => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | pip => '*', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | h => '-', v => '|', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | tl => '+', tr => '+', bl => '+', br => '+', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | t => '+', b => '+', l => '+', r => '+', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 28 | our %MARKED = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | recent => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | wide => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | h => "\x{2550}", v => "\x{2551}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | tl => "\x{2554}", tr => "\x{2557}", bl => "\x{255A}", br => "\x{255D}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | t => "\x{2566}", b => "\x{2569}", l => "\x{2560}", r => "\x{2563}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ascii => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | h => '=', v => '#', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | tl => '#', tr => '#', bl => '#', br => '#', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | t => '#', b => '#', l => '#', r => '#', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | preview => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | wide => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | h => "\x{2501}", v => "\x{2503}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | tl => "\x{250F}", tr => "\x{2513}", bl => "\x{2517}", br => "\x{251B}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | t => "\x{2533}", b => "\x{253B}", l => "\x{2523}", r => "\x{252B}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ascii => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | h => '=', v => '!', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | tl => '+', tr => '+', bl => '+', br => '+', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | t => '+', b => '+', l => '+', r => '+', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 28 | our %MARK_INK = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | new => '1;32', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | recent => '32', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | preview => '1;36', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 28 | our %MARK_FRAME = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | new => 'recent', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | recent => 'recent', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | preview => 'preview', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 28 | our %PICK_KEY = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 'v' => 'live', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | '?' => 'help', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 't' => 'type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ':' => 'command', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 28 | our $WINDOW = 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 28 | has game => (is => 'rw', isa => Object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 28 | has bots => (is => 'rw', isa => HashRef, default => {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 28 | has in => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 28 | has out => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 28 | has colour => (is => 'rw', isa => Bool); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 28 | has ascii => (is => 'rw', isa => Bool, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 28 | has compact => (is => 'rw', isa => Bool, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 28 | has width => (is => 'rw', isa => Int, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 28 | has handover => (is => 'rw', isa => Bool); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 28 | has quit => (is => 'rw', isa => Bool, default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 28 | has recent => (is => 'rw', isa => ArrayRef, default => []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 28 | has keysource => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 28 | has pending => (is => 'rw', isa => ArrayRef, default => []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 28 | has keyboard => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 28 | has screen => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 28 | has log => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 28 | has history => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 28 | has save_file => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 28 | has _picking => (is => 'rw', init_arg => 'picking', private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 28 | has _seen => (is => 'rw', isa => Int, default => 0, private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 28 | has _told => (is => 'rw', isa => HashRef, default => {}, private => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 63 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=19 SCAR=30.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 63 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 63 | ▶ | $self->in(\*STDIN) unless $self->in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 63 | ▶ | $self->out(\*STDOUT) unless $self->out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 63 | ▶ | $self->game(Game::Dominoes->new(seed => "\0" x 32)) unless $self->game; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 63 | ▶ | my $tty = eval { -t $self->out } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 63 | ▶ | unless (defined $self->colour) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 17 | ▶ | $self->colour(($tty && !Game::Terminal::Kit::Screen::no_colour()) ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tty and not Game::Terminal::Kit::Screen::no_colour()
MC/DC0%0/2
$tty and not Game::Terminal::Kit::Screen::no_colour()
$tty
not Game::Terminal::Kit::Screen::no_colour()
Truth table33%1/3
A and not(B)
A= $ttyB= not Game::Terminal::Kit::Screen::no_colour()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 63 | ▶ | unless (defined $self->handover) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 23 | ▶ | $self->handover($self->_humans > 1 ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 63 | ▶ | $self->keyboard(Game::Terminal::Kit::Keys->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | in => $self->in, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | pending => $self->pending, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ($self->keysource ? (keysource => $self->keysource) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | )) unless $self->keyboard; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 63 | ▶ | $self->screen(Game::Terminal::Kit::Screen->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | out => $self->out, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | interactive => $tty, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | colour => $self->colour ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ascii => $self->ascii ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | )) unless $self->screen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 63 | ▶ | $self->log(Game::Terminal::Kit::Log->new(keep => $self->game->players)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | unless $self->log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 63 | ▶ | $self->history(_new_history()) unless $self->history; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 63 | ▶ | $self->history->name('dominoes') unless defined $self->history->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 63 | $self->history->version($VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 63 | ▶ | $self->history->file($self->save_file) if defined $self->save_file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 63 | $self->history->start($self->game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 63 | $self->_seen(scalar @{ $self->game->history }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 63 | $self->screen->utf8->flush_on; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 63 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 64 | ▶ | sub _new_history { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_history: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | return Game::Terminal::Kit::History->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | name => 'dominoes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | version => $VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 308 | ▶ | save => sub { $_[0]->to_text(with_seed => 1) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 16 | ▶ | load => sub { Game::Dominoes->from_text($_[0]) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 64 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2519 | ▶ | sub _in_step { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in_step: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2519 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2519 | my $screen = $self->screen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2519 | ▶ | $screen->colour($self->colour ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2519 | ▶ | $screen->ascii($self->ascii ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2519 | return $screen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 23 | ▶ | sub _humans { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_humans: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 23 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 23 | return scalar grep { !$self->bots->{$_} } $self->game->seats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 274 | ▶ | sub remember { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remember: called CC=7 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 274 | my ($self, $seat, $play) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 274 | ▶ | return $self unless ref $play && $play->can('tile') && $play->tile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $play and $play->can("tile") and $play->tile
ref $play and $play->can("tile")
MC/DC0%0/3
ref $play and $play->can("tile") and $play->tile
ref $play
$play->can("tile")
$play->tile
Truth table25%1/4
A and B and C
A= ref $playB= $play->can("tile")C= $play->tile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 274 | my $recent = $self->recent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 274 | push @$recent, { seat => $seat, play => $play }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 274 | ▶ | shift @$recent while @$recent > $self->game->players; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 274 | $self->log->keep($self->game->players); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 274 | ▶ | $self->log->record("seat $seat played " . $play->tile->stringify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | . ' on ' . $play->arm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | . ($play->points ? ' for ' . $play->points : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | . ($play->spinner ? ', the spinner' : '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 274 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 223 | ▶ | sub table_marks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_marks: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 223 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 223 | my $recent = $self->recent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 223 | my %mark; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 223 | for my $i (0 .. $#$recent) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | $mark{ $recent->[$i]{play}->tile->id } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 218 | ▶ | = $i == $#$recent ? 'new' : 'recent'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 223 | return \%mark; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 135 | ▶ | sub recent_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recent_lines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 135 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 135 | return map { @$_ } @{ $self->log->recent }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 2253 | ▶ | sub _say { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_say: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2253 | my ($self, @text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2253 | $self->screen->say(join '', @text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2253 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 77 | ▶ | sub _ask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ask: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 77 | my ($self, $prompt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 77 | return $self->keyboard->read_line($prompt, $self->out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 222 | ▶ | sub table { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 222 | my ($self, $view, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 222 | my $layout = $view->{layout}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 222 | ▶ | $marks ||= $self->table_marks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$marks ||= $self->table_marks
MC/DC0%0/2
$marks ||= $self->table_marks
$marks
$self->table_marks
Truth table66%2/3
A ||= B
A= $marksB= $self->table_marks
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 222 | ▶ | return (' (nothing on the table yet)') unless $layout->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 177 | ▶ | return $self->_compact_table($layout, $marks) if $self->compact; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 176 | my $spinner = $layout->spinner_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 176 | my $line = $layout->line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | my @cell = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 176 | $self->_tile_art($line->[$_]{left}, $line->[$_]{right}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | $line->[$_]{tile}->is_double, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | defined $spinner && $_ == $spinner, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | $marks->{ $line->[$_]{tile}->id }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 717 | ▶ | } 0 .. $#$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $spinner && $_ == $spinner
MC/DC100%2/2
defined $spinner && $_ == $spinner
defined $spinner
$_ == $spinner
Truth table100%3/3
A && B
A= defined $spinnerB= $_ == $spinner
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 176 | my @band = $self->_wrap(\@cell); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 176 | my ($first, $last) = ($band[0], $band[-1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 41 | ▶ | my $at = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 41 | my ($run) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | return 2 unless defined $spinner && $run && $spinner >= $run->{from} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 41 | ▶ | && $spinner <= $run->{to}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $spinner and $run and $spinner >= $run->{"from"} and $spinner <= $run->{"to"}
defined $spinner and $run and $spinner >= $run->{"from"}
defined $spinner and $run
MC/DC0%0/4
defined $spinner and $run and $spinner >= $run->{"from"} and $spinner <= $run->{"to"}
defined $spinner
$run
$spinner >= $run->{"from"}
$spinner <= $run->{"to"}
Truth table20%1/5
A and B and C and D
A= defined $spinnerB= $runC= $spinner >= $run->{"from"}D= $spinner <= $run->{"to"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 41 | return $run->{x}[ $spinner - $run->{from} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 176 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 176 | my @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 176 | ▶ | if (@{ $layout->u }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | my @arm = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | $self->_tile_art($_->{inner}, $_->{outer}, $_->{tile}->is_double, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | $marks->{ $_->{tile}->id }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 36 | } @{ $layout->u }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 36 | my $indent = $at->($first); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 36 | push @rows, map { $self->_band($_, $indent) } $self->_wrap(\@arm, $indent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 36 | push @rows, $self->_stem($indent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 176 | push @rows, map { $self->_band($_, 2) } @band; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 176 | ▶ | if (@{ $layout->d }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | my @arm = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | $self->_tile_art($_->{inner}, $_->{outer}, $_->{tile}->is_double, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | $marks->{ $_->{tile}->id }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 5 | } @{ $layout->d }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 5 | my $indent = $at->($last); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 5 | push @rows, $self->_stem($indent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 5 | push @rows, map { $self->_band($_, $indent) } $self->_wrap(\@arm, $indent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 176 | return @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | ▶ | sub _compact_table { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compact_table: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | my ($self, $layout, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | ▶ | $marks ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$marks ||= {}
MC/DC0%0/1
$marks ||= {}
$marks
Truth table50%1/2
A
A= $marks
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | my @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | push @rows, ' ' . join(' ', map { $self->_tile($_->{tile}, $marks) } @{ $layout->u }) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | if @{ $layout->u }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | push @rows, ' ' . join(' ', map { $self->_tile($_->{tile}, $marks) } @{ $layout->line }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | push @rows, ' ' . join(' ', map { $self->_tile($_->{tile}, $marks) } @{ $layout->d }) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | if @{ $layout->d }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | return @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 54 | ▶ | sub _tile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tile: called CC=6 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 54 | my ($self, $tile, $marks) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 54 | ▶ | my $mark = $marks ? $marks->{ $tile->id } : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 54 | ▶ | my $text = ($mark ? '{' : '[') . $tile->high . '|' . $tile->low | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | . ($mark ? '}' : ']'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 54 | ▶ | return $self->_paint($text, $MARK_INK{$mark}) if $mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 54 | ▶ | return $tile->is_double ? $self->_paint($text, '1;33') : $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 2311 | ▶ | sub _tile_art { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tile_art: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 2311 | my ($self, $one, $two, $across, $bright, $mark) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 2311 | ▶ | my $kind = $self->ascii ? 'ascii' : 'wide'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | my $c = $mark && $MARK_FRAME{$mark} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | ? $MARKED{ $MARK_FRAME{$mark} }{$kind} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 2311 | ▶ | : $CHARS{$kind}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$mark and $Game::Dominoes::Terminal::MARK_FRAME{$mark}
MC/DC50%1/2
$mark and $Game::Dominoes::Terminal::MARK_FRAME{$mark}
$mark
$Game::Dominoes::Terminal::MARK_FRAME{$mark}
Truth table66%2/3
A and B
A= $markB= $Game::Dominoes::Terminal::MARK_FRAME{$mark}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 2311 | my @face = ($self->_face($one, $across), $self->_face($two, $across)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2311 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 2311 | ▶ | if ($across) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 149 | push @lines, $c->{tl} . ($c->{h} x 3) . $c->{tr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 149 | push @lines, map { $c->{v} . $_ . $c->{v} } @{ $face[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 149 | push @lines, $c->{l} . ($c->{h} x 3) . $c->{r}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 149 | push @lines, map { $c->{v} . $_ . $c->{v} } @{ $face[1] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 149 | push @lines, $c->{bl} . ($c->{h} x 3) . $c->{br}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2162 | push @lines, $c->{tl} . ($c->{h} x 3) . $c->{t} . ($c->{h} x 3) . $c->{tr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | push @lines, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 2162 | $c->{v} . $face[0][$_] . $c->{v} . $face[1][$_] . $c->{v} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 6486 | } 0 .. 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 2162 | push @lines, $c->{bl} . ($c->{h} x 3) . $c->{b} . ($c->{h} x 3) . $c->{br}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 2311 | ▶ | my $ink = $mark ? $MARK_INK{$mark} : ($bright ? '1;33' : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 2311 | ▶ | @lines = map { $self->_paint($_, $ink) } @lines if defined $ink; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 2311 | ▶ | return { width => $across ? 5 : 9, lines => \@lines }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 4622 | ▶ | sub _face { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_face: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 4622 | my ($self, $pips, $turned) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 4622 | ▶ | my $pip = $CHARS{ $self->ascii ? 'ascii' : 'wide' }{pip}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 4622 | my @grid = map { [ (' ') x 3 ] } 0 .. 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 4622 | ▶ | for my $spot (@{ $PIPS[$pips] || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Game::Dominoes::Terminal::PIPS[$pips] || []
MC/DC0%0/1
$Game::Dominoes::Terminal::PIPS[$pips] || []
$Game::Dominoes::Terminal::PIPS[$pips]
Truth table50%1/2
A
A= $Game::Dominoes::Terminal::PIPS[$pips]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 12813 | my ($row, $col) = @$spot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 12813 | ▶ | ($row, $col) = ($col, 2 - $row) if $turned; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 12813 | $grid[$row][$col] = $pip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 4622 | return [ map { join '', @$_ } @grid ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 2417 | ▶ | sub _paint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_paint: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 2417 | my ($self, $text, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 2417 | return $self->_in_step->paint($text, $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 430 | ▶ | sub _wrap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrap: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 430 | my ($self, $cells, $indent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 430 | ▶ | $indent = 2 unless defined $indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 430 | ▶ | my $room = ($self->width || ($self->screen->size)[0]) - $indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->width || ($self->screen->size)[0]
MC/DC0%0/2
$self->width || ($self->screen->size)[0]
$self->width
($self->screen->size)[0]
Truth table66%2/3
A || B
A= $self->widthB= ($self->screen->size)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 430 | ▶ | $room = 20 if $room < 20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 430 | my @run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 430 | my ($cells_in, $x, @at) = ([], $indent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 430 | my $from = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 430 | for my $i (0 .. $#$cells) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 2311 | my $cell = $cells->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 2311 | ▶ | if (@$cells_in && $x + $cell->{width} - $indent > $room) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$cells_in and $x + $cell->{"width"} - $indent > $room
MC/DC100%2/2
@$cells_in and $x + $cell->{"width"} - $indent > $room
@$cells_in
$x + $cell->{"width"} - $indent > $room
Truth table100%3/3
A and B
A= @$cells_inB= $x + $cell->{"width"} - $indent > $room
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 23 | push @run, { cells => $cells_in, x => [@at], from => $from, to => $i - 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 23 | ($cells_in, $x, @at) = ([], $indent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 23 | $from = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 2311 | push @$cells_in, $cell; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 2311 | push @at, $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2311 | $x += $cell->{width}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 430 | ▶ | push @run, { cells => $cells_in, x => [@at], from => $from, to => $#$cells } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | if @$cells_in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 430 | return @run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 453 | ▶ | sub _band { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_band: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 453 | my ($self, $run, $indent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 453 | my @cells = @{ $run->{cells} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 453 | my $height = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 453 | for my $cell (@cells) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2311 | ▶ | $height = scalar @{ $cell->{lines} } if @{ $cell->{lines} } > $height; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 453 | my @rows = map { ' ' x $indent } 1 .. $height; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 453 | for my $cell (@cells) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 2311 | my $top = int(($height - scalar @{ $cell->{lines} }) / 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 2311 | for my $row (0 .. $height - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 15417 | my $line = $cell->{lines}[ $row - $top ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | $rows[$row] .= ($row >= $top && defined $line) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 15417 | ▶ | ? $line : ' ' x $cell->{width}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$row >= $top and defined $line
MC/DC100%2/2
$row >= $top and defined $line
$row >= $top
defined $line
Truth table100%3/3
A and B
A= $row >= $topB= defined $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 453 | s/\s+\z// for @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 453 | return @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 41 | ▶ | sub _stem { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stem: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 41 | my ($self, $indent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 41 | ▶ | my $c = $CHARS{ $self->ascii ? 'ascii' : 'wide' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 41 | return (' ' x ($indent + 2)) . $c->{v}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 175 | ▶ | sub _ends_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ends_line: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 175 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 175 | my $count = $view->{count}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 175 | my $short = (5 - $count % 5) % 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 175 | my $text = 'ends ' . join(' ', @{ $view->{ends} }) . ' count ' . $count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 175 | ▶ | $text .= $short ? " ($short more would score)" : ' (scores)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 175 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 218 | ▶ | sub _scores_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_scores_line: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 218 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | return 'scores ' . join(' ', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 482 | "seat $_: $view->{scores}{$_}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 218 | } sort { $a <=> $b } keys %{ $view->{scores} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 212 | ▶ | sub _hands_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hands_line: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 212 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | return 'tiles ' . join(' ', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 468 | "seat $_: $view->{counts}{$_}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 291 | } sort { $a <=> $b } keys %{ $view->{counts} }) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 212 | . ' boneyard: ' . $view->{boneyard}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 220 | ▶ | sub hand_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hand_lines: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 220 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 220 | ▶ | my @tiles = @{ $view->{hand} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$view->{'hand'} || []
MC/DC0%0/1
$view->{'hand'} || []
$view->{'hand'}
Truth table50%1/2
A
A= $view->{'hand'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 220 | ▶ | return ('your tiles: (none)') unless @tiles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 220 | ▶ | return ('your tiles: ' . join ' ', map { $self->_tile($_) } @tiles) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | if $self->compact; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | my @cell = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 213 | my $art = $self->_tile_art($_->high, $_->low, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1490 | push @{ $art->{lines} }, sprintf '%-9s', ' ' . $_->stringify . ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1490 | $art; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } @tiles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 213 | return ('your tiles:', map { $self->_band($_, 2) } $self->_wrap(\@cell)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 77 | ▶ | sub show { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 77 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 77 | $self->_say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 77 | $self->_say("hand $view->{hand_number} " . $self->_scores_line($view)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 77 | $self->_say($self->_hands_line($view)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 77 | $self->_say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 77 | $self->_say($_) for $self->table($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 77 | $self->_say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 77 | ▶ | $self->_say($self->_ends_line($view)) if $view->{layout}->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 77 | $self->_say($_) for $self->hand_lines($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 77 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 203 | ▶ | sub picking { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
picking: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 203 | my ($self, @set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 203 | ▶ | $self->_picking($set[0] ? 1 : 0) if @set; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 203 | ▶ | return $self->_picking ? 1 : 0 if defined $self->_picking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 65 | return $self->keys_available; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 2 | ▶ | sub raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | return $self->keyboard->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 66 | ▶ | sub keys_available { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keys_available: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 66 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 66 | return $self->keyboard->keys_available; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 102 | ▶ | sub enter_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enter_raw: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 102 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 102 | ▶ | return $self->keyboard->enter_raw ? $self : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 101 | ▶ | sub leave_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leave_raw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 101 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 101 | $self->keyboard->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 101 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 154 | ▶ | sub read_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 154 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 154 | return $self->keyboard->read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 127 | ▶ | sub preview { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preview: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 127 | my ($self, $view, $move) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 127 | my $trial = $view->{layout}->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 127 | my $play = $trial->place($move->{tile}, $move->{arm}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | return ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 127 | %$view, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | layout => $trial, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | count => Game::Dominoes::Scoring::count($trial), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | ends => [ $trial->open_ends ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | }, $play); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 101 | ▶ | sub picker { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
picker: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 101 | my ($self, $moves, $at) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | my @items = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 101 | my $label = sprintf '%-8s %s', $_->{tile}->stringify . '@' . $_->{arm}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 495 | ▶ | $_->{points} ? "scores $_->{points}" : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 495 | $label =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 495 | +{ label => $label, value => $_ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } @$moves; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | return Game::Terminal::Kit::Picker->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | items => \@items, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | window => $WINDOW, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 101 | ▶ | game_keys => { %PICK_KEY, %{ $self->history->game_keys }, %{ Game::Terminal::Kit::Save::game_keys() } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | log => $self->log, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | screen => $self->_in_step, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | (defined $at ? (at => $at) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub choice_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
choice_lines: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my ($self, $moves, $at) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return $self->_rows($self->picker($moves, $at)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 135 | ▶ | sub _rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rows: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 135 | my ($self, $picker) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 135 | ▶ | return map { /\A\s+\d+ further / ? " $_" : " $_" } $picker->rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 135 | ▶ | sub legend { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
legend: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 135 | 'arrows to choose, enter to play, a number to jump to it', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 'v for the table as it stands, ? for the commands, t to type, q to quit', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 'u to take back your last move, r to play it again, S to save', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 102 | ▶ | sub pick { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pick: called CC=18 SCAR=29.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 102 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 102 | my $seat = $view->{seat}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 102 | my $moves = $self->game->legal($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 102 | ▶ | return $self->_typed_turn($view) unless @$moves; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 102 | ▶ | unless ($self->enter_raw) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | $self->picking(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 1 | return $self->_typed_turn($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 101 | my $picker = $self->picker($moves); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 101 | my $log = $self->log; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 101 | my $live = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 101 | $self->screen->clear(scrollback => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 101 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 135 | $self->_show_choice($view, $picker, $live); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 135 | my ($event, $value) = $picker->step($self->read_key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 135 | ▶ | if ($event eq 'quit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 25 | $self->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 25 | $self->quit(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 25 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 110 | ▶ | if ($event eq 'chosen') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 68 | $self->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 68 | return $self->_play($seat, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 42 | ▶ | if ($event eq 'back' || ($event eq 'none' && @{ $log->notes })) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$event eq "back" or $event eq "none" and @{$log->notes;}
$event eq "none" and @{$log->notes;}
MC/DC33%1/3
$event eq "back" or $event eq "none" and @{$log->notes;}
$event eq "back"
$event eq "none"
@{$log->notes;}
Truth table50%2/4
A or B and C
A= $event eq "back"B= $event eq "none"C= @{$log->notes;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | $log->shown->note('that key does nothing here. ? for the ones that do'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 41 | ▶ | next unless $event eq 'key'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 16 | ▶ | if ($value eq 'live') { $live = !$live; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | if ($value eq 'help') { $log->note($self->help); next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 14 | ▶ | if ($value eq 'save') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | my $file = Game::Terminal::Kit::Save::ask_file($self->keyboard, $self->_in_step, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | default => $self->save_default, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | head => [ '', $self->table($view), '', $self->hand_lines($view), '' ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 1 | ▶ | $log->note($self->save($file)) if defined $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 13 | ▶ | if ($value eq 'undo' || $value eq 'redo') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$value eq "undo" or $value eq "redo"
MC/DC100%2/2
$value eq "undo" or $value eq "redo"
$value eq "undo"
$value eq "redo"
Truth table100%3/3
A or B
A= $value eq "undo"B= $value eq "redo"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 11 | ▶ | my $moved = $value eq 'undo' ? $self->take_back : $self->play_again; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 11 | ▶ | next unless $moved; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 6 | $self->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 2 | $self->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 2 | ▶ | $self->picking(0) if $value eq 'type'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 2 | return $self->_typed_turn($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 135 | ▶ | sub _show_choice { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_show_choice: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 135 | my ($self, $view, $picker, $live) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 135 | my $log = $self->log; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 135 | my $move = $picker->current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 135 | my @lines = ('', "hand $view->{hand_number} " . $self->_scores_line($view), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | $self->_hands_line($view)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 135 | ▶ | if (my @said = $self->recent_lines) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 79 | push @lines, '', map { " $_" } @said; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 135 | my ($shown, $title); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 135 | ▶ | if ($live) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 8 | $shown = $view; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 8 | $title = ' the table as it stands:'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 127 | my ($peek) = $self->preview($view, $move); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 127 | $shown = $peek; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | $title = ' if you play ' . $move->{tile}->stringify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 127 | . ' on ' . $move->{arm} . ':'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | push @lines, '', $title, $self->table($shown, $live ? undef : { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 127 | %{ $self->table_marks }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 135 | ▶ | $move->{tile}->id => 'preview', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 135 | push @lines, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 135 | ▶ | push @lines, $self->_ends_line($shown) if $shown->{layout}->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 135 | push @lines, '', $self->hand_lines($view), '', $self->_rows($picker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 135 | ▶ | if (my @notice = @{ $log->notes }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 20 | push @lines, '', map { " $_" } @notice; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 135 | push @lines, '', map { " $_" } $self->legend; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 135 | $self->screen->show(\@lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 135 | $log->shown; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 135 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 77 | ▶ | sub _typed_turn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_typed_turn: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 77 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 77 | $self->show($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 77 | $self->_say($_) for $self->_legal_lines($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 77 | my $line = $self->_ask("seat $view->{seat}> "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 77 | return $self->command($line, $view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 80 | ▶ | sub _legal_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_legal_lines: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 80 | my ($self, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 80 | my $moves = $self->game->legal($view->{seat}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 80 | ▶ | return (' (nothing to play)') unless @$moves; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 80 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 80 | my $line = sprintf(' %2d. %-8s %s', ++$i, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | $_->{tile}->stringify . '@' . $_->{arm}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 406 | ▶ | $_->{points} ? "scores $_->{points}" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 406 | $line =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 406 | $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } @$moves; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 77 | ▶ | sub command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=39 SCAR=42.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 77 | my ($self, $line, $view) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 77 | my $game = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 77 | my $seat = $view->{seat}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 77 | ▶ | return 0 unless defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 76 | $line =~ s/\A\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 76 | $line =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 76 | ▶ | return 1 unless length $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 76 | my ($word, @rest) = split /\s+/, $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 76 | $word = lc $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 76 | ▶ | if ($word eq 'quit' || $word eq 'q') { $self->quit(1); return 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$word eq "quit" or $word eq "q"
MC/DC100%2/2
$word eq "quit" or $word eq "q"
$word eq "quit"
$word eq "q"
Truth table100%3/3
A or B
A= $word eq "quit"B= $word eq "q"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 51 | ▶ | if ($word eq 'help' || $word eq '?') { $self->_say($_) for $self->help; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$word eq "help" or $word eq "?"
MC/DC50%1/2
$word eq "help" or $word eq "?"
$word eq "help"
$word eq "?"
Truth table66%2/3
A or B
A= $word eq "help"B= $word eq "?"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 50 | ▶ | if ($word eq 'table' || $word eq 'board') { $self->_say($_) for $self->table($view); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$word eq "table" or $word eq "board"
MC/DC50%1/2
$word eq "table" or $word eq "board"
$word eq "table"
$word eq "board"
Truth table66%2/3
A or B
A= $word eq "table"B= $word eq "board"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 47 | ▶ | if ($word eq 'hand' || $word eq 'tiles') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$word eq "hand" or $word eq "tiles"
MC/DC50%1/2
$word eq "hand" or $word eq "tiles"
$word eq "hand"
$word eq "tiles"
Truth table66%2/3
A or B
A= $word eq "hand"B= $word eq "tiles"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 3 | $self->_say($_) for $self->hand_lines($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 44 | ▶ | if ($word eq 'ends' || $word eq 'count') { $self->_say($self->_ends_line($view)); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$word eq "ends" or $word eq "count"
MC/DC50%1/2
$word eq "ends" or $word eq "count"
$word eq "ends"
$word eq "count"
Truth table66%2/3
A or B
A= $word eq "ends"B= $word eq "count"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 42 | ▶ | if ($word eq 'scores') { $self->_say($self->_scores_line($view)); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 39 | ▶ | if ($word eq 'legal' || $word eq 'moves') { $self->_say($_) for $self->_legal_lines($view); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$word eq "legal" or $word eq "moves"
MC/DC50%1/2
$word eq "legal" or $word eq "moves"
$word eq "legal"
$word eq "moves"
Truth table66%2/3
A or B
A= $word eq "legal"B= $word eq "moves"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | if ($word eq 'ascii') { $self->ascii(!$self->ascii); $self->_in_step->utf8; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | if ($word eq 'type') { $self->picking(0); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 36 | ▶ | if ($word eq 'pick') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | if ($self->keys_available) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | $self->picking(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | return $self->pick($view); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $self->_say('the keys are not available here, so this game is typed.' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | . ' Term::ReadKey and a terminal are what it takes'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | if ($word eq 'compact') { $self->compact(!$self->compact); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | if ($word eq 'colour' || $word eq 'color') { $self->colour(!$self->colour); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$word eq "colour" or $word eq "color"
MC/DC0%0/2
$word eq "colour" or $word eq "color"
$word eq "colour"
$word eq "color"
Truth table33%1/3
A or B
A= $word eq "colour"B= $word eq "color"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | if ($word eq 'history' || $word eq 'log') { $self->_say($game->to_text); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$word eq "history" or $word eq "log"
MC/DC0%0/2
$word eq "history" or $word eq "log"
$word eq "history"
$word eq "log"
Truth table33%1/3
A or B
A= $word eq "history"B= $word eq "log"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 36 | ▶ | if (my (undef, $file) = Game::Terminal::Kit::Save::command($line)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 12 | $self->_say($self->save($file)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 12 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 24 | ▶ | if ($word eq 'undo') { $self->take_back; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 20 | ▶ | if ($word eq 'redo') { $self->play_again; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 19 | ▶ | if ($word eq 'hint') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 1 | my $bot = Game::Dominoes::Bot->new(level => 4, seed => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 1 | my $move = $bot->choose($game, $seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | $self->_say($move | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | ? 'try ' . $move->{tile}->stringify . '@' . $move->{arm} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 1 | ▶ | : 'nothing to suggest'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | if ($word eq 'play' || $word eq 'p') { return $self->_play($seat, join(' ', @rest)) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$word eq "play" or $word eq "p"
MC/DC0%0/2
$word eq "play" or $word eq "p"
$word eq "play"
$word eq "p"
Truth table33%1/3
A or B
A= $word eq "play"B= $word eq "p"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 18 | ▶ | return $self->_play($seat, $line) if $line =~ /\A[0-6]-[0-6]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 16 | ▶ | if ($word =~ /\A\d+\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 13 | my $moves = $game->legal($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 13 | my $pick = $moves->[ $word - 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | unless ($pick) { $self->_say('no such move'); return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 13 | return $self->_play($seat, $pick); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 3 | $self->_say("I do not know '$word'. Try help."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 83 | ▶ | sub _play { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_play: called CC=9 SCAR=22.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 83 | my ($self, $seat, $move) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 83 | ▶ | if (!ref $move && $move =~ /\A([0-6]-[0-6])\s+([LRUDlrud])\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $move and $move =~ /\A([0-6]-[0-6])\s+([LRUDlrud])\z/
MC/DC0%0/2
not ref $move and $move =~ /\A([0-6]-[0-6])\s+([LRUDlrud])\z/
not ref $move
$move =~ /\A([0-6]-[0-6])\s+([LRUDlrud])\z/
Truth table66%2/3
not(A) and B
A= not ref $moveB= $move =~ /\A([0-6]-[0-6])\s+([LRUDlrud])\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $move = "$1\@" . uc $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 83 | ▶ | if (!ref $move && $move =~ /\A([0-6]-[0-6])\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $move and $move =~ /\A([0-6]-[0-6])\z/
MC/DC50%1/2
not ref $move and $move =~ /\A([0-6]-[0-6])\z/
not ref $move
$move =~ /\A([0-6]-[0-6])\z/
Truth table66%2/3
not(A) and B
A= not ref $moveB= $move =~ /\A([0-6]-[0-6])\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 2 | my $want = Game::Dominoes::Notation::parse_tile($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 2 | my @fit = grep { $_->{tile}->id == $want->id } @{ $self->game->legal($seat) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 2 | ▶ | if (@fit > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | $self->_say('which arm? ' . join(' ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | map { $_->{tile}->stringify . '@' . $_->{arm} } @fit)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 2 | ▶ | $move = @fit ? { tile => $want, arm => $fit[0]{arm} } : { tile => $want }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 83 | my $out = $self->game->play($seat, $move); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 83 | ▶ | if (ref $out eq 'Game::Dominoes::Error') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 1 | $self->_say('no: ' . $out->message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 82 | $self->remember($seat, $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 82 | ▶ | $self->_say('played ' . $out->tile->stringify . ' on ' . $out->arm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | . ($out->points ? ' for ' . $out->points : '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 82 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | ▶ | sub help { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 1 | ' play <tile> [arm] or just 6-4, or the number from `legal`', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | ' legal table hand ends scores history hint', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ' undo redo take back your last move and the replies to it, or play it again', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | ' save [FILE] save the game, to carry on with --resume or watch with --replay', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | ' pick type ascii colour compact quit', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | ' arms are L and R along the line, U and D off the spinner', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | ' a double is laid crosswise, which is how the table is drawn', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | ' a tile in a heavy frame is one played since you last looked', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 55 | ▶ | sub _handover { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handover: called CC=3 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 55 | my ($self, $seat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 55 | ▶ | return 1 unless $self->handover; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $self->_say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | $self->_say(('') x 30); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | my $line = $self->_ask("Pass to seat $seat, then press return: "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | return defined $line ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 176 | ▶ | sub person_turn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
person_turn: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 176 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 176 | my $game = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 176 | my $events = $game->history; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 176 | my ($drew, $dealt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 176 | for my $event (@{$events}[ $self->_seen .. $#$events ]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 191 | ▶ | $drew = 1 if $event->{kind} eq 'draw' && !$self->bots->{ $event->{seat} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$event->{"kind"} eq "draw" and not $self->bots->{$event->{"seat"}}
MC/DC100%2/2
$event->{"kind"} eq "draw" and not $self->bots->{$event->{"seat"}}
$event->{"kind"} eq "draw"
not $self->bots->{$event->{"seat"}}
Truth table100%3/3
A and not(B)
A= $event->{"kind"} eq "draw"B= not $self->bots->{$event->{"seat"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 191 | ▶ | $dealt = 1 if $event->{kind} eq 'hand_end'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 176 | $self->_seen(scalar @$events); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 176 | $self->history->turn($game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 176 | ▶ | return $self unless $drew || $dealt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$drew or $dealt
MC/DC100%2/2
$drew or $dealt
$drew
$dealt
Truth table100%3/3
A or B
A= $drewB= $dealt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 11 | $self->history->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 11 | ▶ | $self->_once($drew ? 'draw' : 'deal', $drew | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ? 'Drawing from the boneyard: nothing before it can be taken back.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | : 'A new hand: nothing before it can be taken back.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 12 | ▶ | sub take_back { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
take_back: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 12 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 12 | my $game = $self->history->undo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 12 | ▶ | unless ($game) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 3 | $self->_remark('There is nothing to take back.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 9 | $self->swap($game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 9 | $self->_remark('Taken back.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 4 | ▶ | sub play_again { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play_again: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 4 | my $game = $self->history->redo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 4 | ▶ | unless ($game) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 2 | $self->_remark('There is nothing to play again.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 2 | $self->swap($game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 2 | $self->_remark('Played again.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 11 | ▶ | sub swap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
swap: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 11 | my ($self, $game) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 11 | $self->game($game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 11 | $self->_seen(scalar @{ $game->history }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 11 | $self->log->forget; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 11 | $self->recent([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 11 | my @plays = grep { $_->{kind} eq 'play' } @{ $game->history }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 11 | ▶ | splice @plays, 0, @plays - $game->players if @plays > $game->players; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 11 | $self->remember($_->{seat}, $_->{play}) for @plays; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 24 | ▶ | sub _remark { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remark: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 24 | my ($self, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 24 | ▶ | return $self->log->note($text) if $self->picking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 6 | $self->_say($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 11 | ▶ | sub _once { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_once: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 11 | my ($self, $what, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 11 | ▶ | return $self if $self->_told->{$what}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 8 | return $self->_remark($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 56 | ▶ | sub start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 56 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 56 | my $game = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 56 | $self->history->start($game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 56 | $self->_seen(scalar @{ $game->history }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 56 | $self->_say('Dominoes: All Fives, ' . $game->players . ' seats, to ' . $game->target); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 56 | $self->_say('Type help for the commands.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 56 | my $last_seat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 56 | ▶ | while ($self->game->status eq 'active' && !$self->quit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->game->status eq "active" and not $self->quit
MC/DC50%1/2
$self->game->status eq "active" and not $self->quit
$self->game->status eq "active"
not $self->quit
Truth table66%2/3
A and not(B)
A= $self->game->status eq "active"B= not $self->quit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 358 | $game = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 358 | my $seat = $game->turn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 358 | ▶ | last unless defined $seat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 358 | ▶ | if (my $bot = $self->bots->{$seat}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 182 | ▶ | my $move = $bot->choose($game, $seat) or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 182 | my $out = $game->play($seat, $move); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 182 | ▶ | last if ref $out eq 'Game::Dominoes::Error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 182 | $self->remember($seat, $out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 182 | ▶ | $self->_say("seat $seat played " . $out->tile->stringify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | . ' on ' . $out->arm . ($out->points ? ' for ' . $out->points : '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 182 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 176 | ▶ | if (!defined $last_seat || $last_seat != $seat) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $last_seat or $last_seat != $seat
MC/DC100%2/2
not defined $last_seat or $last_seat != $seat
not defined $last_seat
$last_seat != $seat
Truth table100%3/3
not(A) or B
A= not defined $last_seatB= $last_seat != $seat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 55 | ▶ | last unless $self->_handover($seat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 55 | $last_seat = $seat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 176 | $self->person_turn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 176 | my $view = $game->view($seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 176 | ▶ | if ($self->picking) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 102 | ▶ | last unless $self->pick($view); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 74 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 74 | ▶ | last unless $self->_typed_turn($view); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 56 | $game = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 56 | ▶ | if (my $result = $game->result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 5 | $self->_say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 5 | $self->_say($result->stringify); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 5 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 51 | $self->_say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 51 | $self->_say('stopped'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 51 | return $game->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 16 | ▶ | sub _person_seat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_person_seat: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 16 | my ($seat) = grep { !$self->bots->{$_} } $self->game->seats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 16 | ▶ | return defined $seat ? $seat : ($self->game->seats)[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 13 | ▶ | sub settings { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
settings: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 13 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 13 | my $bots = $self->bots; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 13 | my @seats = $self->game->seats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 13 | my @bot_seats = grep { $bots->{$_} } @seats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | seat => $self->_person_seat, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | hotseat => @bot_seats ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 'bot-vs-bot' => @bot_seats == @seats ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 13 | ▶ | (@bot_seats ? (level => join ',', map { $bots->{$_}->level } @bot_seats) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 8 | ▶ | sub save_default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save_default: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 8 | my $file = $self->history->file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 8 | ▶ | return defined $file ? $file : Game::Terminal::Kit::Save::default_file('dominoes'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 13 | ▶ | sub save { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 13 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 13 | ▶ | $file = $self->save_default unless defined $file && length $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $file and length $file
MC/DC50%1/2
defined $file and length $file
defined $file
length $file
Truth table66%2/3
A and B
A= defined $fileB= length $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 13 | my $history = $self->history; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 13 | $history->settings($self->settings); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 13 | $history->version($VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 13 | my $path = eval { $history->saved($self->game)->write_file($file) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 13 | ▶ | return 'the game was not saved: ' . Game::Terminal::Kit::Save::why($@) unless $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 13 | $history->file($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 13 | return "the game is saved to $path"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 9 | ▶ | sub read_save { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_save: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 9 | my ($class, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 9 | return Game::Terminal::Kit::Save->read_game($file, 'dominoes'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 3 | ▶ | sub replay_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replay_lines: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 3 | my ($self, $game) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 3 | my $was = $self->game; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 3 | $self->game($game); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 3 | my @lines = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 3 | my $view = $game->view($self->_person_seat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 3 | my $result = $game->result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | ("hand $view->{hand_number} " . $self->_scores_line($view), '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | $self->table($view), '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 3 | ▶ | ($view->{layout}->count ? ($self->_ends_line($view), '') : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | $self->hand_lines($view), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | ($result ? ('', $result->stringify) : ())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 3 | my $died = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 3 | $self->game($was); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 3 | ▶ | die $died unless @lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 3 | return @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 16 | ▶ | sub _usage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_usage: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 16 | return <<'USAGE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | dominoes - draw dominoes with All Fives scoring | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | dominoes [options] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | --players=N 2, 3 or 4 (default 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | --seat=N which seat the human takes (default 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | --hotseat every seat is a person, with a hand-over between turns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | --bot-vs-bot nobody is a person | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | --level=N bot level 1 to 5, repeatable, one per bot seat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | --target=N default 250 at two seats, 200 at three or four | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | --scale=N divide every score, for the cribbage board variation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | (use --scale=5 --target=61 together, never one alone) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | --variant=S all_fives, draw or block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | --reserve=N tiles at the back of the boneyard nobody may draw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | --seed=S reproduce a game exactly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | --ascii plain ASCII only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | --compact tiles as [6|4] on one line instead of drawn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | --width=N what the drawn table may use before it wraps (default: the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | terminal's width) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | --colour force colour on or off (--nocolour) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | --nopick type the moves out instead of choosing them with the keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | --save=FILE where S, or save, writes the game: FILE, else the file it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | was resumed from, else dominoes.save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | --resume=FILE carry on a saved game, with its undo and redo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | --replay=FILE watch a saved game a turn at a time; enter plays on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | --version print the version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | --help this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | Arms are L and R along the main line, U and D off the spinner. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | On a terminal the legal moves are listed under the table and chosen with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | the arrow keys: the table above the list is the one the move under the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | cursor would make, with its new count and what it would score, so a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | placement is seen before it is played. Enter plays it, v shows the table as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | it stands, t goes back to typing and ? prints the commands. Needs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | Term::ReadKey; without it, or off a terminal, the moves are typed out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | u takes back your last move and every reply to it, and r plays them again; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | typed, they are undo and redo. S saves the game; typed, it is save. Nothing before a tile you drew from the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | boneyard, or before a new hand, can be taken back. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | The tile each seat just played is marked on the table, because at four | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | seats three of them land between your turns. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | Exit status is 0 if your seat won or nobody was playing a seat, 1 if you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | lost or stopped early, 2 for a bad option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | USAGE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 8 | ▶ | sub _bad { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bad: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 8 | my ($why) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 8 | $why =~ s/ at \S+ line \d+\.?\s*\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 8 | $why =~ s/\A[\w:]+: //; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 8 | chomp $why; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 8 | print {\*STDERR} "dominoes: $why\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 8 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 2 | ▶ | sub options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 2 | { name => 'players', type => 'int', min => 2, max => 4, help => 'seats at the table' }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | { name => 'seat', type => 'int', min => 1, max => 4, help => 'which seat you take' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | { name => 'level', type => 'int', min => 1, max => 5, help => "the bots' level" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | { name => 'variant', type => 'enum', choices => [qw(all_fives draw block)], help => 'the rules' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | { name => 'target', type => 'int', min => 50, max => 500, help => 'the score that wins' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | { name => 'hotseat', type => 'flag', help => 'every seat is a person' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | { name => 'bot-vs-bot', type => 'flag', help => 'nobody is a person' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | { name => 'seed', type => 'str', help => 'reproduce a game exactly' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 38 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 38 | my ($class, @argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 38 | my $saved = Getopt::Long::Configure(qw(bundling no_ignore_case)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 38 | my $status = $class->_run(\@argv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 38 | Getopt::Long::Configure($saved); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 38 | return $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 38 | ▶ | sub _run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run: called CC=62 SCAR=54.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 38 | my ($class, $argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 38 | my %opt = (level => []); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | Getopt::Long::GetOptionsFromArray($argv, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 'players=i' => \$opt{players}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 'seat=i' => \$opt{seat}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 'hotseat' => \$opt{hotseat}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 'bot-vs-bot' => \$opt{botonly}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 'level=i@' => $opt{level}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 'target=i' => \$opt{target}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 'scale=i' => \$opt{scale}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 'variant=s' => \$opt{variant}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 'seed=s' => \$opt{seed}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 'reserve=i' => \$opt{reserve}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 'ascii' => \$opt{ascii}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 'compact' => \$opt{compact}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 'width=i' => \$opt{width}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 'colour!' => \$opt{colour}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 'color!' => \$opt{colour}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 'pick!' => \$opt{pick}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 'version' => \$opt{version}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 'help|h|?' => \$opt{help}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 'save=s' => \$opt{save}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 'resume=s' => \$opt{resume}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 'replay=s' => \$opt{replay}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 38 | ▶ | ) or do { print {\*STDERR} _usage(); return 2 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 37 | ▶ | if ($opt{help}) { print _usage(); return 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 22 | ▶ | if ($opt{version}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | print "dominoes (Game::Dominoes) $Game::Dominoes::VERSION\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 22 | ▶ | if (@{$argv}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | print {\*STDERR} "dominoes: there is nothing to do with '$argv->[0]': options begin with --\n", _usage(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 22 | ▶ | if (my $why = Game::Terminal::Kit::Save::check_flags(\%opt)) { return _bad($why) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 20 | my ($game, $save, $history); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 20 | ▶ | my $from = defined $opt{resume} ? $opt{resume} : $opt{replay}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 20 | ▶ | if (defined $from) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 12 | my %new = (players => 'players', variant => 'variant', target => 'target', scale => 'scale', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | reserve => 'reserve', seed => 'seed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 12 | for my $name (grep { defined $opt{$_} } sort keys %new) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 4 | ▶ | return _bad("--$name begins a new game, and --" . (defined $opt{resume} ? 'resume' : 'replay') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | . ' starts from a saved one'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 8 | ($save, my $why) = $class->read_save($from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 8 | ▶ | return _bad($why) unless $save; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 6 | my $settings = $save->settings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 6 | ▶ | $opt{seat} = $settings->{seat} if !defined $opt{seat} && defined $settings->{seat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $opt{"seat"} and defined $settings->{"seat"}
MC/DC0%0/2
not defined $opt{"seat"} and defined $settings->{"seat"}
not defined $opt{"seat"}
defined $settings->{"seat"}
Truth table33%1/3
not(A) and B
A= not defined $opt{"seat"}B= defined $settings->{"seat"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 6 | ▶ | $opt{hotseat} = 1 if !defined $opt{hotseat} && !defined $opt{botonly} && $settings->{hotseat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $opt{"hotseat"} || defined $opt{"botonly"} and $settings->{"hotseat"}
defined $opt{'hotseat'} || defined $opt{'botonly'}
MC/DC0%0/3
not defined $opt{"hotseat"} || defined $opt{"botonly"} and $settings->{"hotseat"}
defined $opt{'hotseat'}
defined $opt{'botonly'}
$settings->{"hotseat"}
Truth table25%1/4
not(A || B) and C
A= defined $opt{'hotseat'}B= defined $opt{'botonly'}C= $settings->{"hotseat"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 6 | ▶ | $opt{botonly} = 1 if !defined $opt{hotseat} && !defined $opt{botonly} && $settings->{'bot-vs-bot'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $opt{"hotseat"} || defined $opt{"botonly"} and $settings->{"bot-vs-bot"}
defined $opt{'hotseat'} || defined $opt{'botonly'}
MC/DC0%0/3
not defined $opt{"hotseat"} || defined $opt{"botonly"} and $settings->{"bot-vs-bot"}
defined $opt{'hotseat'}
defined $opt{'botonly'}
$settings->{"bot-vs-bot"}
Truth table25%1/4
not(A || B) and C
A= defined $opt{'hotseat'}B= defined $opt{'botonly'}C= $settings->{"bot-vs-bot"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 6 | ▶ | @{ $opt{level} } = split /,/, $settings->{level} if !@{ $opt{level} } && defined $settings->{level}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not @{$opt{"level"};} and defined $settings->{"level"}
MC/DC50%1/2
not @{$opt{"level"};} and defined $settings->{"level"}
not @{$opt{"level"};}
defined $settings->{"level"}
Truth table66%2/3
not(A) and B
A= not @{$opt{"level"};}B= defined $settings->{"level"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 6 | $history = _new_history(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 6 | ▶ | unless (defined $opt{replay}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 5 | $game = eval { $history->resume($save) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 5 | ▶ | return _bad("'" . $save->file . "' cannot be carried on: " . Game::Terminal::Kit::Save::why($@)) unless $game; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 1 | $game = eval { Game::Dominoes->from_text(($save->steps)[0]) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 1 | ▶ | return _bad("'" . $save->file . "' cannot be watched: " . Game::Terminal::Kit::Save::why($@)) unless $game; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 6 | $opt{players} = $game->players; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 14 | ▶ | $opt{players} = 2 unless defined $opt{players}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 14 | ▶ | $opt{seat} = 1 unless defined $opt{seat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 14 | ▶ | $opt{variant} = 'all_fives' unless defined $opt{variant}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 14 | ▶ | return _bad('--players must be 2, 3 or 4') unless $opt{players} =~ /\A[234]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | return _bad("--seat must be a seat from 1 to $opt{players}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | unless $opt{seat} =~ /\A\d+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 14 | ▶ | && $opt{seat} >= 1 && $opt{seat} <= $opt{players}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$opt{"seat"} =~ /\A\d+\z/ and $opt{"seat"} >= 1 and $opt{"seat"} <= $opt{"players"}
$opt{"seat"} =~ /\A\d+\z/ and $opt{"seat"} >= 1
MC/DC0%0/3
$opt{"seat"} =~ /\A\d+\z/ and $opt{"seat"} >= 1 and $opt{"seat"} <= $opt{"players"}
$opt{"seat"} =~ /\A\d+\z/
$opt{"seat"} >= 1
$opt{"seat"} <= $opt{"players"}
Truth table25%1/4
A and B and C
A= $opt{"seat"} =~ /\A\d+\z/B= $opt{"seat"} >= 1C= $opt{"seat"} <= $opt{"players"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 14 | ▶ | unless ($game) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | my $seed = defined $opt{seed} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | ? substr(($opt{seed} x 32), 0, 32) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | ▶ | : pack('N8', map { int rand 2**32 } 1 .. 8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 8 | $game = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | Game::Dominoes->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | seed => $seed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | players => $opt{players}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | variant => $opt{variant}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | (defined $opt{target} ? (target => $opt{target}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | (defined $opt{scale} ? (scale => $opt{scale}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 8 | ▶ | (defined $opt{reserve} ? (reserve => $opt{reserve}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 8 | ▶ | return _bad($@ || 'could not deal') unless $game; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$@ || 'could not deal'
MC/DC0%0/1
$@ || 'could not deal'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | my @bot_seats = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | $opt{hotseat} ? () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | : $opt{botonly} ? ($game->seats) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 14 | ▶ | : (grep { $_ != $opt{seat} } $game->seats); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 14 | my @levels = @{ $opt{level} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 14 | my %bots; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 14 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 14 | for my $seat (@bot_seats) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 14 | ▶ | my $level = $levels[$i] // $levels[-1] // 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($levels[$i] // $levels[-1]) // 3
$levels[$i] // $levels[-1]
MC/DC0%0/2
($levels[$i] // $levels[-1]) // 3
$levels[$i]
$levels[-1]
Truth table33%1/3
A // B
A= $levels[$i]B= $levels[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 14 | $bots{$seat} = Game::Dominoes::Bot->new(level => $level, seed => $seat * 7919); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 14 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 14 | my $terminal = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | $class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | game => $game, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | bots => \%bots, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | ($history && !defined $opt{replay} ? (history => $history) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | (defined $opt{save} ? (save_file => $opt{save}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | (defined $opt{colour} ? (colour => $opt{colour}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | ($opt{ascii} ? (ascii => 1) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | ($opt{compact} ? (compact => 1) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | (defined $opt{width} ? (width => $opt{width}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 14 | ▶ | (defined $opt{pick} ? (picking => $opt{pick} ? 1 : 0) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
Condition100%3/3
$history and not defined $opt{"replay"}
MC/DC100%2/2
$history and not defined $opt{"replay"}
$history
not defined $opt{"replay"}
Truth table100%3/3
A and not(B)
A= $historyB= not defined $opt{"replay"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 14 | ▶ | return _bad($@ || 'could not start') unless $terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$@ || 'could not start'
MC/DC0%0/1
$@ || 'could not start'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 14 | ▶ | if (defined $opt{replay}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | my $replay = Game::Terminal::Kit::Replay->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | save => $save, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 3 | ▶ | load => sub { Game::Dominoes->from_text($_[0]) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 3 | ▶ | draw => sub { $terminal->replay_lines($_[0]) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 1 | ▶ | head => [ 'dominoes, a replay of ' . $save->file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | . (defined $save->saved_at ? ', saved ' . $save->saved_at : ''), '' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | screen => $terminal->screen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | my ($event, $step) = Game::Terminal::Kit::Run::guard( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 1 | ▶ | sub { $replay->play($terminal->keyboard, $terminal->screen) }, $terminal->keyboard, $terminal->screen); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 1 | ▶ | return 0 unless $event eq 'chosen'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | my $resumed = eval { $terminal->history->resume($save->from_step($step)) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | ▶ | return _bad("'" . $save->file . "' cannot be carried on: " . Game::Terminal::Kit::Save::why($@)) unless $resumed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | $terminal->swap($resumed); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | my $result = Game::Terminal::Kit::Run::guard( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 13 | ▶ | sub { $terminal->start }, $terminal->keyboard, $terminal->screen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 13 | ▶ | return 1 unless $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | ▶ | return 0 if $opt{hotseat} || $opt{botonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"hotseat"} or $opt{"botonly"}
MC/DC0%0/2
$opt{"hotseat"} or $opt{"botonly"}
$opt{"hotseat"}
$opt{"botonly"}
Truth table0%0/3
A or B
A= $opt{"hotseat"}B= $opt{"botonly"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | ▶ | return 0 if grep { $_ == $opt{seat} } @{ $result->winners }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 28 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||