diff --git a/views/application.coffee b/views/application.coffee index 7632e07..7374176 100644 --- a/views/application.coffee +++ b/views/application.coffee @@ -76,6 +76,13 @@ class Nikoli.Cell new Cell(@x, @y - 1, @game) ] + isPool: -> + [ + new Cell(@x, @y + 1, @game), + new Cell(@x + 1, @y, @game), + new Cell(@x + 1, @y + 1, @game), + ].every (cell) => cell.valid(@value) + valid: (value) -> 0 <= @x < @game.length && 0 <= @y < @game[@x].length && (!value? || value < 0 && @game[@x][@y] < 0 || value >= 0 && @game[@x][@y] >= 0) diff --git a/views/nurikabe.coffee b/views/nurikabe.coffee index c0856a5..257da94 100644 --- a/views/nurikabe.coffee +++ b/views/nurikabe.coffee @@ -18,7 +18,9 @@ class Nikoli.Nurikabe extends Nikoli.Game black_stream.calculate(cell) else if !black_stream.include(cell) errors.push {row: i, column: j, message: 'The stream must be continuous'} - # TODO check for pools + + if cell.isPool() + errors.push {row: i, column: j, message: 'There must be no pools.'} else if cell.value > 0 if white_walls.some((wall) -> wall.include(cell)) errors.push {row: i, column: j, message: 'Each wall must contain exactly one numbered cell.'}