| 1 | package BalanceOfPower::Role::Warlord; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | $BalanceOfPower::Role::Warlord::VERSION = '0.200000'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Term::ANSIColor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use BalanceOfPower::Constants ':all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use BalanceOfPower::Utils qw( as_title ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use BalanceOfPower::Relations::Crisis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use BalanceOfPower::Relations::War; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | requires 'empire'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 11 | requires 'border_exists'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | requires 'get_nation'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 11 | requires 'get_hates'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | requires 'occupy'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | requires 'broadcast_event'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 11 | requires 'send_event'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 11 | requires 'empire'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 11 | requires 'get_group_borders'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | requires 'get_allies'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 11 | requires 'supported'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | requires 'supporter'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 11 | requires 'military_support_garbage_collector'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | requires 'random'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 11 | requires 'change_diplomacy'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 11 | requires 'get_crises'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 11 | requires 'delete_crisis'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 11 | requires 'at_civil_war'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 11 | requires 'discard_war_bonds'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 11 | requires 'cash_war_bonds'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | has wars => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 14 | ▶ | default => sub { BalanceOfPower::Relations::RelPack->new() }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 11 | handles => { at_war => 'first_link_for_node', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | add_war => 'add_link', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | get_wars => 'links_for_node', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | war_exists => 'exists_link', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | delete_war_link => 'delete_link', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | get_attackers => 'links_for_node2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | has memorial => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 14 | ▶ | default => sub { [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 11 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | sub war_busy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 145 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
war_busy: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 145 | my $n = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 145 | ▶ | return $self->at_civil_war($n) || $self->at_war($n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->at_civil_war($n) || $self->at_war($n)
MC/DC50%1/2
$self->at_civil_war($n) || $self->at_war($n)
$self->at_civil_war($n)
$self->at_war($n)
Truth table66%2/3
A || B
A= $self->at_civil_war($n)B= $self->at_war($n)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | sub in_military_range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 187 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
in_military_range: called CC=13 SCAR=25.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 187 | my $nation1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 187 | my $nation2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 187 | ▶ | my $hostile = shift || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 187 | ▶ | return 1 if($self->border_exists($nation1, $nation2)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 118 | my @supported = $self->supporter($nation1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 118 | for(@supported) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 9 | my $nation_supported = $_->destination($nation1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 9 | my $treaty = $self->exists_treaty_by_type($nation_supported, $nation2, 'no aggression'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 9 | ▶ | if(! $hostile || ! $treaty) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$hostile and $treaty
MC/DC50%1/2
$hostile and $treaty
$hostile
$treaty
Truth table66%2/3
A and B
A= $hostileB= $treaty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 8 | ▶ | if(! $self->war_busy($nation_supported)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | return 1 if $nation_supported eq $nation2 || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$nation_supported eq $nation2 or $self->border_exists($nation_supported, $nation2)
MC/DC50%1/2
$nation_supported eq $nation2 or $self->border_exists($nation_supported, $nation2)
$nation_supported eq $nation2
$self->border_exists($nation_supported, $nation2)
Truth table66%2/3
A or B
A= $nation_supported eq $nation2B= $self->border_exists($nation_supported, $nation2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | $self->border_exists($nation_supported, $nation2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 115 | my @empire = $self->empire($nation1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 115 | for(@empire) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 119 | my $ally = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 119 | ▶ | if(! $self->war_busy($ally)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 119 | ▶ | return 1 if $ally eq $nation2 || $self->border_exists($ally, $nation2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ally eq $nation2 or $self->border_exists($ally, $nation2)
MC/DC50%1/2
$ally eq $nation2 or $self->border_exists($ally, $nation2)
$ally eq $nation2
$self->border_exists($ally, $nation2)
Truth table66%2/3
A or B
A= $ally eq $nation2B= $self->border_exists($ally, $nation2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 113 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | sub war_current_year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 40 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
war_current_year: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 40 | for($self->wars->all) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 5 | $_->current_year($self->current_year); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | sub create_war | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_war: called CC=31 SCAR=34.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | ▶ | my $attacker = shift || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | ▶ | my $defender = shift || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 7 | ▶ | if(! $self->war_exists($attacker->name, $defender->name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 7 | $self->broadcast_event("CRISIS BETWEEN " . $attacker->name . " AND " . $defender->name . " BECAME WAR", $attacker->name, $defender->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 7 | my @attacker_coalition = $self->empire($attacker->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 7 | @attacker_coalition = grep { ! $self->at_war($_) } @attacker_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 7 | @attacker_coalition = grep { ! $self->at_civil_war($_) } @attacker_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 7 | my @defender_coalition = $self->empire($defender->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 7 | @defender_coalition = grep { ! $self->at_war($_) } @defender_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 7 | @defender_coalition = grep { ! $self->at_civil_war($_) } @defender_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | #Allies management | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 7 | my @attacker_allies = $self->get_allies($attacker->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 7 | my @defender_allies = $self->get_allies($defender->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 7 | for(@attacker_allies) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | my $ally_name = $_->destination($attacker->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | my $ally = $self->get_nation( $ally_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | if($ally->good_prey($defender, $self, ALLY_CONFLICT_LEVEL_FOR_INVOLVEMENT, 0 )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | if(! grep { $_ eq $ally_name } @attacker_coalition) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | push @attacker_coalition, $ally_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | $ally->register_event("JOIN WAR AS ALLY OF " . $attacker->name ." AGAINST " . $defender->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 7 | for(@defender_allies) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | my $ally_name = $_->destination($defender->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | my $ally = $self->get_nation( $ally_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | ▶ | if($ally->good_prey($attacker, $self, ALLY_CONFLICT_LEVEL_FOR_INVOLVEMENT, 0 )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | ▶ | if(! grep { $_ eq $ally_name } @defender_coalition) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | push @defender_coalition, $ally_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | $ally->register_event("JOIN WAR AS ALLY OF " . $defender->name ." AGAINST " . $attacker->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 7 | my @attacker_targets = $self->get_group_borders(\@attacker_coalition, \@defender_coalition); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 7 | my @defender_targets = $self->get_group_borders(\@defender_coalition, \@attacker_coalition); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | my @war_couples; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | my @couples_factions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 7 | my %used; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 7 | for(@attacker_coalition, @defender_coalition) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 18 | $used{$_} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | #push @war_couples, [$attacker->name, $defender->name]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | $used{$attacker->name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | $used{$defender->name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | my $faction = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 7 | my $done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 7 | my $faction0_done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | my $faction1_done = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 7 | ▶ | while(! $done) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 18 | my @potential_attackers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 18 | ▶ | if($faction == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 8 | @potential_attackers = grep { $used{$_} == 0 } @attacker_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | elsif($faction == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 10 | @potential_attackers = grep { $used{$_} == 0 } @defender_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 18 | ▶ | if(@potential_attackers == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 15 | ▶ | if($faction0_done == 1 && $faction == 1 || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$faction0_done == 1 and $faction == 1 or $faction1_done == 1 and $faction == 0
$faction0_done == 1 and $faction == 1
$faction1_done == 1 and $faction == 0
MC/DC75%3/4
$faction0_done == 1 and $faction == 1 or $faction1_done == 1 and $faction == 0
$faction0_done == 1
$faction == 1
$faction1_done == 1
$faction == 0
Truth table57%4/7
A and B or C and D
A= $faction0_done == 1B= $faction == 1C= $faction1_done == 1D= $faction == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | $faction1_done == 1 && $faction == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 7 | $done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 7 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | ▶ | if($faction == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | $faction0_done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | $faction = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 6 | $faction1_done = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 6 | $faction = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 8 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 3 | @potential_attackers = $self->shuffle("War creation. Choosing attackers", @potential_attackers); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 3 | my $attack_now = $potential_attackers[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 3 | my $defend_now = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | my $free_level = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | my $searching = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | ▶ | while($searching) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 3 | my @potential_defenders; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 3 | ▶ | if($faction == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | @potential_defenders = grep { ! $self->exists_treaty_by_type($_, $attack_now, 'no aggression') } @defender_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | ▶ | if(@potential_defenders == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | @attacker_coalition = grep { ! $attack_now eq $_ } @attacker_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $self->broadcast_event("NO POSSIBILITY TO PARTECIPATE TO WAR LINKED TO WAR BETWEEN " . $attacker->name . " AND " .$defender->name . " FOR $attack_now", $attack_now); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | elsif($faction == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | @potential_defenders = grep { ! $self->exists_treaty_by_type($_, $attack_now, 'no aggression') } @attacker_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | ▶ | if(@potential_defenders == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | @defender_coalition = grep { ! $attack_now eq $_ } @defender_coalition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | $self->broadcast_event("NO POSSIBILITY TO PARTECIPATE TO WAR LINKED TO WAR BETWEEN " . $attacker->name . " AND " .$defender->name . " FOR $attack_now", $attack_now); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | @potential_defenders = grep { $used{$_} <= $free_level } @potential_defenders; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | if(@potential_defenders > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | @potential_defenders = $self->shuffle("War creation. Choosing defenders", @potential_defenders); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | $defend_now = $potential_defenders[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | $searching = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $free_level++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 3 | ▶ | if($defend_now) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | push @war_couples, [$attack_now, $defend_now]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | push @couples_factions, $faction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | $used{$defend_now} += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 3 | $used{$attack_now} += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 3 | ▶ | if($faction == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | $faction = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | $faction = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 7 | my %attacker_leaders; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 7 | my $war_id = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 7 | my $war = BalanceOfPower::Relations::War->new(node1 => $attacker->name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | node2 => $defender->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | attack_leader => $attacker->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | war_id => $war_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | node1_faction => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | node2_faction => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | start_date => $self->current_year, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | log_active => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 7 | $war = $self->war_starting_report($war); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 7 | $self->add_war($war); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 7 | $attacker_leaders{$defender->name} = $attacker->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 7 | $self->broadcast_event("WAR BETWEEN " . $attacker->name . " AND " .$defender->name . " STARTED", $attacker->name, $defender->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 7 | my $faction_counter = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 7 | foreach my $c (@war_couples) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | my $leader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | ▶ | if(exists $attacker_leaders{$c->[1]}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $leader = $attacker_leaders{$c->[1]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | $leader = $c->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | $attacker_leaders{$c->[1]} = $c->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | my $faction1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | my $faction2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | if($couples_factions[$faction_counter] == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $faction1 = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $faction2 = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $faction1 = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | $faction2 = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | my $node1 = $c->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | my $node2 = $c->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | my $war = BalanceOfPower::Relations::War->new(node1 => $node1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | node2 => $node2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | attack_leader => $leader, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | war_id => $war_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | node1_faction => $faction1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | node2_faction => $faction2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | start_date => $self->current_year, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | log_active => 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | $war = $self->war_starting_report($war); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | $self->add_war($war); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | $self->broadcast_event("WAR BETWEEN " . $node1 . " AND " . $node2 . " STARTED (LINKED TO WAR BETWEEN " . $attacker->name . " AND " .$defender->name . ")", $node1, $node2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | sub war_starting_report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
war_starting_report: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 8 | my $war = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 8 | my $node1 = $war->node1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 8 | my $node2 = $war->node2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 8 | $war->register_event("Starting army for " . $node1 . ": " . $self->get_nation($node1)->army); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 8 | $war->register_event("Progress of " . $node1 . ": " . $self->get_nation($node1)->progress); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 8 | my $sup1 = $self->supported($node1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 8 | ▶ | if($sup1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $war->register_event("$node1 is supported by " . $sup1->node1 . ": " . $sup1->army); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 8 | $war->register_event("Starting army for " . $node2 . ": " . $self->get_nation($node2)->army); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 8 | $war->register_event("Progress of " . $node2 . ": " . $self->get_nation($node2)->progress); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 8 | my $sup2 = $self->supported($node2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 8 | ▶ | if($sup2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 2 | $war->register_event("$node2 is supported by " . $sup2->node1 . ": " . $sup2->army); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 8 | return $war; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub army_for_war | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
army_for_war: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 22 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 22 | my $supported = $self->supported($nation->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 22 | my $army = $nation->army; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 22 | ▶ | if($supported) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | $army += $supported->army; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 22 | return $army; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | sub damage_from_battle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
damage_from_battle: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 22 | my $nation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 22 | my $damage = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 22 | my $attacker = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 22 | my $supported = $self->supported($nation->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 22 | ▶ | if($supported && $self->exists_treaty_by_type($attacker->name, $supported->node1, 'no aggression')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$supported and $self->exists_treaty_by_type($attacker->name, $supported->node1, "no aggression")
MC/DC100%2/2
$supported and $self->exists_treaty_by_type($attacker->name, $supported->node1, "no aggression")
$supported
$self->exists_treaty_by_type($attacker->name, $supported->node1, "no aggression")
Truth table100%3/3
A and B
A= $supportedB= $self->exists_treaty_by_type($attacker->name, $supported->node1, "no aggression")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | $supported = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 22 | my $flip = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 22 | my $army_damage = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 22 | ▶ | while($damage > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 57 | ▶ | if($flip == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 29 | ▶ | if($supported && $supported->army > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$supported and $supported->army > 0
MC/DC50%1/2
$supported and $supported->army > 0
$supported
$supported->army > 0
Truth table66%2/3
A and B
A= $supportedB= $supported->army > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 2 | $supported->casualities(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | $damage--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 29 | $flip = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 28 | $army_damage++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 28 | $damage--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 28 | $flip = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 22 | $nation->add_army(-1 * $army_damage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 22 | ▶ | if($supported) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | ▶ | if($supported->army <= 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $self->broadcast_event("MILITARY SUPPORT TO " . $supported->node2 . " BY " . $supported->node1 . " DESTROYED", $supported->node1, $supported->node2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $self->war_report("Military support to ". $supported->node2 . " by " . $supported->node1 . " destroyed", $supported->node2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 22 | $self->military_support_garbage_collector(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | sub fight_wars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 41 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fight_wars: called CC=17 SCAR=28.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 41 | my %losers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 41 | my %war_bonds_issued = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 41 | foreach my $w ($self->wars->all()) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 11 | ▶ | if(! exists $war_bonds_issued{$w->node1}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 11 | $self->issue_war_bonds($w->node1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 11 | $war_bonds_issued{$w->node1} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 11 | ▶ | if(! exists $war_bonds_issued{$w->node2}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 11 | $self->issue_war_bonds($w->node2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 11 | $war_bonds_issued{$w->node2} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | #As Risiko | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 11 | $self->broadcast_event("WAR BETWEEN " . $w->node1 . " AND " . $w->node2 . " GO ON", $w->node1, $w->node2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 11 | my $attacker = $self->get_nation($w->node1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 11 | my $defender = $self->get_nation($w->node2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 11 | my $attacker_army = $self->army_for_war($attacker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 11 | my $defender_army = $self->army_for_war($defender); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 11 | ▶ | my $attack = $attacker_army >= ARMY_FOR_BATTLE ? ARMY_FOR_BATTLE : $attacker_army; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 11 | ▶ | my $defence = $defender_army >= ARMY_FOR_BATTLE ? ARMY_FOR_BATTLE : $defender_army; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 11 | my $attacker_damage = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 11 | my $defender_damage = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 11 | ▶ | my $counter = $attack < $defence ? $attack : $defence; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 11 | my $progress_delta = $attacker->progress - $defender->progress; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 11 | my $attacker_progress_bonus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | my $defender_progress_bonus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 11 | ▶ | if($progress_delta > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 2 | $attacker_progress_bonus = $progress_delta * PROGRESS_BATTLE_FACTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 2 | $defender_progress_bonus = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 9 | $attacker_progress_bonus = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 9 | $defender_progress_bonus = $progress_delta * PROGRESS_BATTLE_FACTOR * -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 11 | ▶ | for(my $i = 0; $i < $counter; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 30 | my $att = int(($self->random(1, 60, "War risiko: throw for attacker " . $attacker->name) + $attacker_progress_bonus) / 10) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 30 | my $def = int(($self->random(1, 60, "War risiko: throw for defender " . $defender->name) + $defender_progress_bonus) / 10) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 30 | ▶ | if($att > $def) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 15 | $defender_damage++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 15 | $attacker_damage++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 11 | ▶ | if(my $sup = $self->supported($attacker->name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $supporter_n = $sup->start($attacker->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if(! $self->exists_treaty_by_type($defender->name, $supporter_n, 'no aggression')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $self->broadcast_event("RELATIONS BETWEEN " . $defender->name . " AND " . $supporter_n . " CHANGED FOR WAR WITH " . $attacker->name, $attacker->name, $defender->name, $supporter_n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | $self->change_diplomacy($defender->name, $supporter_n, -1 * DIPLOMACY_MALUS_FOR_SUPPORT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 11 | ▶ | if(my $sup = $self->supported($defender->name)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 2 | my $supporter_n = $sup->start($defender->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 2 | ▶ | if(! $self->exists_treaty_by_type($attacker->name, $supporter_n, 'no aggression')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 1 | $self->broadcast_event("RELATIONS BETWEEN " . $attacker->name . " AND " . $supporter_n . " CHANGED FOR WAR WITH " . $defender->name, $attacker->name, $defender->name, $supporter_n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 1 | $self->change_diplomacy($attacker->name, $supporter_n, -1 * DIPLOMACY_MALUS_FOR_SUPPORT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 11 | $self->damage_from_battle($attacker, $attacker_damage, $defender); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 11 | $self->damage_from_battle($defender, $defender_damage, $attacker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 11 | $attacker->register_event("CASUALITIES IN WAR WITH " . $defender->name . ": $attacker_damage"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 11 | $defender->register_event("CASUALITIES IN WAR WITH " . $attacker->name . ": $defender_damage"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 11 | ▶ | if($attacker->army == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | $losers{$attacker->name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | elsif($defender->army == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 2 | $losers{$defender->name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 41 | for(keys %losers) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | $self->lose_war($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | sub lose_war | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lose_war: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 5 | my $loser = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 5 | my $internal_disorder = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 5 | ▶ | $internal_disorder ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$internal_disorder ||= 0
MC/DC100%1/1
$internal_disorder ||= 0
$internal_disorder
Truth table100%2/2
A
A= $internal_disorder
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 5 | my @wars = $self->get_wars($loser); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 5 | my $retreat_penality = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 5 | my @conquerors = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 5 | my $conquerors_leader = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 5 | foreach my $w (@wars) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 3 | my $other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | my $winner_role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 3 | ▶ | if($w->node1 eq $loser) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | #Loser is the attacker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | $retreat_penality = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | $other = $w->node2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1 | $winner_role = "[DEFENDER]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | $self->send_event("RETREAT FROM " . $other, $loser); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | elsif($w->node2 eq $loser) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | #Loser is the defender | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 2 | $other = $w->node1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 2 | push @conquerors, $w->node1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2 | $self->delete_crisis($loser, $other); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 2 | $conquerors_leader = $w->attack_leader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2 | $winner_role = "[ATTACKER]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 2 | $self->get_nation($loser)->internal_disorder(AFTER_CONQUERED_INTERNAL_DISORDER); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | my $ending_line = "WAR BETWEEN $other AND $loser WON BY $other $winner_role"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 3 | $self->broadcast_event($ending_line, $other, $loser); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 3 | my $history_line = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 3 | $self->cash_war_bonds($other); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 3 | $self->discard_war_bonds($loser); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 3 | $history_line .= "$other $winner_role won the war"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 3 | $self->delete_war($other, $loser, $history_line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 5 | ▶ | if(@conquerors > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | $self->occupy($loser, \@conquerors, $conquerors_leader, $internal_disorder); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | sub delete_war | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_war: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 4 | my $nation1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 4 | my $nation2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 4 | my $ending_line = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 4 | my $war = $self->war_exists($nation1, $nation2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 4 | $war->end_date($self->current_year); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 4 | $war->register_event($ending_line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 4 | push @{$self->memorial}, $war; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 4 | $self->delete_war_link($nation1, $nation2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | sub print_wars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_wars: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 1 | my %grouped_wars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 1 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 1 | $out .= as_title("WARS\n===\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | foreach my $w ($self->wars->all()) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 1 | ▶ | if(! exists $grouped_wars{$w->war_id}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | $grouped_wars{$w->war_id} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 1 | push @{$grouped_wars{$w->war_id}}, $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | foreach my $k (keys %grouped_wars) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 1 | $out .= "### WAR $k\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 1 | foreach my $w ( @{$grouped_wars{$k}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 1 | my $nation1 = $self->get_nation($w->node1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 1 | my $nation2 = $self->get_nation($w->node2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1 | $out .= $w->print($nation1->army, $nation2->army); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1 | $out .= "---\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 1 | $out .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 1 | foreach my $n (@{$self->nation_names}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 5 | ▶ | if($self->at_civil_war($n)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $out .= "$n is fighting civil war\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 1 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | sub dump_memorial | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_memorial: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $io = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my $indent = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | foreach my $w (@{$self->memorial}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | print {$io} $w->dump($io, $indent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | sub load_memorial | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_memorial: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my $war_data = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my @memorial; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my @lines = split "\n", $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | foreach my $l (@lines) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if($l !~ /^\s/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if($war_data) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | push @memorial, BalanceOfPower::Relations::War->load($war_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $war_data = $l . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $war_data = $l . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | $war_data .= $l . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | return \@memorial; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||