tournament withdraw resigns current games
This commit is contained in:
parent
782e80643c
commit
c76bcd5df0
|
@ -107,7 +107,7 @@ final class CoreEnv private (application: Application, val settings: Settings) {
|
||||||
flood = security.flood,
|
flood = security.flood,
|
||||||
siteSocket = site.socket,
|
siteSocket = site.socket,
|
||||||
lobbyNotify = lobby.socket.reloadTournaments,
|
lobbyNotify = lobby.socket.reloadTournaments,
|
||||||
abortGame = round.forceAbort.apply,
|
roundMeddler = round.meddler,
|
||||||
mongodb = mongodb.apply _)
|
mongodb = mongodb.apply _)
|
||||||
|
|
||||||
lazy val analyse = new lila.analyse.AnalyseEnv(
|
lazy val analyse = new lila.analyse.AnalyseEnv(
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package lila
|
|
||||||
package round
|
|
||||||
|
|
||||||
import game.{ DbGame, GameRepo }
|
|
||||||
|
|
||||||
import scalaz.effects._
|
|
||||||
|
|
||||||
final class ForceAbort(
|
|
||||||
gameRepo: GameRepo,
|
|
||||||
finisher: Finisher,
|
|
||||||
socket: Socket) {
|
|
||||||
|
|
||||||
def apply(id: String): IO[Unit] = for {
|
|
||||||
gameOption ← gameRepo game id
|
|
||||||
_ ← gameOption.fold(
|
|
||||||
game ⇒ (finisher forceAbort game).fold(
|
|
||||||
err ⇒ putStrLn(err.shows),
|
|
||||||
ioEvents ⇒ for {
|
|
||||||
events ← ioEvents
|
|
||||||
_ ← io { socket.send(game.id, events) }
|
|
||||||
} yield ()
|
|
||||||
),
|
|
||||||
putStrLn("Cannot abort missing game " + id)
|
|
||||||
)
|
|
||||||
} yield ()
|
|
||||||
}
|
|
40
app/round/Meddler.scala
Normal file
40
app/round/Meddler.scala
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package lila
|
||||||
|
package round
|
||||||
|
|
||||||
|
import game.{ DbGame, GameRepo, PovRef }
|
||||||
|
|
||||||
|
import scalaz.effects._
|
||||||
|
|
||||||
|
final class Meddler(
|
||||||
|
gameRepo: GameRepo,
|
||||||
|
finisher: Finisher,
|
||||||
|
socket: Socket) {
|
||||||
|
|
||||||
|
def forceAbort(id: String): IO[Unit] = for {
|
||||||
|
gameOption ← gameRepo game id
|
||||||
|
_ ← gameOption.fold(
|
||||||
|
game ⇒ (finisher forceAbort game).fold(
|
||||||
|
err ⇒ putStrLn(err.shows),
|
||||||
|
ioEvents ⇒ for {
|
||||||
|
events ← ioEvents
|
||||||
|
_ ← io { socket.send(game.id, events) }
|
||||||
|
} yield ()
|
||||||
|
),
|
||||||
|
putStrLn("Cannot abort missing game " + id)
|
||||||
|
)
|
||||||
|
} yield ()
|
||||||
|
|
||||||
|
def resign(povRef: PovRef): IO[Unit] = for {
|
||||||
|
povOption ← gameRepo pov povRef
|
||||||
|
_ ← povOption.fold(
|
||||||
|
pov ⇒ (finisher resign pov).fold(
|
||||||
|
err ⇒ putStrLn(err.shows),
|
||||||
|
ioEvents ⇒ for {
|
||||||
|
events ← ioEvents
|
||||||
|
_ ← io { socket.send(pov.game.id, events) }
|
||||||
|
} yield ()
|
||||||
|
),
|
||||||
|
putStrLn("Cannot resign missing game " + povRef)
|
||||||
|
)
|
||||||
|
} yield ()
|
||||||
|
}
|
|
@ -93,7 +93,7 @@ final class RoundEnv(
|
||||||
lazy val watcherRoomRepo = new WatcherRoomRepo(
|
lazy val watcherRoomRepo = new WatcherRoomRepo(
|
||||||
mongodb(RoundCollectionWatcherRoom))
|
mongodb(RoundCollectionWatcherRoom))
|
||||||
|
|
||||||
lazy val forceAbort = new ForceAbort(
|
lazy val meddler = new Meddler(
|
||||||
gameRepo = gameRepo,
|
gameRepo = gameRepo,
|
||||||
finisher = finisher,
|
finisher = finisher,
|
||||||
socket = socket)
|
socket = socket)
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class TournamentApi(
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
siteSocket: site.Socket,
|
siteSocket: site.Socket,
|
||||||
lobbyNotify: String ⇒ IO[Unit],
|
lobbyNotify: String ⇒ IO[Unit],
|
||||||
abortGame: String ⇒ IO[Unit]) {
|
roundMeddler: round.Meddler) {
|
||||||
|
|
||||||
def makePairings(tour: Started, pairings: NonEmptyList[Pairing]): IO[Unit] =
|
def makePairings(tour: Started, pairings: NonEmptyList[Pairing]): IO[Unit] =
|
||||||
(tour addPairings pairings) |> { tour2 ⇒
|
(tour addPairings pairings) |> { tour2 ⇒
|
||||||
|
@ -61,7 +61,7 @@ final class TournamentApi(
|
||||||
_ ← repo saveIO finished
|
_ ← repo saveIO finished
|
||||||
_ ← socket reloadPage finished.id
|
_ ← socket reloadPage finished.id
|
||||||
_ ← reloadSiteSocket
|
_ ← reloadSiteSocket
|
||||||
_ ← (finished.playingPairings map (_.gameId) map abortGame).sequence
|
_ ← (finished.playingPairings map (_.gameId) map roundMeddler.forceAbort).sequence
|
||||||
} yield finished
|
} yield finished
|
||||||
}, io(started))
|
}, io(started))
|
||||||
|
|
||||||
|
@ -87,14 +87,12 @@ final class TournamentApi(
|
||||||
)
|
)
|
||||||
case started: Started ⇒ (started withdraw userId).fold(
|
case started: Started ⇒ (started withdraw userId).fold(
|
||||||
err ⇒ putStrLn(err.shows) inject tour,
|
err ⇒ putStrLn(err.shows) inject tour,
|
||||||
tour2 ⇒ tour2.readyToFinish.fold(
|
tour2 ⇒ for {
|
||||||
finish(tour2),
|
_ ← repo saveIO tour2
|
||||||
for {
|
_ ← (tour2 userCurrentPov userId).fold(roundMeddler.resign, io())
|
||||||
_ ← repo saveIO tour2
|
_ ← socket reload tour2.id
|
||||||
_ ← socket reload tour2.id
|
_ ← reloadSiteSocket
|
||||||
_ ← reloadSiteSocket
|
} yield tour2
|
||||||
} yield tour2
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
case finished: Finished ⇒ putStrLn("Cannot withdraw from finished tournament " + finished.id) inject tour
|
case finished: Finished ⇒ putStrLn("Cannot withdraw from finished tournament " + finished.id) inject tour
|
||||||
}
|
}
|
||||||
|
@ -115,7 +113,7 @@ final class TournamentApi(
|
||||||
)
|
)
|
||||||
} yield result
|
} yield result
|
||||||
|
|
||||||
private def userIdWhoLostOnTimeWithoutMoving(game: DbGame): Option[String] =
|
private def userIdWhoLostOnTimeWithoutMoving(game: DbGame): Option[String] =
|
||||||
game.playerWhoDidNotMove
|
game.playerWhoDidNotMove
|
||||||
.flatMap(_.userId)
|
.flatMap(_.userId)
|
||||||
.filter(_ ⇒ List(chess.Status.Timeout, chess.Status.Outoftime) contains game.status)
|
.filter(_ ⇒ List(chess.Status.Timeout, chess.Status.Outoftime) contains game.status)
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class TournamentEnv(
|
||||||
flood: Flood,
|
flood: Flood,
|
||||||
siteSocket: site.Socket,
|
siteSocket: site.Socket,
|
||||||
lobbyNotify: String ⇒ IO[Unit],
|
lobbyNotify: String ⇒ IO[Unit],
|
||||||
abortGame: String ⇒ IO[Unit],
|
roundMeddler: round.Meddler,
|
||||||
mongodb: String ⇒ MongoCollection) {
|
mongodb: String ⇒ MongoCollection) {
|
||||||
|
|
||||||
implicit val ctx = app
|
implicit val ctx = app
|
||||||
|
@ -43,7 +43,7 @@ final class TournamentEnv(
|
||||||
socket = socket,
|
socket = socket,
|
||||||
siteSocket = siteSocket,
|
siteSocket = siteSocket,
|
||||||
lobbyNotify = lobbyNotify,
|
lobbyNotify = lobbyNotify,
|
||||||
abortGame = abortGame)
|
roundMeddler = roundMeddler)
|
||||||
|
|
||||||
lazy val roomRepo = new RoomRepo(
|
lazy val roomRepo = new RoomRepo(
|
||||||
collection = mongodb(TournamentCollectionRoom)
|
collection = mongodb(TournamentCollectionRoom)
|
||||||
|
|
|
@ -133,6 +133,8 @@
|
||||||
padding: 0.3em 0.2em;
|
padding: 0.3em 0.2em;
|
||||||
display: block;
|
display: block;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
#tournament_side div.pairings a:hover {
|
#tournament_side div.pairings a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
|
3
todo
3
todo
|
@ -46,9 +46,6 @@ all hub members should use userIds rather than usernames
|
||||||
add opera to list of supported browsers (with websocket trick)
|
add opera to list of supported browsers (with websocket trick)
|
||||||
tournament ties
|
tournament ties
|
||||||
tournament detect leavers and withdraw them (started) (also use force resign)
|
tournament detect leavers and withdraw them (started) (also use force resign)
|
||||||
^ game with no move = withdraw
|
|
||||||
tournament withdraw resigns playing games
|
|
||||||
tournament make pairings overflow hidden http://en.lichess.org/tournament/kswnkqr3
|
|
||||||
tournament warmup games
|
tournament warmup games
|
||||||
send lobby new forum posts html through websockets
|
send lobby new forum posts html through websockets
|
||||||
un-ban IP mechanism (deleting cookies)
|
un-ban IP mechanism (deleting cookies)
|
||||||
|
|
Loading…
Reference in a new issue