fork download
  1. MinesweeperGame.prototype._openNearCells = function(x, y) {
  2. var minesCounter = this.countNearMines(x, y);
  3. if (minesCounter != 0) {
  4. return false;
  5. }
  6. var nearCellList = this._getNearCells(x, y);
  7. for (var nearCellY in nearCellList) {
  8. if (!nearCellList.hasOwnProperty(nearCellY)) continue;
  9. for (var nearCellX in nearCellList[nearCellY]) {
  10. if (!nearCellList[nearCellY].hasOwnProperty(nearCellX)) continue;
  11. if (!this.hasOpened(nearCellX, nearCellY) &&
  12. !this.hasFlag(nearCellX, nearCellY)) {
  13. this.open(nearCellX, nearCellY);
  14. }
  15. }
  16. }
  17. };
  18.  
  19. MinesweeperGame.prototype._isCellInDict = function(x, y, dict) {
  20. if (dict[y]) {
  21. return dict[y][x];
  22. }
  23. return false;
  24. };
  25.  
  26. MinesweeperGame.prototype._addCellToDict = function(x, y, dict) {
  27. if (!this._isCorrectCell(x, y)) {
  28. throw new MinesweeperGameException("При добавлении превышены размеры поля.");
  29. }
  30. if (this._isCellInDict(x, y, dict)) {
  31. throw new MinesweeperGameException("Клетка уже существует в словаре.");
  32. }
  33. dict[y][x] = true;
  34. return dict;
  35. };
  36.  
  37. MinesweeperGame.prototype._isCorrectCell = function(x, y) {
  38. if (x < 1 ||
  39. y < 1 ||
  40. x > this._width ||
  41. y > this._height) {
  42. return false;
  43. }
  44. return true;
  45. };
Runtime error #stdin #stdout #stderr 0.04s 44992KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
/home/ILteaZ/prog.js:1
(function (exports, require, module, __filename, __dirname) { MinesweeperGame.
                                                              ^
ReferenceError: MinesweeperGame is not defined
    at Object.<anonymous> (/home/ILteaZ/prog.js:1:63)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3