check should return score or nothing if invalid

This commit is contained in:
Sidharth Kulkarni 2026-05-09 20:32:17 -07:00
parent 57579fa5e4
commit 38838c47b9
Signed by: skulk
SSH key fingerprint: SHA256:Jby+S9d1WmwqnXIrngHgccYNHz+cYquxN1zm3ym3Kbg
4 changed files with 11 additions and 13 deletions

View file

@ -32,8 +32,8 @@ spec = do
displayText gameBoard `shouldBe` "1 2 \n3 4 \n"
it "validates a move" do
selectCheck (0, 0) (1, 1) gameBoard `shouldBe` True
selectCheck (0, 0) (0, 1) gameBoard `shouldBe` False
selectCheck (0, 0) (1, 1) gameBoard `shouldBe` Just 4
selectCheck (0, 0) (0, 1) gameBoard `shouldBe` Nothing
it "clears properly" do
let cleared = clear (0, 0) (0, 1) gameBoard
@ -55,7 +55,7 @@ spec = do
let action = SelectSquare (0, 0) (0, 1)
newState = makeMove (MkPlayerIndex 0) action initialState
preview (#players % ix 0 % #score) newState `shouldBe` Just 1
preview (#players % ix 0 % #score) newState `shouldBe` Just 2
it "does not increase score if sum does not equal target" do
let invalidAction = SelectSquare (0, 0) (1, 0)