blib/lib/BalanceOfPower/Relations/MilitarySupport.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 45 CC 2 SCAR 10.6
CC
2
Cov
0%
casualities
6.0
bidirectional
2.0
print
2.0
CRAP 2.9
1 package BalanceOfPower::Relations::MilitarySupport;
2 $BalanceOfPower::Relations::MilitarySupport::VERSION = '0.200000';
3 use strict;
4 use v5.10;
5  
6 use Moo;
7  
8 with 'BalanceOfPower::Relations::Role::Relation';
9  
10 has army => (
11 is => 'rw',
12 default => 0
13 );
14  
15  
16 sub bidirectional
17 {
18 return 0;
19 }
20  
21 sub casualities
22 {
23 my $self = shift;
24 my $casualities = shift;
25 $self->army($self->army - $casualities);
26 $self->army(0) if($self->army < 0);
27 }
28  
29 sub print
30 {
31 my $self = shift;
32 return $self->node1 . " --> " . $self->node2 . " [" . $self->army . "]";
33 }
34 sub dump
35 {
36 my $self = shift;
37 my $io = shift;
38 my $indent = shift;
39 print {$io} $indent . join(";", $self->node1, $self->node2, $self->army) . "\n";
40 }
41 sub load
42 {
43 my $self = shift;
44 my $data = shift;
45 $data =~ s/^\s+//;
46 chomp $data;
47 my ($node1, $node2, $army) = split ";", $data;
48 return $self->new(node1 => $node1, node2 => $node2, army => $army);
49 }
50  
51  
52  
53  
54 1;