// Path: app/src/main/java/es/danirod/rectball/scene2d/listeners/BallSelectionListener.java
// public interface BallSelectionListener {
// 
//     /**
//      * This event is triggered when a ball has been selected on a board.
//      *
//      * @param ball ball that has been selected.
//      */
//     void onBallSelected(BallActor ball);
// 
//     /**
//      * This event is triggered when a ball has been unselected from a board.
//      *
//      * @param ball ball that has been unselected.
//      */
//     void onBallUnselected(BallActor ball);
// 
//     /**
//      * This event is triggered when a selection is made and the selection has
//      * already be checked to be valid. All the selected balls form a rectangle
//      * whose four corners are made of the same color.
//      *
//      * @param selection balls that form this selection.
//      */
//     void onSelectionSucceeded(List<BallActor> selection);
// 
//     /**
//      * This event is triggered when a selection is made and the selection is
//      * checked not to be valid. Any of the conditions required to be a valid
//      * selection is not happening.
//      *
//      * @param selection balls that don't form this selection.
//      */
//     void onSelectionFailed(List<BallActor> selection);
// 
//     /**
//      * This event is triggered when the board is forced to unselect every ball.
//      * This happens, for instance, when the game is over, so that no selected
//      * balls remain on the screen while the animations start.
//      *
//      * @param selection the list of balls that has been unselected.
//      */
//     void onSelectionCleared(List<BallActor> selection);
// }


import java.util.*;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.utils.Align;
import es.danirod.rectball.model.*;
import es.danirod.rectball.scene2d.input.DragBoardSelectionListener;
import es.danirod.rectball.scene2d.listeners.BallSelectionListener;
/*
 * This file is part of Rectball
 * Copyright (C) 2015 Dani Rodríguez
 *
 * This program 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, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package es.danirod.rectball.scene2d.game;




public class BoardActor extends Table {

    private final BallActor[][] actors;

    private final Set<BallActor> selection = new HashSet<>();

// Path: app/src/main/java/es/danirod/rectball/scene2d/listeners/BallSelectionListener.java
// public interface BallSelectionListener {
// 
//     /**
//      * This event is triggered when a ball has been selected on a board.
//      *
//      * @param ball ball that has been selected.
//      */
//     void onBallSelected(BallActor ball);
// 
//     /**
//      * This event is triggered when a ball has been unselected from a board.
//      *
//      * @param ball ball that has been unselected.
//      */
//     void onBallUnselected(BallActor ball);
// 
//     /**
//      * This event is triggered when a selection is made and the selection has
//      * already be checked to be valid. All the selected balls form a rectangle
//      * whose four corners are made of the same color.
//      *
//      * @param selection balls that form this selection.
//      */
//     void onSelectionSucceeded(List<BallActor> selection);
// 
//     /**
//      * This event is triggered when a selection is made and the selection is
//      * checked not to be valid. Any of the conditions required to be a valid
//      * selection is not happening.
//      *
//      * @param selection balls that don't form this selection.
//      */
//     void onSelectionFailed(List<BallActor> selection);
// 
//     /**
//      * This event is triggered when the board is forced to unselect every ball.
//      * This happens, for instance, when the game is over, so that no selected
//      * balls remain on the screen while the animations start.
//      *
//      * @param selection the list of balls that has been unselected.
//      */
//     void onSelectionCleared(List<BallActor> selection);
// }


// Path: app/src/main/java/es/danirod/rectball/scene2d/game/BoardActor.java
import java.util.*;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.utils.Align;
import es.danirod.rectball.model.*;
import es.danirod.rectball.scene2d.input.DragBoardSelectionListener;
import es.danirod.rectball.scene2d.listeners.BallSelectionListener;

/*
 * This file is part of Rectball
 * Copyright (C) 2015 Dani Rodríguez
 *
 * This program 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, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package es.danirod.rectball.scene2d.game;




public class BoardActor extends Table {

    private final BallActor[][] actors;

    private final Set<BallActor> selection = new HashSet<>();

    private final List<BallSelectionListener> subscribers = new ArrayList<>();