| 1 | package Game::Terminal; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 21 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 21 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 21 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 21 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 21 | ▶ | use Game::Terminal::Kit::Options (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 21 | ▶ | use Game::Terminal::Kit::Save (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 21 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 21 | our @ROSTER; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 21 | my %BY_NAME; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 21 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 21 | my %ALL = (ascii => '--ascii', pick => '--no-pick'); | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 21 | @ROSTER = ( | |||||||||||||||||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | key => 'backgammon', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | module => 'Game::Backgammon', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | class => 'Game::Backgammon::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | blurb => 'backgammon', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 28 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 29 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | key => 'brandubh', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | module => 'Game::Brandubh', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | class => 'Game::Brandubh::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | blurb => 'the Irish 7 by 7 tafl game', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 39 | aliases => ['tafl'], | ||||||||||||||||||||||||||||||||||||||||||
| 40 | flags => { ascii => '--no-unicode', pick => '--no-pick' }, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | key => 'checkers', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | module => 'Game::Checkers', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | class => 'Game::Checkers::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | blurb => 'English draughts', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 50 | aliases => ['draughts'], | ||||||||||||||||||||||||||||||||||||||||||
| 51 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||||||||||||||||
| 54 | key => 'chess', | ||||||||||||||||||||||||||||||||||||||||||
| 55 | module => 'Term::Chess', | ||||||||||||||||||||||||||||||||||||||||||
| 56 | class => 'Term::Chess', | ||||||||||||||||||||||||||||||||||||||||||
| 57 | blurb => 'chess', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 61 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 62 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | key => 'cribbage', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | module => 'Game::Cribbage', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | class => 'Game::Cribbage::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 68 | blurb => 'cribbage', | ||||||||||||||||||||||||||||||||||||||||||
| 69 | family => 'card', | ||||||||||||||||||||||||||||||||||||||||||
| 70 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 71 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 72 | aliases => ['crib'], | ||||||||||||||||||||||||||||||||||||||||||
| 73 | flags => { pick => '--no-pick' }, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | key => 'dominoes', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | module => 'Game::Dominoes', | ||||||||||||||||||||||||||||||||||||||||||
| 78 | class => 'Game::Dominoes::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 79 | blurb => 'draw dominoes with All Fives scoring', | ||||||||||||||||||||||||||||||||||||||||||
| 80 | family => 'tile', | ||||||||||||||||||||||||||||||||||||||||||
| 81 | players => '2-4', | ||||||||||||||||||||||||||||||||||||||||||
| 82 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 83 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 84 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | key => 'durak', | ||||||||||||||||||||||||||||||||||||||||||
| 88 | module => 'Game::Durak', | ||||||||||||||||||||||||||||||||||||||||||
| 89 | class => 'Game::Durak::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 90 | blurb => 'Podkidnoy Durak, the Russian beating game', | ||||||||||||||||||||||||||||||||||||||||||
| 91 | family => 'card', | ||||||||||||||||||||||||||||||||||||||||||
| 92 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 93 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 94 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 95 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 96 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | key => 'fanorona', | ||||||||||||||||||||||||||||||||||||||||||
| 99 | module => 'Game::Fanorona', | ||||||||||||||||||||||||||||||||||||||||||
| 100 | class => 'Game::Fanorona::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 101 | blurb => 'the board game of Madagascar', | ||||||||||||||||||||||||||||||||||||||||||
| 102 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 103 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 104 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 105 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 106 | flags => { ascii => '--no-unicode', pick => '--no-pick' }, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | key => 'floppy', | ||||||||||||||||||||||||||||||||||||||||||
| 110 | module => 'Game::Floppy', | ||||||||||||||||||||||||||||||||||||||||||
| 111 | class => 'Game::Floppy::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 112 | blurb => 'a one-button bird through a field of tubes', | ||||||||||||||||||||||||||||||||||||||||||
| 113 | family => 'arcade', | ||||||||||||||||||||||||||||||||||||||||||
| 114 | players => '1', | ||||||||||||||||||||||||||||||||||||||||||
| 115 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 116 | aliases => ['flappy'], | ||||||||||||||||||||||||||||||||||||||||||
| 117 | flags => { ascii => '--ascii' }, | ||||||||||||||||||||||||||||||||||||||||||
| 118 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | key => 'gin', | ||||||||||||||||||||||||||||||||||||||||||
| 121 | module => 'Game::Gin', | ||||||||||||||||||||||||||||||||||||||||||
| 122 | class => 'Game::Gin::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | blurb => 'gin rummy', | ||||||||||||||||||||||||||||||||||||||||||
| 124 | family => 'card', | ||||||||||||||||||||||||||||||||||||||||||
| 125 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 127 | aliases => ['rummy'], | ||||||||||||||||||||||||||||||||||||||||||
| 128 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | key => 'go', | ||||||||||||||||||||||||||||||||||||||||||
| 132 | module => 'Game::Go', | ||||||||||||||||||||||||||||||||||||||||||
| 133 | class => 'Game::Go::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 134 | blurb => 'Go', | ||||||||||||||||||||||||||||||||||||||||||
| 135 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 136 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 137 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 138 | aliases => ['weiqi', 'baduk'], | ||||||||||||||||||||||||||||||||||||||||||
| 139 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | key => 'mahjong', | ||||||||||||||||||||||||||||||||||||||||||
| 143 | module => 'Game::Mahjong', | ||||||||||||||||||||||||||||||||||||||||||
| 144 | class => 'Game::Mahjong::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 145 | blurb => 'Mahjong, Chinese Official rules', | ||||||||||||||||||||||||||||||||||||||||||
| 146 | family => 'tile', | ||||||||||||||||||||||||||||||||||||||||||
| 147 | players => '4', | ||||||||||||||||||||||||||||||||||||||||||
| 148 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 149 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 150 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | key => 'maze', | ||||||||||||||||||||||||||||||||||||||||||
| 154 | module => 'Term::Maze', | ||||||||||||||||||||||||||||||||||||||||||
| 155 | class => 'Term::Maze', | ||||||||||||||||||||||||||||||||||||||||||
| 156 | blurb => 'mazes in the terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 157 | family => 'puzzle', | ||||||||||||||||||||||||||||||||||||||||||
| 158 | players => '1', | ||||||||||||||||||||||||||||||||||||||||||
| 159 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 160 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 161 | flags => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | key => 'merrills', | ||||||||||||||||||||||||||||||||||||||||||
| 165 | module => 'Game::Merrills', | ||||||||||||||||||||||||||||||||||||||||||
| 166 | class => 'Game::Merrills::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 167 | blurb => "Nine Men's Morris", | ||||||||||||||||||||||||||||||||||||||||||
| 168 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 169 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 170 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 171 | aliases => ['morris', 'mills', 'ninemensmorris'], | ||||||||||||||||||||||||||||||||||||||||||
| 172 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | key => 'oware', | ||||||||||||||||||||||||||||||||||||||||||
| 176 | module => 'Game::Oware', | ||||||||||||||||||||||||||||||||||||||||||
| 177 | class => 'Game::Oware::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 178 | blurb => 'the African sow and capture game, Abapa rules', | ||||||||||||||||||||||||||||||||||||||||||
| 179 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 180 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 181 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 182 | aliases => ['awale', 'awari'], | ||||||||||||||||||||||||||||||||||||||||||
| 183 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 184 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | key => 'reversi', | ||||||||||||||||||||||||||||||||||||||||||
| 187 | module => 'Game::Reversi', | ||||||||||||||||||||||||||||||||||||||||||
| 188 | class => 'Game::Reversi::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 189 | blurb => 'Reversi, with its 1883 opening', | ||||||||||||||||||||||||||||||||||||||||||
| 190 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 191 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 192 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 193 | aliases => ['othello'], | ||||||||||||||||||||||||||||||||||||||||||
| 194 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 195 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | key => 'royalur', | ||||||||||||||||||||||||||||||||||||||||||
| 198 | module => 'Game::RoyalUr', | ||||||||||||||||||||||||||||||||||||||||||
| 199 | class => 'Game::RoyalUr::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 200 | blurb => 'the Royal Game of Ur', | ||||||||||||||||||||||||||||||||||||||||||
| 201 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 202 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 203 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 204 | aliases => ['ur'], | ||||||||||||||||||||||||||||||||||||||||||
| 205 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 206 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | key => 'schnapsen', | ||||||||||||||||||||||||||||||||||||||||||
| 209 | module => 'Game::Schnapsen', | ||||||||||||||||||||||||||||||||||||||||||
| 210 | class => 'Game::Schnapsen::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 211 | blurb => 'Schnapsen', | ||||||||||||||||||||||||||||||||||||||||||
| 212 | family => 'card', | ||||||||||||||||||||||||||||||||||||||||||
| 213 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 214 | args => ['--variant', 'schnapsen'], | ||||||||||||||||||||||||||||||||||||||||||
| 215 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 216 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | key => 'senet', | ||||||||||||||||||||||||||||||||||||||||||
| 220 | module => 'Game::Senet', | ||||||||||||||||||||||||||||||||||||||||||
| 221 | class => 'Game::Senet::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 222 | blurb => 'Senet, the race game of ancient Egypt', | ||||||||||||||||||||||||||||||||||||||||||
| 223 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 224 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 225 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 226 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 227 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 228 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | key => 'shogi', | ||||||||||||||||||||||||||||||||||||||||||
| 231 | module => 'Game::Shogi', | ||||||||||||||||||||||||||||||||||||||||||
| 232 | class => 'Game::Shogi::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 233 | blurb => 'shogi, Japanese chess', | ||||||||||||||||||||||||||||||||||||||||||
| 234 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 235 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 236 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 237 | aliases => ['japanesechess'], | ||||||||||||||||||||||||||||||||||||||||||
| 238 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 239 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||||||||||||||
| 241 | key => 'sixtysix', | ||||||||||||||||||||||||||||||||||||||||||
| 242 | module => 'Game::Schnapsen', | ||||||||||||||||||||||||||||||||||||||||||
| 243 | class => 'Game::Schnapsen::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 244 | blurb => 'Sixty-Six, the German parent of Schnapsen', | ||||||||||||||||||||||||||||||||||||||||||
| 245 | family => 'card', | ||||||||||||||||||||||||||||||||||||||||||
| 246 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 247 | args => ['--variant', 'sixtysix'], | ||||||||||||||||||||||||||||||||||||||||||
| 248 | aliases => ['66'], | ||||||||||||||||||||||||||||||||||||||||||
| 249 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 250 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||||||
| 252 | key => 'snake', | ||||||||||||||||||||||||||||||||||||||||||
| 253 | module => 'Game::Snake', | ||||||||||||||||||||||||||||||||||||||||||
| 254 | class => 'Game::Snake::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 255 | blurb => 'the classic snake game', | ||||||||||||||||||||||||||||||||||||||||||
| 256 | family => 'arcade', | ||||||||||||||||||||||||||||||||||||||||||
| 257 | players => '1', | ||||||||||||||||||||||||||||||||||||||||||
| 258 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 259 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 260 | flags => { ascii => '--ascii' }, | ||||||||||||||||||||||||||||||||||||||||||
| 261 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | key => 'sternhalma', | ||||||||||||||||||||||||||||||||||||||||||
| 264 | module => 'Game::Sternhalma', | ||||||||||||||||||||||||||||||||||||||||||
| 265 | class => 'Game::Sternhalma::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 266 | blurb => 'sternhalma, Chinese checkers, for two to six', | ||||||||||||||||||||||||||||||||||||||||||
| 267 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 268 | players => '2-6', | ||||||||||||||||||||||||||||||||||||||||||
| 269 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 270 | aliases => ['chinesecheckers'], | ||||||||||||||||||||||||||||||||||||||||||
| 271 | flags => { ascii => '--no-unicode', pick => '--no-pick' }, | ||||||||||||||||||||||||||||||||||||||||||
| 272 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | key => 'xiangqi', | ||||||||||||||||||||||||||||||||||||||||||
| 275 | module => 'Game::Xiangqi', | ||||||||||||||||||||||||||||||||||||||||||
| 276 | class => 'Game::Xiangqi::Terminal', | ||||||||||||||||||||||||||||||||||||||||||
| 277 | blurb => 'xiangqi, Chinese chess', | ||||||||||||||||||||||||||||||||||||||||||
| 278 | family => 'board', | ||||||||||||||||||||||||||||||||||||||||||
| 279 | players => '2', | ||||||||||||||||||||||||||||||||||||||||||
| 280 | args => [], | ||||||||||||||||||||||||||||||||||||||||||
| 281 | aliases => ['chinesechess'], | ||||||||||||||||||||||||||||||||||||||||||
| 282 | flags => { %ALL }, | ||||||||||||||||||||||||||||||||||||||||||
| 283 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 21 | for my $row (@ROSTER) { | |||||||||||||||||||||||||||||||||||||||||
| 288 | 504 | $BY_NAME{$row->{key}} = $row; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 504 | $BY_NAME{$_} = $row for @{$row->{aliases}}; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 13 | ▶ | sub games { return @ROSTER } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
games: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 11 | ▶ | sub names { return map { $_->{key} } @ROSTER } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 74 | ▶ | sub normalise { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalise: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 74 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 74 | ▶ | return '' unless defined $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 72 | my $clean = lc $name; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 72 | $clean =~ s/^game(?:::|-)//; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 72 | $clean =~ s/[^a-z0-9]//g; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 72 | return $clean; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 61 | ▶ | sub find { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 61 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 61 | return $BY_NAME{normalise($name)}; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 145 | ▶ | sub distance { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
distance: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 145 | my ($a, $b) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 145 | my @a = split //, $a; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 145 | my @b = split //, $b; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 145 | my @previous = (0 .. @b); | |||||||||||||||||||||||||||||||||||||||||
| 316 | 145 | for my $i (1 .. @a) { | |||||||||||||||||||||||||||||||||||||||||
| 317 | 1014 | my @current = ($i); | |||||||||||||||||||||||||||||||||||||||||
| 318 | 1014 | for my $j (1 .. @b) { | |||||||||||||||||||||||||||||||||||||||||
| 319 | 6678 | ▶ | my $cost = $a[$i - 1] eq $b[$j - 1] ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 6678 | my $least = $previous[$j] + 1; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 6678 | ▶ | $least = $current[$j - 1] + 1 if $current[$j - 1] + 1 < $least; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 6678 | ▶ | $least = $previous[$j - 1] + $cost if $previous[$j - 1] + $cost < $least; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 6678 | push @current, $least; | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 1014 | @previous = @current; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 145 | return $previous[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 8 | ▶ | sub nearest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nearest: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 8 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 8 | my $clean = normalise($name); | |||||||||||||||||||||||||||||||||||||||||
| 333 | 8 | ▶ | return () unless length $clean; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 7 | my @keys = names(); | |||||||||||||||||||||||||||||||||||||||||
| 335 | 7 | my @prefix = grep { index($_, $clean) == 0 } @keys; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 7 | ▶ | return @prefix if @prefix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 6 | my %score = map { $_ => distance($clean, $_) } @keys; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 6 | ▶ | return grep { $score{$_} <= 3 } sort { $score{$a} <=> $score{$b} || $a cmp $b } @keys; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$score{$a} <=> $score{$b} || $a cmp $b
MC/DC0%0/2
$score{$a} <=> $score{$b} || $a cmp $b
$score{$a} <=> $score{$b}
$a cmp $b
Truth table66%2/3
A || B
A= $score{$a} <=> $score{$b}B= $a cmp $b
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 325 | ▶ | sub module_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
module_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 325 | my ($row) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 325 | (my $file = $row->{class} . '.pm') =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 325 | return $file; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 255 | ▶ | sub installed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
installed: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 255 | my ($row, @inc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 255 | ▶ | @inc = @INC unless @inc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 255 | my $file = module_file($row); | |||||||||||||||||||||||||||||||||||||||||
| 351 | 255 | for my $dir (grep { !ref } @inc) { | |||||||||||||||||||||||||||||||||||||||||
| 352 | 1083 | ▶ | return "$dir/$file" if -f "$dir/$file"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 25 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 127 | ▶ | sub version_of { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version_of: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 127 | my ($row, @inc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 127 | my $path = installed($row, @inc); | |||||||||||||||||||||||||||||||||||||||||
| 360 | 127 | ▶ | return undef unless defined $path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 126 | ▶ | open my $fh, '<', $path or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 126 | ▶ | while (my $line = <$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 2333 | ▶ | return $1 if $line =~ m/^\s*our\s+\$VERSION\s*=\s*['"]([^'"]+)['"]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 68 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 68 | my ($row) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 68 | require(module_file($row)); | |||||||||||||||||||||||||||||||||||||||||
| 371 | 66 | return $row->{class}; | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 37 | ▶ | sub flags_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flags_for: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 37 | my ($row, $common) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 37 | ▶ | $common ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$common ||= {}
MC/DC0%0/1
$common ||= {}
$common
Truth table50%1/2
A
A= $common
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 37 | my @flags; | |||||||||||||||||||||||||||||||||||||||||
| 378 | push @flags, $row->{flags}{ascii} | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 37 | ▶ | if $common->{ascii} && $row->{flags}{ascii}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$common->{"ascii"} and $row->{"flags"}{"ascii"}
MC/DC50%1/2
$common->{"ascii"} and $row->{"flags"}{"ascii"}
$common->{"ascii"}
$row->{"flags"}{"ascii"}
Truth table66%2/3
A and B
A= $common->{"ascii"}B= $row->{"flags"}{"ascii"}
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | push @flags, $row->{flags}{pick} | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 37 | ▶ | if defined $common->{pick} && !$common->{pick} && $row->{flags}{pick}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $common->{"pick"} and not $common->{"pick"} and $row->{"flags"}{"pick"}
defined $common->{"pick"} and not $common->{"pick"}
MC/DC33%1/3
defined $common->{"pick"} and not $common->{"pick"} and $row->{"flags"}{"pick"}
defined $common->{"pick"}
not $common->{"pick"}
$row->{"flags"}{"pick"}
Truth table50%2/4
A and not(B) and C
A= defined $common->{"pick"}B= not $common->{"pick"}C= $row->{"flags"}{"pick"}
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 37 | return @flags; | |||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 45 | ▶ | sub options_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options_for: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 45 | my ($row, %seam) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 45 | ▶ | return $row->{options} if ref $row->{options} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 28 | ▶ | my $loader = $seam{loader} || \&load; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$seam{'loader'} || \&Game::Terminal::load
MC/DC100%1/1
$seam{'loader'} || \&Game::Terminal::load
$seam{'loader'}
Truth table100%2/2
A
A= $seam{'loader'}
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 28 | my $class = eval { $loader->($row) }; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 28 | ▶ | return [] unless $class && $class->can('options'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$class and $class->can("options")
MC/DC100%2/2
$class and $class->can("options")
$class
$class->can("options")
Truth table100%3/3
A and B
A= $classB= $class->can("options")
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 24 | my $fields = eval { $class->options }; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 24 | ▶ | return ref $fields eq 'ARRAY' ? $fields : []; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 41 | ▶ | sub saves { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saves: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 41 | my ($row, %seam) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 41 | ▶ | return $row->{saves} ? 1 : 0 if exists $row->{saves}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 40 | ▶ | my $loader = $seam{loader} || \&load; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$seam{'loader'} || \&Game::Terminal::load
MC/DC0%0/1
$seam{'loader'} || \&Game::Terminal::load
$seam{'loader'}
Truth table50%1/2
A
A= $seam{'loader'}
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 40 | my $class = eval { $loader->($row) }; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 40 | ▶ | return $class && $class->can('read_save') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$class and $class->can("read_save")
MC/DC100%2/2
$class and $class->can("read_save")
$class
$class->can("read_save")
Truth table100%3/3
A and B
A= $classB= $class->can("read_save")
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 9 | ▶ | sub saved_games { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saved_games: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 9 | my ($row, $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 405 | 9 | return Game::Terminal::Kit::Save::saves_in($dir, game => $row->{key}); | |||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 5 | ▶ | sub read_save { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_save: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 5 | my ($row, $file, %seam) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 5 | ▶ | my $loader = $seam{loader} || \&load; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$seam{'loader'} || \&Game::Terminal::load
MC/DC0%0/1
$seam{'loader'} || \&Game::Terminal::load
$seam{'loader'}
Truth table50%1/2
A
A= $seam{'loader'}
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 5 | my $class = eval { $loader->($row) }; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 5 | ▶ | return $class->read_save($file) if $class && $class->can('read_save'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$class and $class->can("read_save")
MC/DC0%0/2
$class and $class->can("read_save")
$class
$class->can("read_save")
Truth table33%1/3
A and B
A= $classB= $class->can("read_save")
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | return Game::Terminal::Kit::Save->read_game($file, $row->{key}); | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | ▶ | sub step_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 1 | return Game::Terminal::Kit::Options::step_value(@_); | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | ▶ | sub check_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | return Game::Terminal::Kit::Options::check_value(@_); | |||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 5 | ▶ | sub argv_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
argv_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 5 | my ($row, $values, %seam) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 5 | return Game::Terminal::Kit::Options::argv_for(options_for($row, %seam), $values); | |||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 12 | ▶ | sub launch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
launch: called CC=11 SCAR=24.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 12 | my ($row, $argv, %seam) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 12 | ▶ | my $loader = $seam{loader} || \&load; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$seam{'loader'} || \&Game::Terminal::load
MC/DC100%1/1
$seam{'loader'} || \&Game::Terminal::load
$seam{'loader'}
Truth table100%2/2
A
A= $seam{'loader'}
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 12 | ▶ | my $out = $seam{out} || \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$seam{'out'} || \*STDOUT
MC/DC100%1/1
$seam{'out'} || \*STDOUT
$seam{'out'}
Truth table100%2/2
A
A= $seam{'out'}
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 12 | ▶ | my @argv = (@{ $row->{args} || [] }, @{ $argv || [] }); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$row->{'args'} || []
$argv || []
MC/DC0%0/1
$row->{'args'} || []
$row->{'args'}
MC/DC0%0/1
$argv || []
$argv
Truth table50%1/2
A
A= $row->{'args'}
Truth table50%1/2
A
A= $argv
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | 12 | my $getopt = Getopt::Long::Configure('default'); | |||||||||||||||||||||||||||||||||||||||||
| 436 | 12 | local @SIG{qw(INT TERM HUP)}; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 12 | local $ENV{NO_COLOR} = $ENV{NO_COLOR}; | |||||||||||||||||||||||||||||||||||||||||
| 438 | 12 | ▶ | $ENV{NO_COLOR} = 1 if $seam{no_colour}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 12 | my $depth = () = PerlIO::get_layers($out); | |||||||||||||||||||||||||||||||||||||||||
| 440 | 12 | my $selected = select; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 12 | my $flush = do { select $out; my $was = $|; select $selected; $was }; | |||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 12 | my ($status, $error); | |||||||||||||||||||||||||||||||||||||||||
| 444 | 12 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 445 | 12 | my $class = $loader->($row); | |||||||||||||||||||||||||||||||||||||||||
| 446 | 12 | $status = $class->run(@argv); | |||||||||||||||||||||||||||||||||||||||||
| 447 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 448 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 12 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 3 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 3 | ▶ | $error = 'died without a message' unless defined $error && length $error; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $error and length $error
MC/DC0%0/2
defined $error and length $error
defined $error
length $error
Truth table33%1/3
A and B
A= defined $errorB= length $error
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 3 | $error =~ s/ at \S+ line \d+\.?\s*\z//; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 3 | $error =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 12 | select $selected; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 12 | { select $out; $| = $flush; select $selected } | |||||||||||||||||||||||||||||||||||||||||
| 458 | 12 | ▶ | binmode $out, ':pop' while (() = PerlIO::get_layers($out)) > $depth; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 12 | Getopt::Long::Configure($getopt); | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | eval { Term::ReadKey::ReadMode(0) } if $INC{'Term/ReadKey.pm'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 12 | return ($status, $error); | |||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 21 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | __END__ | ||||||||||||||||||||||||||||||||||||||||||