bin/fanorona

filter: Statementstmt 100% 49 / 49 Branchbran 85.7% 24 / 28 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 93.6% 88 / 94 CC 1 SCAR 0.0
CC
1
Cov
94%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« fn_search.c ↑ Summary fn_engine.c »
1 #!perl
2  
3 13 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 13 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Game::Fanorona;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use Game::Fanorona::Terminal;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 my %given;
12 13 my $parsed = Getopt::Long::GetOptionsFromArray(
13 \@ARGV, \%given,
14 'level=i', 'side=s', 'variant=s', 'load=s',
15 'colour|color!', 'pick!', 'unicode!', 'version', 'help',
16 );
17  
18 13 ▶if (!$parsed || @ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $parsed or @ARGV) 2 11 13
Condition100%3/3
not $parsed or @ARGV
l!l&&r!l&&!r
1111
MC/DC100%2/2
not $parsed or @ARGV
not $parsed @ARGV
Truth table100%3/3
not(A) or B
A= not $parsedB= @ARGV
ABresult
1X1
011
000
19 2 ▶ print STDERR "fanorona: I do not know '@ARGV'.\n" if $parsed && @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
if $parsed and @ARGV 1 1 2
Condition66%2/3
$parsed and @ARGV
!ll&&!rl&&r
101
MC/DC50%1/2
$parsed and @ARGV
$parsed @ARGV
Truth table66%2/3
A and B
A= $parsedB= @ARGV
ABresult
0X0
100
111
20 2 print STDERR usage();
21 2 exit 2;
22 }
23 11 ▶if ($given{help}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($given{"help"}) 1 10 11
24 1 print usage();
25 1 exit 0;
26 }
27 10 ▶if ($given{version}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($given{"version"}) 1 9 10
28 1 print "fanorona $Game::Fanorona::VERSION\n";
29 1 exit 0;
30 }
31  
32 9 my %with;
33 9 ▶$with{level} = $given{level} if defined $given{level};
Branch: 1 branch
BranchTrueFalseTotal
if defined $given{"level"} 2 7 9
34 9 ▶$with{human} = $given{side} if defined $given{side};
Branch: 1 branch
BranchTrueFalseTotal
if defined $given{"side"} 6 3 9
35 9 ▶$with{variant} = $given{variant} if defined $given{variant};
Branch: 1 branch
BranchTrueFalseTotal
if defined $given{"variant"} 3 6 9
36 9 ▶$with{colour} = $given{colour} if defined $given{colour};
Branch: 1 branch
BranchTrueFalseTotal
if defined $given{"colour"} 0 9 9
37 9 ▶$with{picking} = $given{pick} if defined $given{pick};
Branch: 1 branch
BranchTrueFalseTotal
if defined $given{"pick"} 0 9 9
38 9 ▶$with{unicode} = $given{unicode} if defined $given{unicode};
Branch: 1 branch
BranchTrueFalseTotal
if defined $given{"unicode"} 0 9 9
39 9 ▶$with{menu} = 1 unless grep { defined $given{$_} } qw(side level variant load);
Branch: 1 branch
BranchTrueFalseTotal
unless grep {defined $given{$_};} "side", "level", "variant", "load" 0 9 9
40  
41 9 my $terminal = eval { Game::Fanorona::Terminal->new(%with) };
42 9 ▶if (!$terminal) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($terminal) 3 6 9
43 3 (my $why = $@) =~ s/ at \S+ line \d+\.?\s*\z//;
44 3 $why =~ s/\AGame::Fanorona(?:::\w+)*: //;
45 3 print STDERR "fanorona: $why.\n";
46 3 exit 2;
47 }
48  
49 6 ▶if (defined $given{load}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $given{"load"}) 2 4 6
50 2 ▶ exit 2 unless $terminal->load($given{load});
Branch: 1 branch
BranchTrueFalseTotal
unless $terminal->load($given{"load"}) 1 1 2
51 }
52  
53 5 exit $terminal->start;
54  
55 3 ▶sub usage {
Subroutine usage: called CC=1 SCAR=0.0
56 3 return <<'USAGE';
57 fanorona - the board game of Madagascar, in a terminal
58  
59 fanorona [options]
60  
61 --side WHO white (the default, and White moves first), black, both, or neither
62 --level N how hard the program plays: 1 to 5, 3 by default
63 --variant NAME the board: sivy (nine by five, the default), dimy or telo
64 --load FILE carry on with a saved game
65 --no-colour letters and lines instead of a painted board
66 --no-pick type moves instead of choosing them with the arrow keys
67 --no-unicode letters for the stones, with colour kept
68 --version the version, and stop
69 --help this, and stop
70  
71 In a terminal, moves are chosen on the board with the arrow keys; press ? for
72 the keys. Anywhere else, type a move as the points the stone stands on, like
73 d2-e3A, or help.
74 USAGE
75 }
76  
77 __END__
« fn_search.c ↑ Summary fn_engine.c »