board API: distinct endpoint to offer/accept/decline draw
parent
a024ead25f
commit
7bc84d320c
|
@ -97,10 +97,10 @@ final class PlayApi(
|
|||
as(id, me) { pov =>
|
||||
env.bot.player.resign(pov) pipe toResult
|
||||
}
|
||||
// case Array("game", id, "draw", bool) =>
|
||||
// as(id, me) { pov =>
|
||||
// env.bot.player.setDraw(pov, lila.common.Form.trueish(bool)) pipe toResult
|
||||
// }
|
||||
case Array("game", id, "draw", bool) =>
|
||||
as(id, me) { pov =>
|
||||
fuccess(env.bot.player.setDraw(pov, lila.common.Form.trueish(bool))) pipe toResult
|
||||
}
|
||||
case _ => notFoundJson("No such command")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ final class BotPlayer(
|
|||
else {
|
||||
val promise = Promise[Unit]
|
||||
if (pov.player.isOfferingDraw && (offeringDraw contains false)) declineDraw(pov)
|
||||
else if (!pov.player.isOfferingDraw && (offeringDraw contains true)) offerDraw(pov)
|
||||
else if (!pov.player.isOfferingDraw && ~offeringDraw) offerDraw(pov)
|
||||
Bus.publish(
|
||||
Tell(pov.gameId, BotPlay(pov.playerId, uci, promise.some)),
|
||||
"roundMapTell"
|
||||
|
@ -96,7 +96,7 @@ final class BotPlayer(
|
|||
)
|
||||
|
||||
def offerDraw(pov: Pov): Unit =
|
||||
if (pov.game.drawable && pov.game.playerCanOfferDraw(pov.color) && pov.isMyTurn)
|
||||
if (pov.game.drawable && pov.game.playerCanOfferDraw(pov.color))
|
||||
Bus.publish(
|
||||
Tell(pov.gameId, DrawYes(PlayerId(pov.playerId))),
|
||||
"roundMapTell"
|
||||
|
|
Loading…
Reference in New Issue