lib/BalanceOfPower/Role/GameMaster.pm

filter: Statementstmt 82.5% 33 / 40 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 4 totaltotal 77.1% 44 / 57 CC 4 SCAR 4.6
CC
4
Cov
82%
add_player
2.0
get_player
2.0
delete_player
2.0
CRAP 1.6
« lib/BalanceOfPower/Role/Logger.pm ↑ Summary lib/BalanceOfPower/Role/Herald.pm »
1 package BalanceOfPower::Role::GameMaster;
2 11 $BalanceOfPower::Role::GameMaster::VERSION = '0.200000';
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use BalanceOfPower::Constants ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 has players => (
11 is => 'rw',
12 14 ▶ default => sub { [] }
Subroutine __ANON__: called CC=1 SCAR=0.0
13 11 );
14  
15 sub get_player
16 {
17 12 ▶ my $self = shift;
Subroutine get_player: called CC=2 SCAR=6.9
Pod undocumented
18 12 my $name = shift;
19 12 my @good = grep { $_->name eq $name} @{$self->players};
20 12 ▶ if(@good)
Branch: 1 branch
BranchTrueFalseTotal
if (@good) { } 11 1 12
21 {
22 11 return $good[0];
23 }
24 else
25 {
26 1 return undef;
27 }
28 }
29 sub add_player
30 {
31 1 ▶ my $self = shift;
Subroutine add_player: called CC=2 SCAR=7.1
Pod undocumented
32 1 my $player = shift;
33 1 ▶ if($self->get_player($player->name))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_player($player->name)) { } 0 1 1
34 {
35 0 return 0;
36 }
37 else
38 {
39 1 push @{$self->players}, $player;
40 1 return 1;
41 }
42 }
43 sub delete_player
44 {
45 0 ▶ my $self = shift;
Subroutine delete_player: not called CC=1 SCAR=6.9
Pod undocumented
46 0 my $player = shift;
47 0 my @players = grep { $_->name ne $player} @{$self->players};
48 0 $self->players(\@players);
49 }
50 sub player_current_year
51 {
52 40 ▶ my $self = shift;
Subroutine player_current_year: called CC=2 SCAR=6.9
Pod undocumented
53 40 for(@{$self->players})
54 {
55 5 $_->current_year($self->current_year);
56 }
57 }
58  
59 11 1;
« lib/BalanceOfPower/Role/Logger.pm ↑ Summary lib/BalanceOfPower/Role/Herald.pm »