Return cells with same prototype in Cell#adjacentCells()

master
Guillaume Dott 2014-12-12 12:23:25 +01:00
parent 9f8fdbb025
commit f96725b822
1 changed files with 5 additions and 4 deletions

View File

@ -115,11 +115,12 @@ class Nikoli.Cell
getRow: -> @game[@x] getRow: -> @game[@x]
adjacentCells: -> adjacentCells: ->
constructor = Object.getPrototypeOf(this).constructor
[ [
new Cell(@x + 1, @y, @game), new constructor(@x + 1, @y, @game),
new Cell(@x - 1, @y, @game), new constructor(@x - 1, @y, @game),
new Cell(@x, @y + 1, @game), new constructor(@x, @y + 1, @game),
new Cell(@x, @y - 1, @game) new constructor(@x, @y - 1, @game)
] ]
valid: (value) -> valid: (value) ->