CellMark.swift (1356B)
1 import Foundation 2 3 /// Non-letter state attached to a single cell. The letter itself lives in 4 /// `Game.entries`; `CellMark` describes how that letter (or the absence of 5 /// one) should be interpreted and rendered. 6 /// 7 /// Cases model two orthogonal dimensions — whether the entry is pen or pencil, 8 /// and whether a check has flagged it as wrong — plus `revealed`, which is a 9 /// distinct, locked state. `.none` is the canonical "no mark" value; we never 10 /// store `.pen(checkedWrong: false)` because it's semantically equivalent to 11 /// `.none`. `.pencil(checkedWrong: false)` is a real state (a tentative entry 12 /// that hasn't been checked) and is preserved. 13 /// 14 /// All marks are shared state — they live on `Game` alongside `entries` so 15 /// both players in a collaborative session see the same marks. 16 enum CellMark: Sendable, Equatable { 17 case none 18 case pen(checkedWrong: Bool) 19 case pencil(checkedWrong: Bool) 20 case revealed 21 22 var isRevealed: Bool { 23 if case .revealed = self { return true } 24 return false 25 } 26 27 var isPencil: Bool { 28 if case .pencil = self { return true } 29 return false 30 } 31 32 var isCheckedWrong: Bool { 33 switch self { 34 case .pen(let wrong), .pencil(let wrong): 35 return wrong 36 case .none, .revealed: 37 return false 38 } 39 } 40 }