/**
 * A solitaire Can't Stop game board.
 *
 * This is a skeleton.  Complete code will not be posted to protect it
 * from the prying eyes of CS201 students.
 *
 * @author Jim Glenn
 * @version SKELETON 11/18/2008
 */

public class CantStopBoard
{
    private int[] colored;
    private int[] neutral;

    public CantStopBoard()
    {
    }

    public CantStopBoard(int[] c, int[] n)
    {
	colored = c;
	neutral = n;
    }

    public int getColoredMarkerPosition(int col)
    {
	return 0;
    }

    public int getNeutralMarkerPosition(int col)
    {
	return -1;
    }

    public boolean isLegalMove(int col1, int col2)
    {
	return true;
    }

    public boolean isLegalMove(int col, FourDice dice)
    {
	return true;
    }

    public void moveNeutralMarkers(int col1, int col2)
    {
    }

    public void moveNeutralMarkers(int col)
    {
    }

    public void endTurnWithProgress()
    {
    }

    public void endTurnNoProgress()
    {
    }

    public int countNeutralMarkersUsed()
    {
	return 0;
    }

    public boolean isGameOver()
    {
	return false;
    }

    public int getColumnLength(int col)
    {
	return 13 - 2 * Math.abs(7 - col);
    }

    /**
     * Returns a printable representation of this board.
     *
     * @return a printable representation of this board
     */

    public String toString()
    {
	// change these if you think it is hard to read as is

	final char MARKER = 'O';
	final char NEUTRAL = 'o';
	final char EMPTY =  '.';

	// create a buffer for a drawing of each column

	StringBuffer[] cols = new StringBuffer[11];

	for (int c = 2; c <= 12; c++)
	    {
		int ci = c - 2; // the array index of column c
		cols[ci] = new StringBuffer("             "); // 13 spaces

		int len = getColumnLength(c);
		int bottom = Math.abs(7 - c); // how many spaces below column

		for (int s = 1; s <= len; s++) // draw each space in the column
		    {
			if (s == getColoredMarkerPosition(c))
			    {
				cols[ci].setCharAt(s + bottom - 1, MARKER);
			    }
			else if (s == getNeutralMarkerPosition(c))
			    {
				cols[ci].setCharAt(s + bottom - 1, NEUTRAL);
			    }
			else
			    {
				cols[ci].setCharAt(s + bottom - 1, EMPTY);
			    }
		    }
	    }

	// transpose the columns to get the final string

	StringBuffer result = new StringBuffer();
	for (int r = 0; r < 13; r++)
	    {
		for (int c = 2; c <= 12; c++)
		    {
			result.append(cols[c - 2].charAt(12 - r));
		    }
		result.append('\n');
	    }

	return result.toString();
    }
}

	

