negociate round resign and abort through websockets
This commit is contained in:
parent
d83ced489f
commit
c88d7d7ff0
|
@ -96,10 +96,6 @@ object Round extends LilaController with TheftPrevention {
|
|||
pov, v, roomHtml, bookmarkers, analysed, tour))
|
||||
}
|
||||
|
||||
def abort(fullId: String) = performAndRedirect(fullId, Abort(_))
|
||||
def resign(fullId: String) = performAndRedirect(fullId, Resign(_))
|
||||
def resignForce(fullId: String) = performAndRedirect(fullId, ResignForce(_))
|
||||
|
||||
def tableWatcher(gameId: String, color: String) = Open { implicit ctx ⇒
|
||||
OptionOk(GameRepo.pov(gameId, color)) { html.round.table.watch(_) }
|
||||
}
|
||||
|
@ -122,20 +118,4 @@ object Round extends LilaController with TheftPrevention {
|
|||
} toMap) ++ ctx.me.??(me ⇒ Map("me" -> me.usernameWithElo))
|
||||
})
|
||||
}
|
||||
|
||||
protected def performAndRedirect(fullId: String, makeMessage: String ⇒ Any) = Action {
|
||||
Async {
|
||||
perform(fullId, makeMessage) recover {
|
||||
case e: Exception ⇒ logwarn("[round] perform " + e.getMessage)
|
||||
} inject Redirect(routes.Round.player(fullId))
|
||||
}
|
||||
}
|
||||
|
||||
protected def perform(fullId: String, makeMessage: String ⇒ Any): Funit = {
|
||||
Env.round.roundMap ! Tell(
|
||||
GameModel takeGameId fullId,
|
||||
makeMessage(GameModel takePlayerId (fullId))
|
||||
)
|
||||
Env.round.roundMap ? Await(GameModel takeGameId fullId) void
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
</div>
|
||||
<div class="lichess_control clearfix">
|
||||
@if(game.abortable) {
|
||||
<a href="@routes.Round.abort(fullId)" class="lichess_abort">@trans.abortGame()</a>
|
||||
<a class="lichess_abort socket-link" data-msg="abort">@trans.abortGame()</a>
|
||||
} else {
|
||||
<a href="@routes.Round.resign(fullId)" class="lichess_resign">@trans.resign()</a>
|
||||
<a class="lichess_resign socket-link" data-msg="resign">@trans.resign()</a>
|
||||
@if(game.playerCanOfferDraw(color)) {
|
||||
<a class="offer_draw socket-link" data-msg="draw-yes">@trans.offerDraw()</a>
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
|||
@if(game.resignable && !game.hasAi) {
|
||||
<div class="force_resign_zone">
|
||||
@trans.theOtherPlayerHasLeftTheGameYouCanForceResignationOrWaitForHim()<br />
|
||||
<a class="force_resign" href="@routes.Round.resignForce(fullId)">@trans.forceResignation()</a>
|
||||
<a class="force_resign socket-link" data-msg="resign-force">@trans.forceResignation()</a>
|
||||
</div>
|
||||
}
|
||||
@if(game.turnOf(player) && game.toChessHistory.threefoldRepetition) {
|
||||
|
|
|
@ -43,9 +43,6 @@ GET /$fullId<[\w\-]{12}> controllers.Round.player(fu
|
|||
GET /$gameId<[\w\-]{8}>/$color<white|black>/socket controllers.Round.websocketWatcher(gameId: String, color: String)
|
||||
GET /$gameId<[\w\-]{8}>/s.js controllers.Round.signedJs(gameId: String)
|
||||
GET /$fullId<[\w\-]{12}>/socket controllers.Round.websocketPlayer(fullId: String)
|
||||
GET /$fullId<[\w\-]{12}>/abort controllers.Round.abort(fullId: String)
|
||||
GET /$fullId<[\w\-]{12}>/resign controllers.Round.resign(fullId: String)
|
||||
GET /$fullId<[\w\-]{12}>/resign/force controllers.Round.resignForce(fullId: String)
|
||||
GET /$gameId<[\w\-]{8}>/$color<white|black>/table controllers.Round.tableWatcher(gameId: String, color: String)
|
||||
GET /$fullId<[\w\-]{12}>/table controllers.Round.tablePlayer(fullId: String)
|
||||
GET /$gameId<[\w\-]{8}>/players controllers.Round.players(gameId: String)
|
||||
|
|
|
@ -40,7 +40,6 @@ private[round] final class Finisher(
|
|||
((g.status >= Status.Mate) ?? incNbGames(g, Black)) >>-
|
||||
(indexer ! lila.game.actorApi.InsertGame(g)) >>-
|
||||
(tournamentOrganizer ! FinishGame(g.id))
|
||||
// TODO send redirection events
|
||||
} yield p2.events
|
||||
|
||||
private def incNbGames(game: Game, color: Color): Funit =
|
||||
|
|
|
@ -52,6 +52,9 @@ private[round] final class SocketHandler(
|
|||
case ("draw-yes", _) ⇒ roundMap ! Tell(gameId, DrawYes(playerId))
|
||||
case ("draw-no", _) ⇒ roundMap ! Tell(gameId, DrawNo(playerId))
|
||||
case ("draw-claim", _) ⇒ roundMap ! Tell(gameId, DrawClaim(playerId))
|
||||
case ("resign", _) ⇒ roundMap ! Tell(gameId, Resign(playerId))
|
||||
case ("resign-force", _) ⇒ roundMap ! Tell(gameId, ResignForce(playerId))
|
||||
case ("abort", _) ⇒ roundMap ! Tell(gameId, Abort(playerId))
|
||||
case ("move", o) ⇒ parseMove(o) foreach {
|
||||
case (orig, dest, prom, blur, lag) ⇒ {
|
||||
socket ! Ack(uid)
|
||||
|
|
1
todo
1
todo
|
@ -84,7 +84,6 @@ from MoralIntentions email:
|
|||
- The possibility of team matches (with solutions for players who are in several teams), where the team leader has to choose the board order, where the team results are shown and where the team player (who has played all of the games of the match) with the highest Percentage Score gets crowned Player of the Match of team "A".
|
||||
safari has high bounce rate
|
||||
tell, instead of asking, the round actor. it may send the events to the socket
|
||||
negociate resign and all with websockets
|
||||
|
||||
DEPLOY p21
|
||||
----------
|
||||
|
|
Loading…
Reference in a new issue