// Class: Chess110Controller
//
// Author: Alyce Brady
//
// Created on Feb 26, 2004
//    Modified 21 May 2017 to add @Override
//
// License Information:
//   This class is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation.
//
//   This class is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.

import java.awt.Color;

import edu.kzoo.grid.BoundedGrid;
import edu.kzoo.grid.GridObject;
import edu.kzoo.grid.Location;
import edu.kzoo.grid.gui.SteppedGridAppController;
import edu.kzoo.util.Debug;

/**
 *  Chess 110:<br>
 *
 *  A <code>Chess110Controller</code> object controls the action
 *  of a Chess 110 chess game.
 *
 *  @author Alyce Brady
 *  @version 21 May 2017
 **/
public class Chess110Controller extends SteppedGridAppController
{
    private boolean whitesTurn = true;
    private ChessPiece whiteKing = null, blackKing = null;
    private Chess110GUI gui = null;

    /** Constructs a Chess110Controller to control the progress of a
     *  Chess 110 game.  This should be followed up with a call to
     *  <code>setGUI</code>.
     */
    public Chess110Controller()
    {
    }

    /** Sets the graphical user interface that the controller will
     *  communicate with as the game progresses.
     **/
    public void setGUI(Chess110GUI gui)
    {
        this.gui = gui;
    }

    /* (non-Javadoc)
     * @see edu.kzoo.grid.gui.GridAppController#step()
     */
    @Override
    public void step()
    {
        // If the game is over, don't do anything.
        if ( hasReachedStoppingState() )
            return;

        // Otherwise, move all the pieces that can move for the current player.
        //    CRITICAL CODE MISSING !

        // Next time it should be the other player's turn.
        whitesTurn = ! whitesTurn;
    }

    /* (non-Javadoc)
     * @see edu.kzoo.grid.gui.GridAppController#hasReachedStoppingState()
     */
    @Override
    public boolean hasReachedStoppingState()
    {
        // If the pieces haven't been initialized yet, the game hasn't started.
        if ( whiteKing == null || blackKing == null )
            return false;

        // Determine if the game is over (one of the kings has been captured).
        //    CRITICAL CODE MISSING !

        // Otherwise return false;
        return false;
    }

    /* (non-Javadoc)
     * @see edu.kzoo.grid.gui.GridAppController#init()
     */
    @Override
    public void init()
    { 
        Debug.println("=== Beginning of Game ===");
        gui.setGrid(new BoundedGrid(true, 8, 8));

        // Initialize the board for the game.
        //    CRITICAL CODE MISSING !

        whitesTurn = true;
    }

}
