changeset 83:e12c03b40e61 misc

Handle post-reinc essence gains.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 24 Apr 2010 17:35:26 +0000
parents 8adb44c8767a
children c3554f46ca49
files magestats.pl
diffstat 1 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/magestats.pl	Tue Apr 20 15:04:50 2010 +0000
+++ b/magestats.pl	Sat Apr 24 17:35:26 2010 +0000
@@ -104,10 +104,11 @@
   $spells->{$type}{"essence"}{"increase"} = 0;
   $spells->{$type}{"essence"}{"blasts"}{"single"} = [];
   $spells->{$type}{"essence"}{"blasts"}{"area"} = [];
+  $spells->{$type}{"reinc"} = 0;
  
   $spells->{$type}{"blasts"} = 0;
   $spells->{$type}{"reagents"} = 0;
-
+  
   $spells->{$type}{"single"} = $src->[0];
   $spells->{$type}{"area"} = $src->[1];
 
@@ -175,7 +176,12 @@
 } else {
   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)\.$/) {
+    if ($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);
+      }
+    } 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);
 
@@ -186,12 +192,20 @@
       # If essence was gained, get the type etc ..
       if ($essence_flag) {
         $essence_flag = 0;
-        $spells->{$type}{"essence"}{"increase"}++;
+        
+        # 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"});
+          # 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"});
+          }
         }
       }
       
@@ -207,7 +221,6 @@
       $spells->{"total"}{"reagents"}++;
     } elsif ($s =~ /^You feel your skills in handling elemental forces improve\./) {
       $essence_flag = 1;
-      $spells->{"total"}{"essence"}++;
     } elsif ($s =~ /^Your fingertips are surrounded with swirling (ENERGY) as you cast the spell\./ ||
       $s =~ /^You feel like you managed to channel additional (POWER) to your spell\./ ||
       $s =~ /^You feel like your spell gained additional (power)\./ ||