Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. var MineSweeperUtils = {
  2. // cell states
  3. PURE: -1,
  4. MARK: -2,
  5. FLAG: -3,
  6. BOMB: -4,
  7.  
  8. forAdjacentCells: function(options) {
  9. var rows = options.rows || this.rows || 0;
  10. var cols = options.cols || this.cols || 0;
  11.  
  12. var row = options.row || 0;
  13. var col = options.col || 0;
  14.  
  15. var left = Math.max(0, col-1);
  16. var top = Math.max(0, row-1);
  17. var right = Math.min(cols-1, col+1);
  18. var bottom = Math.min(rows-1, row+1);
  19. for (var i = top; i <= bottom; i++) {
  20. for (var j = left; j <= right; j++) {
  21. if (i != row || j != col) {
  22. options.callback(i, j);
  23. }
  24. }
  25. }
  26. }
  27. };
  28.  
  29. function MineSweeper(options) {
  30. this.rowCount = options.rows || 8;
  31. this.colCount = options.cols || 8;
  32. this.field = null;
  33. this.cellsState = null;
  34. }
  35.  
  36. MineSweeper.prototype.generateField = function() {
  37.  
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement