package se.urmo.game.graphics;

import lombok.Getter;
import se.urmo.game.entities.ghost.Ghost;
import se.urmo.game.entities.pacman.PacMan;
import se.urmo.game.map.GameMap;
import se.urmo.game.util.LoadSave;

import java.awt.image.BufferedImage;

@Getter
public enum SpriteLocation {
    MAP("sprites/PacMan-custom-spritemap-0-3.png", 5, 11, GameMap.MAP_TILESIZE),
    ITEM("sprites/PacManAssets-Items.png", 2, 8, GameMap.MAP_TILESIZE),
    GHOST("sprites/PacManAssets-Ghosts.png", 11, 4, Ghost.GHOST_SIZE),
    PACMAN("sprites/PacManAssets-PacMan.png", 3, 4, PacMan.PACMAN_SIZE),
    NONE("", 0, 0, 0) {  // Special case for tiles without sprites
        @Override
        public BufferedImage[][] loadSprites(int tileSize) {
            return new BufferedImage[][] {{ null }}; // Single null sprite
        }
    };

    private final String path;
    private final int rows;
    private final int cols;
    private final int size;

    SpriteLocation(String path, int rows, int cols, int size) {
        this.path = path;
        this.rows = rows;
        this.cols = cols;
        this.size = size;
    }

    public BufferedImage[][] loadSprites(int tileSize) {
        return LoadSave.loadSprites(path, rows, cols, tileSize);
    }
}