| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package BalanceOfPower::Commands::TargetNation; |
|
2
|
|
|
|
|
|
|
$BalanceOfPower::Commands::TargetNation::VERSION = '0.400115'; |
|
3
|
13
|
|
|
13
|
|
4919
|
use Moo; |
|
|
13
|
|
|
|
|
19
|
|
|
|
13
|
|
|
|
|
65
|
|
|
4
|
13
|
|
|
13
|
|
2808
|
use v5.10; |
|
|
13
|
|
|
|
|
51
|
|
|
5
|
13
|
|
|
13
|
|
56
|
use IO::Prompter; |
|
|
13
|
|
|
|
|
21
|
|
|
|
13
|
|
|
|
|
106
|
|
|
6
|
13
|
|
|
13
|
|
812
|
use Data::Dumper; |
|
|
13
|
|
|
|
|
18
|
|
|
|
13
|
|
|
|
|
5104
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with "BalanceOfPower::Commands::Role::Command"; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has exclude_actor => ( |
|
12
|
|
|
|
|
|
|
is => 'rw', |
|
13
|
|
|
|
|
|
|
default => 1 |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub select_message |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
0
|
|
|
0
|
0
|
0
|
return "Select a nation:"; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub execute |
|
22
|
|
|
|
|
|
|
{ |
|
23
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
24
|
0
|
|
|
|
|
0
|
my $query = shift; |
|
25
|
0
|
|
|
|
|
0
|
my $nation = shift; |
|
26
|
0
|
|
|
|
|
0
|
my $argument = $self->extract_argument($query); |
|
27
|
0
|
|
|
|
|
0
|
$argument = $self->world->correct_nation_name($argument); |
|
28
|
0
|
0
|
|
|
|
0
|
if($argument) |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
0
|
0
|
|
|
|
0
|
if($self->good_target($argument)) |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
0
|
|
|
|
|
0
|
return { status => 1, command => $self->name . " " . $argument }; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
else |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
0
|
|
|
|
|
0
|
say "Bad argument provided: $argument"; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
else |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
0
|
0
|
|
|
|
0
|
if($self->good_target($nation)) |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
|
|
0
|
return { status => 1, command => $self->name . " " . $nation }; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
0
|
|
|
|
|
0
|
my @nations = $self->get_available_targets; |
|
47
|
0
|
0
|
|
|
|
0
|
if(@nations > 0) |
|
48
|
|
|
|
|
|
|
{ |
|
49
|
0
|
|
|
|
|
0
|
$nation = prompt $self->select_message, -menu=>\@nations; |
|
50
|
0
|
0
|
|
|
|
0
|
return { status => -3} if ! $nation; |
|
51
|
0
|
|
|
|
|
0
|
return { status => 1, command => $self->name . " " . $nation }; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
else |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
0
|
|
|
|
|
0
|
return { status => -2 }; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub good_target |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
2
|
|
|
2
|
0
|
1
|
my $self = shift; |
|
62
|
2
|
|
|
|
|
3
|
my $nation = shift; |
|
63
|
2
|
50
|
|
|
|
7
|
return 0 if(! $nation); |
|
64
|
2
|
|
|
|
|
7
|
my @nations = $self->get_available_targets(); |
|
65
|
2
|
|
|
|
|
4
|
my @selected = grep { $_ eq $nation} @nations; |
|
|
0
|
|
|
|
|
0
|
|
|
66
|
2
|
50
|
|
|
|
4
|
if(@selected >= 1) |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
0
|
|
|
|
|
0
|
return 1; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
else |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
2
|
|
|
|
|
9
|
return 0; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub get_available_targets |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
65
|
|
|
65
|
0
|
82
|
my $self = shift; |
|
79
|
65
|
|
|
|
|
70
|
my @nations = @{$self->world->nation_names}; |
|
|
65
|
|
|
|
|
221
|
|
|
80
|
65
|
50
|
|
|
|
213
|
if($self->exclude_actor) |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
65
|
|
|
|
|
83
|
@nations = grep { $_ ne $self->actor } @nations; |
|
|
325
|
|
|
|
|
601
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
return @nations |
|
85
|
65
|
|
|
|
|
207
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |