Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions modules/round/src/main/Drawer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ final private[round] class Drawer(
Messenger.SystemMessage.Persistent(trans.site.drawOfferAccepted.txt()).some
)
case Pov(g, color) if g.playerCanOfferDraw(color) =>
val progress = Progress(g).map(offerDraw(color))
messenger.system(g, color.fold(trans.site.whiteOffersDraw, trans.site.blackOffersDraw).txt())
for
_ <- proxy.save(progress)
_ = publishDrawOffer(progress.game)
yield List(Event.DrawOffer(by = color.some))
if pov.game.situation.copy(color = color).opponentHasInsufficientMaterial then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot just swap the color and check for opponentHasInsufficientMaterial because it's not only depends on pieces on the board, but also whose turn to play. Look at this antichess position: https://lichess.org/analysis/antichess/8/8/3N4/8/1n6/8/8/8_w_-_-_15_44 (from #17536) whoever play can win the game so pov.game.situation.copy(color = color).opponentHasInsufficientMaterial is true for both sides, even though in real game only White can win.

finisher.other(pov.game, _.Draw, None)
else
val progress = Progress(g).map(offerDraw(color))
messenger.system(g, color.fold(trans.site.whiteOffersDraw, trans.site.blackOffersDraw).txt())
for
_ <- proxy.save(progress)
_ = publishDrawOffer(progress.game)
yield List(Event.DrawOffer(by = color.some))
case _ => fuccess(List(Event.ReloadOwner))

def no(pov: Pov)(using proxy: GameProxy): Fu[Events] = pov.game.drawable.so:
Expand Down