programgames/minesweeper/play.xtl
ᵘa̲sk : Any a => a -> Int
A command: f (flag) or not, then a row and a column from 1 to 9; anything else is asked for again.
ᵘa̲sk ← { s → line ← ᵖl̲ine "OPEN ROW COL, OR F ROW COL ?" v ← ᵖn̲umbersIn line ok ← (2 = t̲ally v) ∧ '∧ r̲/ (v ≥ 1) ∧ v ≤ 9 ok ? (('∨ r̲/ line m̲ember? "fF") c̲at v)◆ ᵘa̲sk s }
ᵘt̲urn : Int -> Char
A turn: the field (as text and as a picture), a command, its result.
ᵘt̲urn ← { s → said ← p̲rint! "" shown ← p̲rint! ᵐv̲iew s pic ← ⎕S̲HOW ᵐp̲icture s 1 = ᵐs̲tatus s ? "YOU CLEARED THE FIELD!" 2 = ᵐs̲tatus s ? "BOOM! YOU HIT A MINE." c ← ᵘa̲sk s 1 = f̲irst c ? ᵘt̲urn s ᵐf̲lag 1 d̲rop c◆ ᵘt̲urn s ᵐr̲eveal 1 d̲rop c }
Used in: ᵘt̲urn, games/minesweeper/play.xtl:28