Mercurial > hg > batmud > misc
changeset 85:9aa648df2366 misc
Mage staff progression stuff. Probably does not work perfectly yet.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 25 Apr 2010 01:03:26 +0000 |
parents | c3554f46ca49 |
children | 3e301f23b20d |
files | magestats.pl |
diffstat | 1 files changed, 77 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/magestats.pl Sat Apr 24 22:54:31 2010 +0000 +++ b/magestats.pl Sun Apr 25 01:03:26 2010 +0000 @@ -125,6 +125,24 @@ $spells->{"total"}{"essence"} = 0; $spells->{"total"}{"reagents"} = 0; +$spells->{"staff"}{"desc"} = ""; +$spells->{"staff"}{"data"} = []; + +### Convert special characters to HTML/XML entities +my %entities = ( + "<" => "lt", + ">" => "gt", + "&" => "amp", +); + +sub htmlentities($) +{ + my $value = $_[0]; + $value =~ s/$_/\&$entities{$_}\;/g foreach (keys %entities); + return $value; +} + +### Get damage type of given mage spell, die if not known spell. sub get_spell_type($) { my $spell = $_[0]; @@ -170,6 +188,7 @@ my $crit_flag = 0; my $crit_type; my $last_spell = ""; +my @staff = (); mlog(2, "Matching regexp '$match'\n"); @@ -178,7 +197,40 @@ } else { mlog(1, "Parsing log from stdin..."); while (defined(my $s = <STDIN>)) { - if ($s =~ /^Time to choose your reincarnation method./) { + 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; + } + } elsif ($s =~ /^Time to choose your reincarnation method./) { # Set reinc flags for each type that has essence foreach my $type (keys %spell_data) { $spells->{$type}{"reinc"} = 1 if ($spells->{$type}{"essence"}{"increase"} > 0); @@ -334,6 +386,8 @@ <p> Generated with $prog_name v$prog_version by Matti Hämäläinen aka Ggr Pupunen. </p> + +<h2>Blasts, essence, etc</h2> <table class="info"> <tr> <th>Type</th> @@ -398,6 +452,28 @@ Total essence gained: <b>".$spells->{"total"}{"essence"}."</b><br /> </p> +<h2>Mage staff development</h2> +<table class=\"info\"> + <tr> + <th>Blasts</th> + <th>Major blasts</th> + <th>Singles</th> + <th>Areas</th> + <th>Staff short description</th> + </tr> +"; + +foreach my $foo (@{$spells->{"staff"}{"data"}}) { + print OUT "<tr><td>".$foo->{"blasts"}."</td><td>". + $foo->{"major"}."</td><td>".$foo->{"single"}."</td><td>". + $foo->{"area"}."</td><td>".htmlentities($foo->{"desc"})."</td></tr>\n"; +} + +print OUT " +</table> +"; + +print OUT " </body> </html> ";