File Coverage

lib/BalanceOfPower/Relations/MilitarySupport.pm
Criterion Covered Total %
statement 13 26 50.0
branch 1 2 50.0
condition n/a
subroutine 5 8 62.5
pod 0 5 0.0
total 19 41 46.3


line stmt bran cond sub pod time code
1             package BalanceOfPower::Relations::MilitarySupport;
2             $BalanceOfPower::Relations::MilitarySupport::VERSION = '0.400115';
3 13     13   58 use strict;
  13         28  
  13         343  
4 13     13   110 use v5.10;
  13         35  
5              
6 13     13   63 use Moo;
  13         30  
  13         76  
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 123     123 0 305 return 0;
19             }
20              
21             sub casualities
22             {
23 2     2 0 3 my $self = shift;
24 2         2 my $casualities = shift;
25 2         5 $self->army($self->army - $casualities);
26 2 50       7 $self->army(0) if($self->army < 0);
27             }
28              
29             sub print
30             {
31 0     0 0   my $self = shift;
32 0           return $self->node1 . " --> " . $self->node2 . " [" . $self->army . "]";
33             }
34             sub dump
35             {
36 0     0 0   my $self = shift;
37 0           my $io = shift;
38 0           my $indent = shift;
39 0           print {$io} $indent . join(";", $self->node1, $self->node2, $self->army) . "\n";
  0            
40             }
41             sub load
42             {
43 0     0 0   my $self = shift;
44 0           my $data = shift;
45 0           $data =~ s/^\s+//;
46 0           chomp $data;
47 0           my ($node1, $node2, $army) = split ";", $data;
48 0           return $self->new(node1 => $node1, node2 => $node2, army => $army);
49             }
50              
51              
52              
53              
54             1;