Created
October 1, 2012 11:48
-
-
Save gfldex/3811149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
# use Grammar::Tracer; | |
my $skiptime; | |
grammar CombatLog { | |
rule TOP { [ <deal-damage> | <venomous-hail> | <rest> ]+ } | |
rule deal-damage { | |
<timestamp> <char-name> [<non-crit>|<crit>] '('<amount>'-'<amount>')->'<raw-damage> 'post soak:' <final-damage> <elemental-damage>* | |
} | |
rule elemental-damage { | |
<timestamp> '+Poison dmg' '('<amount>'-'<amount>')->'<raw-damage> 'post abs:' <final-damage> | |
} | |
token char-name { \w+ } | |
token non-crit { 'deals' } | |
token crit { 'CRITS!' } | |
token amount { \d+ } | |
token raw-damage { \d+ } | |
token final-damage { \d+ } | |
rule venomous-hail { <timestamp> <char-name> 'casts Venomous Hail' } | |
token rest { <timestamp> .+? \n } | |
token timestamp { <hour>':'<minute>[':'<second>]?': '? } | |
token hour { \d\d } | |
token minute { \d\d } | |
token second { \d\d } | |
} | |
class Actions { | |
our $.damage-sum; | |
our $.damage-count = 0; | |
our $.venomous-hail-count = 0; | |
our $.crit-count = 0; | |
our $.first-hit-time; | |
our $.last-hit-time; | |
method deal-damage($/) { | |
$.last-hit-time = $/<timestamp><hour> * 60 * 60 + $/<timestamp><minute> * 60 + $/<timestamp><second>; | |
return if $skiptime && $.last-hit-time < $skiptime; | |
$.first-hit-time //= $.last-hit-time; | |
my $damage = 0; | |
$damage += $<raw-damage>; | |
for $<elemental-damage> -> $/ { | |
$damage += $<raw-damage>; | |
$.damage-count++; | |
} | |
$.damage-sum += $damage; | |
$.damage-count++; | |
$.crit-count++ if $<crit>; | |
} | |
method venomous-hail($/) { | |
$venomous-hail-count++; | |
} | |
} | |
sub MAIN($skip?) { | |
if $skip { | |
$skiptime = CombatLog.parse($skip, rule => 'timestamp'); | |
$skiptime = [+] $skiptime<hour minute second> Z* (60*60, 60, 1); | |
say $skiptime; | |
} | |
my $a = Actions.new; | |
my $m = CombatLog.parse(slurp('combatLog.Log'), actions => $a); | |
say $a.venomous-hail-count; | |
say $a.damage-count; | |
say $a.damage-sum; | |
if $a.damage-count { | |
say "combat time: ", $a.last-hit-time - $a.first-hit-time, "s"; | |
say "average damage per shot: ", $a.damage-sum / $a.damage-count; | |
say "average damage for Venomous Hail: ", ($a.damage-sum / $a.venomous-hail-count).fmt('%i'); | |
say "crit chance: ", $a.crit-count / ($a.venomous-hail-count * 12); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment