-
Notifications
You must be signed in to change notification settings - Fork 2
/
killmatrix.pl
executable file
·55 lines (52 loc) · 1.32 KB
/
killmatrix.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl
foreach $file (@ARGV) {
$tanks = {};
open FH, "<$file";
foreach (<FH>) {
chomp;
@tank{"id","path","cause","killer","errorpos","error"} = split;
$tanks->{$tank{"id"}} = {%tank};
$paths->{$tank{"path"}}++};
foreach (values %$tanks) {
next if $_->{"killer"} eq "(nil)";
next unless $_->{"cause"} eq "shot";
$data->{$tanks->{$_->{"killer"}}->{"path"}}->{$_->{"path"}}++
}
};
@paths = keys %$paths;
print
"var names = [",
(join
",",
map {
open NF, $_."/name";
$name = <NF>;
chomp $name;"\"$name\""
}
@paths
),
"];\n";
print "var colors = [",
(join
",",
map {
open CF, $_."/color";
$color = <CF>;
$color ||= "#c0c0c0";
chomp $color;
"\"$color\""
} @paths
),
"];\n";
print
"var matrix = [\n [",
(join
("],\n [",
map {
join(
",",
map{$_||=0} @{$data->{$_}}{@paths}
)
}
@paths)
),"]\n];\n";