line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Relations::MilitarySupport; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Relations::MilitarySupport::VERSION = '0.400110'; |
3
|
13
|
|
|
13
|
|
42
|
use strict; |
|
13
|
|
|
|
|
16
|
|
|
13
|
|
|
|
|
275
|
|
4
|
13
|
|
|
13
|
|
84
|
use v5.10; |
|
13
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
36
|
use Moo; |
|
13
|
|
|
|
|
15
|
|
|
13
|
|
|
|
|
52
|
|
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
|
114
|
|
|
114
|
0
|
208
|
return 0; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub casualities |
22
|
|
|
|
|
|
|
{ |
23
|
2
|
|
|
2
|
0
|
1
|
my $self = shift; |
24
|
2
|
|
|
|
|
3
|
my $casualities = shift; |
25
|
2
|
|
|
|
|
4
|
$self->army($self->army - $casualities); |
26
|
2
|
50
|
|
|
|
13
|
$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; |