commit 3a16f6f8124d76aad27eebcddde762f572fdef1f
parent 49922995fe4e7d368a03b5f66d9a67d8cf8f66b7
Author: Michael Camilleri <[email protected]>
Date: Thu, 21 May 2026 11:53:13 +0900
Promote correct draft entries when checking
Checking a square, word, or puzzle now commits any correct pencil entries by
clearing their draft mark to the canonical non-draft state. Wrong pencil
entries still preserve pencil mode while carrying checkedWrong, so users can
distinguish a checked draft mistake from a pen mistake.
Co-Authored-By: Codex GPT 5.5 <[email protected]>
Diffstat:
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Crossmate/Models/Game.swift b/Crossmate/Models/Game.swift
@@ -65,7 +65,8 @@ final class Game {
/// For each non-empty, non-revealed target cell, compares the current
/// entry against the solution. Wrong entries get `checkedWrong = true`
/// (preserving pen-vs-pencil style); correct entries have the wrong mark
- /// cleared. Empty cells and cells without a known solution are skipped.
+ /// cleared and are promoted out of pencil mode. Empty cells and cells
+ /// without a known solution are skipped.
func checkCells(_ cells: [Puzzle.Cell]) {
for cell in cells {
guard !cell.isBlock else { continue }
@@ -77,7 +78,7 @@ final class Game {
let isWrong = !cell.accepts(entry)
switch squares[cell.row][cell.col].mark {
case .pencil:
- squares[cell.row][cell.col].mark = .pencil(checkedWrong: isWrong)
+ squares[cell.row][cell.col].mark = isWrong ? .pencil(checkedWrong: true) : .none
case .none, .pen:
squares[cell.row][cell.col].mark = isWrong ? .pen(checkedWrong: true) : .none
case .revealed:
diff --git a/Tests/Unit/GameMutatorTests.swift b/Tests/Unit/GameMutatorTests.swift
@@ -55,6 +55,17 @@ struct GameMutatorTests {
#expect(game.squares[0][0].mark == .pen(checkedWrong: true))
}
+ @Test("checkCells promotes correct pencil entries to pen")
+ func checkCellsPromotesCorrectPencilEntries() throws {
+ let (game, mutator, _, _) = try makeTestGame()
+
+ // Cell (0,0) has solution "A"; checking a correct draft commits it.
+ mutator.setLetter("A", atRow: 0, atCol: 0, pencil: true)
+ mutator.checkCells([game.puzzle.cells[0][0]])
+
+ #expect(game.squares[0][0].mark == .none)
+ }
+
@Test("revealCells sets entry to solution and marks revealed")
func revealCellsSetsAnswer() throws {
let (game, mutator, _, _) = try makeTestGame()