3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

Group players with identical stats under the same rank

If Bill and Bob both have 10 correct answers, place them both
under the same rank of #5 instead of putting Bill at #5 and
Bob at #6.
This commit is contained in:
Pragmatic Software 2015-02-14 14:03:26 -08:00
parent 559b9ddde1
commit 76bb9a2c5f

View File

@ -178,10 +178,15 @@ if (lc $command eq 'rank') {
my $rank = 0; my $rank = 0;
my $stats; my $stats;
my $last_value = -1;
foreach my $player (@$players) { foreach my $player (@$players) {
next if $player->{nick} eq 'keep2play'; next if $player->{nick} eq 'keep2play';
$stats = $ranks{$key}->{print}->($player); $stats = $ranks{$key}->{print}->($player);
$rank++ if defined $stats; if (defined $stats) {
my ($value) = $stats =~ /[^:]+:\s+(.*)/;
$rank++ if $value ne $last_value;
$last_value = $value;
}
last if lc $player->{nick} eq $opt; last if lc $player->{nick} eq $opt;
} }
if ($rank == 0) { if ($rank == 0) {