comparison skillbot.pl @ 38:a8b60d2968b2

Small tidy and removing useless skill time check
author Dominic Cleal <dominic@computerkb.co.uk>
date Sun, 07 Dec 2008 11:52:44 +0000
parents 5900a37101eb
children 4dd6009b0d2a
comparison
equal deleted inserted replaced
37:5900a37101eb 38:a8b60d2968b2
229 if ($msg =~ /^\!eta(\s+(.+))?/i) { 229 if ($msg =~ /^\!eta(\s+(.+))?/i) {
230 my $found = 0; 230 my $found = 0;
231 for my $f (@friends) { 231 for my $f (@friends) {
232 if ((defined $2 && lc($f->{char}->name) eq lc($2)) 232 if ((defined $2 && lc($f->{char}->name) eq lc($2))
233 || (!defined $2 && $f->{nick} eq $their_nick)) { 233 || (!defined $2 && $f->{nick} eq $their_nick)) {
234 my $text = ((defined $f->{skill} 234 my $text = (defined $f->{skill}
235 && $f->{skill}->finish_time > time())
236 ? sprintf("Currently training %s %s (finish in %s)", 235 ? sprintf("Currently training %s %s (finish in %s)",
237 $f->{skill}->name, $f->{skill}->level, 236 $f->{skill}->name, $f->{skill}->level,
238 $f->{skill}->time_remaining) 237 $f->{skill}->time_remaining)
239 : "No skill currently training"); 238 : "No skill currently training");
240 239
258 } 257 }
259 258
260 # lists the chars in order of shortest training time 259 # lists the chars in order of shortest training time
261 elsif ($msg =~ /^\!next/i) { 260 elsif ($msg =~ /^\!next/i) {
262 my $nreply = "Training: "; 261 my $nreply = "Training: ";
262
263 my @training = sort {
264 $a->{skill}->finish_time <=> $b->{skill}->finish_time
265 } grep { defined $_->{skill} } @friends;
263 266
264 for my $f (sort { $a->{skill}->finish_time <=> $b->{skill}->finish_time } grep(defined $_->{skill}, @friends)) { 267 for my $f (@training) {
265 $nreply .= sprintf("\002%s\002 (%s) | ", 268 $nreply .= sprintf("\002%s\002 (%s) | ",
266 $f->{char}->name, $f->{skill}->time_remaining); 269 $f->{char}->name, $f->{skill}->time_remaining);
267 } 270 }
268 271
269 $self->privmsg('#' . $config{channel}, substr($nreply, 0, -3)); 272 $self->privmsg('#' . $config{channel}, substr($nreply, 0, -3));