package ch.epfl.isochrone.tiledmap;

import java.awt.image.BufferedImage;

/**
 * Classe à représenter une tuile
 * 
 * @author Charles Thiebaut (238935)
 * @author Arnaud Delamare (234841)
 * 
 */
public final class Tile {

    private int x;
    private int y;
    public int zoom;
    private BufferedImage image;

    /**
     * Construit la tile en fonction des coordonnées, du zoom et d'une
     * BufferedImage
     */
    public Tile(int x, int y, int zoom, BufferedImage image) {
        this.x = x;
        this.y = y;
        this.zoom = zoom;
        this.image = image;
    }

    @Override
    public int hashCode() {
        return x + y + zoom;
    }

    public boolean equals(Object that) {
        if (that.getClass() == this.getClass()) {
            if (((Tile) that).x == this.x && ((Tile) that).y == this.y
                    && ((Tile) that).zoom == this.zoom) {
                return true;
            }
        }
        return false;
    }

    /**
     * 
     * @return l'image de la tuile
     */
    public BufferedImage image() {
        return image;
    }
}
