lib/BalanceOfPower/Role/Diplomat.pm

filter: Statementstmt 12.5% 32 / 255 Branchbran 0.0% 0 / 44 Conditioncond 0.0% 0 / 48 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 19.5% 8 / 41 Podpod 0.0% 0 / 30 totaltotal 9.0% 40 / 442 CC 51 SCAR 34.2
CC
51
Cov
9%
print_treaties
132.0
get_hates
56.0
change_diplomacy
42.0
CRAP 30.6
« lib/BalanceOfPower/Relations/Role/Relation.pm ↑ Summary blib/lib/BalanceOfPower/Commands/BuildTroops.pm »
1 package BalanceOfPower::Role::Diplomat;
2 11 $BalanceOfPower::Role::Diplomat::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 11 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 ▶use BalanceOfPower::Constants ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 11 ▶use BalanceOfPower::Relations::Friendship;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶use BalanceOfPower::Relations::Treaty;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 11 ▶use BalanceOfPower::Relations::RelPack;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 11 ▶use BalanceOfPower::Utils qw( as_main_title as_html_box br);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 has diplomatic_relations => (
15 is => 'ro',
16 0 ▶ default => sub { BalanceOfPower::Relations::RelPack->new() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 11 handles => { add_diplomacy => 'add_link',
18 _diplomacy_exists => 'exists_link',
19 update_diplomacy => 'update_link',
20 get_diplomatic_relations => 'links_for_node' }
21 );
22 has treaties => (
23 is => 'ro',
24 0 ▶ default => sub { BalanceOfPower::Relations::RelPack->new() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 11 handles => { add_treaty => 'add_link',
26 exists_treaty => 'exists_link',
27 get_treaties_for_nation => 'links_for_node',
28 reset_treaties => 'delete_link_for_node',
29 delete_treaty => 'delete_link', }
30 );
31  
32 11 requires 'random';
33 11 requires 'distance';
34 11 requires 'border_exists';
35 11 requires 'broadcast_event';
36 11 requires 'is_under_influence';
37  
38 sub init_diplomacy
39 {
40 0 ▶ my $self = shift;
Subroutine init_diplomacy: not called CC=5 SCAR=34.0
Pod undocumented
41 0 my @nations = @{$self->nation_names};
42 0 foreach my $n1 (@nations)
43 {
44 0 foreach my $n2 (@nations)
45 {
46 0 ▶ if($n1 ne $n2 && ! $self->_diplomacy_exists($n1, $n2))
Branch: 1 branch
BranchTrueFalseTotal
if ($n1 ne $n2 and not $self->_diplomacy_exists($n1, $n2)) 0 0 0
Condition0%0/3
$n1 ne $n2 and not $self->_diplomacy_exists($n1, $n2)
!ll&&!rl&&r
000
MC/DC0%0/2
$n1 ne $n2 and not $self->_diplomacy_exists($n1, $n2)
$n1 ne $n2 not $self->_diplomacy_exists($n1, $n2)
Truth table0%0/3
A and not(B)
A= $n1 ne $n2B= not $self->_diplomacy_exists($n1, $n2)
ABresult
0X0
100
111
47 {
48 0 my $minimum_friendship = 0;
49 0 my $rel = BalanceOfPower::Relations::Friendship->new( node1 => $n1,
50 node2 => $n2,
51 factor => $self->calculate_random_friendship($n1, $n2));
52 0 $self->add_diplomacy($rel);
53 }
54 }
55 }
56 }
57  
58 #Random friendship is function of the distance
59 sub calculate_random_friendship
60 {
61 0 ▶ my $self = shift;
Subroutine calculate_random_friendship: not called CC=3 SCAR=24.8
Pod undocumented
62 0 my $nation1 = shift;
63 0 my $nation2 = shift;
64 0 my $distance = $self->distance($nation1, $nation2);
65 0 ▶ $distance = 3 if $distance > 3;
Branch: 1 branch
BranchTrueFalseTotal
if $distance > 3 0 0 0
66  
67 0 my $middle = 50;
68  
69 0 my $polar_factor = ( 4 - $distance ) * 5;
70 0 my $random_floor = ( ( 3 - $distance ) * 5 ) + 25;
71  
72 0 my $side = $self->random(0, 1, "Side for friendship between $nation1 and $nation2");
73 0 ▶ $side = $side == 0 ? -1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$side == 0 ? : 0 0 0
74 0 my $random_factor = $self->random(0, $random_floor, "Random factor for friendship between $nation1 and $nation2 [floor: $random_floor]");
75  
76 0 my $friendship = $middle + ( $side * ( $polar_factor + $random_factor ) );
77 0 return $friendship;
78 }
79  
80  
81 sub init_random_alliances
82 {
83 0 ▶ my $self = shift;
Subroutine init_random_alliances: not called CC=3 SCAR=24.8
Pod undocumented
84 0 my @nations = @{$self->nation_names};
85 0 ▶ for(my $i = 0; $i < STARTING_ALLIANCES; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 7) 0 0 0
86 {
87 0 my $n1 = $nations[$self->random(0, $#nations, "Nation1 for random alliance")];
88 0 my $n2 = $nations[$self->random(0, $#nations, "Nation2 for random alliance")];
89 0 ▶ if($n1 ne $n2)
Branch: 1 branch
BranchTrueFalseTotal
if ($n1 ne $n2) 0 0 0
90 {
91 0 $self->add_alliance($n1, $n2);
92 0 $self->broadcast_event("ALLIANCE BETWEEN $n1 AND $n2 CREATED", $n1, $n2);
93 }
94 }
95 }
96 sub reroll_diplomacy
97 {
98 0 ▶ my $self = shift;
Subroutine reroll_diplomacy: not called CC=2 SCAR=17.9
Pod undocumented
99 0 my $nation = shift;
100 0 my @rels = $self->get_diplomatic_relations($nation);
101 0 for(@rels)
102 {
103 0 $_->factor($self->random(0 ,100, "Reroll diplomacy for " . $_->node1 . ", " . $_->node2));
104 }
105 }
106  
107 sub diplomacy_exists
108 {
109 0 ▶ my $self = shift;
Subroutine diplomacy_exists: not called CC=2 SCAR=17.9
Pod undocumented
110 0 my $n1 = shift;
111 0 my $n2 = shift;
112 0 my $r = $self->_diplomacy_exists($n1, $n2);
113 0 ▶ if(! defined $r)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $r) 0 0 0
114 {
115 0 say "ERROR! No diplomacy between $n1, $n2";
116 }
117 0 return $r;
118 }
119  
120 sub get_hates
121 {
122 0 ▶ my $self = shift;
Subroutine get_hates: not called CC=7 SCAR=40.3
Pod undocumented
123 0 my $nation = shift;
124 0 ▶ my @hates = $self->diplomatic_relations->query( sub { my $rel = shift; return $rel->status eq 'HATE' });
Subroutine __ANON__: not called CC=1 SCAR=6.9
125 0 my @out = ();
126 0 foreach my $r (@hates)
127 {
128 0 ▶ if(($nation && $r->has_node($nation)) || (! $nation))
Branch: 1 branch
BranchTrueFalseTotal
if ($nation and $r->has_node($nation) or not $nation) 0 0 0
Condition0%0/6
$nation and $r->has_node($nation) or not $nation
l!l&&r!l&&!r
000
$nation and $r->has_node($nation)
!ll&&!rl&&r
000
MC/DC0%0/3
$nation and $r->has_node($nation) or not $nation
$nation $r->has_node($nation) not $nation
Truth table0%0/5
A and B or not(C)
A= $nationB= $r->has_node($nation)C= not $nation
ABCresult
11X1
0X11
1011
0X00
1000
129 {
130 0 ▶ if(! $self->is_under_influence($r->node1) && ! $self->is_under_influence($r->node2))
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_under_influence($r->node1) or $self->is_under_influence($r->node2)) 0 0 0
Condition0%0/3
$self->is_under_influence($r->node1) or $self->is_under_influence($r->node2)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->is_under_influence($r->node1) or $self->is_under_influence($r->node2)
$self->is_under_influence($r->node1) $self->is_under_influence($r->node2)
Truth table0%0/3
A or B
A= $self->is_under_influence($r->node1)B= $self->is_under_influence($r->node2)
ABresult
1X1
011
000
131 {
132 0 push @out, $r;
133 }
134 }
135 }
136 0 return @out;
137 }
138 sub get_nations_with_status
139 {
140 0 ▶ my $self = shift;
Subroutine get_nations_with_status: not called CC=3 SCAR=24.8
Pod undocumented
141 0 my $nation = shift;
142 0 my $status = shift;
143 0 my @st_array = @{$status};
144 0 my @relations = $self->get_diplomatic_relations($nation);
145 0 my @out = ();
146 0 for(@relations)
147 {
148 0 my $r = $_;
149 0 ▶ if(grep{ $_ eq $r->status } @st_array)
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $r->status;} @st_array) 0 0 0
150 {
151 0 push @out, $r->destination($nation);
152 }
153 }
154 0 return @out;
155 }
156  
157 sub get_friends
158 {
159 0 ▶ my $self = shift;
Subroutine get_friends: not called CC=1 SCAR=6.9
Pod undocumented
160 0 my $nation = shift;
161 0 return $self->get_nations_with_status($nation, ['FRIENDSHIP', 'ALLIANCE', 'INFLUENCE PRESENT']);
162 }
163 sub set_diplomacy
164 {
165 0 ▶ my $self = shift;
Subroutine set_diplomacy: not called CC=2 SCAR=17.9
Pod undocumented
166 0 my $node1 = shift;
167 0 my $node2 = shift;
168 0 my $new_factor = shift;
169 0 my $r = $self->diplomacy_exists($node1, $node2);
170 0 ▶ return undef if(!$r ); #Should never happen
Branch: 1 branch
BranchTrueFalseTotal
unless $r 0 0 0
171 0 $r->factor($new_factor);
172 0 return $r;
173 }
174 sub copy_diplomacy
175 {
176 0 ▶ my $self = shift;
Subroutine copy_diplomacy: not called CC=3 SCAR=24.8
Pod undocumented
177 0 my $nation_from = shift;
178 0 my $nation_to = shift;
179 0 my @relations = $self->get_diplomatic_relations($nation_from);
180 0 for(@relations)
181 {
182 0 my $r = $_;
183 0 my $other = $r->destination($nation_from);
184 0 ▶ if($other ne $nation_to)
Branch: 1 branch
BranchTrueFalseTotal
if ($other ne $nation_to) 0 0 0
185 {
186 0 $self->set_diplomacy($nation_to, $other, $r->factor);
187 }
188 }
189  
190  
191 }
192  
193 sub change_diplomacy
194 {
195 0 ▶ my $self = shift;
Subroutine change_diplomacy: not called CC=6 SCAR=37.4
Pod undocumented
196 0 my $node1 = shift;
197 0 my $node2 = shift;
198 0 my $dipl = shift;
199 0 my $r = $self->diplomacy_exists($node1, $node2);
200 0 ▶ return if(!$r ); #Should never happen
Branch: 1 branch
BranchTrueFalseTotal
unless $r 0 0 0
201 0 ▶ return if $r->status eq 'ALLIANCE' || $r->status eq 'INFLUENCE PRESENT';
Branch: 1 branch
BranchTrueFalseTotal
if $r->status eq "ALLIANCE" or $r->status eq "INFLUENCE PRESENT" 0 0 0
Condition0%0/3
$r->status eq "ALLIANCE" or $r->status eq "INFLUENCE PRESENT"
l!l&&r!l&&!r
000
MC/DC0%0/2
$r->status eq "ALLIANCE" or $r->status eq "INFLUENCE PRESENT"
$r->status eq "ALLIANCE" $r->status eq "INFLUENCE PRESENT"
Truth table0%0/3
A or B
A= $r->status eq "ALLIANCE"B= $r->status eq "INFLUENCE PRESENT"
ABresult
1X1
011
000
202 0 my $present_status = $r->status;
203 0 $r->change_factor($dipl);
204 0 my $actual_status = $r->status;
205 0 ▶ if($present_status ne $actual_status)
Branch: 1 branch
BranchTrueFalseTotal
if ($present_status ne $actual_status) 0 0 0
206 {
207 0 $self->broadcast_event("RELATION BETWEEN $node1 AND $node2 CHANGED FROM $present_status TO $actual_status", $node1, $node2);
208 0 ▶ if($actual_status eq 'HATE')
Branch: 1 branch
BranchTrueFalseTotal
if ($actual_status eq "HATE") 0 0 0
209 {
210 0 $self->diplomatic_breakdown($node1, $node2);
211 }
212 }
213 }
214 sub diplomacy_status
215 {
216 0 ▶ my $self = shift;
Subroutine diplomacy_status: not called CC=1 SCAR=6.9
Pod undocumented
217 0 my $n1 = shift;
218 0 my $n2 = shift;
219 0 my $r = $self->diplomacy_exists($n1, $n2);
220 0 return $r->status;
221 }
222  
223 sub diplomatic_breakdown
224 {
225 0 ▶ my $self = shift;
Subroutine diplomatic_breakdown: not called CC=2 SCAR=17.9
Pod undocumented
226 0 my $n1 = shift;
227 0 my $n2 = shift;
228 0 my $treaty = $self->exists_treaty($n1, $n2);
229 0 ▶ if($treaty)
Branch: 1 branch
BranchTrueFalseTotal
if ($treaty) 0 0 0
230 {
231 0 $self->broadcast_event($treaty->short_tag . " TREATY BETWEEN $n1 AND $n2 BROKEN", $n1, $n2);
232 }
233 0 $self->stop_military_support($self->get_nation($n1), $self->get_nation($n2), 1);
234 0 $self->stop_military_support($self->get_nation($n2), $self->get_nation($n1), 1);
235 }
236  
237 sub diplomacy_for_node
238 {
239 0 ▶ my $self = shift;
Subroutine diplomacy_for_node: not called CC=3 SCAR=24.8
Pod undocumented
240 0 my $node = shift;
241 0 my %relations;
242 0 foreach my $n (@{$self->nation_names})
243 {
244 0 ▶ if($n ne $node)
Branch: 1 branch
BranchTrueFalseTotal
if ($n ne $node) 0 0 0
245 {
246 0 my $real_r = $self->diplomacy_exists($node, $n);
247 0 $relations{$n} = $real_r->factor;
248 }
249 }
250 0 return %relations;;
251 }
252  
253 sub print_diplomacy
254 {
255 0 ▶ my $self = shift;
Subroutine print_diplomacy: not called CC=2 SCAR=17.9
Pod undocumented
256 0 my $n = shift;
257 0 ▶ my $mode = shift || "print";
Condition0%0/2
shift() || 'print'
l!l
00
MC/DC0%0/1
shift() || 'print'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
258 0 my $out;
259 0 my @outnodes = sort { $a->factor <=> $b->factor} $self->get_diplomatic_relations($n);
260 0 return BalanceOfPower::Printer::print($mode, $self, 'print_diplomacy',
261 { nation => $n,
262 relationships => \@outnodes,
263 } );
264  
265 }
266  
267  
268 sub diplomatic_pressure
269 {
270 0 ▶ my $self = shift;
Subroutine diplomatic_pressure: not called CC=2 SCAR=17.9
Pod undocumented
271 0 my $nation1 = shift;
272 0 my $nation2 = shift;
273 0 my @friends = $self->get_friends($nation1);
274 0 $self->change_diplomacy($nation1, $nation2, DIPLOMATIC_PRESSURE_FACTOR);
275 0 $self->broadcast_event("DIPLOMATIC PRESSURE OF $nation1 ON $nation2", $nation1, $nation2);
276 0 for(@friends)
277 {
278 0 my $f = $_;
279 0 $self->change_diplomacy($f, $nation2, DIPLOMATIC_PRESSURE_FACTOR);
280 }
281 }
282  
283  
284 #Functions to manage relationships as crises
285 sub add_crisis
286 {
287 0 ▶ my $self = shift;
Subroutine add_crisis: not called CC=2 SCAR=17.9
Pod undocumented
288 0 my $nation1 = shift;
289 0 my $nation2 = shift;
290 0 my $rel = $self->diplomacy_exists($nation1, $nation2);
291 0 ▶ if($rel->get_crisis_level == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($rel->get_crisis_level == 0) 0 0 0
292 {
293 0 $rel->escalate_crisis();
294 }
295 }
296 sub delete_crisis
297 {
298 0 ▶ my $self = shift;
Subroutine delete_crisis: not called CC=1 SCAR=6.9
Pod undocumented
299 0 my $nation1 = shift;
300 0 my $nation2 = shift;
301 0 my $rel = $self->diplomacy_exists($nation1, $nation2);
302 0 $rel->crisis_level(0);
303 }
304 sub crisis_exists
305 {
306 0 ▶ my $self = shift;
Subroutine crisis_exists: not called CC=5 SCAR=34.0
Pod undocumented
307 0 ▶ my $nation1 = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
308 0 ▶ my $nation2 = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
309 0 my $rel = $self->diplomacy_exists($nation1, $nation2);
310 0 ▶ if(! $rel)
Branch: 1 branch
BranchTrueFalseTotal
unless ($rel) 0 0 0
311 {
312 0 say "ERROR: no diplomacy between $nation1, $nation2";
313 0 return undef;
314 }
315 0 ▶ if($rel->get_crisis_level > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($rel->get_crisis_level > 0) { } 0 0 0
316 {
317 0 return $rel;
318 }
319 else
320 {
321 0 return undef;
322 }
323 }
324 sub get_crises
325 {
326 0 ▶ my $self = shift;
Subroutine get_crises: not called CC=1 SCAR=6.9
Pod undocumented
327 0 my $nation = shift;
328 0 my @crises = $self->get_diplomatic_relations($nation);
329 0 @crises = grep { $_->get_crisis_level > 0 } @crises;
330 0 return @crises;
331 }
332 sub get_all_crises
333 {
334 0 ▶ my $self = shift;
Subroutine get_all_crises: not called CC=1 SCAR=6.9
Pod undocumented
335 0 my @rels = $self->diplomatic_relations->all();
336 0 return grep { $_->is_crisis() } @rels;
337 }
338 sub reset_crises
339 {
340 0 ▶ my $self = shift;
Subroutine reset_crises: not called CC=2 SCAR=17.9
Pod undocumented
341 0 my $nation = shift;
342 0 my @rels = $self->get_diplomatic_relations($nation);
343 0 for(@rels)
344 {
345 0 $_->crisis_level(0);
346 }
347 }
348  
349 #Functions to manage treaties
350 sub create_treaty
351 {
352 0 ▶ my $self = shift;
Subroutine create_treaty: not called CC=1 SCAR=6.9
Pod undocumented
353 0 my $nation1 = shift;
354 0 my $nation2 = shift;
355 0 my $type = shift;
356 0 $self->add_treaty(BalanceOfPower::Relations::Treaty->new(
357 node1 => $nation1,
358 node2 => $nation2,
359 type => $type ));
360 }
361 sub exists_treaty_by_type
362 {
363 0 ▶ my $self = shift;
Subroutine exists_treaty_by_type: not called CC=4 SCAR=30.0
Pod undocumented
364 0 my $nation1 = shift;
365 0 my $nation2 = shift;
366 0 my $type = shift;
367 0 my $rel = $self->exists_treaty($nation1, $nation2);
368 0 ▶ if( $rel && ($rel->type eq $type || $rel->type eq 'alliance')) #Alliance means both treaties are active
Branch: 1 branch
BranchTrueFalseTotal
if ($rel and $rel->type eq $type || $rel->type eq 'alliance') { } 0 0 0
Condition0%0/6
$rel and $rel->type eq $type || $rel->type eq "alliance"
!ll&&!rl&&r
000
$rel->type eq $type or $rel->type eq "alliance"
l!l&&r!l&&!r
000
MC/DC0%0/3
$rel and $rel->type eq $type || $rel->type eq "alliance"
$rel $rel->type eq $type $rel->type eq "alliance"
Truth table0%0/4
A and B or C
A= $relB= $rel->type eq $typeC= $rel->type eq "alliance"
ABCresult
0XX0
1000
11X1
1011
369 {
370 0 return $rel;
371 }
372 else
373 {
374 0 return undef;
375 }
376 }
377 sub get_treaties_for_nation_by_type
378 {
379 0 ▶ my $self = shift;
Subroutine get_treaties_for_nation_by_type: not called CC=1 SCAR=6.9
Pod undocumented
380 0 my $nation = shift;
381 0 my $type = shift;
382 0 my @treaties = $self->get_treaties_for_nation($nation);
383 0 return grep { $_->type eq $type } @treaties;
384 }
385  
386 #Functions to manage alliances
387 sub add_alliance
388 {
389 0 ▶ my $self = shift;
Subroutine add_alliance: not called CC=1 SCAR=6.9
Pod undocumented
390 0 my $nation1 = shift;
391 0 my $nation2 = shift;
392 0 $self->create_treaty($nation1, $nation2, 'alliance');
393 0 $self->set_diplomacy($nation1, $nation2, ALLIANCE_FRIENDSHIP_FACTOR);
394 }
395 sub print_allies
396 {
397 0 ▶ my $self = shift;
Subroutine print_allies: not called CC=1 SCAR=6.9
Pod undocumented
398 0 my $nation = shift;
399 0 my $mode = shift;
400 0 return $self->print_treaties($nation, "ALLIANCES", 'alliance', $mode);
401 }
402 sub print_treaties
403 {
404 0 ▶ my $self = shift;
Subroutine print_treaties: not called CC=11 SCAR=48.8
Pod undocumented
405 0 my $nation = shift;
406 0 ▶ my $title = shift || "TREATIES";
Condition0%0/2
shift() || 'TREATIES'
l!l
00
MC/DC0%0/1
shift() || 'TREATIES'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
407 0 ▶ my $treaty = shift || undef;
Condition0%0/2
shift() || undef
l!l
00
MC/DC0%0/1
shift() || undef
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
408 0 ▶ my $mode = shift || 'print';
Condition0%0/2
shift() || 'print'
l!l
00
MC/DC0%0/1
shift() || 'print'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
409 0 my @treaties = $self->treaties->all();
410 0 my @to_print;
411 0 for(@treaties)
412 {
413 0 ▶ if((($treaty && $_->type eq $treaty) || ! $treaty) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($treaty && $_->type eq $treaty || !$treaty and $nation && $_->involve($nation) || !$nation) 0 0 0
Condition0%0/15
$treaty && $_->type eq $treaty || !$treaty and $nation && $_->involve($nation) || !$nation
!ll&&!rl&&r
000
$treaty and $_->type eq $treaty or not $treaty
l!l&&r!l&&!r
000
$treaty and $_->type eq $treaty
!ll&&!rl&&r
000
$nation and $_->involve($nation) or not $nation
l!l&&r!l&&!r
000
$nation and $_->involve($nation)
!ll&&!rl&&r
000
MC/DC0%0/6
$treaty && $_->type eq $treaty || !$treaty and $nation && $_->involve($nation) || !$nation
$treaty $_->type eq $treaty not $treaty $nation $_->involve($nation) not $nation
Truth table0%0/17
A and B or not(C) and D and E or not(F)
A= $treatyB= $_->type eq $treatyC= not $treatyD= $nationE= $_->involve($nation)F= not $nation
ABCDEFresult
0X0XXX0
100XXX0
11X0X00
11X1000
0X10X00
0X11000
1010X00
1011000
11X11X1
11X0X11
11X1011
0X111X1
0X10X11
0X11011
10111X1
1010X11
1011011
414 (($nation && $_->involve($nation)) || ! $nation))
415 {
416 0 push @to_print, $_;
417 }
418 }
419 0 return BalanceOfPower::Printer::print($mode, $self, 'print_treaties',
420 { title => $title,
421 treaties => \@to_print,
422 } );
423 }
424  
425 sub exists_alliance
426 {
427 0 ▶ my $self = shift;
Subroutine exists_alliance: not called CC=1 SCAR=6.9
Pod undocumented
428 0 my $nation1 = shift;
429 0 my $nation2 = shift;
430 0 return $self->exists_treaty_by_type($nation1, $nation2, 'alliance');
431 }
432  
433 sub get_allies
434 {
435 0 ▶ my $self = shift;
Subroutine get_allies: not called CC=1 SCAR=6.9
Pod undocumented
436 0 my $nation = shift;
437 0 return $self->get_treaties_for_nation_by_type($nation, 'alliance');
438 }
439  
440  
441 11 1;
« lib/BalanceOfPower/Relations/Role/Relation.pm ↑ Summary blib/lib/BalanceOfPower/Commands/BuildTroops.pm »