PangZero/DeathBall.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 59 CC 7 SCAR 20.6
CC
7
Cov
0%
NormalAdvance
12.0
Pop
12.0
SpawnChildren
6.0
CRAP 7.8
1 ##########################################################################
2 package Games::PangZero::DeathBall;
3 ##########################################################################
4  
5 @ISA = qw(Games::PangZero::Ball);
6 use strict;
7 use warnings;
8  
9 sub new {
10 my $class = shift;
11 my $self = Games::PangZero::Ball->new(@_);
12 $self->{expires} = 2000; # 20sec
13 $self->{speedX} *= 0.9;
14 bless $self, $class;
15 }
16  
17 sub NormalAdvance {
18 my $self = shift;
19  
20 $self->SUPER::NormalAdvance();
21 if (--$self->{expires} < 0) {
22 $self->{bonus} = 1 if $self->{hasmagic};
23 $self->Pop(undef, 'expire');
24 }
25  
26 }
27  
28 sub Pop {
29 my ($self, $guy, $popEffect) = @_;
30
31 $self->{dontspawn} = 1 if $popEffect eq 'expire' or $popEffect eq 'superkill';
32 $self->SUPER::Pop($guy, $popEffect);
33 if (CountDeathBalls() > 30) {
34 $Games::PangZero::GameEvents{'meltdown'} = 1;
35 }
36 }
37  
38 sub SpawnChildren {
39 my $self = shift;
40  
41 return if $self->{dontspawn};
42 $self->SUPER::SpawnChildren(@_);
43 }
44  
45 sub CountDeathBalls {
46 my $count = 0;
47  
48 foreach my $ball (@Games::PangZero::GameObjects) {
49 if (ref($ball) eq 'Games::PangZero::DeathBall') { ++$count; }
50 }
51 return $count;
52 }
53  
54 1;