blib/lib/Term/Maze.pm

filter: Statementstmt 48.3% 15 / 31 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 46.6% 21 / 45 CC 5 SCAR 22.6
CC
5
Cov
41%
run
20.0
refresh
6.0
BEGIN
1.0
CRAP 9.6
↑ Summary blib/lib/aze.pm »
1 package Term::Maze;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Term::ReadKey;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 our $VERSION = '0.04';
8  
9 1 require XSLoader;
10 1 XSLoader::load('Term::Maze', $VERSION);
11  
12 0 ▶sub run {
Subroutine run: not called CC=4 SCAR=30.0
Pod documented
13 0 my ($self, $width, $height) = @_;
14 0 ReadMode("cbreak");
15 0 my $maze = Term::Maze->new($width, $height);
16 0 $maze->refresh();
17 0 ▶ while (!$maze->at_exit) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($maze->at_exit) 0 0 0
18 0 my $key = ReadKey(0);
19 0 ▶ next unless defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 0 0 0
20 0 ▶ if ($key =~ m/^[wasdhjkl]$/){
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^[wasdhjkl]$/) 0 0 0
21 0 $maze->move_player($key);
22 }
23 0 $maze->refresh();
24 }
25 0 print "You win!\n";
26 }
27  
28 0 ▶sub refresh {
Subroutine refresh: not called CC=2 SCAR=17.9
Pod documented
29 0 my ($self) = @_;
30 0 print "\e[H\e[2J";
31 0 my $rows = $self->get_maze_with_player();
32 0 print "$_\n" for @$rows;
33 0 print "Use WASD or HJKL to move. Reach the exit to win.\n";
34 }
35  
36 1 1;
37  
38 __END__
↑ Summary blib/lib/aze.pm »