line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Player; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Player::VERSION = '0.400105'; |
3
|
13
|
|
|
13
|
|
48
|
use strict; |
|
13
|
|
|
|
|
16
|
|
|
13
|
|
|
|
|
293
|
|
4
|
13
|
|
|
13
|
|
118
|
use v5.10; |
|
13
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
43
|
use Moo; |
|
13
|
|
|
|
|
16
|
|
|
13
|
|
|
|
|
89
|
|
7
|
13
|
|
|
13
|
|
3095
|
use BalanceOfPower::Constants ':all'; |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
12676
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'BalanceOfPower::Role::Reporter'; |
10
|
|
|
|
|
|
|
with 'BalanceOfPower::Player::Role::Broker'; |
11
|
|
|
|
|
|
|
with 'BalanceOfPower::Player::Role::Hitman'; |
12
|
|
|
|
|
|
|
with 'BalanceOfPower::Player::Role::Traveler'; |
13
|
|
|
|
|
|
|
with 'BalanceOfPower::Player::Role::Cargo'; |
14
|
|
|
|
|
|
|
#with 'BalanceOfPower::Player::Role::Friend'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has name => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
default => 'Player' |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
has current_year => ( |
22
|
|
|
|
|
|
|
is => 'rw' |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub dump |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
29
|
0
|
|
|
|
|
|
my $io = shift; |
30
|
0
|
|
0
|
|
|
|
my $indent = shift || ""; |
31
|
0
|
|
|
|
|
|
print {$io} $indent . |
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
join(";", $self->name, $self->money, $self->current_year, $self->mission_points) . "\n"; |
33
|
0
|
|
|
|
|
|
print {$io} $indent . " " . "### WALLET\n"; |
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$self->dump_wallet($io, " " . $indent); |
35
|
0
|
|
|
|
|
|
print {$io} $indent . " " . "### EVENTS\n"; |
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->dump_events($io, " " . $indent); |
37
|
0
|
|
|
|
|
|
print {$io} $indent . " " . "### TARGETS\n"; |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$self->dump_targets($io, " " . $indent); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub load |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
my $data = shift; |
45
|
0
|
|
|
|
|
|
my $version = shift; |
46
|
0
|
|
|
|
|
|
my $world = shift; |
47
|
0
|
|
|
|
|
|
my @player_lines = split /\n/, $data; |
48
|
0
|
|
|
|
|
|
my $player_line = shift @player_lines; |
49
|
0
|
|
|
|
|
|
$player_line =~ s/^\s+//; |
50
|
0
|
|
|
|
|
|
chomp $player_line; |
51
|
0
|
|
|
|
|
|
my %params = $self->manage_player_line($player_line, $version); |
52
|
0
|
|
|
|
|
|
my $what = ''; |
53
|
0
|
|
|
|
|
|
my $extracted_data; |
54
|
0
|
|
|
|
|
|
my $wallet = {}; |
55
|
0
|
|
|
|
|
|
my $targets = []; |
56
|
0
|
|
|
|
|
|
my $events = {}; |
57
|
0
|
|
|
|
|
|
foreach my $line (@player_lines) |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
|
|
|
$line =~ s/^\s+//; |
60
|
0
|
|
|
|
|
|
chomp $line; |
61
|
0
|
0
|
|
|
|
|
if($line eq '### WALLET') |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
|
|
|
$what = 'wallet'; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif($line eq '### EVENTS') |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
|
$what = 'events'; |
68
|
0
|
|
|
|
|
|
$wallet = $self->load_wallet($extracted_data); |
69
|
0
|
|
|
|
|
|
$extracted_data = ""; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
elsif($line eq '### TARGETS') |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
|
|
|
$what = 'targets'; |
74
|
0
|
|
|
|
|
|
$events = $self->load_events($extracted_data); |
75
|
0
|
|
|
|
|
|
$extracted_data = ""; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
|
|
|
$extracted_data .= $line . "\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
0
|
0
|
|
|
|
|
if($what eq 'targets') |
|
|
0
|
|
|
|
|
|
83
|
|
|
|
|
|
|
{ |
84
|
0
|
|
|
|
|
|
$targets = $self->load_targets($extracted_data, $world); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
elsif($what eq 'events') |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
|
|
|
|
|
$events = $self->load_events($extracted_data); |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
|
$params{'wallet'} = $wallet; |
91
|
0
|
|
|
|
|
|
$params{'events'} = $events; |
92
|
0
|
|
|
|
|
|
$params{'targets'} = $targets; |
93
|
0
|
|
|
|
|
|
return $self->new(%params); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub manage_player_line |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
99
|
0
|
|
|
|
|
|
my $data = shift; |
100
|
0
|
|
|
|
|
|
my $version = shift; |
101
|
0
|
0
|
|
|
|
|
if($version >= 3) |
102
|
|
|
|
|
|
|
{ |
103
|
0
|
|
|
|
|
|
my ($name, $money, $current_year, $mission_points) = split ";", $data; |
104
|
0
|
|
|
|
|
|
return ( name => $name, |
105
|
|
|
|
|
|
|
money => $money, |
106
|
|
|
|
|
|
|
current_year => $current_year, |
107
|
|
|
|
|
|
|
mission_points => $mission_points ); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
else |
110
|
|
|
|
|
|
|
{ |
111
|
0
|
|
|
|
|
|
my ($name, $money, $current_year) = split ";", $data; |
112
|
0
|
|
|
|
|
|
return ( name => $name, |
113
|
|
|
|
|
|
|
money => $money, |
114
|
|
|
|
|
|
|
current_year => $current_year, |
115
|
|
|
|
|
|
|
mission_points => 0 ); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |