lib/BalanceOfPower/Relations/War.pm

filter: Statementstmt 40.8% 29 / 71 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 6 / 12 Podpod 0.0% 0 / 6 totaltotal 33.0% 35 / 106 CC 9 SCAR 31.0
CC
9
Cov
33%
output
56.0
dump
12.0
bidirectional
2.0
CRAP 22.1
« lib/BalanceOfPower/Role/Ruler.pm ↑ Summary lib/BalanceOfPower/Dice.pm »
1 package BalanceOfPower::Relations::War;
2 11 $BalanceOfPower::Relations::War::VERSION = '0.300010';
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;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use BalanceOfPower::Utils qw( from_to_turns as_html_evidenced );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use HTML::Entities;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 with 'BalanceOfPower::Relations::Role::Relation';
12 11 with 'BalanceOfPower::Role::Reporter';
13  
14 11 has attack_leader => (
15 is => 'rw',
16 default => ""
17 );
18 11 has war_id => (
19 is => 'rw',
20 default => ""
21 );
22 11 has name => (
23 is => 'rw',
24 default => "WAR"
25 );
26 11 has node1_faction => (
27 is => 'rw',
28 default => ""
29 );
30 11 has node2_faction => (
31 is => 'rw',
32 default => ""
33 );
34 11 has start_date => (
35 is => 'ro',
36 default => ""
37 );
38 11 has end_date => (
39 is => 'rw',
40 default => ""
41 );
42 11 has current_year => (
43 is => 'rw',
44 default => ""
45 );
46  
47  
48 sub bidirectional
49 {
50 0 ▶ return 0;
Subroutine bidirectional: not called CC=1 SCAR=6.9
Pod undocumented
51 }
52  
53 sub print
54 {
55 0 ▶ my $self = shift;
Subroutine print: not called CC=1 SCAR=6.9
Pod undocumented
56 0 my $army_node1 = shift;
57 0 my $army_node2 = shift;
58 0 return $self->output($army_node1, $army_node2, 'print');
59 }
60 sub html
61 {
62 0 ▶ my $self = shift;
Subroutine html: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my $army_node1 = shift;
64 0 my $army_node2 = shift;
65 0 return $self->output($army_node1, $army_node2, 'html');
66 }
67  
68  
69  
70 sub output
71 {
72 0 ▶ my $self = shift;
Subroutine output: not called CC=7 SCAR=40.3
Pod undocumented
73 0 my $army_node1 = shift;
74 0 my $army_node2 = shift;
75 0 my $mode = shift;
76 0 ▶ my $army_node1_label = $army_node1 ? "[".$army_node1."] " : "";
Branch: 1 branch
BranchTrueFalseTotal
$army_node1 ? : 0 0 0
77 0 ▶ my $army_node2_label = $army_node2 ? " [".$army_node2."]" : "";
Branch: 1 branch
BranchTrueFalseTotal
$army_node2 ? : 0 0 0
78 0 my $node1 = $army_node1_label . $self->node1;
79 0 my $node2 = $self->node2 . $army_node2_label;
80 0 ▶ if($mode eq 'print')
Branch: 2 branches
BranchTrueFalseTotal
if ($mode eq 'print') { } 0 0 0
elsif ($mode eq 'html') { } 0 0 0
81 {
82 0 ▶ if($self->node1_faction == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->node1_faction == 0) { } 0 0 0
83 {
84 0 $node1 = color("bold") . $node1 . color("reset");
85 }
86 else
87 {
88 0 $node2 = color("bold") . $node2 . color("reset");
89 }
90 0 return $node1 . " -> " . $node2;
91 }
92 elsif($mode eq 'html')
93 {
94 0 ▶ if($self->node1_faction == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->node1_faction == 0) { } 0 0 0
95 {
96 0 $node1 = as_html_evidenced($node1);
97 }
98 else
99 {
100 0 $node2 = as_html_evidenced($node2);
101 }
102 0 return $node1 . " -> " . $node2;
103 }
104
105
106
107 }
108 sub dump
109 {
110 0 ▶ my $self = shift;
Subroutine dump: not called CC=3 SCAR=24.8
Pod undocumented
111 0 my $io = shift;
112 0 ▶ my $indent = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
113 0 print {$io} $indent . join(";", $self->node1, $self->node2, $self->attack_leader,
114 $self->war_id, $self->name, $self->node1_faction, $self->node2_faction,
115 $self->start_date, $self->end_date, $self->current_year ). "\n";
116 0 ▶ if($self->events)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->events) 0 0 0
117 {
118 0 $self->dump_events($io, $indent . " ");
119 }
120 }
121 sub load
122 {
123 0 ▶ my $self = shift;
Subroutine load: not called CC=1 SCAR=6.9
Pod undocumented
124 0 my $data = shift;
125 0 my $war_line = ( split /\n/, $data )[0];
126 0 $war_line =~ s/^\s+//;
127 0 chomp $war_line;
128 0 my ($node1, $node2, $attack_leader, $war_id, $name, $node1_faction, $node2_faction, $start_date, $end_date, $current_year) = split ";", $war_line;
129 0 $data =~ s/^.*?\n//;
130 0 my $events = $self->load_events($data);
131 0 return $self->new(node1 => $node1, node2 => $node2,
132 attack_leader => $attack_leader,
133 war_id => $war_id, name => $name,
134 node1_faction => $node1_faction, node2_faction => $node2_faction,
135 start_date => $start_date, end_date => $end_date, current_year => $current_year,
136 events => $events);
137 }
138  
139  
140  
141 11 1;
« lib/BalanceOfPower/Role/Ruler.pm ↑ Summary lib/BalanceOfPower/Dice.pm »