Mercurial > hg > batmud > misc
changeset 89:56cee55c2a6c misc
Perhaps handle old GgrTF mangled logs better.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 25 Apr 2010 03:28:10 +0000 |
parents | 6d3f15ee18d9 |
children | bf736fdd4290 |
files | magestats.pl |
diffstat | 1 files changed, 58 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/magestats.pl Sun Apr 25 01:58:43 2010 +0000 +++ b/magestats.pl Sun Apr 25 03:28:10 2010 +0000 @@ -31,6 +31,7 @@ my $opt_noinput = 0; my $opt_width = 500; my $opt_height = 250; +my $opt_ggrtf = 1; my @crit_types = ("Unseen", "ENERGY", "POWER", "power"); @@ -46,7 +47,7 @@ ### Print out help if no arguments given ### my $prog_name = "Magestats"; -my $prog_version = "0.6"; +my $prog_version = "0.6.1"; my $opt_mode = shift or die( "$prog_name v$prog_version - BatMUD Mage guild statistics generator Developed by Matti Hamalainen (Ggr \@ bat), <ccr\@tnsp.org> @@ -61,6 +62,7 @@ -t <png|gif> Image format to be used ('$opt_imgfmt') -s <WxH> Graph dimensions in pixels ($opt_width x $opt_height) -n No input (only handle cache, if specified) + -g Assume GgrTF mangled logfiles NOTICE! The input log data is assumed to be in CHRONOLOGICAL ORDER! Things will go bonkers if that is not the case. Thus, make sure you @@ -82,6 +84,8 @@ $opt_prefix = shift or die("-p option requires an argument.\n"); } elsif ($opt eq "-n") { $opt_noinput = 1; + } elsif ($opt eq "-g") { + $opt_ggrtf = 1; } elsif ($opt eq "-s") { my $tmp = shift or die("-s option requires an argument.\n"); if ($tmp =~ /^(\d+)[x:](\d+)$/) { @@ -231,8 +235,49 @@ } } +sub spell_update($) +{ + $last_spell = $_[0]; + + my $type = get_spell_type($last_spell); + + $spells->{$last_spell}{"blasts"}++; + $spells->{"total"}{"blasts"}++; + $spells->{$type}{"blasts"}++; + + # If essence was gained, get the type etc .. + if ($essence_flag) { + $essence_flag = 0; + + # Handle the post-reinc essence increase + if ($spells->{$type}{"reinc"}) { + mlog(2, "Ignoring post-reinc essence gain for type $type.\n"); + $spells->{$type}{"reinc"} = 0; + } else { + $spells->{"total"}{"essence"}++; + $spells->{$type}{"essence"}{"increase"}++; + + # Save amount of major blasts for each "essence gain" step + foreach my $class ("single", "area") { + my $name = $spells->{$type}{$class}; + push(@{$spells->{$type}{"essence"}{"blasts"}{$class}}, $spells->{$name}{"blasts"}); + } + } + } + + # Crit hits + if ($crit_flag) { + $crit_flag = 0; +# print STDERR "crit: $type : $last_spell : $crit_type\n"; + $spells->{$type}{"crits"}{$crit_type}++; + } +} + +mlog(1, "Using GgrTF format only!") if ($opt_ggrtf); mlog(2, "Matching regexp '$match'\n"); +my $gflag = 0; + if ($opt_noinput) { mlog(1, "Skipping input parsing."); } else { @@ -249,44 +294,20 @@ foreach my $type (keys %spell_data) { $spells->{$type}{"reinc"} = 1 if ($spells->{$type}{"essence"}{"increase"} > 0); } - } elsif ($s =~ /^You watch with selfpride as your ($match) hits / || $s =~ /^You hit .+ with your ($match)\.$/) { - $last_spell = $1; - my $type = get_spell_type($last_spell); - - $spells->{$last_spell}{"blasts"}++; - $spells->{"total"}{"blasts"}++; - $spells->{$type}{"blasts"}++; - - # If essence was gained, get the type etc .. - if ($essence_flag) { - $essence_flag = 0; - - # Handle the post-reinc essence increase - if ($spells->{$type}{"reinc"}) { - mlog(2, "Ignoring post-reinc essence gain for type $type.\n"); - $spells->{$type}{"reinc"} = 0; - } else { - $spells->{"total"}{"essence"}++; - $spells->{$type}{"essence"}{"increase"}++; - - # Save amount of major blasts for each "essence gain" step - foreach my $class ("single", "area") { - my $name = $spells->{$type}{$class}; - push(@{$spells->{$type}{"essence"}{"blasts"}{$class}}, $spells->{$name}{"blasts"}); - } - } - } - - # Crit hits - if ($crit_flag) { - $crit_flag = 0; -# print STDERR "crit: $type : $last_spell : $crit_type\n"; - $spells->{$type}{"crits"}{$crit_type}++; + } elsif ($s =~ /^You watch with selfpride as your ($match) hits / || $s =~ /^You hit .+? with your ($match)\.$/) { + spell_update($1) if $gflag == 0; + $gflag = 0; + } elsif ($s =~ /^Your .($match). hits / || $s =~ /^Your ($match) hits /) { + if ($opt_ggrtf) { + spell_update($1); + $gflag = 1; } } elsif ($s =~ /^Your knowledge in elemental powers helps you to save the reagent for further use\./) { - my $type = get_spell_type($last_spell); - $spells->{$type}{"reagents"}++; - $spells->{"total"}{"reagents"}++; + if ($last_spell ne "") { + my $type = get_spell_type($last_spell); + $spells->{$type}{"reagents"}++; + $spells->{"total"}{"reagents"}++; + } } elsif ($s =~ /^You feel your skills in handling elemental forces improve\./) { $essence_flag = 1; } elsif ($s =~ /^Your fingertips are surrounded with swirling (ENERGY) as you cast the spell\./ ||