changeset 170:d5b260fae82a misc

Added experimental option for attempting to ignore blasts for mage staff counters that were cast when staff was not worn.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 06 Jan 2011 20:37:41 +0000
parents 863c9d955d71
children 7198e3ba605c
files magestats.pl
diffstat 1 files changed, 50 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/magestats.pl	Thu Jan 06 17:35:31 2011 +0000
+++ b/magestats.pl	Thu Jan 06 20:37:41 2011 +0000
@@ -76,13 +76,10 @@
  -s <WxH>          Graph dimensions in pixels ($opt_width x $opt_height)
  -n                No input (only handle cache, if specified)
  -g                Assume GgrTF mangled logfiles
-".
 
-# -i                Try to ignore blasts for staff counters that occured
-#                   when staff was not being worn. WARNING! This is a very
-#                   fragile and EXPERIMENTAL feature!
-
-"
+ -i                Try to ignore blasts for staff counters that occured
+                   when staff was not being worn. WARNING! This is a very
+                   fragile and EXPERIMENTAL feature!
 
 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
@@ -131,12 +128,15 @@
   foreach my $spell (@{$src}) {
     $spells->{$spell}{"type"} = $type;
     $spells->{$spell}{"blasts"} = 0;
+    $spells->{"staff"}{$spell}{"blasts"} = 0;
   }
 
   $spells->{$type}{"essence"}{"increase"} = 0;
   $spells->{$type}{"essence"}{"blasts"}{"single"} = [];
   $spells->{$type}{"essence"}{"blasts"}{"area"} = [];
   $spells->{$type}{"reinc"} = 0;
+
+  $spells->{"staff"}{$type}{"blasts"} = 0;
  
   $spells->{$type}{"blasts"} = 0;
   $spells->{$type}{"reagents"} = 0;
@@ -156,7 +156,9 @@
 $spells->{"total"}{"reagents"} = 0;
 
 $spells->{"staff"}{"desc"} = "";
-$spells->{"staff"}{"data"} = [];
+$spells->{"staff"}{"data"}{"normal"} = [];
+$spells->{"staff"}{"data"}{"ignore"} = [];
+$spells->{"staff"}{"total"}{"blasts"} = 0;
 
 
 ### Convert special characters to HTML/XML entities
@@ -237,17 +239,27 @@
     foreach my $type (keys %spell_data) {
       foreach my $class ("single", "area") {
         my $name = $spells->{$type}{$class};
-        $blasts{$class} += $spells->{$name}{"blasts"};
+        $blasts{"ignore"}{$class} += $spells->{"staff"}{$name}{"blasts"};
+        $blasts{"normal"}{$class} += $spells->{$name}{"blasts"};
       }
     }
 
-    push(@{$spells->{"staff"}{"data"}},
+    push(@{$spells->{"staff"}{"data"}{"normal"}},
       {
         "desc" => $desc,
         "blasts" => $spells->{"total"}{"blasts"},
-        "major" => $blasts{"single"} + $blasts{"area"},
-        "single" => $blasts{"single"},
-        "area" => $blasts{"area"},
+        "major" => $blasts{"normal"}{"single"} + $blasts{"normal"}{"area"},
+        "single" => $blasts{"normal"}{"single"},
+        "area" => $blasts{"normal"}{"area"},
+      });
+
+    push(@{$spells->{"staff"}{"data"}{"ignore"}},
+      {
+        "desc" => $desc,
+        "blasts" => $spells->{"staff"}{"total"}{"blasts"},
+        "major" => $blasts{"ignore"}{"single"} + $blasts{"ignore"}{"area"},
+        "single" => $blasts{"ignore"}{"single"},
+        "area" => $blasts{"ignore"}{"area"},
       });
 
     $spells->{"staff"}{"desc"} = $desc;
@@ -265,6 +277,12 @@
   $spells->{"total"}{"blasts"}++;
   $spells->{$type}{"blasts"}++;
 
+  if ($staff_worn) {
+    $spells->{"staff"}{$last_spell}{"blasts"}++;
+    $spells->{"staff"}{"total"}{"blasts"}++;
+    $spells->{"staff"}{$type}{"blasts"}++;
+  }
+
   # If essence was gained, get the type etc ..
   if ($essence_flag) {
     $essence_flag = 0;
@@ -316,7 +334,9 @@
   if ($postfix ne "") {
     if ($postfix =~ /^ \(glowing\) <.+? glow>/) {
       $postfix = " <red glow>";
-    } elsif ($postfix =~ /^( <.+? glow>| of Power)/) {
+    } elsif ($postfix =~ /^ <.+? glow>/) {
+      $postfix = " <red glow>";
+    } elsif ($postfix =~ /^( of Power)/i) {
       $postfix = $1;
     } else {
       $postfix = "";
@@ -324,11 +344,11 @@
   }
   
   if ($result ne "") {
+    $staff_worn = $wear;
     if ($wear) {
 #      print STDERR "'$result' :: '$postfix'\n";
       staff_update($result.$postfix, $line);
     }
-    $staff_worn = $wear;
   }
 }
 
@@ -477,10 +497,15 @@
 <p>
 Generated with $prog_name v$prog_version by Matti H&auml;m&auml;l&auml;inen aka Ggr Pupunen.
 </p>
+
+<h2>Mage staff development</h2>
 |;
 
+if ($opt_ignore) {
+  print OUT "<p><b>NOTICE!</b> Experimental 'ignore non-worn staff blasts' mode enabled.</p>\n";
+}
+
 print OUT "
-<h2>Mage staff development</h2>
 <table class=\"info\">
  <tr>
   <th>Blasts</th>
@@ -491,7 +516,9 @@
  </tr>
 ";
 
-foreach my $foo (@{$spells->{"staff"}{"data"}}) {
+my $tab = $opt_ignore ? "ignore" : "normal";
+
+foreach my $foo (@{$spells->{"staff"}{"data"}{$tab}}) {
   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";
@@ -499,6 +526,13 @@
 
 print OUT "
 </table>
+
+<ul>
+ <li><b>Blasts</b>: All blasts, including minor.</li>
+ <li><b>Major blasts</b>: Only major blasts (sum of major singles + areas).</li>
+ <li><b>Singles</b>: Major single blasts.</li>
+ <li><b>Areas</b>: Major area blasts.</li>
+</ul>
 ";