| 1 | package BalanceOfPower::World; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | $BalanceOfPower::World::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 Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Cwd 'abs_path'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use File::Path 'make_path'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use BalanceOfPower::Constants ':all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use BalanceOfPower::Utils qw(prev_turn next_turn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use BalanceOfPower::Nation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | ▶ | use BalanceOfPower::Dice; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | ▶ | use BalanceOfPower::Commands; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | has name => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | default => 'WORLD' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | has silent => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | has first_year => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | is => 'ro' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | has current_year => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | is => 'rw' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | has nations => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | default => sub { [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | has nation_names => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | default => sub { [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | has nation_codes => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | default => sub { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | has order => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | default => "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | has ia_orders => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | default => sub { [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | has autoplay => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | has data_directory => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | my $module_file_path = __FILE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | my $root_path = abs_path($module_file_path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $root_path =~ s/World\.pm//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | my $data_directory = $root_path . "data"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | has dice => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | default => sub { BalanceOfPower::Dice->new( log_name => "bop-dice.log" ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | handles => { random => 'random', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | random10 => 'random10', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | random_around_zero => 'random_around_zero', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | shuffle => 'shuffle_array', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | tricks => 'tricks', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | forced_advisor => 'forced_advisor', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | only_one_nation_acting => 'only_one_nation_acting', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | dice_log => 'log_active' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | has savefile => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | default => "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | with 'BalanceOfPower::Role::GameMaster'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | with 'BalanceOfPower::Role::Historian'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | with 'BalanceOfPower::Role::Herald'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | with 'BalanceOfPower::Role::Ruler'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | with 'BalanceOfPower::Role::Mapmaker'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | with 'BalanceOfPower::Role::Supporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | with 'BalanceOfPower::Role::Diplomat'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | with 'BalanceOfPower::Role::Merchant'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | with 'BalanceOfPower::Role::Broker'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | with 'BalanceOfPower::Role::Warlord'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | with 'BalanceOfPower::Role::CrisisManager'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | with 'BalanceOfPower::Role::Analyst'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | with 'BalanceOfPower::Role::WebMaster'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | with 'BalanceOfPower::Role::Recorder'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | sub get_nation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_nation: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if(! $nation) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | say "Nation is undef"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my @nations = grep { $_->name eq $nation } @{$self->nations}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if(@nations > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return $nations[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | say "Cannot found $nation"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | sub correct_nation_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
correct_nation_name: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return undef if(! $nation); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $nation = $self->nation_codes->{uc $nation} if(exists $self->nation_codes->{uc $nation}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | for(@{$self->nation_names}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return $_ if(uc $_ eq uc $nation); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | sub check_nation_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_nation_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return grep {$_ eq $name} @{$self->nation_names}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub get_prev_year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_prev_year: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return prev_turn($self->current_year); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | sub load_nations_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_nations_data: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $datafile = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $file = $self->data_directory . "/" . $datafile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | open(my $nations_file, "<", $file) || die $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $area; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | my %nations_data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | for(<$nations_file>) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $n = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | chomp $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if(! ($n =~ /^#/)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ($name, $code, $size, $government) = split(',', $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if($government eq 'd') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $government = 'democracy'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | elsif($government eq 'D') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $government = 'dictatorship'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $nations_data{$name} = { code => $code, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | area => $area, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | government => $government , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $n =~ /^# (.*)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $area = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | return %nations_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | #Initial values, randomly generated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | sub init_random | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_random: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $datafile = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my $bordersfile = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my %nations_data = $self->load_nations_data($datafile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $flags = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $trades = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $diplomacy = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $alliances = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if($flags) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | $trades = $flags->{'trades'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if(exists $flags->{'trades'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | $diplomacy = $flags->{'diplomacy'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if(exists $flags->{'diplomacy'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | $alliances = $flags->{'alliances'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if(exists $flags->{'alliances'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->delete_log(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $self->dice->delete_log(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my @nation_names = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | foreach my $n (keys %nations_data) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | push @nation_names, $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | say "Working on $n" if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $export_quote = $self->random10(MIN_EXPORT_QUOTE, MAX_EXPORT_QUOTE, "Export quote $n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | say " export quote: $export_quote" if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $government_strength = $self->random10(MIN_GOVERNMENT_STRENGTH, MAX_GOVERNMENT_STRENGTH, "Government strenght $n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | say " government strength: $government_strength" if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $executive = BalanceOfPower::Executive->new( actor => $n ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $executive->init($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | push @{$self->nations}, BalanceOfPower::Nation->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | name => $n, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | code => $nations_data{$n}->{code}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | executive => $executive, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | area => $nations_data{$n}->{area}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | size => $nations_data{$n}->{size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | government => $nations_data{$n}->{government}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | export_quote => $export_quote, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | government_strength => $government_strength, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | available_stocks => START_STOCKS->[$nations_data{$n}->{size}], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | log_dir => $self->log_dir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | log_name => $self->log_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | log_on_stdout => $self->log_on_stdout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $self->nation_codes->{$nations_data{$n}->{code}} = $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->nation_names(\@nation_names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $self->load_borders($bordersfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if($trades) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | say "Trades generation..." if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->init_trades(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | say "Trades generation skipped" if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if($diplomacy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | say "Diplomacy generation..." if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $self->init_diplomacy(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | say "Diplomacy generation skipped" if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if($alliances) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | say "Alliances generation..." if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $self->init_random_alliances(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | say "Alliances generation skipped" if ! $self->silent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | #Group function for all the steps involved in a turn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | sub pre_decisions_elaborations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pre_decisions_elaborations: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my $t = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->init_year($t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $self->war_current_year(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $self->player_current_year(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $self->war_debts(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $self->crisis_generator(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | sub post_decisions_elaborations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post_decisions_elaborations: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $self->execute_stock_orders(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $self->execute_decisions(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $self->economy(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->warfare(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $self->internal_conflict(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->register_global_data(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $self->collect_events(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | sub elaborate_turn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
elaborate_turn: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $t = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->pre_decisions_elaborations($t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $self->decisions(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->post_decisions_elaborations(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | #To automatically generate turns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | sub autopilot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autopilot: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $start = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $stop = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $self->autoplay(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | for($start..$stop) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $y = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | foreach my $t (get_year_turns($y)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $self->elaborate_turn($t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $self->autoplay(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # Configure current year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # Give production to countries. Countries split it between export and domestic and, if allowed, raise the debt in case of necessity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # Wealth reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # Production and debt recorded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | sub init_year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_year: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my $turn = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if(! $turn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $turn = next_turn($self->current_year); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $self->log("--- $turn ---"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | say $turn if $self->autoplay(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $self->current_year($turn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | foreach my $n (@{$self->nations}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $n->current_year($turn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $n->wealth(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $prod = $self->calculate_production($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $n->production($prod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $prestige = $self->calculate_prestige($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $n->prestige($prestige); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $self->set_statistics_value($n, 'production', $prod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $self->set_statistics_value($n, 'debt', $n->debt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $self->set_statistics_value($n, 'prestige', $prestige); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # PRODUCTION MANAGEMENT ############################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | #Say the value of starting production used to calculate production for a turn. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | #Usually is just the value of production the turn before, but if rebels won a civil war it has to be undef to allow a totally random generation of production. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | sub get_base_production | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_base_production: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my @newgov = $nation->get_events("NEW GOVERNMENT CREATED", prev_turn($nation->current_year)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $previous_production = $self->get_statistics_value(prev_turn($nation->current_year), $nation->name, 'production'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | return () if(@newgov > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | return () if(! $previous_production); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my @prods = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | for(my $i = 0; $i < PRODUCTION_UNITS->[$nation->size]; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | push @prods, $self->get_statistics_value(prev_turn($nation->current_year), $nation->name, 'production' . $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return @prods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | sub calculate_production | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate_production: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my @prev_prods = $self->get_base_production($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my @next_prods = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $cost_for_retreat = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my @retreats = $n->get_events("RETREAT FROM", prev_turn($n->current_year)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $global_production = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | for(my $i = 0; $i < PRODUCTION_UNITS->[$n->size]; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if(@prev_prods > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $next_prods[$i] = $prev_prods[$i] + $self->random10(MIN_DELTA_PRODUCTION, MAX_DELTA_PRODUCTION, "Delta production" . $i . " " . $n->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $next_prods[$i] = $self->random10(MIN_STARTING_PRODUCTION, MAX_STARTING_PRODUCTION, "Starting production" . $i . " " . $n->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | #DEFEAT COST MANAGEMENT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if(@retreats) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $next_prods[$i] -= ATTACK_FAILED_PRODUCTION_MALUS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $cost_for_retreat += ATTACK_FAILED_PRODUCTION_MALUS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | $next_prods[$i] = 0 if($next_prods[$i] < 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | $next_prods[$i] = MAX_PRODUCTION if($next_prods[$i] > MAX_PRODUCTION); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $self->set_statistics_value($n, 'production' . $i, $next_prods[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $global_production += $next_prods[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if($cost_for_retreat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $self->send_event("COST FOR DEFEAT ON PRODUCTION: " . $cost_for_retreat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return $global_production; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | #Conquered nations give to the conqueror a quote of their production at start of the turn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | sub war_debts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
war_debts: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | for($self->influences->all()) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $self->loot($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $self->situation_clock(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | sub loot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loot: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my $influence = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $n2 = $influence->node2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my $n1 = $influence->node1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $quote = $influence->get_loot_quote(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | return if(! $quote || $quote == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $quote or $quote == 0
MC/DC0%0/2
not $quote or $quote == 0
not $quote
$quote == 0
Truth table0%0/3
not(A) or B
A= not $quoteB= $quote == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $nation = $self->get_nation($n2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $receiver = $self->get_nation($n1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | my $amount_domestic = $nation->production_for_domestic >= $quote ? $quote : $nation->production_for_domestic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | my $amount_export = $nation->production_for_export >= $quote ? $quote : $nation->production_for_export; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $nation->subtract_production('domestic', $amount_domestic); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $nation->subtract_production('export', $amount_export); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $nation->register_event("PAY LOOT TO " . $receiver->name . ": $amount_domestic + $amount_export"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $receiver->subtract_production('domestic', -1 * $amount_domestic); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | $receiver->subtract_production('export', -1 * $amount_export); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $receiver->register_event("ACQUIRE LOOT FROM " . $nation->name . ": $amount_domestic + $amount_export"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # PRODUCTION MANAGEMENT END ############################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # PRESTIGE MANAGEMENT ##################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | sub calculate_prestige | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate_prestige: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my $nation_name = $nation->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my $prestige = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my @routes = $self->routes_for_node($nation_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $prestige += @routes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my @supported = $self->supporter($nation_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $prestige += @supported; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my @influenced = $self->has_influence($nation_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $prestige += @influenced * INFLUENCE_PRESTIGE_BONUS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $bonus = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my @ordered_best_w = $self->order_statistics(prev_turn($nation->current_year), 'w/d'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if(@ordered_best_w >= BEST_WEALTH_FOR_PRESTIGE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | for(my $i = 0; $i < BEST_WEALTH_FOR_PRESTIGE; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | if($ordered_best_w[$i]->{nation} eq $nation_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $bonus += BEST_WEALTH_FOR_PRESTIGE_BONUS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $self->broadcast_event("ONE OF THE FIRST " . BEST_WEALTH_FOR_PRESTIGE . " NATIONS FOR WEALTH WAS " . $nation_name, $nation_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my @ordered_best_p = $self->order_statistics(prev_turn($nation->current_year), 'progress'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | if(@ordered_best_p >= BEST_PROGRESS_FOR_PRESTIGE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | for(my $i = 0; $i < BEST_PROGRESS_FOR_PRESTIGE; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | if($ordered_best_p[$i]->{nation} eq $nation_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $bonus += BEST_PROGRESS_FOR_PRESTIGE_BONUS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $self->broadcast_event("ONE OF THE FIRST " . BEST_PROGRESS_FOR_PRESTIGE . " NATIONS FOR PROGRESS WAS " . $nation_name, $nation_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $prestige += $bonus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my @wins = $nation->get_events("WAR BETWEEN .* AND .* WON BY ". $nation_name, prev_turn($nation->current_year)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if(@wins > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $prestige += WAR_PRESTIGE_BONUS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return $prestige; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # PRESTIGE MANAGEMENT END ##################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # DECISIONS ############################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # Decisions are collected and executed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | sub execute_decisions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_decisions: not called CC=28 SCAR=67.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my @decisions = @{$self->ia_orders}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my @route_adders = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | #foreach my $d (@decisions) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | foreach my $n (@{$self->nation_names}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $command = $self->control($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | if(! $command) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | my @nation_orders = grep { $_ =~ /^$n: / } @decisions; if(@nation_orders > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $nation_orders[0] =~ /^(.*): (.*)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $command = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $nation = $self->get_nation($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if($command =~ /^DELETE TRADEROUTE (.*)->(.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 16 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $self->delete_route($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | elsif($command =~ /^ADD ROUTE$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | push @route_adders, $nation->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | elsif($command =~ /^LOWER DISORDER$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $nation->lower_disorder($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | elsif($command =~ /^BUILD TROOPS$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $nation->build_troops(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | elsif($command =~ /^BOOST PRODUCTION$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $nation->boost_production(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | elsif($command =~ /DECLARE WAR TO (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $attacker = $nation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $defender = $self->get_nation($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | if(! $self->at_war($attacker->name) && ! $self->at_war($defender->name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->at_war($attacker->name) or $self->at_war($defender->name)
MC/DC0%0/2
$self->at_war($attacker->name) or $self->at_war($defender->name)
$self->at_war($attacker->name)
$self->at_war($defender->name)
Truth table0%0/3
A or B
A= $self->at_war($attacker->name)B= $self->at_war($defender->name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | $self->create_war($attacker, $defender); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | elsif($command =~ /^MILITARY SUPPORT (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my $supporter = $nation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | my $supported = $self->get_nation($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | if($supported->accept_military_support($supporter->name, $self)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $self->start_military_support($supporter, $supported); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $self->broadcast_event($supported->name . " REFUSED MILITARY SUPPORT FROM " . $supporter->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | elsif($command =~ /^RECALL MILITARY SUPPORT (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $supporter = $nation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $supported = $self->get_nation($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $self->stop_military_support($supporter, $supported); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | elsif($command =~ /^AID INSURGENTS IN (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | my $victim = $self->get_nation($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $self->aid_insurgents($nation, $victim); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | elsif($command =~ /^TREATY (.*) WITH (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my $nation2 = $self->get_nation($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $self->stipulate_treaty($nation, $nation2, $1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | elsif($command =~ /^ECONOMIC AID FOR (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $nation2 = $self->get_nation($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $self->economic_aid($nation, $nation2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | elsif($command =~ /^REBEL MILITARY SUPPORT (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my $nation2 = $self->get_nation($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $rebsup = $self->rebel_supported($nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | if($rebsup && $rebsup->node1 ne $nation->name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rebsup and $rebsup->node1 ne $nation->name
MC/DC0%0/2
$rebsup and $rebsup->node1 ne $nation->name
$rebsup
$rebsup->node1 ne $nation->name
Truth table0%0/3
A and B
A= $rebsupB= $rebsup->node1 ne $nation->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $self->broadcast_event("REBEL SUPPORT IN " . $nation2->name . " IMPOSSIBLE FOR " . $nation->name, $nation->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $self->start_rebel_military_support($nation, $nation2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | elsif($command =~ /^DIPLOMATIC PRESSURE ON (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $n2 = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | if($nation->prestige >= DIPLOMATIC_PRESSURE_PRESTIGE_COST) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my $under_infl = $self->is_under_influence($n2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | $under_infl ||= ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$under_infl ||= ""
MC/DC0%0/1
$under_infl ||= ""
$under_infl
Truth table0%0/2
A
A= $under_infl
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | if($under_infl ne $nation->name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $self->diplomatic_pressure($nation->name, $n2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $self->broadcast_event("DIPLOMATIC PRESSURE ON $n2 BY " . $nation->name . " IMPOSSIBLE! $n2 IS UNDER INFLUENCE OF " . $nation->name, $nation->name, $n2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | elsif($command =~ /^RECALL REBEL MILITARY SUPPORT (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $supported = $self->get_nation($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | $self->stop_rebel_military_support($nation, $supported); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | elsif($command =~ /^MILITARY AID FOR (.*)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my $nation2 = $self->get_nation($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | $self->military_aid($nation, $nation2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | elsif($command =~ /^PROGRESS$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $nation->grow(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $self->broadcast_event("INVESTMENT IN PROGRESS FOR " . $nation->name, $nation->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | $self->set_statistics_value($nation, 'order', $command); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $self->empty_control_orders(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $self->manage_route_adding(@route_adders); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | sub empty_control_orders | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
empty_control_orders: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | foreach my $p (@{$self->players}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | $p->empty_control_orders(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | sub manage_route_adding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
manage_route_adding: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my @route_adders = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if(@route_adders > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | @route_adders = $self->shuffle("Route adders", @route_adders); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my $done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | while(! $done) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my $node1 = shift @route_adders; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | if($self->suitable_route_creator($node1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | if(@route_adders == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $self->send_event("TRADEROUTE CREATION FAILED FOR LACK OF PARTNERS", $node1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | my $complete = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | foreach my $second (@route_adders) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | if($self->suitable_new_route($node1, $second)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | @route_adders = grep { $_ ne $second } @route_adders; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | $self->generate_traderoute($node1, $second, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | $complete = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | last if $complete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | if($complete == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | $self->send_event("TRADEROUTE CREATION FAILED FOR LACK OF PARTNERS", $node1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | $self->broadcast_event("TRADEROUTE CREATION NOT POSSIBLE FOR $node1", $node1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | $done = 1 if(@route_adders == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | sub decisions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decisions: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my @decisions = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | foreach my $nation (@{$self->nations}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | my $decision; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | $decision = $nation->decision($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | if($decision) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | push @decisions, $decision; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | $self->ia_orders(\@decisions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | sub control | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
control: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | my $quote = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my $winner = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my @losers = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | my $winner_command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | foreach my $player (@{$self->players}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $player_command = $player->get_control_order($nation); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | if($player_command) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | if($player->stocks($nation) > $quote) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | if($winner) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | push @losers, $winner; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | $winner = $player; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $quote = $player->stocks($nation); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | $winner_command = $player_command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | push @losers, $player; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | if($winner) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $winner->add_influence(-1 * INFLUENCE_COST, $nation); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | $winner->register_event("ORDER FOR $nation IS EXECUTED: $winner_command"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | for(@losers) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $_->register_event("ORDER FOR $nation NOT EXECUTED! " . $winner->name . " MORE POWERFUL"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | return $winner_command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | # DECISIONS END ########################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # ECONOMY ################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | # Calculate internal wealth converting domestic production to wealth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # Active trade routes one by one trying to generate wealth from each of them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | # Convert remain as generating internal wealth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | sub economy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
economy: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | foreach my $n (@{$self->nations}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | $n->calculate_internal_wealth(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | $n->calculate_trading($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | $n->convert_remains(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | if($self->at_war($n->name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | $n->war_cost(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | if($self->at_civil_war($n->name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | $n->civil_war_cost(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | my $wealth = $n->wealth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | my $pu = PRODUCTION_UNITS->[$n->size]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | my $prod = $self->get_statistics_value($self->current_year, $n->name, 'production'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | $self->set_statistics_value($n, 'wealth', $n->wealth); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $self->set_statistics_value($n, 'w/d', int(($wealth / $pu) * 100) / 100); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | if($prod != 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | $self->set_statistics_value($n, 'growth', int(($wealth / $prod) * 100) / 100 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | $self->set_statistics_value($n, 'growth', 'X' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | sub economic_aid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
economic_aid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | my $nation1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | my $nation2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $nation1->subtract_production('export', ECONOMIC_AID_COST); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | $nation2->receive_aid($nation1->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | $self->broadcast_event("ECONOMIC AID FROM " . $nation1->name . " TO " . $nation2->name, $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | $self->change_diplomacy($nation1->name, $nation2->name, ECONOMIC_AID_DIPLOMACY_FACTOR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # ECONOMY END ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | # INTERNAL DISORDER ####################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | sub internal_conflict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
internal_conflict: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | foreach my $n (@{$self->nations}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | my $present_status = $n->internal_disorder_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | $n->calculate_disorder($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | my $winner = $n->fight_civil_war($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | if($winner && $winner eq 'rebels') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$winner and $winner eq "rebels"
MC/DC0%0/2
$winner and $winner eq "rebels"
$winner
$winner eq "rebels"
Truth table0%0/3
A and B
A= $winnerB= $winner eq "rebels"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | $n->win_civil_war('rebels', $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | $n->new_government($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | ▶ | elsif($winner && $winner eq 'government') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$winner and $winner eq "government"
MC/DC0%0/2
$winner and $winner eq "government"
$winner
$winner eq "government"
Truth table0%0/3
A and B
A= $winnerB= $winner eq "government"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | $n->win_civil_war('government', $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | $self->set_statistics_value($n, 'internal disorder', $n->internal_disorder); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | sub aid_insurgents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
aid_insurgents: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my $nation1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | my $nation2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | if($nation1->production_for_export >= AID_INSURGENTS_COST && $nation2->internal_disorder_status ne 'Civil war') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$nation1->production_for_export >= 25 and $nation2->internal_disorder_status ne "Civil war"
MC/DC0%0/2
$nation1->production_for_export >= 25 and $nation2->internal_disorder_status ne "Civil war"
$nation1->production_for_export >= 25
$nation2->internal_disorder_status ne "Civil war"
Truth table0%0/3
A and B
A= $nation1->production_for_export >= 25B= $nation2->internal_disorder_status ne "Civil war"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | $self->broadcast_event("AIDS FOR INSURGENTS OF " . $nation2->name . " FROM " . $nation1->name, $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | $nation1->subtract_production('export', AID_INSURGENTS_COST); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | $nation2->add_internal_disorder(INSURGENTS_AID, $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | sub at_civil_war | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at_civil_war: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | my $nation = $self->get_nation($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | return $nation->internal_disorder_status eq 'Civil war'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | sub start_civil_war | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_civil_war: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | $self->broadcast_event("CIVIL WAR OUTBREAK IN " . $nation->name, $nation->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | $nation->rebel_provinces(STARTING_REBEL_PROVINCES->[$nation->size]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | $self->war_report("Civil war in " . $nation->name . "!", $nation->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $self->lose_war($nation->name, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | # INTERNAL DISORDER END ###################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | # WAR ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | sub warfare | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warfare: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | $self->fight_wars(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | foreach my $n (@{$self->nations}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | $self->set_statistics_value($n, 'army', $n->army); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | sub military_aid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
military_aid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | my $nation1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | my $nation2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $nation1->subtract_production('export', MILITARY_AID_COST); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | $nation2->add_army(ARMY_UNIT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $self->broadcast_event("MILITARY AID FROM " . $nation1->name . " TO " . $nation2->name, $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | $self->change_diplomacy($nation1->name, $nation2->name, MILITARY_AID_DIPLOMACY_FACTOR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | sub war_report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
war_report: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | my @wars = $self->get_wars($nation); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | for(@wars) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | $_->register_event($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | # WAR END ################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # TREATIES ################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | sub stipulate_treaty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stipulate_treaty: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $nation1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | my $nation2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | my $present_treaty = $self->exists_treaty($nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my $diplomatic_status = $self->diplomacy_status($nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | if($diplomatic_status eq 'HATE') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | $self->broadcast_event("TREATY BETWEEN " . $nation1->name . " AND " . $nation2->name . " NOT POSSIBLE BECAUSE OF HATE", $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | ▶ | if($self->get_treaties_for_nation($nation1->name) >= $nation1->treaty_limit || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_treaties_for_nation($nation1->name) >= $nation1->treaty_limit or $self->get_treaties_for_nation($nation2->name) >= $nation2->treaty_limit
MC/DC0%0/2
$self->get_treaties_for_nation($nation1->name) >= $nation1->treaty_limit or $self->get_treaties_for_nation($nation2->name) >= $nation2->treaty_limit
$self->get_treaties_for_nation($nation1->name) >= $nation1->treaty_limit
$self->get_treaties_for_nation($nation2->name) >= $nation2->treaty_limit
Truth table0%0/3
A or B
A= $self->get_treaties_for_nation($nation1->name) >= $nation1->treaty_limitB= $self->get_treaties_for_nation($nation2->name) >= $nation2->treaty_limit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | $self->get_treaties_for_nation($nation2->name) >= $nation2->treaty_limit) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | $self->broadcast_event("TREATY BETWEEN " . $nation1->name . " AND " . $nation2->name . " NOT POSSIBLE BECAUSE ONE NATION HAS ALREADY REACHED MAXIMUM ALLOWED TREATIES", $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | ▶ | if($nation1->prestige >= TREATY_PRESTIGE_COST) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | if($type eq 'COM') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | if(! $present_treaty) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | ▶ | if($self->route_exists($nation1->name, $nation2->name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | $self->create_treaty($nation1->name, $nation2->name, 'commercial'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | $self->broadcast_event("COMMERCIAL TREATY BETWEEN " . $nation1->name . " AND " . $nation2->name, $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | $self->broadcast_event("COMMERCIAL TREATY BETWEEN " . $nation1->name . " AND " . $nation2->name . " MADE USELESS BY ROUTE CANCELATION", $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | elsif($type eq 'NAG') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | ▶ | if(! $present_treaty) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | $self->create_treaty($nation1->name, $nation2->name, 'no aggression'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | $self->broadcast_event("NO AGGRESSION TREATY BETWEEN " . $nation1->name . " AND " . $nation2->name, $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | if($present_treaty && $present_treaty->type ne 'alliance') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$present_treaty and $present_treaty->type ne "alliance"
MC/DC0%0/2
$present_treaty and $present_treaty->type ne "alliance"
$present_treaty
$present_treaty->type ne "alliance"
Truth table0%0/3
A and B
A= $present_treatyB= $present_treaty->type ne "alliance"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | $self->create_treaty($nation1->name, $nation2->name, 'alliance'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | $self->broadcast_event("ALLIANCE BETWEEN " . $nation1->name . " AND " . $nation2->name, $nation1->name, $nation2->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # TRATIES END ############################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | sub register_global_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_global_data: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my $crises = $self->get_all_crises(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | my $wars = $self->wars->all(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $self->set_statistics_value(undef, 'crises', $crises); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | $self->set_statistics_value(undef, 'wars', $wars); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | sub collect_events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect_events: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | my @events_to_collect = ("DISORDER LOWERED TO", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | "INTERNAL DISORDER LEVEL FROM", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | "THE GOVERNMENT WON THE CIVIL WAR", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | "THE REBELS WON THE CIVIL WAR", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | "NEW GOVERNMENT CREATED", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | "TRADEROUTE CREATION FAILED FOR LACK OF PARTNERS"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | foreach my $n (@{$self->nations}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | my @collected = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | foreach my $e (@events_to_collect) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | push @collected, $n->get_events($e, $self->current_year); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | foreach my $c (@collected) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | $self->register_event($n->name . ": ". $c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $self->set_statistics_value($n, 'progress', $n->progress); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | ### Commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | sub build_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_commands: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | my $commands = BalanceOfPower::Commands->new( world => $self, log_name => 'bop-commands.log', log_active => $self->log_active, log_dir => $self->log_dir ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | return $commands; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | ### Logs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | sub set_log_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_log_dir: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | my $log_dir = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | $self->log_dir($log_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | $self->dice->log_dir($log_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | for(@{$self->nations}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | $_->log_dir($log_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | for(@{$self->players}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | $_->log_dir($log_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||