Mercurial > hg > batmud > misc
changeset 73:54e33015ba7c misc
Lots of fixes, and minor improvements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 09 Apr 2010 16:16:01 +0000 |
parents | bc05f9d391bb |
children | 6483aa47f297 |
files | magestats.pl |
diffstat | 1 files changed, 53 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/magestats.pl Fri Apr 09 10:58:42 2010 +0000 +++ b/magestats.pl Fri Apr 09 16:16:01 2010 +0000 @@ -13,13 +13,13 @@ # List of spells per damage type. Only major blasts/areas. my %spell_data = ( - "acid" => [ "acid blast", "acid storm" ], - "fire" => [ "lava blast", "lava storm" ], - "elec" => [ "electrocution", "lightning storm" ], - "pois" => [ "summon carnal spores", "killing cloud" ], - "cold" => [ "cold ray", "hailstorm" ], - "mana" => [ "golden arrow", "magic eruption" ], - "asph" => [ "blast vacuum", "vacuum globe" ], + "acid" => [ "acid blast", "acid storm", "acid ray", "acid rain", "acid arrow", "acid wind", "disruption" ], + "fire" => [ "lava blast", "lava storm", "meteor blast", "meteor swarm", "fire blast", "fire bolt", "flame arrow" ], + "elec" => [ "electrocution", "lightning storm", "forked lightning", "chain lightning", "blast lightning", "lightning bolt", "shocking grasp" ], + "pois" => [ "summon carnal spores","killing cloud", "power blast", "venom strike", "poison blast", "poison spray", "thorn spray" ], + "cold" => [ "cold ray", "hailstorm", "ice bolt", "cone of cold", "darkfire", "flaming ice", "chill touch" ], + "mana" => [ "golden arrow", "magic eruption", "summon greater spores", "magic wave", "levin bolt", "summon lesser spores", "magic missile" ], + "asph" => [ "blast vacuum", "vacuum globe", "strangulation", "chaos bolt", "vacuum ball", "suffocation", "vacuumbolt" ], ); # Settings and defaults @@ -44,7 +44,7 @@ ### Print out help if no arguments given ### my $opt_mode = shift or die( -"Magestats - BatMUD Mage guild statistics generator +"Magestats v0.4 - BatMUD Mage guild statistics generator Developed by Matti Hamalainen (Ggr \@ bat), <ccr\@tnsp.org> (C) Copyright 2010 Tecnic Software productions (TNSP) @@ -130,46 +130,51 @@ ### ### Scan input for blasts etc. ### -my $match_single = join("|", @{$spells->{"single"}}); -my $match_area = join("|", @{$spells->{"area"}}); +my @all_spells = (); +foreach my $type (keys %spell_data) { + push(@all_spells, @{$spell_data{$type}}); +} +my $match = join("|", @all_spells); my $essence_flag = 0; my $last_spell = ""; +#print STDERR "$match\n"; + if ($opt_noinput) { mlog(1, "Skipping input parsing."); } else { -mlog(1, "Parsing log from stdin..."); -while (defined(my $s = <STDIN>)) { - if ($s =~ /^You watch with selfpride as your ($match_single) hits / || $s =~ /^You hit .+ with your ($match_area)\.$/) { - $last_spell = $1; + mlog(1, "Parsing log from stdin..."); + while (defined(my $s = <STDIN>)) { + if ($s =~ /^You watch with selfpride as your ($match) hits / || + $s =~ /^You hit .+ with your ($match)\.$/ || + $s =~ /^Your ($match) hits /) { + $last_spell = $1; - $spells->{$last_spell}{"blasts"}++; - $spells->{"total"}{"blasts"}++; + $spells->{$last_spell}{"blasts"}++; + $spells->{"total"}{"blasts"}++; - if ($essence_flag) { - my $type = get_spell_type($last_spell); - $spells->{$type}{"essence"}{"increase"}++; + # If essence was gained, get the type etc .. + if ($essence_flag) { + my $type = get_spell_type($last_spell); + $spells->{$type}{"essence"}{"increase"}++; - foreach my $class ("single", "area") { - my $name = $spells->{$type}{$class}; - push(@{$spells->{$type}{"essence"}{"blasts"}{$class}}, $spells->{$name}{"blasts"}); - -# foreach my $crit ("1", "2", "3", "") { -# push(@{$spells->{$type}{"essence"}{"crits_".$crit}{$class}}, $spells->{$name}{"crits_".$crit}); -# } - } + # 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"}); + } - $essence_flag = 0; + $essence_flag = 0; + } + } elsif ($s =~ /^Your knowledge in elemental powers helps you to save the reagent for further use\./) { + $spells->{get_spell_type($last_spell)}{"reagents"}++; + $spells->{"total"}{"reagents"}++; + } elsif ($s =~ /^You feel your skills in handling elemental forces improve\./) { + $essence_flag = 1; + $spells->{"total"}{"essence"}++; } - } elsif ($s =~ /^Your knowledge in elemental powers helps you to save the reagent for further use\./) { - $spells->{get_spell_type($last_spell)}{"reagents"}++; - $spells->{"total"}{"reagents"}++; - } elsif ($s =~ /^You feel your skills in handling elemental forces improve\./) { - $essence_flag = 1; - $spells->{"total"}{"essence"}++; } } -} ### @@ -214,17 +219,23 @@ </tr> |; +my $major_blasts = 0; foreach my $type (sort { $a cmp $b } keys %spell_data) { - my $s = $spells->{$type}{"single"}; - my $a = $spells->{$type}{"area"}; + my $s_s = $spells->{$type}{"single"}; + my $s_a = $spells->{$type}{"area"}; + + my $b_s = $spells->{$s_s}{"blasts"}; + my $b_a = $spells->{$s_a}{"blasts"}; + + $major_blasts += $b_s + $b_a; print OUT "<tr><td>$type</td><td> <table border=\"1\"><th></th><th>Single</th><th>Area</th></tr> - <tr><th>Name</th><td>$s</td><td>$a</td></tr> - <tr><th>Blasts</th><td>".$spells->{$s}{"blasts"}."</td><td>".$spells->{$a}{"blasts"}."</td></tr> + <tr><th>Name</th><td>$s_s</td><td>$s_a</td></tr> + <tr><th>Blasts</th><td>".$b_s."</td><td>".$b_a."</td></tr> </table>"; - my $total_blasts = $spells->{$s}{"blasts"} + $spells->{$a}{"blasts"}; + my $total_blasts = $b_s + $b_a; printf OUT "</td><td><b>%d</b> (%1.2f %%)</td><td>%d</td><td>", $spells->{$type}{"reagents"}, @@ -243,7 +254,8 @@ print OUT "</table> <p> -Total blasts: <b>".$spells->{"total"}{"blasts"}."</b><br /> +Total major blasts: <b>".$major_blasts."</b><br /> +Total blasts: <b>".$spells->{"total"}{"blasts"}."</b> (including minor)<br /> Total reagents saved: <b>".$spells->{"total"}{"reagents"}."</b><br /> Total essence gained: <b>".$spells->{"total"}{"essence"}."</b><br /> </p>