# XP Rate counter by Urquart
print "${BGreen}Loading xprate.pl\n";

my $xptotal = 123456;
my $xptime = 0;
my $xptemp = 0;

sub xptrig {
	if (/You are awarded (.*) experience points for the battle./)
	 { $xptotal = $xptotal + $1; }
	if (/You recieve (.*) experience points from the battle of (.*) total./)
	 { $xptotal = $xptotal + $1; }

}

sub xpsecinc {
	$xptime++;
}

sub cmd_xpreset  {
	$xptime = 0;
	$xptotal = 0;
	print "${BRed}XP Rate${BBlack}: ${White}RESET";
}

sub cmd_showxp  {
        $xptemp = $xptime / 60;
	print "\n${BRed}XP Time${BBlack}: ${White}$xptemp minutes\n";
        $xptemp = $xptotal / 1000000;
	print "\n${BRed}XP Total${BBlack}: ${White}$xptemp mil xp\n";
        $xptemp = $xptotal / $xptime;
	print "${BRed}XP per Second${BBlack}: ${White}$xptemp xp\n";
	$xptemp = $xptemp * 60;
	print "${BRed}XP per Minute${BBlack}: ${White}$xptemp xp\n";
	$xptemp = $xptemp * 60 / 1000000;
	print "${BRed}XP per Hour${BBlack}: ${White}$xptemp mil xp\n";
}
	
output_add(\&xptrig);
callout_add(\&xpsecinc, 1);

1;