| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package BalanceOfPower::Role::Rebel; |
|
2
|
|
|
|
|
|
|
$BalanceOfPower::Role::Rebel::VERSION = '0.400105'; |
|
3
|
13
|
|
|
13
|
|
4524
|
use strict; |
|
|
13
|
|
|
|
|
20
|
|
|
|
13
|
|
|
|
|
289
|
|
|
4
|
13
|
|
|
13
|
|
103
|
use v5.10; |
|
|
13
|
|
|
|
|
29
|
|
|
5
|
13
|
|
|
13
|
|
63
|
use Moo::Role; |
|
|
13
|
|
|
|
|
16
|
|
|
|
13
|
|
|
|
|
96
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
5935
|
use BalanceOfPower::CivilWar; |
|
|
13
|
|
|
|
|
27
|
|
|
|
13
|
|
|
|
|
345
|
|
|
8
|
13
|
|
|
13
|
|
66
|
use BalanceOfPower::Constants ':all'; |
|
|
13
|
|
|
|
|
18
|
|
|
|
13
|
|
|
|
|
13193
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
requires 'broadcast_event'; |
|
11
|
|
|
|
|
|
|
requires 'war_report'; |
|
12
|
|
|
|
|
|
|
requires 'lose_war'; |
|
13
|
|
|
|
|
|
|
requires 'supported'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has civil_wars => ( |
|
17
|
|
|
|
|
|
|
is => 'rw', |
|
18
|
|
|
|
|
|
|
default => sub { [] } |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has civil_memorial => ( |
|
22
|
|
|
|
|
|
|
is => 'rw', |
|
23
|
|
|
|
|
|
|
default => sub { [] } |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_civil_war |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
641
|
|
|
641
|
0
|
506
|
my $self = shift; |
|
30
|
641
|
|
|
|
|
494
|
my $nation = shift; |
|
31
|
641
|
|
|
|
|
451
|
for(@{$self->civil_wars}) |
|
|
641
|
|
|
|
|
1191
|
|
|
32
|
|
|
|
|
|
|
{ |
|
33
|
104
|
100
|
|
|
|
348
|
return $_ if $_->is_about($nation); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
584
|
|
|
|
|
986
|
return undef; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub start_civil_war |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
5
|
|
|
5
|
0
|
7
|
my $self = shift; |
|
41
|
5
|
|
|
|
|
8
|
my $nation = shift; |
|
42
|
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
19
|
my $rebel_provinces = STARTING_REBEL_PROVINCES->[$nation->size]; |
|
44
|
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
47
|
my $civwar = BalanceOfPower::CivilWar->new(nation => $nation, |
|
46
|
|
|
|
|
|
|
rebel_provinces => $rebel_provinces, |
|
47
|
|
|
|
|
|
|
start_date => $nation->current_year); |
|
48
|
5
|
|
|
|
|
91
|
$civwar->register_event("Starting army: " . $nation->army); |
|
49
|
5
|
|
|
|
|
33
|
my $sup = $self->supported($nation->name); |
|
50
|
5
|
50
|
|
|
|
16
|
if($sup) |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
0
|
|
|
|
|
0
|
$civwar->register_event("Support to government from " . $sup->node1); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
5
|
|
|
|
|
53
|
$self->broadcast_event({ code => "civiloutbreak", |
|
55
|
|
|
|
|
|
|
text => "CIVIL WAR OUTBREAK IN " . $nation->name, |
|
56
|
|
|
|
|
|
|
involved => [$nation->name] }, $nation->name); |
|
57
|
5
|
|
|
|
|
40
|
$self->war_report("Civil war in " . $nation->name . "!", $nation->name); |
|
58
|
5
|
|
|
|
|
32
|
my $occupied = $self->lose_war($nation->name, 1); |
|
59
|
5
|
50
|
|
|
|
15
|
if(! $occupied) |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
5
|
|
|
|
|
18
|
$self->add_civil_war($civwar); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub add_civil_war |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
5
|
|
|
5
|
0
|
7
|
my $self = shift; |
|
68
|
5
|
|
|
|
|
7
|
my $civwar = shift; |
|
69
|
5
|
|
|
|
|
30
|
my $already = $self->get_civil_war($civwar->nation->name); |
|
70
|
5
|
50
|
|
|
|
14
|
if($already) |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
0
|
|
|
|
|
0
|
say "ERROR: Civil war in " . $civwar->nation->name . " already present!"; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
else |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
5
|
|
|
|
|
7
|
push @{$self->civil_wars}, $civwar; |
|
|
5
|
|
|
|
|
23
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
sub delete_civil_war |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
|
82
|
2
|
|
|
|
|
4
|
my $nation = shift; |
|
83
|
2
|
|
|
|
|
4
|
my $cw = $self->get_civil_war($nation); |
|
84
|
2
|
50
|
|
|
|
6
|
if($cw) |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
2
|
|
|
|
|
11
|
$cw->end_date($self->current_year); |
|
87
|
|
|
|
|
|
|
|
|
88
|
2
|
|
|
|
|
3
|
push @{$self->civil_memorial}, $cw; |
|
|
2
|
|
|
|
|
8
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
2
|
|
|
|
|
2
|
my @civwars = grep { ! $_->is_about($nation) } @{$self->civil_wars}; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
6
|
|
|
91
|
2
|
|
|
|
|
9
|
$self->civil_wars(\@civwars); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
sub civil_war_current_year |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
46
|
|
|
46
|
0
|
64
|
my $self = shift; |
|
96
|
46
|
|
|
|
|
48
|
for(@{$self->civil_wars}) |
|
|
46
|
|
|
|
|
150
|
|
|
97
|
|
|
|
|
|
|
{ |
|
98
|
16
|
|
|
|
|
59
|
$_->current_year($self->current_year); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub at_civil_war |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
442
|
|
|
442
|
0
|
382
|
my $self = shift; |
|
105
|
442
|
|
|
|
|
353
|
my $n = shift; |
|
106
|
442
|
100
|
|
|
|
658
|
if($self->get_civil_war($n)) |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
32
|
|
|
|
|
87
|
return 1; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
else |
|
111
|
|
|
|
|
|
|
{ |
|
112
|
410
|
|
|
|
|
1225
|
return 0; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub dump_civil_memorial |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
119
|
0
|
|
|
|
|
|
my $io = shift; |
|
120
|
0
|
|
|
|
|
|
my $indent = shift; |
|
121
|
0
|
|
|
|
|
|
foreach my $cw (@{$self->civil_memorial}) |
|
|
0
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
{ |
|
123
|
0
|
|
|
|
|
|
print {$io} $cw->dump($io, $indent); |
|
|
0
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
sub load_civil_memorial |
|
127
|
|
|
|
|
|
|
{ |
|
128
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
129
|
0
|
|
|
|
|
|
my $data = shift; |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$data .= "EOF"; |
|
132
|
0
|
|
|
|
|
|
my $war_data = ""; |
|
133
|
0
|
|
|
|
|
|
my @memorial; |
|
134
|
0
|
|
|
|
|
|
my @lines = split "\n", $data; |
|
135
|
0
|
|
|
|
|
|
foreach my $l (@lines) |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
0
|
0
|
|
|
|
|
if($l !~ /^\s/) |
|
138
|
|
|
|
|
|
|
{ |
|
139
|
0
|
0
|
|
|
|
|
if($war_data) |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
0
|
|
|
|
|
|
my $cw = BalanceOfPower::CivilWar->load($war_data); |
|
142
|
0
|
|
|
|
|
|
$cw->load_nation($self); |
|
143
|
0
|
|
|
|
|
|
push @memorial, $cw; |
|
144
|
0
|
|
|
|
|
|
$war_data = $l . "\n"; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
else |
|
147
|
|
|
|
|
|
|
{ |
|
148
|
0
|
|
|
|
|
|
$war_data = $l . "\n"; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
else |
|
152
|
|
|
|
|
|
|
{ |
|
153
|
0
|
|
|
|
|
|
$war_data .= $l . "\n"; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
} |
|
156
|
0
|
|
|
|
|
|
return \@memorial; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|