package se.urmo.game.map;

import lombok.Getter;
import se.urmo.game.graphics.SpriteLocation;

@Getter
public enum TileType {
    SMALL_PELLET(0, false, SpriteLocation.ITEM, 1, 0, true, 10),
    TILE_1(1, true, SpriteLocation.MAP, 0, 0, false, 0),
    TILE_2(2, true, SpriteLocation.MAP, 0, 1, false, 0),
    TILE_3(3, true, SpriteLocation.MAP, 0, 2, false, 0),
    TILE_4(4, true, SpriteLocation.MAP, 0, 3, false, 0),
    TILE_5(5, true, SpriteLocation.MAP, 0, 4, false, 0),
    TILE_6(6, true, SpriteLocation.MAP, 0, 5, false, 0),
    TILE_7(7, true, SpriteLocation.MAP, 0, 6, false, 0),
    TILE_8(8, true, SpriteLocation.MAP, 0, 7, false, 0),
    TILE_9(9, true, SpriteLocation.MAP, 0, 8, false ,0),
    TILE_10(10, true, SpriteLocation.MAP, 0, 9, false ,0),
    TILE_11(11, true, SpriteLocation.MAP, 0, 10, false, 0),
    TILE_12(12, true, SpriteLocation.MAP, 1, 0, false ,0),
    TILE_13(13, true, SpriteLocation.MAP, 1, 1, false ,0),
    TILE_14(14, true, SpriteLocation.MAP, 1, 2, false ,0),
    TILE_15(15, true, SpriteLocation.MAP, 1, 3, false ,0),
    TILE_16(16, true, SpriteLocation.MAP, 1, 4, false ,0),
    TILE_17(17, true, SpriteLocation.MAP, 1, 5, false ,0),
    TILE_18(18, true, SpriteLocation.MAP, 1, 6, false ,0),
    TILE_19(19, true, SpriteLocation.MAP, 1, 7, false ,0),
    TILE_20(20, true, SpriteLocation.MAP, 1, 8, false ,0),
    TILE_21(21, true, SpriteLocation.MAP, 1, 9, false ,0),
    TILE_22(22, true, SpriteLocation.MAP, 1, 10, false ,0),
    TILE_23(23, true, SpriteLocation.MAP, 2, 0, false ,0),
    TILE_24(24, true, SpriteLocation.MAP, 2, 1, false ,0),
    TILE_25(25, true, SpriteLocation.MAP, 2, 2, false ,0),
    TILE_26(26, true, SpriteLocation.MAP, 2, 3, false ,0),
    TILE_27(27, true, SpriteLocation.MAP, 2, 4, false ,0),
    TILE_28(28, true, SpriteLocation.MAP, 2, 5, false ,0),
    TILE_29(29, true, SpriteLocation.MAP, 2, 6, false ,0),
    TILE_30(30, true, SpriteLocation.MAP, 2, 7, false ,0),
    TILE_31(31, true, SpriteLocation.MAP, 2, 8, false ,0),
    TILE_32(32, true, SpriteLocation.MAP, 2, 9, false ,0),
    TILE_33(33, true, SpriteLocation.MAP, 2, 10, false ,0),
    TILE_34(34, true, SpriteLocation.MAP, 3, 0, false ,0),
    TILE_35(35, true, SpriteLocation.MAP, 3, 1, false ,0),
    TILE_36(36, true, SpriteLocation.MAP, 3, 2, false ,0),
    TILE_37(37, true, SpriteLocation.MAP, 3, 3, false ,0),
    DOOR(38, true, SpriteLocation.MAP, 3, 4, false, 0),
    TILE_39(39, true, SpriteLocation.MAP, 3, 5, false ,0),
    TILE_40(40, true, SpriteLocation.MAP, 3, 6, false ,0),
    TILE_41(41, true, SpriteLocation.MAP, 3, 7, false ,0),
    TILE_42(42, true, SpriteLocation.MAP, 3, 8, false ,0),
    TILE_43(43, true, SpriteLocation.MAP, 3, 9, false ,0),
    TILE_44(44, true, SpriteLocation.MAP, 3, 10, false ,0),
    TILE_45(45, true, SpriteLocation.MAP, 4, 0, false ,0),
    TILE_46(46, true, SpriteLocation.MAP, 4, 1, false ,0),
    TILE_47(47, true, SpriteLocation.MAP, 4, 2, false ,0),
    TILE_48(48, true, SpriteLocation.MAP, 4, 3, false ,0),
    TILE_49(49, true, SpriteLocation.MAP, 4, 4, false ,0),
    TILE_50(50, true, SpriteLocation.MAP, 4, 5, false ,0),
    TILE_51(51, true, SpriteLocation.MAP, 4, 6, false ,0),
    TILE_52(52, true, SpriteLocation.MAP, 4, 7, false ,0),
    TILE_53(53, true, SpriteLocation.MAP, 4, 8, false ,0),
    TILE_54(54, true, SpriteLocation.MAP, 4, 9, false ,0),
    TILE_55(55, true, SpriteLocation.MAP, 4, 10, false ,0),
    LARGE_PELLET(56, false, SpriteLocation.ITEM, 1 ,1,true, 50),
    TUNNEL(57, false, SpriteLocation.ITEM, 1, 0, true, 10),
    EMPTY(99, false, SpriteLocation.NONE, 0, 0, false, 0); // No sprite associated with empty tiles

    private final int value;
    private final boolean solid;
    private final SpriteLocation spriteSheet;
    private final int row;
    private final int col;
    private final boolean removable;
    private final int score;


    TileType(int value, boolean solid, SpriteLocation spriteSheet, int row, int col, boolean removable, int score) {
        this.value = value;
        this.solid = solid;
        this.spriteSheet = spriteSheet;
        this.row = row;
        this.col = col;
        this.removable = removable;
        this.score = score;
    }

    public static TileType fromValue(int value) {
        for (TileType type : values()) {
            if (type.value == value) return type;
        }
        return EMPTY;
    }

    public boolean hasSprite() {
        return spriteSheet != null;
    }

    @Override
    public String toString() {
        return "TileType{" +
                "value=" + value +
                ", removable=" + removable +
                ", score=" + score +
                ", solid=" + solid +
                '}';
    }
}