← All repositories

crossmate

A collaborative crossword app for iPhone and iPad

git clone https://code.inqk.net/crossmate.git


commit 18f3f9d50ef9cd390764218683507abc544ea08e
parent b1cbac41fe5e822a88850e9f5b96067e834e57f8
Author: Michael Camilleri <[email protected]>
Date:   Thu, 18 Jun 2026 08:59:37 +0900

Ink correct pencil entries on check

This commit updates grid checking so a correct pencil entry is promoted
to ink when the user checks a square, word, or puzzle. Wrong pencil
entries keep their tentative styling while gaining the wrong-check mark,
so checking no longer leaves confirmed answers looking provisional.

Co-Authored-By: Codex GPT 5.5 <[email protected]>

Diffstat

MCrossmate/Models/Game.swift | 9++++++---
MTests/Unit/GameMutatorTests.swift | 18++++++++++++++----

2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/Crossmate/Models/Game.swift b/Crossmate/Models/Game.swift

@@ -83,8 +83,9 @@ final class Game {
     /// correct entries get `checkedRight = true` (was previously cleared to
     /// `.none` — the new flag carries the verification through so peers can
     /// see what their partner has already checked in a co-solving session).
-    /// Pen-vs-pencil style is preserved across the check. Empty cells and
-    /// cells without a known solution are skipped.
+    /// Correct pencil entries are promoted to ink; wrong pencil entries keep
+    /// their pencil style so the tentative entry remains visually distinct.
+    /// Empty cells and cells without a known solution are skipped.
     func checkCells(_ cells: [Puzzle.Cell]) {
         for cell in cells {
             guard !cell.isBlock else { continue }
@@ -96,7 +97,9 @@ final class Game {
             let result: CheckResult = cell.accepts(entry) ? .right : .wrong
             switch squares[cell.row][cell.col].mark {
             case .pencil:
-                squares[cell.row][cell.col].mark = .pencil(checked: result)
+                squares[cell.row][cell.col].mark = result == .right
+                    ? .pen(checked: .right)
+                    : .pencil(checked: .wrong)
             case .none, .pen:
                 squares[cell.row][cell.col].mark = .pen(checked: result)
             case .revealed:

diff --git a/Tests/Unit/GameMutatorTests.swift b/Tests/Unit/GameMutatorTests.swift

@@ -84,16 +84,26 @@ struct GameMutatorTests {
         #expect(game.squares[0][0].mark == .pen(checked: .wrong))
     }
 
-    @Test("checkCells stamps correct pencil entries with .right and keeps the pencil style")
+    @Test("checkCells inks correct pencil entries")
     func checkCellsStampsCorrectPencilEntries() throws {
         let (game, mutator, _, _) = try makeTestGame()
 
-        // Cell (0,0) has solution "A"; checking a correct draft now records
-        // the verification on the cell so peers can see what's been checked.
+        // Cell (0,0) has solution "A"; checking a correct draft commits it to ink.
         mutator.setLetter("A", atRow: 0, atCol: 0, pencil: true)
         mutator.checkCells([game.puzzle.cells[0][0]])
 
-        #expect(game.squares[0][0].mark == .pencil(checked: .right))
+        #expect(game.squares[0][0].mark == .pen(checked: .right))
+    }
+
+    @Test("checkCells keeps wrong pencil entries penciled")
+    func checkCellsKeepsWrongPencilEntriesPenciled() throws {
+        let (game, mutator, _, _) = try makeTestGame()
+
+        // Cell (0,0) has solution "A"; wrong drafts stay tentative after check.
+        mutator.setLetter("Z", atRow: 0, atCol: 0, pencil: true)
+        mutator.checkCells([game.puzzle.cells[0][0]])
+
+        #expect(game.squares[0][0].mark == .pencil(checked: .wrong))
     }
 
     @Test("revealCells sets entry to solution and marks revealed")