| 1 | package BalanceOfPower::Role::Analyst; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | $BalanceOfPower::Role::Analyst::VERSION = '0.200000'; | |||||||||||||||||||||||||||||||||||||||||
| 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 | 11 | ▶ | use Term::ANSIColor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use BalanceOfPower::Constants ':all'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use BalanceOfPower::Utils qw( prev_turn as_title as_title as_subtitle compare_turns); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | requires 'diplomacy_exists'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | requires 'get_borders'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | requires 'supported'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | requires 'exists_military_support'; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | requires 'near_nations'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | requires 'routes_for_node'; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 11 | requires 'get_allies'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | requires 'get_crises'; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 11 | requires 'get_wars'; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | requires 'print_nation_situation'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | requires 'print_nation_statistics_header'; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 11 | requires 'print_nation_statistics_line'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 11 | requires 'get_player'; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | sub print_nation_actual_situation | ||||||||||||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_nation_actual_situation: called CC=14 SCAR=26.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | my $in_the_middle = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | my $turn = shift; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | if($in_the_middle) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | $turn = prev_turn($self->current_year); | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | else | ||||||||||||||||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $turn = $self->current_year; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | my $nation_obj = $self->get_nation($nation); | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | my $out = as_title("$nation\n===\n"); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | $out .= $nation_obj->print_attributes(); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | $out .= $self->print_nation_situation($nation); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | $out .= $self->print_nation_statistics_header() . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | $out .= $self->print_nation_statistics_line($nation, $turn) . "\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | $out .= as_title("TRADEROUTES\n---\n"); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | foreach my $tr ($self->routes_for_node($nation)) | |||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | $out .= $tr->print($nation) . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | my $allies_support_title = sprintf "%-35s %-35s", "TREATIES [" . $nation_obj->treaty_limit . "]" , "SUPPORTS"; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | $allies_support_title .="\n"; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | $allies_support_title .= sprintf "%-35s %-35s", "---", "---"; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | $allies_support_title .="\n"; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | $out .= as_title($allies_support_title); | |||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | my @allies = $self->get_treaties_for_nation($nation); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | my @supports = $self->supports($nation); | |||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my @rebel_supports = $self->rebel_supports($nation); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | for(my $i = 0; ;$i++) | |||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | last if(@allies == 0 && @supports == 0 && @rebel_supports == 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@allies == 0 and @supports == 0 and @rebel_supports == 0
@allies == 0 and @supports == 0
MC/DC33%1/3
@allies == 0 and @supports == 0 and @rebel_supports == 0
@allies == 0
@supports == 0
@rebel_supports == 0
Truth table50%2/4
A and B and C
A= @allies == 0B= @supports == 0C= @rebel_supports == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | my $allies_text = ""; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | if(@allies) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | my $a = shift @allies; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | $allies_text = $a->print; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | my $support_text = ""; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | ▶ | if(@supports) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $s = shift @supports; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | $support_text = $s->print; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | else | ||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | if(@rebel_supports) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $rs = shift @rebel_supports; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $support_text = "REB: " . $rs->print; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | $out .= sprintf "%-35s %-35s", $allies_text, $support_text; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | $out .="\n"; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | my $crises_wars_title = sprintf "%-35s %-35s", "CRISES", "WARS"; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | $crises_wars_title .="\n"; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | $crises_wars_title .= sprintf "%-35s %-35s", "---", "---"; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | $crises_wars_title .="\n"; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | $out .= as_title($crises_wars_title); | |||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | my @crises = $self->get_crises($nation); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | my @wars = $self->get_wars($nation); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | for(my $i = 0; ;$i++) | |||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | ▶ | last if(@crises == 0 && @wars == 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@crises == 0 and @wars == 0
MC/DC50%1/2
@crises == 0 and @wars == 0
@crises == 0
@wars == 0
Truth table66%2/3
A and B
A= @crises == 0B= @wars == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | my $crisis_text = ""; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | ▶ | if(@crises) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | my $c = shift @crises; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 4 | $crisis_text = $c->print_crisis(0); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 4 | my $war_text = ""; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | ▶ | if(@wars) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | my $w = shift @wars; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | $war_text = $w->print; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | $out .= sprintf "%-35s %-35s", $crisis_text, $war_text; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | $out .="\n"; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | my $order = $self->get_statistics_value($turn, $nation, 'order') ? $self->get_statistics_value($turn, $nation, 'order') : 'NONE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | $out .= "Latest given order: $order\n"; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | sub print_borders_analysis | ||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_borders_analysis: called CC=5 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | my @borders = $self->near_nations($nation, 1); | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | foreach my $b (@borders) | |||||||||||||||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | $out .= as_title("# " . $b . " #") . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 6 | my $rel = $self->diplomacy_exists($nation, $b); | |||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | $out .= " Relations: " . $rel->print_status() . " " . | |||||||||||||||||||||||||||||||||||||||||
| 131 | $rel->print_crisis_bar() . "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 6 | my $supps = $self->supported($b); | |||||||||||||||||||||||||||||||||||||||||
| 133 | 6 | ▶ | if($supps) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $out .= as_subtitle(" Military support in the country:\n"); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $supporter = $supps->start($b); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $sup_rel = $self->diplomacy_exists($nation, $supporter); | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if($sup_rel) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $out .= " $supporter (" . $sup_rel->print_status(); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if($sup_rel->is_crisis()) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $out .= " " . $sup_rel->print_crisis_bar; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | sub war_current_year | ||||||||||||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
war_current_year: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | for($self->wars->all) | |||||||||||||||||||||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $_->current_year($self->current_year); | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | } $out .= ")"; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | sub print_near_analysis | ||||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_near_analysis: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my @near = $self->near_nations($nation, 0); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | foreach my $b (@near) | |||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $out .= as_title($b) . " " . $self->diplomacy_exists($nation, $b)->print_status(); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if(! $self->border_exists($nation, $b)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if($self->exists_military_support($nation, $b)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $out .= " (supported)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | else | ||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my @foreign_borders = $self->get_borders($b); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | foreach my $fb (@foreign_borders) | |||||||||||||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $other_n = $fb->destination($b); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $sups = $self->supported($other_n); | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | for($sups) | |||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if($sups->start($other_n) eq $nation) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $out .= " Military support from: $other_n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | else | ||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | sub print_hotspots | ||||||||||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_hotspots: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my @crises = $self->get_all_crises(); | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $out .= as_title("CRISES") . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | for(@crises) | |||||||||||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $c = $_; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if(! $self->war_exists($c->node1, $c->node2)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $out .= as_subtitle($c->print_crisis()) . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 212 | #$out .= " " . $self->diplomacy_exists($self->player_nation, $c->node1)->print() . "\n" if($self->player_nation ne $c->node1); | ||||||||||||||||||||||||||||||||||||||||||
| 213 | #$out .= " " . $self->diplomacy_exists($self->player_nation, $c->node2)->print(). "\n" if($self->player_nation ne $c->node2); | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $out .= as_title("WARS") . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my @wars = $self->wars->all(); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | for(@wars) | |||||||||||||||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $w = $_; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $out .= $w->print() . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 224 | #$out .= " " . $self->diplomacy_exists($self->player_nation, $w->node1)->print() . "\n" if($self->player_nation ne $w->node1); | ||||||||||||||||||||||||||||||||||||||||||
| 225 | #$out .= " " . $self->diplomacy_exists($self->player_nation, $w->node2)->print(). "\n" if($self->player_nation ne $w->node2); | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $out .= as_title("CIVIL WARS") . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | foreach my $n (@{$self->nation_names}) | |||||||||||||||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if($self->at_civil_war($n)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $out .= "$n is fighting civil war\n"; | |||||||||||||||||||||||||||||||||||||||||
| 235 | #$out .= " " . $self->diplomacy_exists($self->player_nation, $n)->print() . "\n" if($self->player_nation ne $n); | ||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | sub print_civil_war_report | ||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_civil_war_report: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if (! $self->at_civil_war($nation)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return "$nation is not fightinh civil war"; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $nation_obj = $self->get_nation($nation); | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $out .= "Rebel provinces: " . $nation_obj->rebel_provinces . "/" . PRODUCTION_UNITS->[$nation_obj->size] . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $out .= "Army: " . $nation_obj->army . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $sup = $self->supported($nation); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $rebsup = $self->rebel_supported($nation); | |||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $out .= "Support: " . $sup->print . "\n" if($sup); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $out .= "Rebel support: " . $rebsup->print . "\n" if ($rebsup); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | sub print_war_history | ||||||||||||||||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_war_history: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | my $out .= as_title("WAR HISTORY\n\n"); | |||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | my %wars; | |||||||||||||||||||||||||||||||||||||||||
| 265 | my @war_names; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | foreach my $w (@{$self->memorial}) | |||||||||||||||||||||||||||||||||||||||||
| 267 | { | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | ▶ | if(exists $wars{$w->war_id}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $wars{$w->war_id} .= $w->print_history . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | else | ||||||||||||||||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | $wars{$w->war_id} = $w->print_history . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | push @war_names, { name => $w->war_id, | |||||||||||||||||||||||||||||||||||||||||
| 276 | start => $w->start_date }; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | sub comp | ||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | compare_turns($a->{start}, $b->{start}); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | for(sort comp @war_names) | |||||||||||||||||||||||||||||||||||||||||
| 284 | { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | $out .= "### WAR " . $_->{name} . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | $out .= $wars{$_->{name}}; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | sub print_treaties_table | ||||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_treaties_table: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | my $out = sprintf "%-20s %-6s %-5s %-5s %-5s", "Nation", "LIMIT", "ALL", "NAG", "COM"; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | my @nations = @{$self->nation_names}; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | for(@nations) | |||||||||||||||||||||||||||||||||||||||||
| 297 | { | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 5 | my $n = $_; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 5 | my $limit = $self->get_nation($n)->treaty_limit; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | my $alls = $self->get_treaties_for_nation_by_type($n, 'alliance'); | |||||||||||||||||||||||||||||||||||||||||
| 301 | 5 | my $coms = $self->get_treaties_for_nation_by_type($n, 'commercial'); | |||||||||||||||||||||||||||||||||||||||||
| 302 | 5 | my $nags = $self->get_treaties_for_nation_by_type($n, 'no aggression'); | |||||||||||||||||||||||||||||||||||||||||
| 303 | 5 | $out .= sprintf "%-20s %-6s %-5s %-5s %-5s", $n, $limit, $alls, $nags, $coms; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 5 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | sub print_stocks | ||||||||||||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_stocks: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $player = shift; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $player_obj = $self->get_player($player); | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $stock_value = 0; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $out .= as_title(sprintf "%-15s %-10s %-10s %-10s %-10s", "NATION", "Q", "VALUE", "INFLUENCE", "WAR BONDS"); | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | foreach my $nation(keys %{$player_obj->wallet}) | |||||||||||||||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if( $player_obj->stocks($nation) > 0 || $player_obj->influence($nation) > 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$player_obj->stocks($nation) > 0 or $player_obj->influence($nation) > 0
MC/DC0%0/2
$player_obj->stocks($nation) > 0 or $player_obj->influence($nation) > 0
$player_obj->stocks($nation) > 0
$player_obj->influence($nation) > 0
Truth table0%0/3
A or B
A= $player_obj->stocks($nation) > 0B= $player_obj->influence($nation) > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $out .= sprintf "%-15s %-10s %-10s %-10s %-10s", $nation, $player_obj->wallet->{$nation}->{stocks}, $self->get_statistics_value(prev_turn($self->current_year), $nation, "w/d"), $player_obj->wallet->{$nation}->{influence}, $player_obj->wallet->{$nation}->{'war bonds'} ; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $stock_value += $player_obj->wallet->{$nation}->{stocks} * $self->get_statistics_value(prev_turn($self->current_year), $nation, "w/d"); | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $out .= "Stock value: " . $stock_value . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $out .= "Money: " . $player_obj->money . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $total_value = $stock_value + $player_obj->money; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $out .= "Total value: " . $total_value . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | sub print_market | ||||||||||||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_market: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $out .= as_title(sprintf "%-20s %-10s %-10s %-10s", "NATION", "STOCK", "VALUE", "STATUS"); | |||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my @ordered = $self->order_statistics(prev_turn($self->current_year), 'w/d'); | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | foreach my $stats (@ordered) | |||||||||||||||||||||||||||||||||||||||||
| 341 | { | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $nation = $self->get_nation($stats->{nation}); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $status = ""; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if($self->at_war($nation->name)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $status = "WAR"; | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | elsif($self->at_civil_war($nation->name)) | ||||||||||||||||||||||||||||||||||||||||||
| 349 | { | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $status = "CIVILW"; | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $out .= sprintf "%-20s %-10s %-10s %-10s", $nation->name, $nation->available_stocks, $stats->{value}, $status; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||