EnergyLoop.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 12 / 12 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 100% 50 / 50 CC 11 SCAR 22.5
CC
11
Cov
100%
update
11.0
BEGIN
1.0
BEGIN
1.0
CRAP 9.5
« EnergyLoop/ConfigData.pm ↑ Summary
1 # -*- Perl -*-
2 #
3 # Game::EnergyLoop - a simple energy system
4  
5 package Game::EnergyLoop;
6 2 our $VERSION = '0.01';
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 ▶sub update {
Subroutine update: called CC=11 SCAR=24.0
Pod documented
11 6 my ($enlos, $initiative, $arg) = @_;
12 6 my $min = ~0;
13 6 for my $ent (@$enlos) {
14 9 my $energy = $ent->enlo_energy;
15 9 ▶ $min = $energy if $energy < $min;
Branch: 1 branch
BranchTrueFalseTotal
if $energy < $min 5 4 9
16 }
17 6 ▶ die "negative minimum energy $min" if $min < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $min < 0 1 5 6
18 5 my @active;
19 5 for my $ent (@$enlos) {
20 8 my $energy = $ent->enlo_energy;
21 8 $energy -= $min;
22 8 ▶ push @active, $ent if $energy == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $energy == 0 5 3 8
23 8 $ent->enlo_energy($energy);
24 }
25 5 ▶ $initiative->( \@active ) if defined $initiative and @active > 1;
Branch: 1 branch
BranchTrueFalseTotal
if defined $initiative and @active > 1 1 4 5
Condition100%3/3
defined $initiative and @active > 1
!ll&&!rl&&r
311
MC/DC100%2/2
defined $initiative and @active > 1
defined $initiative @active > 1
Truth table100%3/3
A and B
A= defined $initiativeB= @active > 1
ABresult
0X0
100
111
26 5 my @newbies;
27 5 for my $ent (@active) {
28 5 my ( $new_energy, $noobs ) = $ent->enlo_update( $min, $arg );
29 5 ▶ die "negative entity new_energy $new_energy" if $new_energy < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $new_energy < 0 1 4 5
30 4 $ent->enlo_energy($new_energy);
31 4 ▶ push @newbies, @$noobs if defined $noobs;
Branch: 1 branch
BranchTrueFalseTotal
if defined $noobs 1 3 4
32 }
33 4 push @$enlos, @newbies;
34 4 return $min;
35 }
36  
37 # TODO may need a return flag to indicate whether game is blocked? but
38 # if that's important the caller could set a flag in their world object
39 # and check for that...
40  
41 2 1;
42 __END__
« EnergyLoop/ConfigData.pm ↑ Summary