forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blind implementation of players move times pie chart
- Loading branch information
Showing
7 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package lila | ||
package analyse | ||
|
||
import game.{ DbPlayer, Pov } | ||
|
||
import com.codahale.jerkson.Json | ||
|
||
final class TimePie(val pov: Pov) { | ||
|
||
import pov._ | ||
|
||
val columns = Json generate List( | ||
"string" :: "Move time" :: Nil, | ||
"number" :: "Moves" :: Nil) | ||
|
||
def rows = Json generate { | ||
|
||
val steps = (0 to 5) ++ (6 to 12 by 2) ++ (15 to 30 by 3) ++ (35 to 60 by 5) | ||
|
||
val ranges = steps zip (steps drop 1) map { case (a, b) ⇒ Range(a, b) } | ||
|
||
val moveTimes = player.moveTimeList | ||
|
||
def nbMoves(range: Range) = moveTimes count range.contains | ||
|
||
def nameRange(range: Range) = { | ||
import range._ | ||
if (min == max) (min < 2).fold("%d second", "%d seconds") format min | ||
else "%d to %d seconds".format(min, max) | ||
} | ||
|
||
ranges zip (ranges map nbMoves) collect { | ||
case (range, nb) if nb > 0 ⇒ List(nameRange(range), nb) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters