comparison skillbot.pl @ 34:8b631d17dfd0

Fixed some stuff after talking to dom -- yeah it could have been done simpler if he told me yesterday :P
author df
date Sun, 07 Dec 2008 11:16:49 +0000
parents 48df6d55427b
children b0436bc63f9e
comparison
equal deleted inserted replaced
33:48df6d55427b 34:8b631d17dfd0
258 } 258 }
259 259
260 # lists the chars in order of shortest training time 260 # lists the chars in order of shortest training time
261 if ($msg =~ /^\!next/i) { 261 if ($msg =~ /^\!next/i) {
262 my $nreply = "Training: "; 262 my $nreply = "Training: ";
263 my (@fc) = (order_friend_copy @friends);
264 263
265 foreach (@fc) 264 for my $f (sort { $a->{skill}->finish_time <=> $b->{skill}->finish_time } grep(defined $_->{skill}, @friends)) {
266 $nreply .= $_->{char}->name . " (" . $_->{skill}->time_remaining . ") | "; 265 $nreply .= $f->{char}->name . " (" . $f->{skill}->time_remaining . ") | ";
266 }
267 267
268 $self->privmsg('#' . $config{channel}, $nreply); 268 $self->privmsg('#' . $config{channel}, $nreply);
269 } 269 }
270 } 270 }
271 271
506 encode("utf8", $text))); 506 encode("utf8", $text)));
507 delete $f->{skill}; 507 delete $f->{skill};
508 }); 508 });
509 } 509 }
510 510
511 =pod
512
513 Returns a copy of the input @friends that is ordered by training time
514 and doesnt contain any chars that are not in training.
515
516 =cut
517 sub order_friend_copy
518 {
519 my @friendcopy;
520 foreach ($_)
521 push(@friendcopy, $_) unless defined($_->{char}->skill->in_training);
522
523 sort { $a->{skill}->finish_time <=> $b->{skill}->finish_time } @friendcopy;
524
525 return @friendcopy;
526 }
527
528 END { 511 END {
529 cleanup_and_die(); 512 cleanup_and_die();
530 } 513 }