line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Commands::TargetNation; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Commands::TargetNation::VERSION = '0.400105'; |
3
|
13
|
|
|
13
|
|
3956
|
use Moo; |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
52
|
|
4
|
13
|
|
|
13
|
|
2360
|
use v5.10; |
|
13
|
|
|
|
|
34
|
|
5
|
13
|
|
|
13
|
|
51
|
use IO::Prompter; |
|
13
|
|
|
|
|
15
|
|
|
13
|
|
|
|
|
81
|
|
6
|
13
|
|
|
13
|
|
605
|
use Data::Dumper; |
|
13
|
|
|
|
|
18
|
|
|
13
|
|
|
|
|
4129
|
|
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
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
62
|
0
|
|
|
|
|
0
|
my $nation = shift; |
63
|
0
|
0
|
|
|
|
0
|
return 0 if(! $nation); |
64
|
0
|
|
|
|
|
0
|
my @nations = $self->get_available_targets(); |
65
|
0
|
|
|
|
|
0
|
my @selected = grep { $_ eq $nation} @nations; |
|
0
|
|
|
|
|
0
|
|
66
|
0
|
0
|
|
|
|
0
|
if(@selected >= 1) |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
|
|
0
|
return 1; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
|
|
|
|
0
|
return 0; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub get_available_targets |
77
|
|
|
|
|
|
|
{ |
78
|
49
|
|
|
49
|
0
|
48
|
my $self = shift; |
79
|
49
|
|
|
|
|
32
|
my @nations = @{$self->world->nation_names}; |
|
49
|
|
|
|
|
159
|
|
80
|
49
|
50
|
|
|
|
136
|
if($self->exclude_actor) |
81
|
|
|
|
|
|
|
{ |
82
|
49
|
|
|
|
|
54
|
@nations = grep { $_ ne $self->actor } @nations; |
|
245
|
|
|
|
|
320
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
return @nations |
85
|
49
|
|
|
|
|
115
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |