nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
11afaad
)
contrib/nitrpg: add a Comparator to sort games by number of players
author
Alexandre Terrasa
<alexandre@moz-code.org>
Tue, 21 Apr 2015 23:33:20 +0000
(19:33 -0400)
committer
Alexandre Terrasa
<alexandre@moz-code.org>
Tue, 21 Apr 2015 23:37:49 +0000
(19:37 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
contrib/nitrpg/src/game.nit
patch
|
blob
|
history
diff --git
a/contrib/nitrpg/src/game.nit
b/contrib/nitrpg/src/game.nit
index
4d62283
..
d1dff3e
100644
(file)
--- a/
contrib/nitrpg/src/game.nit
+++ b/
contrib/nitrpg/src/game.nit
@@
-292,6
+292,19
@@
end
# utils
+# Sort games by descending number of players.
+#
+# The first in the list is the game with the more players.
+class GamePlayersComparator
+ super Comparator
+
+ redef type COMPARED: Game
+
+ redef fun compare(a, b) do
+ return b.load_players.length <=> a.load_players.length
+ end
+end
+
# Sort players by descending number of nitcoins.
#
# The first in the list is the player with the more of nitcoins.