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,
|
||||
siteSocket = site.socket,
|
||||
lobbyNotify = lobby.socket.reloadTournaments,
|
||||
abortGame = round.forceAbort.apply,
|
||||
roundMeddler = round.meddler,
|
||||
mongodb = mongodb.apply _)
|
||||
|
||||
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(
|
||||
mongodb(RoundCollectionWatcherRoom))
|
||||
|
||||
lazy val forceAbort = new ForceAbort(
|
||||
lazy val meddler = new Meddler(
|
||||
gameRepo = gameRepo,
|
||||
finisher = finisher,
|
||||
socket = socket)
|
||||
|
|
|
@ -18,7 +18,7 @@ final class TournamentApi(
|
|||
socket: Socket,
|
||||
siteSocket: site.Socket,
|
||||
lobbyNotify: String ⇒ IO[Unit],
|
||||
abortGame: String ⇒ IO[Unit]) {
|
||||
roundMeddler: round.Meddler) {
|
||||
|
||||
def makePairings(tour: Started, pairings: NonEmptyList[Pairing]): IO[Unit] =
|
||||
(tour addPairings pairings) |> { tour2 ⇒
|
||||
|
@ -61,7 +61,7 @@ final class TournamentApi(
|
|||
_ ← repo saveIO finished
|
||||
_ ← socket reloadPage finished.id
|
||||
_ ← reloadSiteSocket
|
||||
_ ← (finished.playingPairings map (_.gameId) map abortGame).sequence
|
||||
_ ← (finished.playingPairings map (_.gameId) map roundMeddler.forceAbort).sequence
|
||||
} yield finished
|
||||
}, io(started))
|
||||
|
||||
|
@ -87,14 +87,12 @@ final class TournamentApi(
|
|||
)
|
||||
case started: Started ⇒ (started withdraw userId).fold(
|
||||
err ⇒ putStrLn(err.shows) inject tour,
|
||||
tour2 ⇒ tour2.readyToFinish.fold(
|
||||
finish(tour2),
|
||||
for {
|
||||
_ ← repo saveIO tour2
|
||||
_ ← socket reload tour2.id
|
||||
_ ← reloadSiteSocket
|
||||
} yield tour2
|
||||
)
|
||||
tour2 ⇒ for {
|
||||
_ ← repo saveIO tour2
|
||||
_ ← (tour2 userCurrentPov userId).fold(roundMeddler.resign, io())
|
||||
_ ← socket reload tour2.id
|
||||
_ ← reloadSiteSocket
|
||||
} yield tour2
|
||||
)
|
||||
case finished: Finished ⇒ putStrLn("Cannot withdraw from finished tournament " + finished.id) inject tour
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ final class TournamentEnv(
|
|||
flood: Flood,
|
||||
siteSocket: site.Socket,
|
||||
lobbyNotify: String ⇒ IO[Unit],
|
||||
abortGame: String ⇒ IO[Unit],
|
||||
roundMeddler: round.Meddler,
|
||||
mongodb: String ⇒ MongoCollection) {
|
||||
|
||||
implicit val ctx = app
|
||||
|
@ -43,7 +43,7 @@ final class TournamentEnv(
|
|||
socket = socket,
|
||||
siteSocket = siteSocket,
|
||||
lobbyNotify = lobbyNotify,
|
||||
abortGame = abortGame)
|
||||
roundMeddler = roundMeddler)
|
||||
|
||||
lazy val roomRepo = new RoomRepo(
|
||||
collection = mongodb(TournamentCollectionRoom)
|
||||
|
|
|
@ -133,6 +133,8 @@
|
|||
padding: 0.3em 0.2em;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
#tournament_side div.pairings a:hover {
|
||||
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)
|
||||
tournament ties
|
||||
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
|
||||
send lobby new forum posts html through websockets
|
||||
un-ban IP mechanism (deleting cookies)
|
||||
|
|
Loading…
Reference in a new issue