display a warning when the opponent is known to use a computer engine
parent
a1c1fa2344
commit
79d658da7a
|
@ -22,6 +22,7 @@ object Round extends LilaController {
|
|||
def rematcher = env.setup.rematcher
|
||||
def joiner = env.setup.friendJoiner
|
||||
def bookmarkApi = env.bookmark.api
|
||||
def userRepo = env.user.userRepo
|
||||
|
||||
def websocketWatcher(gameId: String, color: String) = WebSocket.async[JsValue] { req ⇒
|
||||
implicit val ctx = reqToCtx(req)
|
||||
|
@ -43,9 +44,13 @@ object Round extends LilaController {
|
|||
for {
|
||||
roomHtml ← messenger render pov.game
|
||||
bookmarkers ← bookmarkApi usersByGame pov.game
|
||||
engine ← pov.opponent.userId.fold(
|
||||
u ⇒ userRepo isEngine u,
|
||||
io(false))
|
||||
} yield Ok(html.round.player(
|
||||
pov,
|
||||
version(pov.gameId),
|
||||
engine,
|
||||
roomHtml map { Html(_) },
|
||||
bookmarkers)),
|
||||
io(Redirect(routes.Setup.await(fullId)))
|
||||
|
|
|
@ -27,7 +27,7 @@ trait GameHelper { self: I18nHelper with UserHelper with StringHelper ⇒
|
|||
|
||||
def clockName(clock: Clock): String = Namer clock clock
|
||||
|
||||
def shortClockName(clock: Option[Clock])(implicit ctx: Context): String =
|
||||
def shortClockName(clock: Option[Clock])(implicit ctx: Context): String =
|
||||
clock.fold(shortClockName, trans.unlimited.str())
|
||||
|
||||
def shortClockName(clock: Clock): String = Namer shortClock clock
|
||||
|
@ -43,10 +43,11 @@ trait GameHelper { self: I18nHelper with UserHelper with StringHelper ⇒
|
|||
player: DbPlayer,
|
||||
cssClass: Option[String] = None,
|
||||
withOnline: Boolean = true,
|
||||
withDiff: Boolean = true)(implicit ctx: Context) = Html {
|
||||
withDiff: Boolean = true,
|
||||
engine: Boolean = false)(implicit ctx: Context) = Html {
|
||||
player.userId.fold(
|
||||
userId ⇒ userIdToUsername(userId) |> { username ⇒
|
||||
"""<a class="user_link%s%s" href="%s">%s</a>""".format(
|
||||
"""<a class="user_link%s%s" href="%s">%s%s</a>""".format(
|
||||
cssClass.fold(" " + _, ""),
|
||||
withOnline.fold(
|
||||
isUsernameOnline(username).fold(" online", " offline"),
|
||||
|
@ -54,6 +55,9 @@ trait GameHelper { self: I18nHelper with UserHelper with StringHelper ⇒
|
|||
routes.User.show(username),
|
||||
usernameWithElo(player) + player.eloDiff.filter(_ ⇒ withDiff).fold(
|
||||
diff ⇒ " (%s)".format(showNumber(diff)),
|
||||
""),
|
||||
engine.fold(
|
||||
"""<span class="engine_mark tipsyme" title="%s"></span>""" format trans.thisPlayerUsesChessComputerAssistance(),
|
||||
"")
|
||||
)
|
||||
},
|
||||
|
|
|
@ -11,8 +11,7 @@ import org.joda.time.DateTime
|
|||
import ornicar.scalalib.OrnicarRandom
|
||||
|
||||
class UserRepo(
|
||||
collection: MongoCollection
|
||||
) extends SalatDAO[User, String](collection) {
|
||||
collection: MongoCollection) extends SalatDAO[User, String](collection) {
|
||||
|
||||
val enabledQuery = DBObject("enabled" -> true)
|
||||
def byIdQuery(id: String): DBObject = DBObject("_id" -> normalize(id))
|
||||
|
@ -131,6 +130,13 @@ class UserRepo(
|
|||
$set("engine" -> !user.engine)
|
||||
}
|
||||
|
||||
def isEngine(username: String): IO[Boolean] = io {
|
||||
for {
|
||||
obj ← collection.findOne(byIdQuery(username), DBObject("engine" -> true))
|
||||
engine ← obj.getAs[Boolean]("engine")
|
||||
} yield engine
|
||||
} map (_ | false)
|
||||
|
||||
def setBio(user: User, bio: String) = updateIO(user)($set("bio" -> bio))
|
||||
|
||||
def enable(user: User) = updateIO(user)($set("enabled" -> true))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(pov: Pov, version: Int, roomHtml: Option[Html], bookmarkers: List[User])(implicit ctx: Context)
|
||||
@(pov: Pov, version: Int, engine: Boolean, roomHtml: Option[Html], bookmarkers: List[User])(implicit ctx: Context)
|
||||
|
||||
@import pov._
|
||||
|
||||
|
@ -32,7 +32,7 @@ underchat = underchat.some) {
|
|||
}
|
||||
<div class="lichess_table@{ if(game.hasClock) " table_with_clock" }@{ if(game.finished) " finished" }">
|
||||
<div class="lichess_opponent">
|
||||
@round.username(pov.opponent)
|
||||
@round.username(pov.opponent, engine)
|
||||
</div>
|
||||
<div class="lichess_separator"></div>
|
||||
<div class="table_inner">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(player: DbPlayer)(implicit ctx: Context)
|
||||
@(player: DbPlayer, engine: Boolean = false)(implicit ctx: Context)
|
||||
|
||||
@ai(level: Int) = {
|
||||
<div class="username connected">
|
||||
|
@ -8,7 +8,7 @@
|
|||
|
||||
@human = {
|
||||
<div class="username @player.color.name">
|
||||
@playerLink(player, Some("blank_if_play"))
|
||||
@playerLink(player, Some("blank_if_play"), engine = engine)
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ $(function() {
|
|||
$('body').on('lichess.content_loaded', translateTexts);
|
||||
|
||||
$.tipsyfy = function($elem) {
|
||||
$elem.find('a:not(div.game_list_inner a):not(.notipsy):not(#boardTable a), input, label, div.tipsyme, button').filter('[title]').tipsy({
|
||||
$elem.find('a:not(div.game_list_inner a):not(.notipsy):not(#boardTable a), input, label, .tipsyme, button').filter('[title]').tipsy({
|
||||
fade: true,
|
||||
html: false,
|
||||
live: true
|
||||
|
|
|
@ -450,7 +450,7 @@ div.ui-tooltip div.engine_warning {
|
|||
background-position: 8px 0px;
|
||||
}
|
||||
|
||||
span.engine_mark {
|
||||
.engine_mark {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
|
|
2
todo
2
todo
|
@ -25,8 +25,6 @@ autoclose top menus
|
|||
tournaments http://www.chess.com/tournaments/help.html
|
||||
long name display issue http://en.lichess.org/forum/lichess-feedback/long-names-alter-layout
|
||||
fix game list translations
|
||||
display cheater mark on game table http://fr.lichess.org/forum/lichess-feedback/can-you-make-it-more-obvious-that-you-are-playing-a-cheater#2
|
||||
chess960 replay bug http://fr.lichess.org/forum/lichess-feedback/replay-and-analyse-feature-for-960#1
|
||||
|
||||
new translations:
|
||||
-rematchOfferCanceled=Rematch offer canceled
|
||||
|
|
Loading…
Reference in New Issue