changeset 90:bf736fdd4290 misc

Cleanups, added debug thingies.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 25 Apr 2010 04:35:04 +0000
parents 56cee55c2a6c
children d513a05279d3
files magestats.pl
diffstat 1 files changed, 16 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/magestats.pl	Sun Apr 25 03:28:10 2010 +0000
+++ b/magestats.pl	Sun Apr 25 04:35:04 2010 +0000
@@ -197,21 +197,20 @@
 my $crit_type;
 my $last_spell = "";
 
-sub staff_update($$)
+sub staff_update($$$)
 {
-  my $tmp = $_[0];
-  my $post = $_[1];
+  my $desc = $_[0];
+  my $postfix = $_[1];
+  my $line = $_[2];
   
-#print STDERR "foo: $tmp : $post\n";
-
-  if ($post =~ / glow>/) {
-    $tmp .= " <red glow>";
+  if ($postfix =~ / glow>/) {
+    $desc .= " <red glow>";
   } else {
-    $tmp .= $post;
+    $desc .= $postfix;
   }
       
-  if ($spells->{"staff"}{"desc"} ne $tmp) {
-    mlog(2, "Staff change '".$spells->{"staff"}{"desc"}."' -> '$tmp'\n");
+  if ($spells->{"staff"}{"desc"} ne $desc) {
+    mlog(2, "Staff change '".$spells->{"staff"}{"desc"}."' -> '$desc'\n# $line\n");
     my %blasts = ();
     my $area = 0;
 
@@ -224,14 +223,14 @@
 
     push(@{$spells->{"staff"}{"data"}},
       {
-        "desc" => $tmp,
+        "desc" => $desc,
         "blasts" => $spells->{"total"}{"blasts"},
         "major" => $blasts{"single"} + $blasts{"area"},
         "single" => $blasts{"single"},
         "area" => $blasts{"area"},
       });
 
-    $spells->{"staff"}{"desc"} = $tmp;
+    $spells->{"staff"}{"desc"} = $desc;
   }
 }
 
@@ -284,11 +283,13 @@
   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)/) {
-      staff_update($1, $4);
+      staff_update($1, $4, $s);
+    } elsif ($s =~ /^You wear.*? (\S+ the ([Ww]hite|[Gg]rey|[Dd]ark|[Bb]lack) mage staff)( <.+? glow>| of Power)/) {
+      staff_update($1, $4, $s);
     } elsif ($s =~ /^You wear.*? ((Shimmering|Radiating|Glowing) ([Ww]hite|[Gg]rey|[Dd]ark|[Bb]lack) mage staff)( <.+? glow>| of Power)/) {
-      staff_update($1, $4);
+      staff_update($1, $4, $s);
     } elsif ($s =~ /^You wear.*? (([Ww]hite|[Gg]rey|[Dd]ark|[Bb]lack) mage staff)( <.+? glow>| of Power)/) {
-      staff_update($1, $3);
+      staff_update($1, $3, $s);
     } elsif ($s =~ /^Time to choose your reincarnation method./) {
       # Set reinc flags for each type that has essence
       foreach my $type (keys %spell_data) {