Skip to content
Snippets Groups Projects
Tile.java 1.18 KiB
Newer Older
Josua Oppermann's avatar
Josua Oppermann committed

David Reiser's avatar
David Reiser committed
public class Tile {
Josua Oppermann's avatar
Josua Oppermann committed

Josua Oppermann's avatar
Josua Oppermann committed

    /**These Values are being set when initialized
     */
    int size, posx, posy;

Josua Oppermann's avatar
Josua Oppermann committed
    /**The Value of this Integer determines who owns this Tile
Josua Oppermann's avatar
Josua Oppermann committed
     * -1 = no one; 0 = Player 1; 1 = Player 2
Josua Oppermann's avatar
Josua Oppermann committed
     */
Josua Oppermann's avatar
Josua Oppermann committed
    int owner = -1;
Josua Oppermann's avatar
Josua Oppermann committed

    /**Initializer for Tile Objects
     * @param size Sets the Size of the Image
     * @param posx Sets the x-Position of the Image
     * @param posy Sets the y-Position of the Image
     */
David Reiser's avatar
David Reiser committed
    public Tile(int size, int posx, int posy){
        size = this.size;
        posx = this.posx;
        posy = this.posy;
Josua Oppermann's avatar
Josua Oppermann committed
    }
Josua Oppermann's avatar
Josua Oppermann committed

    /**Lets you set a new owner;
Josua Oppermann's avatar
Josua Oppermann committed
     * -1 = no one; 0 = Player 1; 1 = Player 2
Josua Oppermann's avatar
Josua Oppermann committed
     * @param owner
     */
    public void set_owner(int player){
        owner = player;
    }

    /**Returns the owner
Josua Oppermann's avatar
Josua Oppermann committed
     * -1 = no one; 0 = Player 1; 1 = Player 2
Josua Oppermann's avatar
Josua Oppermann committed
     * @return owner
     */
    public int get_owner(){
        return owner;
    }

    /**Returns if the Tile-owner is equal to the given Player
     * @param owner
     */
    public boolean is_owner(int player){
        return owner == player;
    }

    /**Whether this Tile is owned by a Player
Josua Oppermann's avatar
Josua Oppermann committed
     */
Josua Oppermann's avatar
Josua Oppermann committed
    public boolean exist_owner(){
David Reiser's avatar
David Reiser committed
        return owner != -1;
Josua Oppermann's avatar
Josua Oppermann committed
    }
Josua Oppermann's avatar
Josua Oppermann committed

David Reiser's avatar
David Reiser committed
}