Remove iocolor methods

This commit is contained in:
Thibault Duplessis 2012-04-19 22:58:02 +02:00
parent db3af3dbbd
commit d2a254c75a
3 changed files with 29 additions and 36 deletions

View file

@ -87,33 +87,35 @@ final class AppApi(
whiteRedirect: String,
blackRedirect: String,
entryData: String,
messageString: String): IO[Valid[Unit]] = for {
color ioColor(colorName)
newGameOption gameRepo game newGameId
g1Option gameRepo game gameId
result (newGameOption |@| g1Option).tupled.fold(
games {
val (newGame, g1) = games
val progress = Progress(g1, List(
RedirectEvent(White, whiteRedirect),
RedirectEvent(Black, blackRedirect),
// tell spectators to reload the table
ReloadTableEvent(White),
ReloadTableEvent(Black)))
for {
_ gameRepo save progress
_ gameSocket send progress
newProgress starter.start(newGame, entryData)
newProgress2 messenger.systemMessages(
newProgress.game, messageString
) map newProgress.++
_ gameRepo save newProgress2
_ gameSocket send newProgress2
} yield success()
},
io(GameNotFound)
): IO[Valid[Unit]]
} yield result
messageString: String): IO[Valid[Unit]] = Color(colorName).fold(
color for {
newGameOption gameRepo game newGameId
g1Option gameRepo game gameId
result (newGameOption |@| g1Option).tupled.fold(
games {
val (newGame, g1) = games
val progress = Progress(g1, List(
RedirectEvent(White, whiteRedirect),
RedirectEvent(Black, blackRedirect),
// tell spectators to reload the table
ReloadTableEvent(White),
ReloadTableEvent(Black)))
for {
_ gameRepo save progress
_ gameSocket send progress
newProgress starter.start(newGame, entryData)
newProgress2 messenger.systemMessages(
newProgress.game, messageString
) map newProgress.++
_ gameRepo save newProgress2
_ gameSocket send newProgress2
} yield success()
},
io(GameNotFound)
): IO[Valid[Unit]]
} yield result,
io { !!("Wrong color name") }
)
def reloadTable(gameId: String): IO[Valid[Unit]] = for {
g1Option gameRepo game gameId
@ -151,8 +153,4 @@ final class AppApi(
io()
)
} yield ()
private def ioColor(colorName: String): IO[Color] = io {
Color(colorName) err "Invalid color"
}
}

View file

@ -54,8 +54,4 @@ final class Api(
hook hookRepo ownedHook hookOwnerId
_ hook.fold(fisherman.+, io())
} yield ()
private def ioColor(colorName: String): IO[Color] = io {
Color(colorName) err "Invalid color"
}
}

1
todo
View file

@ -1,3 +1,2 @@
ping nbm
compress player.ps notation
remove iocolor