line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Relations::Influence; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Relations::Influence::VERSION = '0.400110'; |
3
|
13
|
|
|
13
|
|
44
|
use strict; |
|
13
|
|
|
|
|
16
|
|
|
13
|
|
|
|
|
272
|
|
4
|
13
|
|
|
13
|
|
92
|
use v5.10; |
|
13
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
40
|
use Moo; |
|
13
|
|
|
|
|
13
|
|
|
13
|
|
|
|
|
53
|
|
7
|
13
|
|
|
13
|
|
2642
|
use BalanceOfPower::Constants ':all'; |
|
13
|
|
|
|
|
15
|
|
|
13
|
|
|
|
|
11424
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'BalanceOfPower::Relations::Role::Relation'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Status: |
13
|
|
|
|
|
|
|
# 0: occupy |
14
|
|
|
|
|
|
|
# 1: dominate |
15
|
|
|
|
|
|
|
# 2: control |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has status => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
default => -1 |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
has next => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
default => -1 |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
has clock => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
default => 0 |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
sub bidirectional |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
0
|
0
|
0
|
return 0; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
sub status_label |
34
|
|
|
|
|
|
|
{ |
35
|
8
|
|
|
8
|
0
|
5
|
my $self = shift; |
36
|
8
|
100
|
|
|
|
28
|
if($self->status == 0) |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
37
|
|
|
|
|
|
|
{ |
38
|
2
|
|
|
|
|
4
|
return 'occupy'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
elsif($self->status == 1) |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
|
|
0
|
return 'dominate'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif($self->status == 2) |
45
|
|
|
|
|
|
|
{ |
46
|
6
|
|
|
|
|
8
|
return 'control'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
|
|
0
|
return undef; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
sub get_loot_quote |
54
|
|
|
|
|
|
|
{ |
55
|
4
|
|
|
4
|
0
|
4
|
my $self = shift; |
56
|
4
|
50
|
|
|
|
17
|
if($self->status == 0) |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
57
|
|
|
|
|
|
|
{ |
58
|
0
|
|
|
|
|
0
|
return OCCUPATION_LOOT_BY_TYPE |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
elsif($self->status == 1) |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
|
|
0
|
return DOMINATION_LOOT_BY_TYPE; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
elsif($self->status == 2) |
65
|
|
|
|
|
|
|
{ |
66
|
4
|
|
|
|
|
6
|
return CONTROL_LOOT_BY_TYPE; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
|
|
|
|
0
|
return undef; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
sub click |
74
|
|
|
|
|
|
|
{ |
75
|
6
|
|
|
6
|
0
|
4
|
my $self = shift; |
76
|
6
|
|
|
|
|
15
|
$self->clock($self->clock + 1); |
77
|
6
|
100
|
66
|
|
|
28
|
if($self->status == 0 && $self->clock >= OCCUPATION_CLOCK_LIMIT) |
|
|
50
|
33
|
|
|
|
|
78
|
|
|
|
|
|
|
{ |
79
|
2
|
|
|
|
|
4
|
return $self->change_to_next(); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
elsif($self->status == 1 && $self->clock >= DOMINATION_CLOCK_LIMIT) |
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
|
|
0
|
return $self->change_to_next(); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else |
86
|
|
|
|
|
|
|
{ |
87
|
4
|
|
|
|
|
7
|
return $self->status; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
sub change_to_next |
91
|
|
|
|
|
|
|
{ |
92
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
93
|
2
|
|
|
|
|
4
|
$self->status($self->next); |
94
|
2
|
|
|
|
|
3
|
$self->clock(0); |
95
|
2
|
|
|
|
|
3
|
return $self->status_label; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
sub print |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
100
|
0
|
|
|
|
|
0
|
return $self->node1 . " " . $self->status_label . " " . $self->node2; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
sub actual_influence |
103
|
|
|
|
|
|
|
{ |
104
|
19
|
|
|
19
|
0
|
12
|
my $self = shift; |
105
|
19
|
50
|
33
|
|
|
86
|
if(($self->status == 1 && $self->next != -1) || |
|
|
|
33
|
|
|
|
|
106
|
|
|
|
|
|
|
$_->status > 1) |
107
|
|
|
|
|
|
|
{ |
108
|
19
|
|
|
|
|
43
|
return 1; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
else |
111
|
|
|
|
|
|
|
{ |
112
|
0
|
|
|
|
|
|
return 0; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
sub dump |
116
|
|
|
|
|
|
|
{ |
117
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
118
|
0
|
|
|
|
|
|
my $io = shift; |
119
|
0
|
|
0
|
|
|
|
my $indent = shift || ""; |
120
|
0
|
|
|
|
|
|
print {$io} $indent . join(";", $self->node1, $self->node2, $self->status, $self->next, $self->clock) . "\n"; |
|
0
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
sub load |
123
|
|
|
|
|
|
|
{ |
124
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
125
|
0
|
|
|
|
|
|
my $data = shift; |
126
|
0
|
|
|
|
|
|
$data =~ s/^\s+//; |
127
|
0
|
|
|
|
|
|
chomp $data; |
128
|
0
|
|
|
|
|
|
my ($node1, $node2, $status, $next, $clock) = split ";", $data; |
129
|
0
|
|
|
|
|
|
return $self->new(node1 => $node1, node2 => $node2, status => $status, next => $next, clock => $clock); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |