// Generated by CoffeeScript 1.6.3 (function() { this.SudokuCell = (function() { function SudokuCell(initVal, boardObj) { this.boardObj = boardObj; this.changed = false; this.original = false; this.value = 0; this.set = (1 << this.boardObj.dim2) - 1; this.setValue(initVal); } SudokuCell.prototype.setMask = function(newSet) { if (newSet !== this.set) { this.set = newSet; this.changed = true; return this.boardObj.changed = true; } }; SudokuCell.prototype.setValue = function(newValue) { var setidx; if (newValue === this.value) { return false; } setidx = this.boardObj.set.indexOf(newValue); if (setidx !== -1) { this.value = newValue; this.setMask(1 << setidx); this.changed = true; this.boardObj.changed = true; return true; } else if (newValue === -1) { this.value = 0; this.setMask((1 << this.boardObj.dim2) - 1); this.changed = true; this.boardObj.changed = true; } return false; }; SudokuCell.prototype.getValue = function() { if (this.value === 0) { return '.'; } return this.value; }; SudokuCell.prototype.getMask = function() { return this.set; }; SudokuCell.prototype.getUnknownsCount = function() { var n, result, _i, _ref; result = 0; for (n = _i = 0, _ref = this.boardObj.dim2; _i < _ref; n = _i += 1) { if ((1 << n) & this.set) { result++; } } return result; }; SudokuCell.prototype.hasChanged = function() { return this.changed; }; SudokuCell.prototype.resetChangeFlag = function() { return this.changed = false; }; SudokuCell.prototype.setOriginal = function(newValue) { return this.original = newValue; }; SudokuCell.prototype.isOriginal = function() { return this.original; }; return SudokuCell; })(); }).call(this);