| 1 | package Game::Terminal::Menu; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Object::Proto::Sugar -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Game::Terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Game::Terminal::Kit::Form; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Game::Terminal::Kit::Keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Game::Terminal::Kit::Log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Game::Terminal::Kit::Run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Game::Terminal::Kit::Screen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Text::ParseWords (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | my %WORD = (0 => 'won or drew', 1 => 'lost', 2 => 'bad option'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | my $LEGEND = 'up and down to choose, enter to set up and play, a letter to jump, q to quit'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | my $MORE = 'k and j move too, space plays, home and end jump to the ends'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | my %INK = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | title => '1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | count => '2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | key => '1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | board => '38;5;75', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | card => '38;5;203', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | tile => '38;5;220', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | puzzle => '38;5;177', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | arcade => '38;5;80', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | detail => '38;5;245', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | legend => '2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | set => '38;5;114', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | own => '2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | play => '1;32', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | good => '38;5;114', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | bad => '38;5;203', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | warn => '38;5;220', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | has [qw/in out/] => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | is => 'rw' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | has [qw/interactive colour picking/] => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | is => 'rw' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | has [qw/keyboard screen/] => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | is => 'rw' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | has keysource => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | isa => CodeRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | has pending => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | isa => ArrayRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | default => [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | has runner => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | isa => CodeRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | has common => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | default => {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | has inc => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | isa => ArrayRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | has games => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | isa => ArrayRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | has at => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | has status => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | default => '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | has tone => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | default => '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | has rows => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | has values => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | default => {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 33 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=19 SCAR=33.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 33 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 33 | ▶ | $self->in(\*STDIN) unless $self->in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 33 | ▶ | $self->out(\*STDOUT) unless $self->out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 33 | ▶ | $self->interactive(-t $self->in ? 1 : 0) unless defined $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 33 | ▶ | $self->colour($self->interactive && !Game::Terminal::Kit::Screen::no_colour() ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$self->interactive and not Game::Terminal::Kit::Screen::no_colour()
MC/DC0%0/2
$self->interactive and not Game::Terminal::Kit::Screen::no_colour()
$self->interactive
not Game::Terminal::Kit::Screen::no_colour()
Truth table0%0/3
A and not(B)
A= $self->interactiveB= not Game::Terminal::Kit::Screen::no_colour()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | unless defined $self->colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 33 | ▶ | $self->keyboard(Game::Terminal::Kit::Keys->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | in => $self->in, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | pending => $self->pending, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ($self->keysource ? (keysource => $self->keysource) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | )) unless $self->keyboard; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 33 | ▶ | $self->screen(Game::Terminal::Kit::Screen->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | out => $self->out, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | interactive => $self->interactive, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | colour => $self->colour, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ascii => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | )) unless $self->screen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 33 | ▶ | $self->picking($self->interactive ? 1 : 0) unless defined $self->picking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 33 | ▶ | $self->picking(0) unless $self->keys_available; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 33 | ▶ | $self->inc([ @INC ]) unless $self->inc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 33 | ▶ | $self->runner(\&Game::Terminal::launch) unless $self->runner; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 33 | ▶ | unless ($self->games) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | my @inc = @{$self->inc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $self->games([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 4 | ▶ | map { { %{$_}, installed => Game::Terminal::installed($_, @inc) ? 1 : 0 } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | Game::Terminal::games() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 33 | $self->at($self->first_installed); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 33 | ▶ | $self->rows($self->height) unless $self->rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 33 | $self->screen->flush_on; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 33 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | sub raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | return $self->keyboard->raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 34 | ▶ | sub keys_available { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keys_available: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 34 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 34 | return $self->keyboard->keys_available; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 47 | ▶ | sub enter_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enter_raw: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 47 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 47 | ▶ | return $self->keyboard->enter_raw ? $self : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 27 | ▶ | sub leave_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leave_raw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 27 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 27 | $self->keyboard->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 27 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 190 | ▶ | sub read_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 190 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 190 | return $self->keyboard->read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 32 | ▶ | sub height { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
height: called CC=3 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 32 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 32 | ▶ | return 0 unless $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my (undef, $rows) = $self->screen->measured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | return $rows || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rows || 0
MC/DC0%0/1
$rows || 0
$rows
Truth table0%0/2
A
A= $rows
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 3852 | ▶ | sub say { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3852 | my ($self, $line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3852 | $self->screen->say($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3852 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 196 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 196 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 196 | $self->screen->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 196 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 4483 | ▶ | sub paint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 4483 | my ($self, $text, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 4483 | return $self->screen->paint($text, $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 33 | ▶ | sub first_installed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first_installed: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 33 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 33 | my $games = $self->games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 33 | for my $index (0 .. $#{$games}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 33 | ▶ | return $index if $games->[$index]{installed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub last_installed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_installed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $games = $self->games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | for my $index (reverse 0 .. $#{$games}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return $index if $games->[$index]{installed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 52 | ▶ | sub note { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 52 | my ($self, $text, $tone) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 52 | ▶ | $self->status(defined $text ? $text : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 52 | ▶ | $self->tone(defined $tone ? $tone : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 52 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 93 | ▶ | sub status_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status_line: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 93 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 93 | ▶ | return () unless length $self->status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 30 | my $tone = $self->tone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 30 | ▶ | return $self->paint($self->status, $INK{$tone} || $INK{detail}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$INK{$tone} || $INK{'detail'}
MC/DC0%0/2
$INK{$tone} || $INK{'detail'}
$INK{$tone}
$INK{'detail'}
Truth table33%1/3
A || B
A= $INK{$tone}B= $INK{'detail'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2028 | ▶ | sub row_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row_line: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2028 | my ($self, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2028 | my $row = $self->games->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | my $line = sprintf '%-11s %-6s %-4s %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2028 | $row->{key}, $row->{family}, $row->{players}, $row->{blurb}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2028 | $line =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2028 | ▶ | return $self->paint(" $line (not installed)", '2') unless $row->{installed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1978 | ▶ | return ' ' . $self->paint("> $line", '1;7') if $index == $self->at; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | return ' ' . $self->paint(sprintf('%-11s', $row->{key}), $INK{key}) . ' ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | . $self->paint(sprintf('%-6s', $row->{family}), $INK{ $row->{family} } || $INK{detail}) . ' ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1894 | ▶ | . sprintf('%-4s %s', $row->{players}, $row->{blurb}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$INK{$row->{'family'}} || $INK{'detail'}
MC/DC0%0/2
$INK{$row->{'family'}} || $INK{'detail'}
$INK{$row->{'family'}}
$INK{'detail'}
Truth table33%1/3
A || B
A= $INK{$row->{'family'}}B= $INK{'detail'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 86 | ▶ | sub list_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_lines: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 86 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 86 | my $games = $self->games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 86 | my $count = scalar @{$games}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 86 | ▶ | my $room = $self->rows ? $self->rows - 7 : $count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 86 | my ($first, $last) = (0, $count - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 86 | ▶ | if ($room < $count && $room >= 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$room < $count and $room >= 5
MC/DC50%1/2
$room < $count and $room >= 5
$room < $count
$room >= 5
Truth table66%2/3
A and B
A= $room < $countB= $room >= 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | my $window = $room - 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | $first = $self->at - int($window / 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | ▶ | $first = 0 if $first < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | $first = $count - $window if $first > $count - $window; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | $last = $first + $window - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 86 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 86 | ▶ | push @lines, sprintf ' %d further up', $first if $first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 86 | push @lines, map { $self->row_line($_) } $first .. $last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 86 | ▶ | push @lines, sprintf ' %d further down', $count - 1 - $last if $last < $count - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 86 | return \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 84 | ▶ | sub detail_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detail_lines: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 84 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 84 | my $row = $self->games->[$self->at]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 84 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 84 | ▶ | if ($row->{installed}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 82 | my $version = Game::Terminal::version_of($row, @{$self->inc}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 82 | ▶ | push @lines, "$row->{key}: $row->{class}" . (defined $version ? " $version" : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | . ", options: game $row->{key} --help"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | push @lines, "$row->{key} is not installed: cpanm $row->{module}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 84 | $lines[0] = $self->paint($lines[0], $INK{detail}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 84 | push @lines, $self->status_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 84 | return \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 84 | ▶ | sub draw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
draw: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 84 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 84 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 84 | my $count = sprintf '%d games', scalar @{$self->games}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 84 | $self->say($self->paint('Game', $INK{title}) . $self->paint(sprintf('%*s', 72, $count), $INK{count})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 84 | $self->say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 84 | $self->say($_) for @{$self->list_lines}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 84 | $self->say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 84 | $self->say($_) for @{$self->detail_lines}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 84 | $self->say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 84 | $self->say($self->paint($LEGEND, $INK{legend})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 84 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 25 | ▶ | sub move { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
move: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 25 | my ($self, $step) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 25 | my $games = $self->games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 25 | my $at = $self->at; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 25 | for (1 .. @{$games}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 28 | $at = ($at + $step) % @{$games}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 28 | ▶ | last if $games->[$at]{installed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 25 | $self->at($at); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 25 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 18 | ▶ | sub jump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jump: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 18 | my ($self, $letter) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 18 | my $games = $self->games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 18 | my $at = $self->at; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 18 | for (1 .. @{$games}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 88 | $at = ($at + 1) % @{$games}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 88 | ▶ | next unless $games->[$at]{installed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 88 | ▶ | next unless index($games->[$at]{key}, $letter) == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 18 | $self->at($at); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 18 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->note("No game starts with $letter"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 47 | ▶ | sub choose { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
choose: called CC=20 SCAR=36.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 47 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 47 | my $games = $self->games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 47 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 84 | $self->draw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 84 | my $key = $self->read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 84 | ▶ | return undef unless defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 84 | ▶ | return undef if $key eq 'q' || $key eq 'escape' || $key eq 'eof' || $key eq 'interrupt'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$key eq "q" or $key eq "escape" or $key eq "eof" or $key eq "interrupt"
$key eq "q" or $key eq "escape" or $key eq "eof"
$key eq "q" or $key eq "escape"
MC/DC25%1/4
$key eq "q" or $key eq "escape" or $key eq "eof" or $key eq "interrupt"
$key eq "q"
$key eq "escape"
$key eq "eof"
$key eq "interrupt"
Truth table40%2/5
A or B or C or D
A= $key eq "q"B= $key eq "escape"C= $key eq "eof"D= $key eq "interrupt"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 60 | ▶ | if ($key eq 'up' || $key eq 'k') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition33%1/3
$key eq "up" or $key eq "k"
MC/DC0%0/2
$key eq "up" or $key eq "k"
$key eq "up"
$key eq "k"
Truth table33%1/3
A or B
A= $key eq "up"B= $key eq "k"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $self->move(-1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ▶ | } elsif ($key eq 'down' || $key eq 'j' || $key eq 'tab') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$key eq "down" or $key eq "j" or $key eq "tab"
$key eq "down" or $key eq "j"
MC/DC33%1/3
$key eq "down" or $key eq "j" or $key eq "tab"
$key eq "down"
$key eq "j"
$key eq "tab"
Truth table50%2/4
A or B or C
A= $key eq "down"B= $key eq "j"C= $key eq "tab"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 23 | $self->move(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | ▶ | } elsif ($key eq 'home' || $key eq 'page_up') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$key eq "home" or $key eq "page_up"
MC/DC0%0/2
$key eq "home" or $key eq "page_up"
$key eq "home"
$key eq "page_up"
Truth table33%1/3
A or B
A= $key eq "home"B= $key eq "page_up"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->at($self->first_installed); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ▶ | } elsif ($key eq 'end' || $key eq 'page_down') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$key eq "end" or $key eq "page_down"
MC/DC0%0/2
$key eq "end" or $key eq "page_down"
$key eq "end"
$key eq "page_down"
Truth table33%1/3
A or B
A= $key eq "end"B= $key eq "page_down"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $self->at($self->last_installed); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ▶ | } elsif ($key eq 'enter' || $key eq ' ') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$key eq "enter" or $key eq " "
MC/DC50%1/2
$key eq "enter" or $key eq " "
$key eq "enter"
$key eq " "
Truth table66%2/3
A or B
A= $key eq "enter"B= $key eq " "
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 24 | my $row = $games->[$self->at]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 24 | ▶ | return $row if $row->{installed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 1 | $self->note("$row->{key} is not installed: cpanm $row->{module}", 'warn'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } elsif ($key eq '?') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $self->note($MORE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } elsif ($key =~ m/^[a-z0-9]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 13 | $self->jump($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $self->note('That key does nothing here'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 6 | ▶ | sub prompt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prompt: called CC=14 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 6 | my $games = $self->games; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 6 | my $in = $self->in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 6 | my $out = $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 6 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 7 | $self->say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 7 | for my $index (0 .. $#{$games}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 168 | my $row = $games->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | $self->say(sprintf '%2d. %-11s %s%s', $index + 1, $row->{key}, $row->{blurb}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 168 | ▶ | $row->{installed} ? '' : ' (not installed)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 7 | $self->say($_) for $self->status_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 7 | print {$out} 'Which game? (number, name, or q) '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 7 | my $answer = readline $in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 7 | ▶ | return undef unless defined $answer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 7 | $answer =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 7 | ▶ | return undef if $answer eq '' || lc $answer eq 'q'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$answer eq "" or lc $answer eq "q"
MC/DC50%1/2
$answer eq "" or lc $answer eq "q"
$answer eq ""
lc $answer eq "q"
Truth table66%2/3
A or B
A= $answer eq ""B= lc $answer eq "q"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 5 | my $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 5 | ▶ | if ($answer =~ m/^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 3 | ▶ | $row = $games->[$answer - 1] if $answer >= 1 && $answer <= @{$games}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$answer >= 1 and $answer <= @{$games;}
MC/DC0%0/2
$answer >= 1 and $answer <= @{$games;}
$answer >= 1
$answer <= @{$games;}
Truth table33%1/3
A and B
A= $answer >= 1B= $answer <= @{$games;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } elsif (my $found = Game::Terminal::find($answer)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | ($row) = grep { $_->{key} eq $found->{key} } @{$games}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 5 | ▶ | if (!$row) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | my @near = Game::Terminal::nearest($answer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | ▶ | $self->note("No game called '$answer'." . (@near ? " Did you mean $near[0]?" : ''), 'warn'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 4 | ▶ | if (!$row->{installed}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $self->note("$row->{key} is not installed: cpanm $row->{module}", 'warn'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 4 | return $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 8 | ▶ | sub read_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_line: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 8 | my ($self, $prompt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 8 | return $self->keyboard->read_line($prompt, $self->out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 23 | ▶ | sub form { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 23 | my ($self, $row) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | return Game::Terminal::Kit::Form->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | title => $self->paint($row->{key}, $INK{title}) . ": $row->{blurb}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | fields => Game::Terminal::options_for($row), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 23 | ▶ | values => ($self->values->{ $row->{key} } ||= {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->values->{$row->{"key"}} ||= {}
MC/DC100%1/1
$self->values->{$row->{"key"}} ||= {}
$self->values->{$row->{"key"}}
Truth table100%2/2
A
A= $self->values->{$row->{"key"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | legend => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | log => Game::Terminal::Kit::Log->new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | screen => $self->screen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 23 | ▶ | sub configure { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure: called CC=13 SCAR=25.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 23 | my ($self, $row) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 23 | my $form = $self->form($row); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 23 | my $log = $form->log; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 23 | $self->note(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 23 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 86 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 86 | $self->say($_) for $form->lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 86 | ▶ | $self->say($_) for length $self->status ? ('', $self->status_line) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 86 | $self->say($_) for '', $self->paint('left and right change a value, enter edits a text, backspace clears,', $INK{legend}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | $self->paint('enter on Play starts, escape goes back', $INK{legend}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 86 | my $key = $self->read_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 86 | ▶ | return undef unless defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 86 | my ($event, $value) = $form->step($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 86 | ▶ | return undef if $event eq 'back' || $event eq 'quit'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$event eq "back" or $event eq "quit"
MC/DC50%1/2
$event eq "back" or $event eq "quit"
$event eq "back"
$event eq "quit"
Truth table66%2/3
A or B
A= $event eq "back"B= $event eq "quit"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 85 | ▶ | return [ $form->argv ] if $event eq 'chosen'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 63 | ▶ | if ($event eq 'edit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 4 | my $line = $self->read_line("$value->{name}: "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 4 | ▶ | $form->set($value->{name}, $line) if defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 63 | my @said = $log->lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 63 | $log->shown; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 63 | ▶ | $self->note($said[0], $said[0] =~ m/^That key/ ? '' : 'warn') if @said; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 4 | ▶ | sub ask_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ask_options: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 4 | my ($self, $row) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 4 | my $line = $self->read_line("Options for $row->{key}, as on the command line (blank for none): "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 4 | ▶ | return [] unless defined $line && length $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $line and length $line
MC/DC50%1/2
defined $line and length $line
defined $line
length $line
Truth table66%2/3
A and B
A= defined $lineB= length $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | return [ Text::ParseWords::shellwords($line) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 30 | ▶ | sub describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 30 | my ($self, $row, $status, $error) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 30 | ▶ | return "$row->{key} died: $error" if defined $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 28 | ▶ | $status = 0 unless defined $status && $status =~ m/^\d+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $status and $status =~ /^\d+$/u
MC/DC0%0/2
defined $status and $status =~ /^\d+$/u
defined $status
$status =~ /^\d+$/u
Truth table33%1/3
A and B
A= defined $statusB= $status =~ /^\d+$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 28 | my $word = $WORD{$status}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 28 | ▶ | return "$row->{key} finished with status $status" . ($word ? " ($word)" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 26 | ▶ | sub launch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
launch: called CC=11 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 26 | my ($self, $row, $argv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 26 | $self->leave_raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 26 | $self->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 26 | my $common = $self->common; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 26 | my @flags = Game::Terminal::flags_for($row, $common); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 26 | ▶ | my ($status, $error) = $self->runner->($row, [ @flags, @{ $argv || [] } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$argv || []
defined $common->{"colour"} and not $common->{"colour"}
MC/DC0%0/1
$argv || []
$argv
MC/DC50%1/2
defined $common->{"colour"} and not $common->{"colour"}
defined $common->{"colour"}
not $common->{"colour"}
Truth table50%1/2
A
A= $argv
Truth table66%2/3
A and not(B)
A= defined $common->{"colour"}B= not $common->{"colour"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | out => $self->out, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 26 | no_colour => (defined $common->{colour} && !$common->{colour}) ? 1 : 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 26 | my $out = $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | print {$out} "\e[0m\e[?25h" if $self->interactive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 26 | ▶ | $self->picking(0) if $self->picking && !$self->enter_raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->picking and not $self->enter_raw
MC/DC0%0/2
$self->picking and not $self->enter_raw
$self->picking
not $self->enter_raw
Truth table66%2/3
A and not(B)
A= $self->pickingB= not $self->enter_raw
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 26 | ▶ | $self->note($self->describe($row, $status, $error), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
not defined $status or $status eq 0
MC/DC50%1/2
not defined $status or $status eq 0
not defined $status
$status eq 0
Truth table66%2/3
not(A) or B
A= not defined $statusB= $status eq 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | defined $error ? 'bad' : !defined $status || $status eq '0' ? 'good' : $status eq '1' ? 'bad' : 'warn'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 26 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 26 | ▶ | sub start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 26 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 26 | ▶ | $self->picking(0) if $self->picking && !$self->enter_raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->picking and not $self->enter_raw
MC/DC0%0/2
$self->picking and not $self->enter_raw
$self->picking
not $self->enter_raw
Truth table66%2/3
A and not(B)
A= $self->pickingB= not $self->enter_raw
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 26 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 26 | ▶ | Game::Terminal::Kit::Run::guard(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 26 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 53 | ▶ | my $row = $self->picking ? $self->choose : $self->prompt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 53 | ▶ | last unless $row; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 27 | ▶ | my $argv = $self->picking ? $self->configure($row) : $self->ask_options($row); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 27 | ▶ | next unless $argv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 26 | $self->launch($row, $argv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 26 | }, $self->keyboard); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 26 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 26 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 26 | ▶ | if ($self->interactive) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $out = $self->out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | print {$out} "\e[0m\e[?25h\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 26 | ▶ | die $error unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 26 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||