3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-05-29 02:47:36 +02: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  instead of putting Bill at  and
Bob at .
This commit is contained in:
Pragmatic Software 2015-02-14 14:03:26 -08:00
parent 559b9ddde1
commit 76bb9a2c5f

@ -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) {