blib/lib/Game/Shogi/Handicap.pm

filter: Statementstmt 100% 28 / 28 Branchbran 70.0% 7 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 6 / 6 totaltotal 91.5% 54 / 59 CC 8 SCAR 7.5
CC
8
Cov
90%
known
3.0
sfen
3.0
english
2.1
CRAP 2.1
« blib/lib/Game/Shogi/Move.pm ↑ Summary blib/arch/Game/Shogi/Install/Files.pm »
1 package Game::Shogi::Handicap;
2  
3 9 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 our $VERSION = '0.01';
9  
10 9 my @ORDER = qw(lance bishop rook rook_lance two four six eight nine ten);
11  
12 9 my %TABLE = (
13 lance => [ 'Lance', '香落ち', [qw(1a)] ],
14 bishop => [ 'Bishop', '角落ち', [qw(2b)] ],
15 rook => [ 'Rook', '飛車落ち', [qw(8b)] ],
16 rook_lance => [ 'Rook–Lance', '飛香落ち', [qw(8b 1a)] ],
17 two => [ '2-Piece', '二枚落ち', [qw(8b 2b)] ],
18 four => [ '4-Piece', '四枚落ち', [qw(8b 2b 9a 1a)] ],
19 six => [ '6-Piece', '六枚落ち', [qw(8b 2b 9a 1a 8a 2a)] ],
20 eight => [ '8-Piece', '八枚落ち', [qw(8b 2b 9a 1a 8a 2a 7a 3a)] ],
21 nine => [ '9-Piece', '九枚落ち', [qw(8b 2b 9a 1a 8a 2a 7a 3a 4a)] ],
22 ten => [ '10-Piece', '十枚落ち', [qw(8b 2b 9a 1a 8a 2a 7a 3a 4a 6a)] ],
23 );
24  
25 9 my $START = 'lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL';
26  
27 7 ▶sub names { @ORDER }
Subroutine names: called CC=1 SCAR=0.0
Pod documented
28 107 ▶sub known { defined $_[1] && exists $TABLE{ $_[1] } ? 1 : 0 }
Subroutine known: called CC=3 SCAR=11.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] && exists $TABLE{$_[1]} ? : 102 5 107
Condition66%2/3
defined $_[1] and exists $TABLE{$_[1]}
!ll&&!rl&&r
05102
MC/DC50%1/2
defined $_[1] and exists $TABLE{$_[1]}
defined $_[1] exists $TABLE{$_[1]}
Truth table66%2/3
A and B
A= defined $_[1]B= exists $TABLE{$_[1]}
ABresult
0X0
100
111
29 10 ▶sub english { $_[0]->known($_[1]) ? $TABLE{ $_[1] }[0] : undef }
Subroutine english: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->known($_[1]) ? : 10 0 10
30 10 ▶sub japanese { $_[0]->known($_[1]) ? $TABLE{ $_[1] }[1] : undef }
Subroutine japanese: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->known($_[1]) ? : 10 0 10
31 37 ▶sub removed { $_[0]->known($_[1]) ? @{ $TABLE{ $_[1] }[2] } : () }
Subroutine removed: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->known($_[1]) ? : 37 0 37
32  
33 28 ▶sub sfen {
Subroutine sfen: called CC=3 SCAR=11.0
Pod documented
34 28 my ($class, $name) = @_;
35 28 ▶ return undef unless $class->known($name);
Branch: 1 branch
BranchTrueFalseTotal
unless $class->known($name) 1 27 28
36 27 require Game::Shogi::Engine;
37 27 my $b = Game::Shogi::Engine->new(sfen => "$START w - 1");
38 27 $b->lift(Game::Shogi::Engine->square($_)) for $class->removed($name);
39 27 return $b->sfen;
40 }
41  
42 9 1;
43  
44 __END__
« blib/lib/Game/Shogi/Move.pm ↑ Summary blib/arch/Game/Shogi/Install/Files.pm »