line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Targets::Fall; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Targets::Fall::VERSION = '0.400105'; |
3
|
13
|
|
|
13
|
|
43
|
use Moo; |
|
13
|
|
|
|
|
15
|
|
|
13
|
|
|
|
|
64
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with "BalanceOfPower::Targets::Role::Target"; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has government_id => ( |
8
|
|
|
|
|
|
|
is => 'ro' |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
|
11
|
13
|
|
|
13
|
|
2892
|
use constant INTERNAL_DISORDER_LIMIT_FOR_CHOOSE => 40; |
|
13
|
|
|
|
|
15
|
|
|
13
|
|
|
|
|
5683
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub type |
16
|
|
|
|
|
|
|
{ |
17
|
0
|
|
|
0
|
0
|
0
|
return "FALL"; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
sub name |
20
|
|
|
|
|
|
|
{ |
21
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
22
|
1
|
|
|
|
|
7
|
return "Fall of " . $self->target_obj->name |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
sub description |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
0
|
0
|
0
|
return "Make government fall"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
sub achieved |
29
|
|
|
|
|
|
|
{ |
30
|
8
|
|
|
8
|
0
|
9
|
my $self = shift; |
31
|
8
|
|
|
|
|
8
|
my $world = shift; |
32
|
8
|
|
|
|
|
42
|
return $self->target_obj->government_id > $self->government_id; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
sub select_random_target |
35
|
|
|
|
|
|
|
{ |
36
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
37
|
2
|
|
|
|
|
2
|
my $world = shift; |
38
|
2
|
|
|
|
|
4
|
my @possible_targets = (); |
39
|
2
|
|
|
|
|
3
|
for(@{$world->nations}) |
|
2
|
|
|
|
|
8
|
|
40
|
|
|
|
|
|
|
{ |
41
|
11
|
|
|
|
|
8
|
my $n = $_; |
42
|
11
|
100
|
66
|
|
|
24
|
if((! $world->war_busy($n->name)) && |
43
|
|
|
|
|
|
|
$n->internal_disorder < INTERNAL_DISORDER_LIMIT_FOR_CHOOSE ) |
44
|
|
|
|
|
|
|
{ |
45
|
9
|
|
|
|
|
17
|
push @possible_targets, $n; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
2
|
50
|
|
|
|
6
|
if(@possible_targets > 0) |
49
|
|
|
|
|
|
|
{ |
50
|
2
|
|
|
|
|
33
|
@possible_targets = $world->shuffle("Choosing FALL target", @possible_targets); |
51
|
2
|
|
|
|
|
7
|
return $possible_targets[0]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
|
|
|
return undef; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sub dump |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my $io = shift; |
62
|
0
|
|
0
|
|
|
|
my $indent = shift || ""; |
63
|
0
|
|
|
|
|
|
print {$io} $indent . |
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
join(";", "FALL", $self->target_obj->name, $self->government_id, $self->countdown) . "\n"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
sub load_target |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my $world = shift; |
70
|
0
|
|
|
|
|
|
my $nation_obj = $world->get_nation($self->target_to_load); |
71
|
0
|
|
|
|
|
|
$self->target_obj($nation_obj); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
sub load |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
0
|
|
|
|
|
|
my $data = shift; |
77
|
0
|
|
|
|
|
|
my $f_line = ( split /\n/, $data )[0]; |
78
|
0
|
|
|
|
|
|
$f_line =~ s/^\s+//; |
79
|
0
|
|
|
|
|
|
chomp $f_line; |
80
|
0
|
|
|
|
|
|
my ($type, $nation, $government, $countdown) = split ";", $f_line; |
81
|
0
|
|
|
|
|
|
$data =~ s/^.*?\n//; |
82
|
0
|
|
|
|
|
|
return $self->new( target_to_load => $nation, government_id => $government, countdown => $countdown); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
1; |