Mercurial > hg > batmud > misc
changeset 87:28e24f92e957 misc
Try to improve mage staff shortdesc grabbing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 25 Apr 2010 01:48:13 +0000 |
parents | 3e301f23b20d |
children | 6d3f15ee18d9 |
files | magestats.pl |
diffstat | 1 files changed, 44 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/magestats.pl Sun Apr 25 01:07:24 2010 +0000 +++ b/magestats.pl Sun Apr 25 01:48:13 2010 +0000 @@ -188,7 +188,44 @@ my $crit_flag = 0; my $crit_type; my $last_spell = ""; -my @staff = (); + +sub staff_update($$) +{ + my $tmp = $_[0]; + my $post = $_[1]; + +#print STDERR "foo: $tmp : $post\n"; + + if ($post =~ / glow>/) { + $tmp .= " <red glow>"; + } else { + $tmp .= $post; + } + + if ($spells->{"staff"}{"desc"} ne $tmp) { + mlog(2, "Staff change '".$spells->{"staff"}{"desc"}."' -> '$tmp'\n"); + my %blasts = (); + my $area = 0; + + foreach my $type (keys %spell_data) { + foreach my $class ("single", "area") { + my $name = $spells->{$type}{$class}; + $blasts{$class} += $spells->{$name}{"blasts"}; + } + } + + push(@{$spells->{"staff"}{"data"}}, + { + "desc" => $tmp, + "blasts" => $spells->{"total"}{"blasts"}, + "major" => $blasts{"single"} + $blasts{"area"}, + "single" => $blasts{"single"}, + "area" => $blasts{"area"}, + }); + + $spells->{"staff"}{"desc"} = $tmp; + } +} mlog(2, "Matching regexp '$match'\n"); @@ -197,39 +234,12 @@ } else { mlog(1, "Parsing log from stdin..."); while (defined(my $s = <STDIN>)) { - if ($s =~ /^You wear .* ((\S+ the |)(|Shimmering |Radiating |Glowing )([Ww]hite|[Gg]rey|[Dd]ark|[Bb]lack) mage staff)( <.+? glow>| of Power)/) { - my $tmp = $1; - my $post = $5; - - if ($post =~ / glow>/) { - $tmp .= " <red glow>"; - } else { - $tmp .= $post; - } - - if ($spells->{"staff"}{"desc"} ne $tmp) { - mlog(2, "Staff change '".$spells->{"staff"}{"desc"}."' -> '$tmp'\n"); - my %blasts = (); - my $area = 0; - - foreach my $type (keys %spell_data) { - foreach my $class ("single", "area") { - my $name = $spells->{$type}{$class}; - $blasts{$class} += $spells->{$name}{"blasts"}; - } - } - - push(@{$spells->{"staff"}{"data"}}, - { - "desc" => $tmp, - "blasts" => $spells->{"total"}{"blasts"}, - "major" => $blasts{"single"} + $blasts{"area"}, - "single" => $blasts{"single"}, - "area" => $blasts{"area"}, - }); - - $spells->{"staff"}{"desc"} = $tmp; - } + if ($s =~ /^You wear.*? (\S+ the (Shimmering|Radiating|Glowing) ([Ww]hite|[Gg]rey|[Dd]ark|[Bb]lack) mage staff)( <.+? glow>| of Power)/) { + staff_update($1, $4); + } elsif ($s =~ /^You wear.*? ((Shimmering|Radiating|Glowing) ([Ww]hite|[Gg]rey|[Dd]ark|[Bb]lack) mage staff)( <.+? glow>| of Power)/) { + staff_update($1, $4); + } elsif ($s =~ /^You wear.*? (([Ww]hite|[Gg]rey|[Dd]ark|[Bb]lack) mage staff)( <.+? glow>| of Power)/) { + staff_update($1, $3); } elsif ($s =~ /^Time to choose your reincarnation method./) { # Set reinc flags for each type that has essence foreach my $type (keys %spell_data) {