changeset 32:276658826bc0

Local commit, so dom can help me out. -- love perl
author df
date Sun, 07 Dec 2008 09:42:22 +0000
parents ba7303a5f42d
children 48df6d55427b
files skillbot.pl
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/skillbot.pl	Sun Dec 07 08:47:25 2008 +0000
+++ b/skillbot.pl	Sun Dec 07 09:42:22 2008 +0000
@@ -257,6 +257,14 @@
 		$self->privmsg('#' . $config{channel}, "Done");
 	}
 
+	# lists the chars in order of shortest training time
+	if ($msg =~ /^\!next/i) {
+		my $nreply = "Training: ";
+		my (@fc) = (order_friend_copy @friends);
+		
+		foreach (@fc) 
+			$nreply .= $_->{char}->name . " (" . $_->{skill}->time_remaining . ") | ";
+	}
 }
 
 sub on_notice
@@ -498,6 +506,23 @@
 	});
 }
 
+=pod
+
+Returns a copy of the input @friends that is ordered by training time
+and doesnt contain any chars that are not in training.
+
+=cut
+sub order_friend_copy
+{
+	my @friendcopy;
+	foreach ($_)
+		push(@friendcopy, $_) unless defined($_->{char}->skill->in_training);
+	
+	sort { $a->{skill}->finish_time <=> $b->{skill}->finish_time } @friendcopy;
+	
+	return @friendcopy;
+}
+
 END {
 	cleanup_and_die();
 }