-
Notifications
You must be signed in to change notification settings - Fork 9
/
parsexlog.pl
88 lines (77 loc) · 2.9 KB
/
parsexlog.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/perl
# Dungeon names
%dungeons = ( 0 => "the Dungeons of Doom",
1 => "Gehennom",
2 => "the Gnomish Mines",
3 => "the Quest",
4 => "Sokoban",
5 => "Fort Ludios",
6 => "Vlad's Tower",
7 => "the Elemental Planes" );
# Conducts, in the order that they are stored in the conduct bitfield
@conducts = ( "Foodless", "Vegan", "Vegetarian", "Atheist", "Weaponless",
"Pacifist", "Illiterate", "Polypileless", "Polyselfless",
"Wishless", "Artifact Wishless", "Genocideless" );
# Achievements, in the order that they are stored in the achievement
# bitfield
@achievements = ( "Obtained the Bell of Opening",
"Entered Gehennom",
"Obtained the Candelabrum of Invocation",
"Obtained the Book of the Dead",
"Performed the invocation ritual",
"Obtained the Amulet of Yendor",
"Reached the Elemental Planes",
"Reached the Astral Plane",
"Ascended",
"Completed the Mines",
"Completed Sokoban",
"Killed Medusa",
"Killed Nightmare",
"Killed Vecna",
"Killed the Beholder",
"Killed Ruggo the Gnome King",
"Killed Kroo the Kobold King",
"Killed Grund the Orc King",
"Killed The Largest Giant",
"Killed Shelob",
"Killed Girtab",
"Killed Aphrodite",
"Killed Doctor Frankenstein",
"Killed Father Dagon",
"Killed Mother Hydra");
while($entry = <>) {
# Parse the line and store in the hash %field
@fields = split /:/, $entry;
foreach $field (@fields) {
if($field =~ /^([^=]*)=(.*)$/) {
$fname = $1;
$fval = $2;
$field{$fname} = $fval;
}
}
# Display
printf "%s-%s-%s-%s-%s, %s\n", $field{name},
$field{role}, $field{race}, $field{gender}, $field{align},
$field{death};
printf " Died in %s on level %d (max %d). Final HP %d/%d.\n",
$dungeons{$field{deathdnum}}, $field{deathlev}, $field{maxlvl},
$field{hp}, $field{maxhp};
@c = ();
$field{conduct} = oct $field{conduct};
for($i = 0; $i <= $#conducts; $i++) {
if($field{conduct} & (1 << $i)) {
push @c, $conducts[$i];
}
}
print " Conducts: ", join(', ', @c), "\n";
@a = ();
$field{achieve} = oct $field{achieve};
for($i = 0; $i <= $#achievements; $i++) {
if($field{achieve} & (1 << $i)) {
push @a, $achievements[$i];
}
}
print " Notable achievements: ", join(', ', @a), "\n";
printf " The game lasted %d turns, and took %d seconds of playtime.\n",
$field{turns}, $field{realtime};
}