pull/133/head
Thibault Duplessis 2014-11-28 02:41:22 +01:00
parent 9441eb9e03
commit d9d434480c
16 changed files with 39 additions and 37 deletions

View File

@ -28,7 +28,7 @@ sealed trait PieceSetObject {
object PieceSet extends PieceSetObject {
val all = NonEmptyList("cburnett", "merida", "pirouetti", "alpha", "spatial", "light") map { name => new PieceSet(name) }
val all = NonEmptyList("cburnett", "merida", "pirouetti", "alpha", "spatial", "lightp") map { name => new PieceSet(name) }
}
object PieceSet3d extends PieceSetObject {

View File

@ -18,27 +18,26 @@ private[puzzle] final class Selector(
toleranceMax: Int,
modulo: Int) {
private val popularSelector = BSONDocument(
Puzzle.BSONFields.voteSum -> BSONDocument("$gt" -> BSONInteger(anonMinRating)))
private def popularSelector(mate: Boolean) = BSONDocument(
Puzzle.BSONFields.voteSum -> BSONDocument("$gt" -> BSONInteger(mate.fold(anonMinRating, 0))))
private def mateSelector(mate: Boolean) = BSONDocument("mate" -> mate)
private lazy val popularCount = puzzleColl.db command Count(puzzleColl.name, popularSelector.some)
private def difficultyDecay(difficulty: Int) = difficulty match {
case 1 => -200
case 3 => +200
case _ => 0
}
val anonSkipMax = 2000
def apply(me: Option[User], difficulty: Int): Fu[Puzzle] = {
val isMate = scala.util.Random.nextBoolean
me match {
case None => popularCount map (_ - 1) flatMap { skipMax =>
puzzleColl.find(popularSelector ++ mateSelector(isMate))
.options(QueryOpts(skipN = Random nextInt skipMax))
case None =>
puzzleColl.find(popularSelector(isMate) ++ mateSelector(isMate))
.options(QueryOpts(skipN = Random nextInt anonSkipMax))
.one[Puzzle] flatten "Can't find a puzzle for anon player!"
}
case Some(user) => api.attempt.playedIds(user, modulo) flatMap { ids =>
tryRange(user, toleranceStep, difficultyDecay(difficulty), ids, isMate)
}

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -384,42 +384,42 @@ body.is2d.spatial .cg-piece.queen.black {
body.is2d.spatial .cg-piece.king.black {
background-image: url(../piece/spatial/bK.svg);
}
body.is2d.light .cg-piece.pawn.white {
background-image: url(../piece/light/wP.png);
body.is2d.lightp .cg-piece.pawn.white {
background-image: url(../piece/lightp/wP.png);
}
body.is2d.light .cg-piece.bishop.white {
background-image: url(../piece/light/wB.png);
body.is2d.lightp .cg-piece.bishop.white {
background-image: url(../piece/lightp/wB.png);
}
body.is2d.light .cg-piece.knight.white,
#top .cg-piece.light {
background-image: url(../piece/light/wN.png);
body.is2d.lightp .cg-piece.knight.white,
#top .cg-piece.lightp {
background-image: url(../piece/lightp/wN.png);
}
body.is2d.light .cg-piece.rook.white {
background-image: url(../piece/light/wR.png);
body.is2d.lightp .cg-piece.rook.white {
background-image: url(../piece/lightp/wR.png);
}
body.is2d.light .cg-piece.queen.white {
background-image: url(../piece/light/wQ.png);
body.is2d.lightp .cg-piece.queen.white {
background-image: url(../piece/lightp/wQ.png);
}
body.is2d.light .cg-piece.king.white {
background-image: url(../piece/light/wK.png);
body.is2d.lightp .cg-piece.king.white {
background-image: url(../piece/lightp/wK.png);
}
body.is2d.light .cg-piece.pawn.black {
background-image: url(../piece/light/bP.png);
body.is2d.lightp .cg-piece.pawn.black {
background-image: url(../piece/lightp/bP.png);
}
body.is2d.light .cg-piece.bishop.black {
background-image: url(../piece/light/bB.png);
body.is2d.lightp .cg-piece.bishop.black {
background-image: url(../piece/lightp/bB.png);
}
body.is2d.light .cg-piece.knight.black {
background-image: url(../piece/light/bN.png);
body.is2d.lightp .cg-piece.knight.black {
background-image: url(../piece/lightp/bN.png);
}
body.is2d.light .cg-piece.rook.black {
background-image: url(../piece/light/bR.png);
body.is2d.lightp .cg-piece.rook.black {
background-image: url(../piece/lightp/bR.png);
}
body.is2d.light .cg-piece.queen.black {
background-image: url(../piece/light/bQ.png);
body.is2d.lightp .cg-piece.queen.black {
background-image: url(../piece/lightp/bQ.png);
}
body.is2d.light .cg-piece.king.black {
background-image: url(../piece/light/bK.png);
body.is2d.lightp .cg-piece.king.black {
background-image: url(../piece/lightp/bK.png);
}
body.is2d.alpha .cg-piece.pawn.white {
background-image: url(../piece/alpha/wP.svg);

View File

@ -499,7 +499,7 @@ div.content_box .loader:after {
display: inline-block;
}
.none {
display: none!important;
display: none;
}
html {
min-height: 100%;
@ -1008,8 +1008,11 @@ body.offline #nb_connected_players {
display: block;
padding: 5px 10px 10px 10px;
}
#top #message_notifications_tag span:before,
#top #challenge_notifications_tag span:before {
#challenge_notifications_tag.none {
display: none!important;
}
#message_notifications_tag span:before,
#challenge_notifications_tag span:before {
font-size: 1.45em;
padding-left: 3px;
}