Skip to content
Snippets Groups Projects
Tile.java 1.44 KiB
Newer Older
Josua Oppermann's avatar
Josua Oppermann committed
import java.util.Random;

Josua Oppermann's avatar
Josua Oppermann 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
    
    /**Random for Images
     * 
    */
    Random rnd = new Random();

    /**Paths for the images
     * 
     */
    String imagePathPlayer = "./textures/" + owner + "_" + rnd.nextInt(3);
    String imagePathEmpty = "./textures/empty";


    /**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
     */
    public Tile(int size, int posx, int posy){
        size = this.size;
        posx = this.posx;
        posy = this.posy;
    }
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(){
        return owner != -1;
Josua Oppermann's avatar
Josua Oppermann committed
    }
Josua Oppermann's avatar
Josua Oppermann committed

}