Mercurial > hg > batmud > misc
changeset 199:6994c88ef1cd misc
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 15 Mar 2011 14:01:49 +0200 |
parents | 9f79ddd5175d |
children | fb8a0390158b |
files | log2template.pl |
diffstat | 1 files changed, 72 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/log2template.pl Sat Feb 19 22:20:22 2011 +0200 +++ b/log2template.pl Tue Mar 15 14:01:49 2011 +0200 @@ -242,6 +242,71 @@ } +### Parse the big data blob +sub parse_id_blob($) +{ + my $info = $_[0]; + + # Weight & size + if ($info =~ /It is ([A-Za-z -]+), ([A-Za-z -]+),/) { + $$id{"weight2"} = $1; + $$id{"size"} = $2; + } + + # Quality + if ($info =~ /of ([A-Za-z ]+) quality/) { + $$id{"quality"} = $1; + } + + # Emits darkness or light + if ($info =~ /(emits darkness|emits light)/) { + push(@{$$id{"stats"}}, $1); + $$id{"cat"}{$1} = 1; + } + + # Materials, figure out primary material + if ($info =~ /made of,? ?(.+?), (feather|worth)/) { + @{$$id{"materials"}} = split(/\s*,\s*/, $1); + my $qmat = $$id{"materials"}[0]; + my $qmax = -1; + foreach my $mat (@{$$id{"materials"}}) { + if ($mat =~ /^(\d+)% (.+)$/) { + if ($1 >= $qmax) { + $qmax = $1; + $qmat = $2; + } + } + } + $$id{"material"} = $qmat; + $$id{"cat"}{$qmat} = 1; + } + + # Check for nun relics + if ($$id{"full"} =~ / \(holy\)/) { + $$id{"cat"}{"relic"} = 1; + } + + # Set item class + $$id{"class"} = "Item"; + if ($info =~ /The weapon skill to best use this in combat/) { + $$id{"class"} = "Weapon"; + } elsif (defined($$id{"type"}) && $$id{"type"} ne "") { + $$id{"class"} = "Armour"; + } + + # Check if the weight data is for FW'd item + if ($$id{"full"} =~ / <(yellow|green|white) glow>$/) { + $$id{"kg"} = ""; + $$id{"weight"} = ""; + } else { + if (defined($$id{"kg"}{$$id{"full"}})) { + $$id{"kg"} = $$id{"kg"}{$$id{"full"}}; + } else { + $$id{"kg"} = ""; + } + } +} + sub parse_identify($) { my ($s) = @_; @@ -331,67 +396,13 @@ elsif ($s =~ /^It contains a tale;$/) { $id_tale2 = 1; } - elsif ($s =~ /^(.+?) did the heroic deed to bring this piece of equipment before you (.+)$|^It has been in the game for (.+)$/) { - my $info = $2; - $$id{""} = ""; - - # Parse the big data blob - if ($info =~ /It is ([A-Za-z -]+), ([A-Za-z -]+),/) { - $$id{"weight2"} = $1; - $$id{"size"} = $2; - } - - if ($info =~ /of ([A-Za-z ]+) quality/) { - $$id{"quality"} = $1; - } - - if ($info =~ /(emits darkness|emits light)/) { - push(@{$$id{"stats"}}, $1); - $$id{"cat"}{$1} = 1; - } - - if ($info =~ /made of,? ?(.+?), (feather|worth)/) { - @{$$id{"materials"}} = split(/\s*,\s*/, $1); - my $qmat = $$id{"materials"}[0]; - my $qmax = -1; - foreach my $mat (@{$$id{"materials"}}) { - if ($mat =~ /^(\d+)% (.+)$/) { - if ($1 >= $qmax) { - $qmax = $1; - $qmat = $2; - } - } - } - $$id{"material"} = $qmat; - $$id{"cat"}{$qmat} = 1; - } - - # Check for nun relics - if ($$id{"full"} =~ / \(holy\)/) { - $$id{"cat"}{"relic"} = 1; - } - - # Set item class - $$id{"class"} = "Item"; - if ($info =~ /The weapon skill to best use this in combat/) { - $$id{"class"} = "Weapon"; - } elsif (defined($$id{"type"}) && $$id{"type"} ne "") { - $$id{"class"} = "Armour"; - } - - # Check if the weight data is for FW'd item - if ($$id{"full"} =~ / <(yellow|green|white) glow>$/) { - $$id{"kg"} = ""; - $$id{"weight"} = ""; - } else { - if (defined($$id{"kg"}{$$id{"full"}})) { - $$id{"kg"} = $$id{"kg"}{$$id{"full"}}; - } else { - $$id{"kg"} = ""; - } - } - - # Submit data + elsif ($s =~ /^(.+?) did the heroic deed to bring this piece of equipment before you (.+)$/) { + parse_id_blob($2); + $ids{$$id{"full"}} = $id; + set_state(0, $s); + } + elsif ($s =~ /^It has been in the game for (.+)$/) { + parse_id_blob($1); $ids{$$id{"full"}} = $id; set_state(0, $s); }