
import { DIRECTIONS, TILE_TYPES } from './Constants.js';

export const TILES = {
    // -------------------------------------------------------------------------
    // CORRIDOR STRAIGHT
    // -------------------------------------------------------------------------
    'corridor_straight': {
        id: 'corridor_straight',
        name: 'Corridor',
        type: TILE_TYPES.CORRIDOR,
        textures: ['/assets/images/dungeon1/tiles/corridor1.png'],
        variants: {
            [DIRECTIONS.NORTH]: {
                width: 2, height: 6,
                layout: [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.SOUTH }, { x: 1, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 0, y: 5, direction: DIRECTIONS.NORTH }, { x: 1, y: 5, direction: DIRECTIONS.NORTH },
                    { x: 0, y: 3, direction: DIRECTIONS.WEST }, { x: 0, y: 4, direction: DIRECTIONS.WEST },
                    { x: 1, y: 3, direction: DIRECTIONS.EAST }, { x: 1, y: 4, direction: DIRECTIONS.EAST }
                ]
            },
            [DIRECTIONS.SOUTH]: {
                width: 2, height: 6,
                layout: [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.SOUTH }, { x: 1, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 0, y: 5, direction: DIRECTIONS.NORTH }, { x: 1, y: 5, direction: DIRECTIONS.NORTH },
                    { x: 0, y: 3, direction: DIRECTIONS.WEST }, { x: 0, y: 4, direction: DIRECTIONS.WEST },
                    { x: 1, y: 3, direction: DIRECTIONS.EAST }, { x: 1, y: 4, direction: DIRECTIONS.EAST }
                ]
            },
            [DIRECTIONS.EAST]: {
                width: 6, height: 2,
                layout: [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.WEST }, { x: 0, y: 1, direction: DIRECTIONS.WEST },
                    { x: 5, y: 0, direction: DIRECTIONS.EAST }, { x: 5, y: 1, direction: DIRECTIONS.EAST },
                    { x: 3, y: 0, direction: DIRECTIONS.SOUTH }, { x: 4, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 3, y: 1, direction: DIRECTIONS.NORTH }, { x: 4, y: 1, direction: DIRECTIONS.NORTH }
                ]
            },
            [DIRECTIONS.WEST]: {
                width: 6, height: 2,
                layout: [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.WEST }, { x: 0, y: 1, direction: DIRECTIONS.WEST },
                    { x: 5, y: 0, direction: DIRECTIONS.EAST }, { x: 5, y: 1, direction: DIRECTIONS.EAST },
                    { x: 3, y: 0, direction: DIRECTIONS.SOUTH }, { x: 4, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 3, y: 1, direction: DIRECTIONS.NORTH }, { x: 4, y: 1, direction: DIRECTIONS.NORTH }
                ]
            }
        }
    },

    // -------------------------------------------------------------------------
    // CORRIDOR STEPS
    // -------------------------------------------------------------------------
    'corridor_steps': {
        id: 'corridor_steps',
        name: 'Steps',
        type: TILE_TYPES.CORRIDOR,
        textures: ['/assets/images/dungeon1/tiles/stairs1.png'],
        variants: {
            [DIRECTIONS.NORTH]: {
                width: 2, height: 6,
                layout: [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.SOUTH }, { x: 1, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 0, y: 5, direction: DIRECTIONS.NORTH }, { x: 1, y: 5, direction: DIRECTIONS.NORTH },
                    { x: 0, y: 3, direction: DIRECTIONS.WEST }, { x: 0, y: 4, direction: DIRECTIONS.WEST },
                    { x: 1, y: 3, direction: DIRECTIONS.EAST }, { x: 1, y: 4, direction: DIRECTIONS.EAST }
                ]
            },
            [DIRECTIONS.SOUTH]: {
                width: 2, height: 6,
                layout: [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.SOUTH }, { x: 1, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 0, y: 5, direction: DIRECTIONS.NORTH }, { x: 1, y: 5, direction: DIRECTIONS.NORTH },
                    { x: 0, y: 3, direction: DIRECTIONS.WEST }, { x: 0, y: 4, direction: DIRECTIONS.WEST },
                    { x: 1, y: 3, direction: DIRECTIONS.EAST }, { x: 1, y: 4, direction: DIRECTIONS.EAST }
                ]
            },
            [DIRECTIONS.EAST]: {
                width: 6, height: 2,
                layout: [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.WEST }, { x: 0, y: 1, direction: DIRECTIONS.WEST },
                    { x: 5, y: 0, direction: DIRECTIONS.EAST }, { x: 5, y: 1, direction: DIRECTIONS.EAST },
                    { x: 3, y: 0, direction: DIRECTIONS.SOUTH }, { x: 4, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 3, y: 1, direction: DIRECTIONS.NORTH }, { x: 4, y: 1, direction: DIRECTIONS.NORTH }
                ]
            },
            [DIRECTIONS.WEST]: {
                width: 6, height: 2,
                layout: [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.WEST }, { x: 0, y: 1, direction: DIRECTIONS.WEST },
                    { x: 5, y: 0, direction: DIRECTIONS.EAST }, { x: 5, y: 1, direction: DIRECTIONS.EAST },
                    { x: 3, y: 0, direction: DIRECTIONS.SOUTH }, { x: 4, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 3, y: 1, direction: DIRECTIONS.NORTH }, { x: 4, y: 1, direction: DIRECTIONS.NORTH }
                ]
            }
        }
    },

    // -------------------------------------------------------------------------
    // CORNER (L-Shape)
    // -------------------------------------------------------------------------
    'corridor_corner': {
        id: 'corridor_corner',
        name: 'Corner',
        type: TILE_TYPES.CORRIDOR,
        textures: ['/assets/images/dungeon1/tiles/L.png'],
        variants: {
            [DIRECTIONS.NORTH]: {
                // Shape: Top and Left are solid.
                // 1111 (Top-Most)
                // 1111
                // 1100
                // 1100
                width: 4, height: 4,
                layout: [
                    [1, 1, 1, 1],
                    [1, 1, 1, 1],
                    [1, 1, 0, 0],
                    [1, 1, 0, 0]
                ],
                exits: [
                    { x: 0, y: 0, direction: DIRECTIONS.SOUTH }, { x: 1, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 3, y: 2, direction: DIRECTIONS.EAST }, { x: 3, y: 3, direction: DIRECTIONS.EAST }
                ]
            },
            [DIRECTIONS.EAST]: {
                // Rotated 90 CW: Top -> Right, Left -> Top.
                // Shape: Top and Right are solid.
                // 1111 (Top-Most)
                // 1111
                // 0011
                // 0011
                width: 4, height: 4,
                layout: [
                    [1, 1, 1, 1],
                    [1, 1, 1, 1],
                    [0, 0, 1, 1],
                    [0, 0, 1, 1]
                ],
                exits: [
                    { x: 3, y: 0, direction: DIRECTIONS.SOUTH }, { x: 2, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 0, y: 3, direction: DIRECTIONS.WEST }, { x: 0, y: 2, direction: DIRECTIONS.WEST }
                ]
            },
            [DIRECTIONS.SOUTH]: {
                // Rotated 180: Bottom and Right are solid.
                // 0011
                // 0011
                // 1111
                // 1111
                width: 4, height: 4,
                layout: [
                    [0, 0, 1, 1],
                    [0, 0, 1, 1],
                    [1, 1, 1, 1],
                    [1, 1, 1, 1]
                ],
                exits: [
                    { x: 2, y: 3, direction: DIRECTIONS.NORTH }, { x: 3, y: 3, direction: DIRECTIONS.NORTH },
                    { x: 0, y: 0, direction: DIRECTIONS.WEST }, { x: 0, y: 1, direction: DIRECTIONS.WEST }
                ]
            },
            [DIRECTIONS.WEST]: {
                // Rotated 270: Bottom and Left are solid.
                // 1100
                // 1100
                // 1111
                // 1111
                width: 4, height: 4,
                layout: [
                    [1, 1, 0, 0],
                    [1, 1, 0, 0],
                    [1, 1, 1, 1],
                    [1, 1, 1, 1]
                ],
                exits: [
                    { x: 3, y: 1, direction: DIRECTIONS.EAST }, { x: 3, y: 0, direction: DIRECTIONS.EAST },
                    { x: 0, y: 3, direction: DIRECTIONS.NORTH }, { x: 1, y: 3, direction: DIRECTIONS.NORTH }
                ]
            }
        }
    },

    // -------------------------------------------------------------------------
    // T-JUNCTION
    // -------------------------------------------------------------------------
    'junction_t': {
        id: 'junction_t',
        name: 'T-Junction',
        type: TILE_TYPES.JUNCTION,
        textures: ['/assets/images/dungeon1/tiles/T.png'],
        variants: {
            [DIRECTIONS.NORTH]: {
                // T Shape (Top bar)
                // 111111
                // 111111
                // 001100
                // 001100
                width: 6, height: 4,
                layout: [
                    [1, 1, 1, 1, 1, 1],
                    [1, 1, 1, 1, 1, 1],
                    [0, 0, 1, 1, 0, 0],
                    [0, 0, 1, 1, 0, 0]
                ],
                exits: [
                    { x: 2, y: 0, direction: DIRECTIONS.SOUTH }, { x: 3, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 0, y: 2, direction: DIRECTIONS.WEST }, { x: 0, y: 3, direction: DIRECTIONS.WEST },
                    { x: 5, y: 2, direction: DIRECTIONS.EAST }, { x: 5, y: 3, direction: DIRECTIONS.EAST }
                ]
            },
            [DIRECTIONS.EAST]: {
                // Rotated 90 CW: Bar is at Right (East)
                // 0011
                // 0011
                // 1111
                // 1111
                // 0011
                // 0011
                width: 4, height: 6,
                layout: [
                    [0, 0, 1, 1],
                    [0, 0, 1, 1],
                    [1, 1, 1, 1],
                    [1, 1, 1, 1],
                    [0, 0, 1, 1],
                    [0, 0, 1, 1]
                ],
                exits: [
                    // Stem points Left (West)
                    { x: 0, y: 2, direction: DIRECTIONS.WEST }, { x: 0, y: 3, direction: DIRECTIONS.WEST },
                    // Bar Top/Bottom
                    { x: 2, y: 5, direction: DIRECTIONS.NORTH }, { x: 3, y: 5, direction: DIRECTIONS.NORTH },
                    { x: 2, y: 0, direction: DIRECTIONS.SOUTH }, { x: 3, y: 0, direction: DIRECTIONS.SOUTH }
                ]
            },
            [DIRECTIONS.SOUTH]: {
                // Rotated 180: Bar is Bottom
                // 001100
                // 001100
                // 111111
                // 111111
                width: 6, height: 4,
                layout: [
                    [0, 0, 1, 1, 0, 0],
                    [0, 0, 1, 1, 0, 0],
                    [1, 1, 1, 1, 1, 1],
                    [1, 1, 1, 1, 1, 1]
                ],
                exits: [
                    { x: 2, y: 3, direction: DIRECTIONS.NORTH }, { x: 3, y: 3, direction: DIRECTIONS.NORTH },
                    { x: 5, y: 0, direction: DIRECTIONS.EAST }, { x: 5, y: 1, direction: DIRECTIONS.EAST },
                    { x: 0, y: 0, direction: DIRECTIONS.WEST }, { x: 0, y: 1, direction: DIRECTIONS.WEST }
                ]
            },
            [DIRECTIONS.WEST]: {
                // Rotated 270: Bar is Left (West)
                // 1100
                // 1100
                // 1111
                // 1111
                // 1100
                // 1100
                width: 4, height: 6,
                layout: [
                    [1, 1, 0, 0],
                    [1, 1, 0, 0],
                    [1, 1, 1, 1],
                    [1, 1, 1, 1],
                    [1, 1, 0, 0],
                    [1, 1, 0, 0]
                ],
                exits: [
                    // Stem points Right (East)
                    { x: 3, y: 2, direction: DIRECTIONS.EAST }, { x: 3, y: 3, direction: DIRECTIONS.EAST },
                    // Bar Top/Bottom
                    { x: 0, y: 5, direction: DIRECTIONS.NORTH }, { x: 1, y: 5, direction: DIRECTIONS.NORTH },
                    { x: 0, y: 0, direction: DIRECTIONS.SOUTH }, { x: 1, y: 0, direction: DIRECTIONS.SOUTH }
                ]
            }
        }
    },

    // -------------------------------------------------------------------------
    // ROOM DUNGEON
    // -------------------------------------------------------------------------
    'room_dungeon': {
        id: 'room_dungeon',
        name: 'Dungeon Room',
        type: TILE_TYPES.ROOM,
        textures: [
            '/assets/images/dungeon1/tiles/room_4x4_circle.png',
            '/assets/images/dungeon1/tiles/room_4x4_orange.png',
            '/assets/images/dungeon1/tiles/room_4x4_squeleton.png'
        ],
        variants: {
            [DIRECTIONS.NORTH]: {
                width: 4, height: 4,
                layout: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
                exits: [
                    { x: 1, y: 0, direction: DIRECTIONS.SOUTH }, { x: 2, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 1, y: 3, direction: DIRECTIONS.NORTH }, { x: 2, y: 3, direction: DIRECTIONS.NORTH }
                ]
            },
            [DIRECTIONS.EAST]: {
                width: 4, height: 4,
                layout: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
                exits: [
                    { x: 0, y: 1, direction: DIRECTIONS.WEST }, { x: 0, y: 2, direction: DIRECTIONS.WEST },
                    { x: 3, y: 1, direction: DIRECTIONS.EAST }, { x: 3, y: 2, direction: DIRECTIONS.EAST }
                ]
            },
            [DIRECTIONS.SOUTH]: {
                width: 4, height: 4,
                layout: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
                exits: [
                    { x: 1, y: 3, direction: DIRECTIONS.NORTH }, { x: 2, y: 3, direction: DIRECTIONS.NORTH },
                    { x: 1, y: 0, direction: DIRECTIONS.SOUTH }, { x: 2, y: 0, direction: DIRECTIONS.SOUTH }
                ]
            },
            [DIRECTIONS.WEST]: {
                width: 4, height: 4,
                layout: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
                exits: [
                    { x: 3, y: 1, direction: DIRECTIONS.EAST }, { x: 3, y: 2, direction: DIRECTIONS.EAST },
                    { x: 0, y: 1, direction: DIRECTIONS.WEST }, { x: 0, y: 2, direction: DIRECTIONS.WEST }
                ]
            }
        }
    },

    // -------------------------------------------------------------------------
    // ROOM OBJECTIVE
    // -------------------------------------------------------------------------
    'room_objective': {
        id: 'room_objective',
        name: 'Dungeon Room',
        type: TILE_TYPES.ROOM,
        textures: [
            '/assets/images/dungeon1/tiles/room_4x4_circle.png',
            '/assets/images/dungeon1/tiles/room_4x4_orange.png',
            '/assets/images/dungeon1/tiles/room_4x4_squeleton.png'
        ],
        variants: {
            [DIRECTIONS.NORTH]: {
                width: 4, height: 4,
                layout: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
                exits: [
                    { x: 1, y: 0, direction: DIRECTIONS.SOUTH }, { x: 2, y: 0, direction: DIRECTIONS.SOUTH },
                    { x: 1, y: 3, direction: DIRECTIONS.NORTH }, { x: 2, y: 3, direction: DIRECTIONS.NORTH }
                ]
            },
            [DIRECTIONS.EAST]: {
                width: 4, height: 4,
                layout: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
                exits: [
                    { x: 0, y: 1, direction: DIRECTIONS.WEST }, { x: 0, y: 2, direction: DIRECTIONS.WEST },
                    { x: 3, y: 1, direction: DIRECTIONS.EAST }, { x: 3, y: 2, direction: DIRECTIONS.EAST }
                ]
            },
            [DIRECTIONS.SOUTH]: {
                width: 4, height: 4,
                layout: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
                exits: [
                    { x: 1, y: 3, direction: DIRECTIONS.NORTH }, { x: 2, y: 3, direction: DIRECTIONS.NORTH },
                    { x: 1, y: 0, direction: DIRECTIONS.SOUTH }, { x: 2, y: 0, direction: DIRECTIONS.SOUTH }
                ]
            },
            [DIRECTIONS.WEST]: {
                width: 4, height: 4,
                layout: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
                exits: [
                    { x: 3, y: 1, direction: DIRECTIONS.EAST }, { x: 3, y: 2, direction: DIRECTIONS.EAST },
                    { x: 0, y: 1, direction: DIRECTIONS.WEST }, { x: 0, y: 2, direction: DIRECTIONS.WEST }
                ]
            }
        }
    },

    // -------------------------------------------------------------------------
    // ROOM OBJECTIVE
    // -------------------------------------------------------------------------
    'room_objective': {
        id: 'room_objective',
        name: 'Objective Room',
        type: TILE_TYPES.OBJECTIVE_ROOM,
        textures: [
            '/assets/images/dungeon1/tiles/room_4x8_altar.png',
            '/assets/images/dungeon1/tiles/room_4x8_tomb.png'
        ],
        variants: {
            [DIRECTIONS.NORTH]: {
                width: 4, height: 8,
                layout: [
                    [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1],
                    [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]
                ],
                exits: [
                    { x: 1, y: 0, direction: DIRECTIONS.SOUTH }, { x: 2, y: 0, direction: DIRECTIONS.SOUTH }
                ]
            },
            [DIRECTIONS.EAST]: {
                width: 8, height: 4,
                layout: [
                    [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1],
                    [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]
                ],
                exits: [
                    { x: 0, y: 1, direction: DIRECTIONS.WEST }, { x: 0, y: 2, direction: DIRECTIONS.WEST }
                ]
            },
            [DIRECTIONS.SOUTH]: {
                width: 4, height: 8,
                layout: [
                    [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1],
                    [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]
                ],
                exits: [
                    { x: 1, y: 7, direction: DIRECTIONS.NORTH }, { x: 2, y: 7, direction: DIRECTIONS.NORTH }
                ]
            },
            [DIRECTIONS.WEST]: {
                width: 8, height: 4,
                layout: [
                    [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1],
                    [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]
                ],
                exits: [
                    { x: 7, y: 1, direction: DIRECTIONS.EAST }, { x: 7, y: 2, direction: DIRECTIONS.EAST }
                ]
            }
        }
    }
};
