package controller;

import java.awt.EventQueue;

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

/**
 * @author Eli Skeggs, and Nick Chaput
 */
public class PlayerReleaseCtrl implements PlayerVariationCtrl {
  PlayerApplication app;
  PlayerModel model;

  public PlayerReleaseCtrl(PlayerApplication app, PlayerModel model) {
    this.app = app;
    this.model = model;
  }

  public boolean specialMove() {
    model.counter--;
    return false;
  }

  public boolean finishMove() {
	    if (model.counter <= 0) {
	      return false;
	    }

	    model.counter--;

	    if (model.counter == 0) {
	      EventQueue.invokeLater(new PlayerEndLevelCtrl(app, model, allBucketsFull()));
	    }

	    return model.move.isValid();
	  }

  private boolean allBucketsFull() {
	for (int x = 0; x < Board.width; x++) {
		for (int y = 0; y < Board.height; y++) {
			  if (model.level.currentBoard.grid[x][y].type == CellType.BUCKET
					 && model.level.currentBoard.grid[x][y].tile != null) {
				  if (model.level.currentBoard.grid[x][y].tile.number != 5) {
					  System.out.println("Something messed up and a non-Six is in your bucket: " + x + " " + y);
				  }
			  }
			  else {
				  return false;
			  }
		  }
	}
	return true;
}

@Override
  public boolean remove() {
    // TODO: implement
    specialMove();
    return false;
  }

  @Override
  public boolean scramble() {
    // TODO: implement
    specialMove();
    return false;
  }

  @Override
  public boolean swap() {
    // TODO: implement
    specialMove();
    return false;
  }
}

@@ -975,18 +975,22 @@
 CKET
+) %7B
 %0A%09%09%09%09
-%09 && 
+  if (
 mode
@@ -1033,24 +1033,25 @@
  != null) %7B%0A
+%09
 %09%09%09%09  if (mo
@@ -1100,24 +1100,25 @@
 ber != 5) %7B%0A
+%09
 %09%09%09%09%09  Syste
@@ -1211,19 +1211,22 @@
 %09%09%09%09
+%09
   %7D%0A
+%09
 %09%09%09  %7D%0A
+%09
 %09%09%09 
@@ -1237,16 +1237,17 @@
 e %7B%0A%09%09%09%09
+%09
   return
@@ -1261,16 +1261,23 @@
 %0A%09%09%09
+%09
   %7D%0A%09%09 
- 
+%09  %7D%0A%09%09
 %7D%0A%09%7D

Fix logic error in allBucketsFilled()