/* Connect four - written in java Copyright (C) 2020 Oliver Schappacher and Dorian Zedler 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 . */ package de.itsblue.ConnectFour.player; import de.itsblue.ConnectFour.Plate.*; import de.itsblue.ConnectFour.*; /** * Player is an abstract class meant for usage with de.itsblue.ConnectFour. It * is a template for a connect four player. * * @author Dorian Zedler */ public abstract class Player { /** * The game the player is playing in. The funtion insertNextPlate() * of the game will be called when a move is done. */ private ConnectFour playingInGame; /** * The button row used to control the game. */ public ButtonRow gameControllingButtonRow; /** * The type of plate the player is using. */ public PlateType usingPlateType; /** * Whether it is this player's turn */ public boolean isMyTurn = false; /** * Constructor * * @param playingInGame The game the Player is plaing in The funtion * insertNextPlate() of the game * will be called when a move is done. * @param gameControllingButtonRow The button row used to control the game. * @param usingPlateType The type of plate the player is using. */ public Player(ConnectFour playingInGame, ButtonRow gameControllingButtonRow, PlateType usingPlateType) { this.playingInGame = playingInGame; this.gameControllingButtonRow = gameControllingButtonRow; this.usingPlateType = usingPlateType; } /** * Function to set wether it is this player's turn */ public void setIsMyTurn(boolean isMyTurn) { this.isMyTurn = isMyTurn; if (isMyTurn) this.gameControllingButtonRow.setColor(Plate.getColor(this.usingPlateType)); } /** * Function to perform a move for the Player * * @param column the column to insert the plate into */ public void doMove(int column) { if (this.isMyTurn) this.playingInGame.insertNextPlate(column); } }