3 package WeaponEncounterProfile;
9 my ($cls, $filename) = @_;
10 my $self = bless { fn => $filename }, 'WeaponEncounterProfile';
19 $self->{mapstats} = {};
20 $self->{addrstats} = {};
21 $self->{allstats} = {};
22 open my $fh, "<", $self->{fn}
27 my ($addr, $map, $attackerweapon, $targweapon, $value) = split /\t/, $_;
28 $self->{stats}->{$addr}{$map}{$attackerweapon}{$targweapon} += $value;
29 $self->{mapstats}->{$map}{$attackerweapon}{$targweapon} += $value;
30 $self->{addrstats}->{$addr}{$attackerweapon}{$targweapon} += $value;
31 $self->{allstats}->{$attackerweapon}{$targweapon} += $value;
38 open my $fh, ">", $self->{fn}
40 while(my ($addr, $addrhash) = each %{$self->{stats}})
42 while(my ($map, $maphash) = each %$addrhash)
44 while(my ($attackerweapon, $attackerweaponhash) = each %$maphash)
46 while(my ($targweapon, $value) = each %$attackerweaponhash)
48 print $fh "$addr\t$map\t$attackerweapon\t$targweapon\t$value\n";
57 my ($self, $addr, $map, $attackerweapon, $targweapon, $type) = @_;
61 $self->{stats}->{$addr}{$map}{$attackerweapon}{$targweapon} += $type;
62 $self->{mapstats}->{$map}{$attackerweapon}{$targweapon} += $type;
63 $self->{addrstats}->{$addr}{$attackerweapon}{$targweapon} += $type;
64 $self->{allstats}->{$attackerweapon}{$targweapon} += $type;
70 my ($self, $callback) = @_;
72 $callback->(undef, undef, $self->{allstats});
74 while(my ($k, $v) = each %{$self->{addrstats}})
76 $callback->($k, undef, $v);
79 while(my ($k, $v) = each %{$self->{mapstats}})
81 $callback->(undef, $k, $v);
84 while(my ($k1, $v1) = each %{$self->{stats}})
86 while(my ($k2, $v2) = each %$v1)
88 $callback->($k1, $k2, $v2);