package controller;

import model.Board;
import model.CellType;
import model.PlayerModel;
import model.Point;
import boundary.PlayerApplication;

/**
 * 
 * @author Nick Chaput
 *
 */

public class PlayerUpdateBoardCtrl {

	PlayerApplication app;
	PlayerModel model;
	
	public PlayerUpdateBoardCtrl(PlayerApplication app, PlayerModel model) {
		this.app = app;
		this.model = model;
	}
	
	 public void processBoard() {
		 app.getView().validate();
		  for (int y = Board.height - 1; y >= 0; y--) {
			  for (int x = Board.width - 1; x >= 0; x--) {
				  if (model.level.currentBoard.grid[y][x].type != CellType.INERT 
						  && model.level.currentBoard.grid[y][x].type != CellType.BUCKET
						  && model.level.currentBoard.grid[y][x].tile == null) {
					  model.level.currentBoard.grid[y][x].tile = model.level.currentBoard.takeTileAbove(new Point(x,y));
				  }
				  if (model.level.currentBoard.grid[y][x].type == CellType.BUCKET
						  && model.level.currentBoard.getTileAbove(new Point(x,y)).number == 5
						  && model.level.currentBoard.grid[y][x].tile == null) {
					  model.level.currentBoard.grid[y][x].tile = model.level.currentBoard.takeTileAbove(new Point(x,y));
				  }
			  }
		  }
	 }
	
}

@@ -419,83 +419,198 @@
 %0A%09%09 
-app.getView().validate();%0A%09%09  for (int y = Board.height - 1; y %3E= 0; y--) %7B
+ for (int x = Board.width - 1; x %3E= 0; x--) %7B%0A%09%09%09  try %7B%0A%09%09%09       Thread.sleep(60);%0A%09%09%09%09%09 app.getView().paintImmediately(0, 0, 500, 500);%0A%09%09%09    %7D catch (InterruptedException ie) %7B%0A%09%09%09    %7D
 %0A%09%09%09
@@ -612,33 +612,33 @@
 %7D%0A%09%09%09  for (int 
-x
+y
  = Board.width -
@@ -630,36 +630,37 @@
 = Board.
-width
+height
  - 1; 
-x
+y
  %3E= 0; 
-x
+y
 --) %7B%0A%09%09
@@ -959,32 +959,199 @@
 ew Point(x,y));%0A
+%09%09%09%09%09    /*try %7B%0A%09%09%09%09%09%09       Thread.sleep(30);%0A%09%09%09%09%09%09%09%09 app.getView().paintImmediately(50, 50, 500, 500);%0A%09%09%09%09%09%09    %7D catch (InterruptedException ie) %7B%0A%09%09%09%09%09%09    %7D*/%0A
 %09%09%09%09  %7D%0A%09%09%09%09  if
@@ -1344,32 +1344,32 @@
 tile == null) %7B%0A
-
 %09%09%09%09%09  model.lev
@@ -1454,24 +1454,191 @@
 oint(x,y));%0A
+%09%09%09%09%09    /*try %7B%0A%09%09%09%09%09%09       Thread.sleep(30);%0A%09%09%09%09%09%09%09%09 app.getView().paintImmediately(50, 50, 500, 500);%0A%09%09%09%09%09%09    %7D catch (InterruptedException ie) %7B%0A%09%09%09%09%09%09    %7D*/%0A
 %09%09%09%09  %7D%0A%09%09%09 

Add staggered board updating (pseudo animation)