Mercurial > hg > skillbot
comparison skillbot.pl @ 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 |
comparison
equal
deleted
inserted
replaced
31:ba7303a5f42d | 32:276658826bc0 |
---|---|
255 update_friends($self); | 255 update_friends($self); |
256 check_training($self); | 256 check_training($self); |
257 $self->privmsg('#' . $config{channel}, "Done"); | 257 $self->privmsg('#' . $config{channel}, "Done"); |
258 } | 258 } |
259 | 259 |
260 # lists the chars in order of shortest training time | |
261 if ($msg =~ /^\!next/i) { | |
262 my $nreply = "Training: "; | |
263 my (@fc) = (order_friend_copy @friends); | |
264 | |
265 foreach (@fc) | |
266 $nreply .= $_->{char}->name . " (" . $_->{skill}->time_remaining . ") | "; | |
267 } | |
260 } | 268 } |
261 | 269 |
262 sub on_notice | 270 sub on_notice |
263 { | 271 { |
264 my ($self, $event) = @_; | 272 my ($self, $event) = @_; |
496 encode("utf8", $text))); | 504 encode("utf8", $text))); |
497 delete $f->{skill}; | 505 delete $f->{skill}; |
498 }); | 506 }); |
499 } | 507 } |
500 | 508 |
509 =pod | |
510 | |
511 Returns a copy of the input @friends that is ordered by training time | |
512 and doesnt contain any chars that are not in training. | |
513 | |
514 =cut | |
515 sub order_friend_copy | |
516 { | |
517 my @friendcopy; | |
518 foreach ($_) | |
519 push(@friendcopy, $_) unless defined($_->{char}->skill->in_training); | |
520 | |
521 sort { $a->{skill}->finish_time <=> $b->{skill}->finish_time } @friendcopy; | |
522 | |
523 return @friendcopy; | |
524 } | |
525 | |
501 END { | 526 END { |
502 cleanup_and_die(); | 527 cleanup_and_die(); |
503 } | 528 } |