Open UEWBot opened 9 months ago
Tournament.best_countries(whole_list=False) does correctly handle ties. Tournament.update_scores() currently gives best country awards to every player of each power with the top score (so it allows ties, and shared awards). The Best Countries view definitely needs tweaking. It would be good if the awards page said "tied" or "shared" or something, because it's keyed by player rather than by award. Similarly, it's not obvious when there are multiple recipients in the awards form, but maybe that's ok if we clearly show them as shared on the awards view.
The awards view doesn't have its own code at the moment - it uses tournament_views.tournament_simple(). I don't see an easy way to detect a shared award from within the template.
I wonder if we should be storing the player's rank in their RoundPlayer and TournamentPlayer (and potentially GamePlayer, too). It only changes when Game scores change, and having it there makes it accessible to the template code. We could also add a rank_tied attribute...
In which case we could also add a best_power_rank to GamePlayer (and potentially best_power_rank_tied).
Of course none of that helps with awards. I think the only way to deal with that is to have an actual class linking the Award to the TournamentPlayer, which can then have an is_shared attribute or method.
This now has a bunch of potential improvements, so let's try to capture them all:
tournament_best_countries() calls Tournament.best_countries(whole_list=True), which doesn't flag ties. For each power, it returns an ordered list of GamePlayers, but some of those may be ties. It can identify ties by looking at the scores.
The commit fixes (1). (2) needs doing, but is tricky, particularly as we have existing data using the current schema. I think (3) is fine as-is. (4) should be a separate Issue.
Created issue #288 to cover (4)
Where two players have the same score as the same power, need to make that clearer on the "Best Countries" page. May want to support automatic tie-breaks. We do now have the ability for the TD to pick who gets the actual award, so that should be reflected in the view.