mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 13:59:47 +01:00
Take tied ranking positions into account when determining offset
This commit is contained in:
parent
e0971e8158
commit
341cad090e
@ -219,19 +219,23 @@ if (lc $command eq 'rank') {
|
|||||||
@$players = sort $sort_method @$players;
|
@$players = sort $sort_method @$players;
|
||||||
|
|
||||||
my @ranking;
|
my @ranking;
|
||||||
my $i = 0;
|
my $rank = 0;
|
||||||
$offset--;
|
my $last_value = -1;
|
||||||
foreach my $player (@$players) {
|
foreach my $player (@$players) {
|
||||||
next if $player->{nick} eq 'keep2play';
|
next if $player->{nick} eq 'keep2play';
|
||||||
next if $i++ < $offset;
|
|
||||||
my $entry = $ranks{$opt}->{print}->($player);
|
my $entry = $ranks{$opt}->{print}->($player);
|
||||||
push @ranking, "#$i $entry" if defined $entry;
|
if (defined $entry) {
|
||||||
last if scalar @ranking >= 15;
|
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 (not scalar @ranking) {
|
||||||
if ($offset) {
|
if ($offset) {
|
||||||
$offset++;
|
|
||||||
print "No rankings available for $channel at offset #$offset.\n";
|
print "No rankings available for $channel at offset #$offset.\n";
|
||||||
} else {
|
} else {
|
||||||
print "No rankings available for $channel yet.\n";
|
print "No rankings available for $channel yet.\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user