/** * Player class. * intial details of positions and mode * * @author Ahsan Mussa, Akbar Sherwani * @version 0.2 * * version 0.2 changed adding extra variables and checks and much more - Akbar */ public class Player { // instance variables private int player_no; private int mode; private int kicks; private double plyr_x; private double plyr_y; private double ball_x; private double ball_y; public GameAnalyser game; public Ball ball; public PitchView pitch; /** * Constructor for Player Class * @param player_no players number * @param mode mode of the player * @param plyr_x position x * @param plyr_y position y * @param game gameanlyser to send details * @param ball ball details */ public Player(int player_no, int mode, double plyr_x, double plyr_y, GameAnalyser game, Ball ball, PitchView pitch) { // initialise instance variables this.player_no=player_no; this.mode=mode; this.plyr_x=plyr_x; this.plyr_y=plyr_y; this.game = game; this.ball = ball; this.pitch = pitch; } /** * Constructor for Player Class * @param player_no player numbers * @param mode mode of player * @param plyr_x players position x * @param plyr_y players position y */ public Player(int player_no, int mode, double plyr_x, double plyr_y) { // initialise instance variables this.player_no=player_no; this.mode=mode; this.plyr_x=plyr_x; this.plyr_y=plyr_y; } /** * Set Details after intialiased * @param player_no player numberrs * @param mode player mode * @param plyr_x player x position * @param plyr_y player y position * @param kicks kicks for stats */ public void setDetails(int player_no, int mode, double plyr_x, double plyr_y, int kicks) { // Set variables this.player_no=player_no; this.mode=mode; this.plyr_x=plyr_x; this.plyr_y=plyr_y; this.kicks = kicks; // Do play mode check playMode(); //Send positions to PitchView pitch.Playerpos(player_no, plyr_x, plyr_y); } /** * Playmode check to see if player has the ball */ public void playMode() { if((mode & 0x0002) == 0x0002) { ball.BallKicked(player_no); game.PlayerKicked(player_no); } } public Ball getBall() { return ball; } public double getBall_x() { return ball_x; } public double getBall_y() { return ball_y; } public GameAnalyser getGame() { return game; } public int getKicks() { return kicks; } public int getMode() { return mode; } public PitchView getPitch() { return pitch; } public int getPlayer_no() { return player_no; } public double getPlyr_x() { return plyr_x; } public double getPlyr_y() { return plyr_y; } }