board API: distinct endpoint to offer/accept/decline draw

pull/6154/head
Thibault Duplessis 2020-03-11 15:50:34 -06:00
parent a024ead25f
commit 7bc84d320c
2 changed files with 6 additions and 6 deletions

View File

@ -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")
}
}

View File

@ -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"