package controller;

import boundary.PlayerApplication;
import model.Move;
import model.PlayerModel;
import model.PlayerState;
import model.Point;

/**
 * @author Eli Skeggs, Nick Chaput
 */
public class PlayerFinishMoveCtrl {
  PlayerApplication app;
  PlayerModel model;

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

  /**
   * TODO: are there anything in the boundary that needs to get updated?
   */
  public void finishMove(Point point) {
    model.playerState = PlayerState.NONE;
    model.move.expand(model.level.currentBoard, point);
    PlayerVariationCtrl pVar = model.variation.createCtrl(app, model);
    //TODO: implement variation controllers
    if (pVar.finishMove()) {
    	if (model.move.isValid()) {

        	for (Point p : model.move.points) {
        	    model.level.currentBoard.grid[p.x][p.y].tile = null;
        	}
        	model.level.currentBoard.processBoard();
        	app.getView().repaint();
    	}
    	else {
    		//I don't know what happens here
    	}
    }
    model.move = new Move();
    //TODO: implement everything else that happens after a move finishes (update score, counter, etc)
  }
  
}

@@ -49,16 +49,49 @@
 cation;%0A
+import boundary.PlayerLevelView;%0A
 import m
@@ -773,56 +773,56 @@
 if (
-pVar.finishMove()) %7B%0A    %09if (model.move.isValid
+model.move.isValid()) %7B%0A    %09if (pVar.finishMove
 ()) 
@@ -1045,20 +1045,21 @@
     
-%09
+%7D%0A    
 else %7B%0A
-    
 %09%09//
@@ -1089,28 +1089,47 @@
 ns here%0A
-    
 %09%7D%0A    
-%7D
+updateScore(model.move);
 %0A    mod
@@ -1259,10 +1259,338 @@
 %0A  %7D%0A  %0A
+  public int updateScore(Move move) %7B%0A%09  int newScore = 10;%0A%09  newScore = newScore * move.points.size();%0A%09  for (Point p : move.points) %7B%0A%09%09  newScore = newScore * model.level.currentBoard.grid%5Bp.x%5D%5Bp.y%5D.tile.multiplier;%0A%09  %7D%0A%09  model.score += newScore;%0A%09  ((PlayerLevelView)app.getView()).update();%0A%09  %0A%09  return newScore;%0A  %7D%0A
 %7D%0A

Implement updating score stuff