export const GAME_WIDTH = 80;
export const GAME_HEIGHT = 25;

export const ROOM_AREA_WIDTH = 40;
export const ROOM_AREA_HEIGHT = GAME_HEIGHT;

export const ROOM_AREA_X = GAME_WIDTH - ROOM_AREA_WIDTH;
export const ROOM_AREA_Y = Math.round((GAME_HEIGHT - ROOM_AREA_HEIGHT) / 2);

export const INVENTORY_HEIGHT = 3;
export const INVENTORY_X = 0;
export const INVENTORY_Y = GAME_HEIGHT - INVENTORY_HEIGHT;

export const MAP_X = 16;
export const MAP_Y = 0;
export const MAP_WIDTH = GAME_WIDTH - ROOM_AREA_WIDTH - MAP_X;
export const MAP_HEIGHT = 10;

export enum Direction {
    NORTH = 0,
    EAST = 1,
    SOUTH = 2,
    WEST = 3,
    UP = 4,
    DOWN = 5,
}

export const DIRECTION_OFFSETS: Record<number, [number, number, number]> = {
    [Direction.NORTH]: [0, -1, 0],
    [Direction.EAST]: [1, 0, 0],
    [Direction.SOUTH]: [0, 1, 0],
    [Direction.WEST]: [-1, 0, 0],
    [Direction.UP]: [0, 0, -1],
    [Direction.DOWN]: [0, 0, 1],
};

export const getOppositeDirection = (d: Direction): Direction => {
    switch (d) {
        case Direction.NORTH: return Direction.SOUTH;
        case Direction.WEST: return Direction.EAST;
        case Direction.SOUTH: return Direction.NORTH;
        case Direction.EAST: return Direction.WEST;
        case Direction.UP: return Direction.DOWN;
        case Direction.DOWN: return Direction.UP;
    }
}

export const MAP_ROOM_CHARS: Record<number, string> = {
    [0b0000]: ' ',
    [0b0001]: '╨',
    [0b0010]: '╞',
    [0b0100]: '╥',
    [0b1000]: '╡',
    [0b0011]: '╚',
    [0b0110]: '╔',
    [0b1100]: '╗',
    [0b1001]: '╝',
    [0b1010]: '═',
    [0b0101]: '║',
    [0b0111]: '╠',
    [0b1110]: '╦',
    [0b1101]: '╣',
    [0b1011]: '╩',
    [0b1111]: '╬',
};