3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-29 23:39:24 +01:00

Take tied ranking positions into account when determining offset

This commit is contained in:
Pragmatic Software 2015-02-17 01:47:28 -08:00
parent e0971e8158
commit 341cad090e

View File

@ -219,19 +219,23 @@ if (lc $command eq 'rank') {
@$players = sort $sort_method @$players;
my @ranking;
my $i = 0;
$offset--;
my $rank = 0;
my $last_value = -1;
foreach my $player (@$players) {
next if $player->{nick} eq 'keep2play';
next if $i++ < $offset;
my $entry = $ranks{$opt}->{print}->($player);
push @ranking, "#$i $entry" if defined $entry;
last if scalar @ranking >= 15;
if (defined $entry) {
my ($value) = $entry =~ /[^:]+:\s+(.*)/;
$rank++ if $value ne $last_value;
$last_value = $value;
next if $rank < $offset;
push @ranking, "#$rank $entry" if defined $entry;
last if scalar @ranking >= 15;
}
}
if (not scalar @ranking) {
if ($offset) {
$offset++;
print "No rankings available for $channel at offset #$offset.\n";
} else {
print "No rankings available for $channel yet.\n";