feat: NCS-40 Rework Draw System #34
@@ -194,7 +194,7 @@ class GameEngineDrawOfferTest extends AnyFunSuite with Matchers:
|
||||
case other =>
|
||||
fail(s"Expected InvalidMoveEvent, but got $other")
|
||||
|
||||
test("Draw offer is cleared when game ends by resignation"):
|
||||
test("Draw offer is cleared when game ends by resignation (accept)"):
|
||||
val engine = new GameEngine()
|
||||
val observer = new DrawOfferMockObserver()
|
||||
engine.subscribe(observer)
|
||||
@@ -214,6 +214,26 @@ class GameEngineDrawOfferTest extends AnyFunSuite with Matchers:
|
||||
case other =>
|
||||
fail(s"Expected InvalidMoveEvent, but got $other")
|
||||
|
||||
test("Draw offer is cleared when game ends by resignation"):
|
||||
val engine = new GameEngine()
|
||||
val observer = new DrawOfferMockObserver()
|
||||
engine.subscribe(observer)
|
||||
|
||||
engine.offerDraw(Color.White)
|
||||
observer.events.clear()
|
||||
engine.resign(Color.Black)
|
||||
|
||||
// Try to accept the now-cleared draw offer
|
||||
observer.events.clear()
|
||||
engine.declineDraw(Color.White)
|
||||
|
||||
observer.events should have length 1
|
||||
observer.events.head match
|
||||
case event: InvalidMoveEvent =>
|
||||
event.reason shouldBe InvalidMoveReason.GameAlreadyOver
|
||||
case other =>
|
||||
fail(s"Expected InvalidMoveEvent, but got $other")
|
||||
|
||||
private class DrawOfferMockObserver extends Observer:
|
||||
val events = mutable.ListBuffer[GameEvent]()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user