Forging/Forging Perl Script: Difference between revisions
Forging <
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{script |
{{script |
||
| title = Forging |
| title = Forging Log Parsing Script |
||
| author = XYGON |
| author = XYGON |
||
| compat = |
| compat = N/A |
||
}} |
}} |
||
Used with scriptname.pl <CharacterName> |
Used with scriptname.pl <CharacterName> <br/> |
||
Returns how many attempts were made to forge for each rank. |
Returns how many attempts were made to forge for each rank.<br/> |
||
<nowiki>#----------------------------------------------------------------------------- |
|||
⚫ | |||
# Gemstone IV - Log Parser for Forging Ranks |
|||
⚫ | |||
# by Xygon Arden |
|||
use DBI; |
|||
# |
|||
# Usage: forgestats.pl <CharName> |
|||
# |
|||
# Returns: Table view of average attempts to each rank (total), |
|||
# actual attempts per rank |
|||
# running total of attempts |
|||
# |
|||
# Updates: |
|||
# 20150714 - Added comments, added statistical average running total |
|||
# 20150706 - Added tabled output for multiple ranks visibility |
|||
# 20150703 - Released to gswiki.play.net |
|||
⚫ | |||
my(%previous_inventory); |
|||
⚫ | |||
my(%current_inventory); |
|||
parse_logs(); |
parse_logs(); |
||
sub get_sorted_files { |
sub get_sorted_files { |
||
# Sorts all of the files by file date |
|||
my $path = shift; |
my $path = shift; |
||
opendir my($dir), $path or die "can't opendir $path: $!"; |
opendir my($dir), $path or die "can't opendir $path: $!"; |
||
Line 29: | Line 41: | ||
sub parse_logs { |
sub parse_logs { |
||
my($charname) = $ARGV[0]; |
my($charname) = $ARGV[0]; |
||
# FOR NOW - delete all data prior to starting |
|||
print "Parsing logs\n"; |
print "Parsing logs...\n"; # Used to have status dots, but the screenwrite slows down |
||
my @arRank; # the log processing, so this has been removed |
|||
my @arRank; |
|||
my $curRank = 1; |
my $curRank = 1; |
||
my %files = get_sorted_files("./"); |
my %files = get_sorted_files("./"); |
||
STDOUT->autoflush( 1 ); |
|||
foreach my $filename (sort{$files{$a} <=> $files{$b}} keys %files) { |
foreach my $filename (sort{$files{$a} <=> $files{$b}} keys %files) { |
||
# Only 2nd argument's logs |
|||
next if ($filename !~ /$charname*/); |
next if ($filename !~ /$charname*/); |
||
# Go through each log, grabbing each "get tongs" via the RT, and "Aha" |
|||
open my $logfile, '<', $filename or die "Could not open '$filename' $!\n"; |
open my $logfile, '<', $filename or die "Could not open '$filename' $!\n"; |
||
while (my $line = <$logfile>) { |
while (my $line = <$logfile>) { |
||
if ($line =~ /180 sec/) { |
|||
# Assumed forge attempt |
|||
if ($line =~ /180 sec/) { |
|||
# print "\nInventory update - $filename\t", scalar localtime($files{$filename}), "\n"; |
|||
$arRank[$curRank] += 1; |
$arRank[$curRank] += 1; |
||
# Gained a Rank |
|||
} elsif ($line =~ /Aha, you learned something that time./) { |
} elsif ($line =~ /Aha, you learned something that time./) { |
||
$curRank += 1; |
$curRank += 1; |
||
Line 56: | Line 66: | ||
} |
} |
||
# Format for cmd line output |
|||
use Text::ASCIITable; |
use Text::ASCIITable; |
||
my($t) = Text::ASCIITable->new({ headingText => 'Attempts Per Rank' }); |
my($t) = Text::ASCIITable->new({ headingText => 'Attempts Per Rank' }); |
||
# Tracks up to three ranks, assumes worked on each till completion with no switching |
|||
if ($curRank > 1000) { |
if ($curRank > 1000) { |
||
$t->setCols('Rank','ToNext','TotalAtt','ToNext','TotalAtt','ToNext','TotalAtt'); |
$t->setCols('Rank','Stat','ToNext','TotalAtt','ToNext','TotalAtt','ToNext','TotalAtt'); |
||
} elsif ($curRank > 500) { |
} elsif ($curRank > 500) { |
||
$t->setCols('Rank','ToNext','TotalAtt','ToNext','TotalAtt'); |
$t->setCols('Rank','Stat','ToNext','TotalAtt','ToNext','TotalAtt'); |
||
} elsif ($curRank <= 500) { |
} elsif ($curRank <= 500) { |
||
$t->setCols('Rank','ToNext','TotalAtt'); |
$t->setCols('Rank','Stat','ToNext','TotalAtt'); |
||
} |
} |
||
# Currently assumes you have the full logic bonus (+2) |
|||
my(@arSum) = (); |
my(@arSum) = (); |
||
my($aveRank) = 0.002; # If you have 0 or +1 bonus, change this to 0 |
|||
for (my $i=1; $i <= $curRank; $i++) { |
for (my $i=1; $i <= $curRank; $i++) { |
||
$aveRank += 500/(502-$i); # If you have +1 bonus, change 502 to 501, or 500 for no bonus |
|||
if ($i + 1000 <= $curRank) { |
|||
$arSum[2] += $arRank[$i+1000]; |
$arSum[2] += $arRank[$i+1000]; |
||
$arSum[1] += $arRank[$i+500]; |
$arSum[1] += $arRank[$i+500]; |
||
$arSum[0] += $arRank[$i]; |
$arSum[0] += $arRank[$i]; |
||
$t->addRow($i,$arRank[$i],$arSum[0],$arRank[$i+500],$arSum[1],$arRank[$i+1000],$arSum[2]); |
$t->addRow($i,int($aveRank),$arRank[$i],$arSum[0],$arRank[$i+500],$arSum[1],$arRank[$i+1000],$arSum[2]); |
||
} elsif ($i + 500 <= $curRank) { |
} elsif ($i + 500 <= $curRank) { |
||
$arSum[1] += $arRank[$i+500]; |
$arSum[1] += $arRank[$i+500]; |
||
$arSum[0] += $arRank[$i]; |
$arSum[0] += $arRank[$i]; |
||
$t->addRow($i,$arRank[$i],$arSum[0],$arRank[$i+500],$arSum[1]); |
$t->addRow($i,int($aveRank),$arRank[$i],$arSum[0],$arRank[$i+500],$arSum[1]); |
||
} else { |
} else { |
||
$arSum[0] += $arRank[$i]; |
$arSum[0] += $arRank[$i]; |
||
$t->addRow($i,$arRank[$i],$arSum[0]); |
$t->addRow($i,int($aveRank),$arRank[$i],$arSum[0]); |
||
} |
} |
||
if ($i == 499) { $curRank = 0; } |
if ($i == 499) { $curRank = 0; } |
Latest revision as of 22:47, 14 July 2015
Title: | Forging Log Parsing Script |
Author: | XYGON |
Compatibility: | #UNDEFINED# |
Used with scriptname.pl <CharacterName>
Returns how many attempts were made to forge for each rank.
#----------------------------------------------------------------------------- # Gemstone IV - Log Parser for Forging Ranks # by Xygon Arden # # Usage: forgestats.pl <CharName> # # Returns: Table view of average attempts to each rank (total), # actual attempts per rank # running total of attempts # # Updates: # 20150714 - Added comments, added statistical average running total # 20150706 - Added tabled output for multiple ranks visibility # 20150703 - Released to gswiki.play.net use strict; use warnings; parse_logs(); sub get_sorted_files { # Sorts all of the files by file date my $path = shift; opendir my($dir), $path or die "can't opendir $path: $!"; my %hash = map {$_ => (stat($_))[9] || undef} # avoid empty list map { "$path$_" } readdir $dir; closedir $dir; return %hash; } sub parse_logs { my($charname) = $ARGV[0]; print "Parsing logs...\n"; # Used to have status dots, but the screenwrite slows down my @arRank; # the log processing, so this has been removed my $curRank = 1; my %files = get_sorted_files("./"); foreach my $filename (sort{$files{$a} <=> $files{$b}} keys %files) { # Only 2nd argument's logs next if ($filename !~ /$charname*/); # Go through each log, grabbing each "get tongs" via the RT, and "Aha" open my $logfile, '<', $filename or die "Could not open '$filename' $!\n"; while (my $line = <$logfile>) { if ($line =~ /180 sec/) { # Assumed forge attempt $arRank[$curRank] += 1; # Gained a Rank } elsif ($line =~ /Aha, you learned something that time./) { $curRank += 1; } } } # Format for cmd line output use Text::ASCIITable; my($t) = Text::ASCIITable->new({ headingText => 'Attempts Per Rank' }); # Tracks up to three ranks, assumes worked on each till completion with no switching if ($curRank > 1000) { $t->setCols('Rank','Stat','ToNext','TotalAtt','ToNext','TotalAtt','ToNext','TotalAtt'); } elsif ($curRank > 500) { $t->setCols('Rank','Stat','ToNext','TotalAtt','ToNext','TotalAtt'); } elsif ($curRank <= 500) { $t->setCols('Rank','Stat','ToNext','TotalAtt'); } # Currently assumes you have the full logic bonus (+2) my(@arSum) = (); my($aveRank) = 0.002; # If you have 0 or +1 bonus, change this to 0 for (my $i=1; $i <= $curRank; $i++) { $aveRank += 500/(502-$i); # If you have +1 bonus, change 502 to 501, or 500 for no bonus if ($i + 1000 <= $curRank) { $arSum[2] += $arRank[$i+1000]; $arSum[1] += $arRank[$i+500]; $arSum[0] += $arRank[$i]; $t->addRow($i,int($aveRank),$arRank[$i],$arSum[0],$arRank[$i+500],$arSum[1],$arRank[$i+1000],$arSum[2]); } elsif ($i + 500 <= $curRank) { $arSum[1] += $arRank[$i+500]; $arSum[0] += $arRank[$i]; $t->addRow($i,int($aveRank),$arRank[$i],$arSum[0],$arRank[$i+500],$arSum[1]); } else { $arSum[0] += $arRank[$i]; $t->addRow($i,int($aveRank),$arRank[$i],$arSum[0]); } if ($i == 499) { $curRank = 0; } } print $t; }