show last move on mini boards
This commit is contained in:
parent
cf9de2c569
commit
d474ac2bea
|
@ -92,12 +92,13 @@ trait GameHelper { self: I18nHelper with UserHelper with StringHelper with AiHel
|
|||
o ⇒ routes.Round.player(game fullIdOf o.color),
|
||||
routes.Round.watcher(game.id, color.name)
|
||||
)
|
||||
"""<a href="%s" title="%s" class="mini_board parse_fen %s" data-live="%s" data-color="%s" data-fen="%s"></a>""".format(
|
||||
"""<a href="%s" title="%s" class="mini_board parse_fen %s" data-live="%s" data-color="%s" data-fen="%s" data-lastmove="%s"></a>""".format(
|
||||
url,
|
||||
trans.viewInFullSize(),
|
||||
live.fold("live live_" + game.id, ""),
|
||||
live.fold(game.id, ""),
|
||||
color.name,
|
||||
Forsyth exportBoard game.toChess.board)
|
||||
Forsyth exportBoard game.toChess.board,
|
||||
game.lastMove | "")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ final class Hand(
|
|||
moretimeSeconds: Int) extends Handler(gameRepo) {
|
||||
|
||||
type IOValidEvents = IO[Valid[List[Event]]]
|
||||
type PlayResult = Future[Valid[(List[Event], String)]]
|
||||
type PlayResult = Future[Valid[(List[Event], String, Option[String])]]
|
||||
|
||||
def play(
|
||||
povRef: PovRef,
|
||||
|
@ -47,8 +47,7 @@ final class Hand(
|
|||
_ ← gameRepo save progress
|
||||
finishEvents ← finisher.moveFinish(progress.game, color)
|
||||
events = progress.events ::: finishEvents
|
||||
fen = fenBoard(progress)
|
||||
} yield success(events -> fen)).toFuture
|
||||
} yield playResult(events, progress)).toFuture
|
||||
else if (progress.game.player.isAi && progress.game.playable) for {
|
||||
initialFen ← progress.game.variant.standard.fold(
|
||||
io(none[String]),
|
||||
|
@ -63,18 +62,22 @@ final class Hand(
|
|||
_ ← gameRepo save progress2
|
||||
finishEvents ← finisher.moveFinish(progress2.game, !color)
|
||||
events = progress2.events ::: finishEvents
|
||||
fen = fenBoard(progress2)
|
||||
} yield success(events -> fen)).toFuture
|
||||
} yield playResult(events, progress2)).toFuture
|
||||
}): PlayResult
|
||||
} yield eventsAndFen
|
||||
else (for {
|
||||
_ ← gameRepo save progress
|
||||
events = progress.events
|
||||
fen = fenBoard(progress)
|
||||
} yield success(events -> fen)).toFuture
|
||||
} yield playResult(events, progress)).toFuture
|
||||
)
|
||||
}
|
||||
|
||||
private def playResult(events: List[Event], progress: Progress) = success((
|
||||
events,
|
||||
Forsyth exportBoard progress.game.toChess.board,
|
||||
progress.game.lastMove
|
||||
))
|
||||
|
||||
def abort(fullId: String): IOValidEvents = attempt(fullId, finisher.abort)
|
||||
|
||||
def resign(fullId: String): IOValidEvents = attempt(fullId, finisher.resign)
|
||||
|
@ -248,7 +251,4 @@ final class Hand(
|
|||
} yield progress2.events
|
||||
} toValid "cannot add moretime"
|
||||
)
|
||||
|
||||
private def fenBoard(progress: Progress) =
|
||||
Forsyth exportBoard progress.game.toChess.board
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ final class MoveNotifier(
|
|||
Akka.system.actorFor("/user/" + name)
|
||||
}
|
||||
|
||||
def apply(gameId: String, fen: String) {
|
||||
def apply(gameId: String, fen: String, lastMove: Option[String]) {
|
||||
countMove()
|
||||
val message = Fen(gameId, fen)
|
||||
val message = Fen(gameId, fen, lastMove)
|
||||
hubRefs foreach (_ ! message)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,9 +70,9 @@ final class Socket(
|
|||
hub ! Resync(uid)
|
||||
println(fs.shows)
|
||||
}
|
||||
case Success((events, fen)) ⇒ {
|
||||
case Success((events, fen, lastMove)) ⇒ {
|
||||
send(povRef.gameId, events)
|
||||
moveNotifier(povRef.gameId, fen)
|
||||
moveNotifier(povRef.gameId, fen, lastMove)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,26 +16,26 @@ abstract class HubActor[M <: SocketMember](uidTimeout: Int) extends Actor {
|
|||
// generic message handler
|
||||
def receiveGeneric: Receive = {
|
||||
|
||||
case Ping(uid) ⇒ ping(uid)
|
||||
case Ping(uid) ⇒ ping(uid)
|
||||
|
||||
case Broom ⇒ broom()
|
||||
case Broom ⇒ broom()
|
||||
|
||||
// when a member quits
|
||||
case Quit(uid) ⇒ quit(uid)
|
||||
case Quit(uid) ⇒ quit(uid)
|
||||
|
||||
case GetNbMembers ⇒ sender ! members.size
|
||||
case GetNbMembers ⇒ sender ! members.size
|
||||
|
||||
case NbMembers(nb) ⇒ pong = makePong(nb)
|
||||
case NbMembers(nb) ⇒ pong = makePong(nb)
|
||||
|
||||
case GetUsernames ⇒ sender ! usernames
|
||||
case GetUsernames ⇒ sender ! usernames
|
||||
|
||||
case LiveGames(uid, gameIds) ⇒ registerLiveGames(uid, gameIds)
|
||||
case LiveGames(uid, gameIds) ⇒ registerLiveGames(uid, gameIds)
|
||||
|
||||
case Fen(gameId, fen) ⇒ notifyFen(gameId, fen)
|
||||
case Fen(gameId, fen, lastMove) ⇒ notifyFen(gameId, fen, lastMove)
|
||||
|
||||
case SendTo(userId, msg) ⇒ sendTo(userId, msg)
|
||||
case SendTo(userId, msg) ⇒ sendTo(userId, msg)
|
||||
|
||||
case Resync(uid) ⇒ resync(uid)
|
||||
case Resync(uid) ⇒ resync(uid)
|
||||
}
|
||||
|
||||
def receive = receiveSpecific orElse receiveGeneric
|
||||
|
@ -101,10 +101,12 @@ abstract class HubActor[M <: SocketMember](uidTimeout: Int) extends Actor {
|
|||
|
||||
def usernames: Iterable[String] = members.values.map(_.username).flatten
|
||||
|
||||
def notifyFen(gameId: String, fen: String) {
|
||||
def notifyFen(gameId: String, fen: String, lastMove: Option[String]) {
|
||||
val msg = makeMessage("fen", JsObject(Seq(
|
||||
"id" -> JsString(gameId),
|
||||
"fen" -> JsString(fen))))
|
||||
"fen" -> JsString(fen),
|
||||
"lm" -> lastMove.fold(JsString(_), JsNull)
|
||||
)))
|
||||
members.values filter (_ liveGames gameId) foreach (_.channel push msg)
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ case object Broom
|
|||
case class Quit(uid: String)
|
||||
|
||||
case class SendTo(userId: String, message: JsObject)
|
||||
case class Fen(gameId: String, fen: String)
|
||||
case class Fen(gameId: String, fen: String, lastMove: Option[String])
|
||||
case class LiveGames(uid: String, gameIds: List[String])
|
||||
case class ChangeFeatured(oldId: Option[String], newId: String)
|
||||
case class Resync(uid: String)
|
||||
|
|
|
@ -7,7 +7,7 @@ import play.api.templates.Html
|
|||
|
||||
trait AssetHelper {
|
||||
|
||||
val assetVersion = 76
|
||||
val assetVersion = 77
|
||||
|
||||
def cssTag(name: String) = css("stylesheets/" + name)
|
||||
|
||||
|
|
BIN
public/images/sprite_mini3.png
Normal file
BIN
public/images/sprite_mini3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -10,6 +10,7 @@ $(function() {
|
|||
var withKeys = $this.hasClass('with_keys');
|
||||
var letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
|
||||
var fen = $this.data('fen').replace(/\//g, '');
|
||||
var lastMove = $this.data('lastmove').split(' ');
|
||||
var x, y, html = '', scolor, pcolor, pclass, c, d, increment;
|
||||
var pclasses = {'p':'pawn', 'r':'rook', 'n':'knight', 'b':'bishop', 'q':'queen', 'k':'king'};
|
||||
var pregex = /(p|r|n|b|q|k)/;
|
||||
|
@ -22,12 +23,11 @@ $(function() {
|
|||
var increment = function() { y--; if(y < 1) { y = 8; x++; } };
|
||||
}
|
||||
function openSquare(x, y) {
|
||||
var key = 'white' == color ? letters[y - 1] + x : letters[8 - y] + (9 - x);
|
||||
var scolor = (x+y)%2 ? 'white' : 'black';
|
||||
if ($.inArray(key, lastMove) != -1) scolor += " moved";
|
||||
var html = '<div class="lmcs '+scolor+'" style="top:'+(28*(8-x))+'px;left:'+(28*(y-1))+'px;"';
|
||||
if (withKeys) {
|
||||
var key = 'white' == color
|
||||
? letters[y - 1] + x
|
||||
: letters[8 - y] + (9 - x);
|
||||
html += ' data-key="' + key + '"';
|
||||
}
|
||||
return html + '>';
|
||||
|
@ -84,7 +84,7 @@ $(function() {
|
|||
lichess.socketDefaults.events.fen = function(e) {
|
||||
$('a.live_' + e.id).each(function() {
|
||||
var $this = $(this);
|
||||
parseFen($this.data("fen", e.fen));
|
||||
parseFen($this.data("fen", e.fen).data("lastmove", e.lm));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -232,10 +232,10 @@ body.dark #GameText a.moveOn {
|
|||
}
|
||||
|
||||
body.dark div.lmcs.white {
|
||||
background: #b0b0b0;
|
||||
background-color: #b0b0b0;
|
||||
}
|
||||
body.dark div.lmcs.black {
|
||||
background: #8a8a8a;
|
||||
background-color: #8a8a8a;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -80,12 +80,16 @@ div.lmcs.white {
|
|||
div.lmcs.black {
|
||||
background: #cacaca;
|
||||
}
|
||||
div.lmcs.moved {
|
||||
background-image: url(../images/sprite_mini3.png);
|
||||
background-position: -168px 0;
|
||||
}
|
||||
|
||||
div.lcmp {
|
||||
position: absolute;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background-image: url(../images/sprite_mini2.png);
|
||||
background-image: url(../images/sprite_mini3.png);
|
||||
}
|
||||
|
||||
div.lcmp.pawn.white{
|
||||
|
|
6
todo
6
todo
|
@ -17,13 +17,9 @@ check(mate) sound
|
|||
takeback play 2 times ?? http://en.lichess.org/analyse/nfjchnmo/black move 45
|
||||
movetimes chart
|
||||
show lobby chat to anon (and rated games?) or show empty chat
|
||||
show last move on miniboards
|
||||
also translate websockets error message
|
||||
@someone = link to someone's profile
|
||||
analysis not the fastest checkmate, but no best move? http://en.lichess.org/analyse/w3xw8fsw/black
|
||||
analysis missing last move (and 2 moves in chart)
|
||||
elo chart average line is late
|
||||
move while disconnected = move lost. should reload the page on ack timeout.
|
||||
finish games per day chart
|
||||
untranslated = https://github.com/ornicar/lila/issues/4
|
||||
game stats timeline issues http://en.lichess.org/forum/lichess-feedback/move-times
|
||||
|
@ -33,10 +29,8 @@ analyse: show main line for every move http://en.lichess.org/forum/lichess-feedb
|
|||
try to show last analysis cp on graph (move 26) http://en.lichess.org/analyse/bwxnx0al
|
||||
elo range must contain player elo
|
||||
complete analysis movetimes with tsinnema - requires ms movetimes and db migration
|
||||
complete search engine using https://github.com/bsadeh/scalastic
|
||||
localize elo chart dates
|
||||
recognize tor IPs http://en.lichess.org/forum/staff/cheater-101#9 https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=37.59.32.99
|
||||
add more system messages to the game chat http://en.lichess.org/forum/lichess-feedback/feedback-about-chat-rooms#2
|
||||
index game positions
|
||||
integrate with google+
|
||||
elo stats (branch elostats)
|
||||
|
|
Loading…
Reference in a new issue