From 6a8b0425fa17a1858146a0bb67f010f9472124db Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Sun, 14 Dec 2014 22:12:27 +0100 Subject: [PATCH] Rename @x and @y to @row and @column in Nikoli.Cell --- views/akari.coffee | 8 ++++---- views/application.coffee | 30 +++++++++++++++--------------- views/nurikabe.coffee | 6 +++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/views/akari.coffee b/views/akari.coffee index 2782a60..2db140a 100644 --- a/views/akari.coffee +++ b/views/akari.coffee @@ -96,13 +96,13 @@ class Nikoli.AkariCell extends Nikoli.Cell return false lightLeft: -> - @y != 0 && @light(@getRow().slice(0, @y).reverse()) + @column != 0 && @light(@getRow().slice(0, @column).reverse()) lightRight: -> - @y != (@getRow().length - 1) && @light(@getRow().slice(@y + 1)) + @column != (@getRow().length - 1) && @light(@getRow().slice(@column + 1)) lightUp: -> - @x != 0 && @light(@getColumn().slice(0, @x).reverse()) + @row != 0 && @light(@getColumn().slice(0, @row).reverse()) lightDown: -> - @x != (@getColumn().length - 1) && @light(@getColumn().slice(@x + 1)) + @row != (@getColumn().length - 1) && @light(@getColumn().slice(@row + 1)) diff --git a/views/application.coffee b/views/application.coffee index e64fef2..05bfa60 100644 --- a/views/application.coffee +++ b/views/application.coffee @@ -113,13 +113,13 @@ class Nikoli.Row row class Nikoli.Cell - constructor: (@x, @y, @game) -> - @value = @game[@x][@y] if @game? && @valid() + constructor: (@row, @column, @game) -> + @value = @game[@row][@column] if @game? && @valid() create: (value) -> cell = document.createElement 'div' - cell.dataset.row = @x - cell.dataset.column = @y + cell.dataset.row = @row + cell.dataset.column = @column cell.classList.add 'grid-cell' @@ -127,27 +127,27 @@ class Nikoli.Cell cell - toString: -> "#{@x};#{@y}" + toString: -> "#{@row};#{@column}" getColumn: -> column = [] - column.push @game[i][@y] for i in [0...@game.length] + column.push @game[i][@column] for i in [0...@game.length] column - getRow: -> @game[@x] + getRow: -> @game[@row] adjacentCells: -> constructor = Object.getPrototypeOf(this).constructor [ - new constructor(@x + 1, @y, @game), - new constructor(@x - 1, @y, @game), - new constructor(@x, @y + 1, @game), - new constructor(@x, @y - 1, @game) + new constructor(@row + 1, @column, @game), + new constructor(@row - 1, @column, @game), + new constructor(@row, @column + 1, @game), + new constructor(@row, @column - 1, @game) ] valid: (value) -> - 0 <= @x < @game.length && 0 <= @y < @game[@x].length && - (!value? || value < 0 && @game[@x][@y] < 0 || value >= 0 && @game[@x][@y] >= 0) + 0 <= @row < @game.length && 0 <= @column < @game[@row].length && + (!value? || value < 0 && @game[@row][@column] < 0 || value >= 0 && @game[@row][@column] >= 0) duplicatesIn: (array) -> array.filter((cell) => cell == @value).length > 1 @@ -160,8 +160,8 @@ class Nikoli.Cell squareDuplicates: (from, size) -> square = [] - for i in [from.x...(from.x + size)] - for j in [from.y...(from.y + size)] + for i in [from.row...(from.row + size)] + for j in [from.column...(from.column + size)] square.push @game[i][j] @duplicatesIn square diff --git a/views/nurikabe.coffee b/views/nurikabe.coffee index b7115cb..b757e3c 100644 --- a/views/nurikabe.coffee +++ b/views/nurikabe.coffee @@ -78,8 +78,8 @@ class Nikoli.NurikabeCell extends Nikoli.Cell isPool: -> [ - new NurikabeCell(@x, @y + 1, @game), - new NurikabeCell(@x + 1, @y, @game), - new NurikabeCell(@x + 1, @y + 1, @game), + new NurikabeCell(@row, @column + 1, @game), + new NurikabeCell(@row + 1, @column, @game), + new NurikabeCell(@row + 1, @column + 1, @game), ].every (cell) => cell.valid(@value)