« blib/lib/BalanceOfPower/Commands/NoArgs.pm
↑ Summary
lib/BalanceOfPower/Relations/Role/Relation.pm »
| 1 | package BalanceOfPower::Role::Mapmaker; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | $BalanceOfPower::Role::Mapmaker::VERSION = '0.300010'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
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::Relations::Border; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use BalanceOfPower::Relations::RelPack; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use BalanceOfPower::Utils qw( as_main_title); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | has borders => ( | ||||||||||||||||||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | default => sub { BalanceOfPower::Relations::RelPack->new() }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | handles => { add_border => 'add_link', | |||||||||||||||||||||||||||||||||||||||||
| 16 | border_exists => 'exists_link', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | get_borders => 'links_for_node', | ||||||||||||||||||||||||||||||||||||||||||
| 18 | near_on_the_map => 'near', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | distance_on_the_map => 'distance' | ||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | sub print_borders | ||||||||||||||||||||||||||||||||||||||||||
| 24 | { | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_borders: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | return $self->output_borders("BORDERS", $n, 'print'); | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | sub html_borders | ||||||||||||||||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html_borders: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | return $self->output_borders("BORDERS", $n, 'html'); | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | sub output_borders | ||||||||||||||||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_borders: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $title = shift; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $mode = shift; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $out .= as_main_title($title, $mode); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $out .= $self->borders->output_links($n, $mode); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | sub load_borders | ||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_borders: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $bordersfile = shift; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $file = shift || $self->data_directory . "/" . $bordersfile; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || $self->data_directory . '/' . $bordersfile
MC/DC0%0/1
shift() || $self->data_directory . '/' . $bordersfile
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | open(my $borders, "<", $file) || die $!;; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | for(<$borders>) | |||||||||||||||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $border = $_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my @nodes = split(/,/, $border); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if($self->check_nation_name($nodes[0]) && $self->check_nation_name($nodes[1])) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->check_nation_name($nodes[0]) and $self->check_nation_name($nodes[1])
MC/DC0%0/2
$self->check_nation_name($nodes[0]) and $self->check_nation_name($nodes[1])
$self->check_nation_name($nodes[0])
$self->check_nation_name($nodes[1])
Truth table0%0/3
A and B
A= $self->check_nation_name($nodes[0])B= $self->check_nation_name($nodes[1])
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if($nodes[0] && $nodes[1] && ! $self->border_exists($nodes[0], $nodes[1])) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$nodes[0] and $nodes[1] and not $self->border_exists($nodes[0], $nodes[1])
$nodes[0] and $nodes[1]
MC/DC0%0/3
$nodes[0] and $nodes[1] and not $self->border_exists($nodes[0], $nodes[1])
$nodes[0]
$nodes[1]
not $self->border_exists($nodes[0], $nodes[1])
Truth table0%0/4
A and B and not(C)
A= $nodes[0]B= $nodes[1]C= not $self->border_exists($nodes[0], $nodes[1])
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $b = BalanceOfPower::Relations::Border->new(node1 => $nodes[0], node2 => $nodes[1]); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $self->add_border($b); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | else | ||||||||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | say "WRONG BORDER: $border"; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | sub near_nations | ||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
near_nations: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $geographical = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if($geographical) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return $self->near_on_the_map($nation, $self->nation_names); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | else | ||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | return grep { $self->in_military_range($nation, $_) && $nation ne $_ } @{$self->nation_names}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | sub print_near_nations | ||||||||||||||||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_near_nations: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | for($self->near_nations($nation)) | |||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $out .= $_ . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | sub distance | ||||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
distance: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $nation1 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $nation2 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return $self->distance_on_the_map($nation1, $nation2, $self->nation_names); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | sub get_group_borders | ||||||||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_group_borders: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $group1 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $group2 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my @from = @{ $group1 }; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my @to = @{ $group2 }; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my @out = (); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | foreach my $to_n (@to) | |||||||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | foreach my $from_n (@from) | |||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if($self->in_military_range($from_n, $to_n)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | push @out, $to_n; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return @out; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | #cache management | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | sub print_distance | ||||||||||||||||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_distance: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $n1 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $n2 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return "Distance between $n1 and $n2: " . $self->distance($n1, $n2); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||