show opponent chat status on game start

This commit is contained in:
Thibault Duplessis 2013-05-28 14:35:04 +02:00
parent 785b483937
commit 14a53b0a6f
4 changed files with 24 additions and 13 deletions

View file

@ -18,14 +18,22 @@ final class Messenger(
private val nbMessagesCopiedToRematch = 20
def init(game: Game): Fu[List[Event]] =
systemMessages(game, List(
game.creatorColor.fold(_.whiteCreatesTheGame, _.blackCreatesTheGame),
game.invitedColor.fold(_.whiteJoinsTheGame, _.blackJoinsTheGame)
))
def init(game: Game): Fu[List[Event]] = systemMessages(game, List(
game.creatorColor.fold(_.whiteCreatesTheGame, _.blackCreatesTheGame),
game.invitedColor.fold(_.whiteJoinsTheGame, _.blackJoinsTheGame)
)) flatMap { events
(Color.all map { color
(game player color).userId ?? { id
UserRepo.getSetting(id, "chat") flatMap {
case Some("false") toggleChat(PovRef(game.id, color), false)
case _ fuccess(Nil)
}
}
}).sequenceFu map { events ::: _.flatten }
}
// // copies chats then init
// // no need to send events back
// copies chats then init
// no need to send events back
def rematch(prev: Game, next: Game): Funit = for {
prevR RoomRepo room prev.id
nextR = prevR.rematchCopy(next.id, nbMessagesCopiedToRematch)
@ -71,7 +79,7 @@ final class Messenger(
}
}
def toggleChat(ref: PovRef, status: Boolean): Fu[List[Event.Message]] =
def toggleChat(ref: PovRef, status: Boolean): Fu[List[Event]] =
"%s chat is %s".format(
ref.color.toString.capitalize,
status.fold("en", "dis") + "abled"

View file

@ -68,6 +68,5 @@ object User {
"settings" -> Json.obj(),
"engine" -> false,
"toints" -> 0,
"settings" -> Json.obj(),
"roles" -> Json.arr())
}

View file

@ -3,7 +3,7 @@ package lila.user
import com.roundeights.hasher.Implicits._
import org.joda.time.DateTime
import ornicar.scalalib.Random
import play.api.libs.json.Json
import play.api.libs.json._
import play.modules.reactivemongo.json.BSONFormats.toJSON
import play.modules.reactivemongo.json.ImplicitBSONHandlers.JsObjectWriter
import reactivemongo.api._
@ -23,7 +23,7 @@ object UserRepo {
def byIds(id: Iterable[ID]): Fu[List[User]] = $find byIds id
def enabledByIds(ids: Seq[ID]): Fu[List[User]] =
def enabledByIds(ids: Seq[ID]): Fu[List[User]] =
$find(enabledQuery ++ $select.byIds(ids))
def named(username: String): Fu[Option[User]] = $find byId normalize(username)
@ -75,6 +75,11 @@ object UserRepo {
def saveSetting(id: ID, key: String, value: String): Funit =
$update($select(id), $set(("settings." + key) -> value))
def getSetting(id: ID, key: String): Fu[Option[String]] =
$primitive.one($select(id), "settings") {
_.asOpt[Map[String, String]] flatMap (_ get key)
}
def authenticate(id: ID, password: String): Fu[Option[User]] =
checkPassword(id, password) flatMap { _ ?? ($find byId id) }
@ -138,7 +143,7 @@ object UserRepo {
$primitive.one($select(id), "salt")(_.asOpt[String]) flatMap { saltOption
saltOption ?? { salt
$update($select(id), $set(Json.obj(
"password" -> hash(password, salt),
"password" -> hash(password, salt),
"sha512" -> false)))
}
}

1
todo
View file

@ -56,7 +56,6 @@ answer http://en.lichess.org/forum/lichess-feedback/expanded-chat-functionality-
chess variants https://github.com/ornicar/lila/issues/2://github.com/ornicar/lila/issues/25
publish scalastic 0.90.0-thib
stream game export
tell opponent chat is disabled
from MoralIntentions email:
- The possibility to use a practice board to play against yourself or to demonstrate something when you're giving chess lessons with your laptop or an interactive whiteboard (with the same features as and with a button beneath "Play with the machine" in Play).
- A time control option of Simple delay and/or Bronstein delay (http://en.wikipedia.org/wiki/Time_control).