package edu.columbia.cs.cs1007.checkers;

import edu.columbia.cs.cs1007.checkers.Constants.HORIZONTAL_DIRECTION;
import edu.columbia.cs.cs1007.checkers.Constants.VERTICAL_DIRECTION;

/**
 * Implementation of a move of the checker board.
 @author Julia Stoyanovich (jds2109@columbia.edu)
 * COMS 1007, Summer 2009.
 *
 */
public class Move {
  
  private int _sourceRow;
  private int _sourceCol;
  private VERTICAL_DIRECTION _verticalDir;
  private HORIZONTAL_DIRECTION _horizontalDir;

  /**
   * Constructor.
   @param sourceRow
   @param sourceCol
   @param verticalDir
   @param horizontalDir
   */
  public Move(int sourceRow, int sourceCol, VERTICAL_DIRECTION verticalDir, HORIZONTAL_DIRECTION horizontalDir) {
    _sourceRow = sourceRow;
    _sourceCol = sourceCol;
    _verticalDir = verticalDir;
    _horizontalDir = horizontalDir;
  }
  
  /**
   * Get the row of the starting position.
   @return row number
   */
  public int getSourceRow() {
    return _sourceRow;
  }
  
  /**
   * Get the column of the starting position.
   @return column number
   */
  public int getSourceColumn() {
    return _sourceCol;
  }
  
  /**
   * Compute the row of the target position.
   @return row number
   */
  public int getTargetRow() {
    int targetRow = _sourceRow;
    if (_verticalDir == VERTICAL_DIRECTION.BACK) {
      targetRow--;
    else {
      targetRow++;
    }
    return targetRow;
  }
  
  /**
   * Computer the column of the target position.
   @return column number
   */
  public int getTargetColumn() {
    int targetCol=_sourceCol;
    if (_horizontalDir == HORIZONTAL_DIRECTION.LEFT) {
      targetCol--;
    else {
      targetCol++;
    }
    return targetCol;
  }
  
  /**
   * Generate a string representation of the move.
   @return string representation
   */
  public String toString() {
    return "Moving " + _verticalDir.toString() " and " + _horizontalDir.toString() " from (" + _sourceRow + "," + _sourceCol + ") ";
  }

}