477 lines
11 KiB
JavaScript
477 lines
11 KiB
JavaScript
/**
|
|
* TileDefinitions.js
|
|
*
|
|
* Defines all dungeon tiles with their properties:
|
|
* - Dimensions (width x height in cells)
|
|
* - Walkability matrix (0 = not walkable, 1-8 = walkable layer/height, 9 = stairs)
|
|
* - Tile type (room, corridor, L, T)
|
|
* - Exit points
|
|
* - Image path
|
|
*/
|
|
|
|
// ============================================================================
|
|
// ROOMS (4x4 and 4x6)
|
|
// ============================================================================
|
|
|
|
const ROOM_4X4_NORMAL = {
|
|
id: 'room_4x4_normal',
|
|
tileType: 'room',
|
|
width: 4,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/room_4x4_normal.png',
|
|
walkability: [
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1]
|
|
],
|
|
exits: ['N', 'S', 'E', 'W']
|
|
};
|
|
|
|
const ROOM_4X4_CIRCLE = {
|
|
id: 'room_4x4_circle',
|
|
tileType: 'room',
|
|
width: 4,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/room_4x4_circle.png',
|
|
walkability: [
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1]
|
|
],
|
|
exits: ['N', 'S', 'E', 'W']
|
|
};
|
|
|
|
const ROOM_4X4_SKELETON = {
|
|
id: 'room_4x4_skeleton',
|
|
tileType: 'room',
|
|
width: 4,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/room_4x4_squeleton.png',
|
|
walkability: [
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1]
|
|
],
|
|
exits: ['N', 'S', 'E', 'W']
|
|
};
|
|
|
|
const ROOM_4X6_ALTAR = {
|
|
id: 'room_4x6_altar',
|
|
tileType: 'room',
|
|
width: 4,
|
|
height: 6,
|
|
image: '/assets/images/dungeons/room_4x6_altar.png',
|
|
walkability: [
|
|
[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: ['N', 'S', 'E', 'W']
|
|
};
|
|
|
|
const ROOM_4X6_TOMB = {
|
|
id: 'room_4x6_tomb',
|
|
tileType: 'room',
|
|
width: 4,
|
|
height: 6,
|
|
image: '/assets/images/dungeons/room_4x6_tomb.png',
|
|
walkability: [
|
|
[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: ['N', 'S', 'E', 'W']
|
|
};
|
|
|
|
// Example room with stairs (2 levels)
|
|
const ROOM_4X6_STAIRS = {
|
|
id: 'room_4x6_stairs',
|
|
tileType: 'room',
|
|
width: 4,
|
|
height: 6,
|
|
image: '/assets/images/dungeons/room_4x6_altar.png', // Using altar image as placeholder
|
|
walkability: [
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 9, 9, 1], // Stairs connecting level 1 and 2
|
|
[1, 2, 2, 1],
|
|
[2, 2, 2, 2],
|
|
[2, 2, 2, 2]
|
|
],
|
|
exits: ['N', 'S']
|
|
};
|
|
|
|
// ============================================================================
|
|
// L-SHAPES (4x4 with 2-tile rows)
|
|
// ============================================================================
|
|
|
|
const L_NE = {
|
|
id: 'L_NE',
|
|
tileType: 'L',
|
|
width: 4,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/L_NE.png',
|
|
walkability: [
|
|
[1, 1, 0, 0],
|
|
[1, 1, 0, 0],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1]
|
|
],
|
|
exits: ['N', 'E'],
|
|
doorCoordinates: {
|
|
'N': { x: 0, y: 0 }, // Anchor: Top-Left of path (col 0,1 -> 0)
|
|
'E': { x: 3, y: 2 } // Anchor: Top-Left of path (row 2,3 -> 2)
|
|
}
|
|
};
|
|
|
|
const L_SE = {
|
|
id: 'L_SE',
|
|
tileType: 'L',
|
|
width: 4,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/L_SE.png',
|
|
walkability: [
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 0, 0],
|
|
[1, 1, 0, 0]
|
|
],
|
|
exits: ['S', 'E'],
|
|
doorCoordinates: {
|
|
'S': { x: 0, y: 3 }, // Anchor: Top-Left (col 0,1 -> 0)
|
|
'E': { x: 3, y: 0 } // Anchor: Top-Left (row 0,1 -> 0)
|
|
}
|
|
};
|
|
|
|
const L_WS = {
|
|
id: 'L_WS',
|
|
tileType: 'L',
|
|
width: 4,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/L_WS.png',
|
|
walkability: [
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[0, 0, 1, 1],
|
|
[0, 0, 1, 1]
|
|
],
|
|
exits: ['W', 'S'],
|
|
doorCoordinates: {
|
|
'W': { x: 0, y: 0 }, // Anchor: Top-Left (row 0,1 -> 0)
|
|
'S': { x: 2, y: 3 } // Anchor: Top-Left (col 2,3 -> 2)
|
|
}
|
|
};
|
|
|
|
const L_WN = {
|
|
id: 'L_WN',
|
|
tileType: 'L',
|
|
width: 4,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/L_WN.png',
|
|
walkability: [
|
|
[0, 0, 1, 1],
|
|
[0, 0, 1, 1],
|
|
[1, 1, 1, 1],
|
|
[1, 1, 1, 1]
|
|
],
|
|
exits: ['W', 'N'],
|
|
doorCoordinates: {
|
|
'W': { x: 0, y: 2 }, // Anchor: Top-Left (row 2,3 -> 2)
|
|
'N': { x: 2, y: 0 } // Anchor: Top-Left (col 2,3 -> 2)
|
|
}
|
|
};
|
|
|
|
// ============================================================================
|
|
// T-JUNCTIONS (4x6 or 6x4 with 2-tile rows)
|
|
// ============================================================================
|
|
|
|
const T_NES = {
|
|
id: 'T_NES',
|
|
tileType: 'T',
|
|
width: 4,
|
|
height: 6,
|
|
image: '/assets/images/dungeons/T_NES.png',
|
|
walkability: [
|
|
[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: ['N', 'E', 'S'],
|
|
doorCoordinates: {
|
|
'N': { x: 0, y: 0 }, // Col 0,1 -> 0
|
|
'E': { x: 3, y: 2 }, // Row 2,3 -> 2
|
|
'S': { x: 0, y: 5 } // Col 0,1 -> 0
|
|
}
|
|
};
|
|
|
|
const T_WNE = {
|
|
id: 'T_WNE',
|
|
tileType: 'T',
|
|
width: 6,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/T_WNE.png',
|
|
walkability: [
|
|
[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: ['W', 'N', 'E'],
|
|
doorCoordinates: {
|
|
'W': { x: 0, y: 2 }, // Row 2,3 -> 2
|
|
'N': { x: 2, y: 0 }, // Col 2,3 -> 2
|
|
'E': { x: 5, y: 2 } // Row 2,3 -> 2
|
|
}
|
|
};
|
|
|
|
const T_WSE = {
|
|
id: 'T_WSE',
|
|
tileType: 'T',
|
|
width: 6,
|
|
height: 4,
|
|
image: '/assets/images/dungeons/T_WSE.png',
|
|
walkability: [
|
|
[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: ['W', 'S', 'E'],
|
|
doorCoordinates: {
|
|
'W': { x: 0, y: 0 }, // Row 0,1 -> 0
|
|
'S': { x: 2, y: 3 }, // Col 2,3 -> 2
|
|
'E': { x: 5, y: 0 } // Row 0,1 -> 0
|
|
}
|
|
};
|
|
|
|
const T_WNS = {
|
|
id: 'T_WNS',
|
|
tileType: 'T',
|
|
width: 4,
|
|
height: 6,
|
|
image: '/assets/images/dungeons/T_WNS.png',
|
|
walkability: [
|
|
[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: ['W', 'N', 'S'],
|
|
doorCoordinates: {
|
|
'W': { x: 0, y: 2 }, // Row 2,3 -> 2
|
|
'N': { x: 2, y: 0 }, // Col 2,3 -> 2
|
|
'S': { x: 2, y: 5 } // Col 2,3 -> 2
|
|
}
|
|
};
|
|
|
|
// ============================================================================
|
|
// CORRIDORS (2x6 or 6x2 with 2-tile rows)
|
|
// ============================================================================
|
|
|
|
const CORRIDOR_DOORS_EW = { 'E': { x: 5, y: 0 }, 'W': { x: 0, y: 0 } };
|
|
const CORRIDOR_DOORS_NS = { 'N': { x: 0, y: 0 }, 'S': { x: 0, y: 5 } };
|
|
|
|
// Corridor 1 - East-West (horizontal)
|
|
const CORRIDOR1_EW = {
|
|
id: 'corridor1_EW',
|
|
tileType: 'corridor',
|
|
width: 6,
|
|
height: 2,
|
|
image: '/assets/images/dungeons/corridor1_EW.png',
|
|
walkability: [
|
|
[1, 1, 1, 1, 1, 1],
|
|
[1, 1, 1, 1, 1, 1]
|
|
],
|
|
exits: ['E', 'W'],
|
|
doorCoordinates: CORRIDOR_DOORS_EW
|
|
};
|
|
|
|
// Corridor 1 - North-South (vertical)
|
|
const CORRIDOR1_NS = {
|
|
id: 'corridor1_NS',
|
|
tileType: 'corridor',
|
|
width: 2,
|
|
height: 6,
|
|
image: '/assets/images/dungeons/corridor1_NS.png',
|
|
walkability: [
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1]
|
|
],
|
|
exits: ['N', 'S'],
|
|
doorCoordinates: CORRIDOR_DOORS_NS
|
|
};
|
|
|
|
// Corridor 2 - East-West (horizontal)
|
|
const CORRIDOR2_EW = {
|
|
id: 'corridor2_EW',
|
|
tileType: 'corridor',
|
|
width: 6,
|
|
height: 2,
|
|
image: '/assets/images/dungeons/corridor2_EW.png',
|
|
walkability: [
|
|
[1, 1, 1, 1, 1, 1],
|
|
[1, 1, 1, 1, 1, 1]
|
|
],
|
|
exits: ['E', 'W'],
|
|
doorCoordinates: CORRIDOR_DOORS_EW
|
|
};
|
|
|
|
// Corridor 2 - North-South (vertical)
|
|
const CORRIDOR2_NS = {
|
|
id: 'corridor2_NS',
|
|
tileType: 'corridor',
|
|
width: 2,
|
|
height: 6,
|
|
image: '/assets/images/dungeons/corridor2_NS.png',
|
|
walkability: [
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1]
|
|
],
|
|
exits: ['N', 'S'],
|
|
doorCoordinates: CORRIDOR_DOORS_NS
|
|
};
|
|
|
|
// Corridor 3 - East-West (horizontal)
|
|
const CORRIDOR3_EW = {
|
|
id: 'corridor3_EW',
|
|
tileType: 'corridor',
|
|
width: 6,
|
|
height: 2,
|
|
image: '/assets/images/dungeons/corridor3_EW.png',
|
|
walkability: [
|
|
[1, 1, 1, 1, 1, 1],
|
|
[1, 1, 1, 1, 1, 1]
|
|
],
|
|
exits: ['E', 'W'],
|
|
doorCoordinates: CORRIDOR_DOORS_EW
|
|
};
|
|
|
|
// Corridor 3 - North-South (vertical)
|
|
const CORRIDOR3_NS = {
|
|
id: 'corridor3_NS',
|
|
tileType: 'corridor',
|
|
width: 2,
|
|
height: 6,
|
|
image: '/assets/images/dungeons/corridor3_NS.png',
|
|
walkability: [
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1],
|
|
[1, 1]
|
|
],
|
|
exits: ['N', 'S'],
|
|
doorCoordinates: CORRIDOR_DOORS_NS
|
|
};
|
|
|
|
// ============================================================================
|
|
// TILE COLLECTIONS
|
|
// ============================================================================
|
|
|
|
export const TILE_DEFINITIONS = {
|
|
// Rooms
|
|
room_4x4_normal: ROOM_4X4_NORMAL,
|
|
room_4x4_circle: ROOM_4X4_CIRCLE,
|
|
room_4x4_skeleton: ROOM_4X4_SKELETON,
|
|
room_4x6_altar: ROOM_4X6_ALTAR,
|
|
room_4x6_tomb: ROOM_4X6_TOMB,
|
|
room_4x6_stairs: ROOM_4X6_STAIRS,
|
|
|
|
// L-shapes
|
|
L_NE: L_NE,
|
|
L_SE: L_SE,
|
|
L_WS: L_WS,
|
|
L_WN: L_WN,
|
|
|
|
// T-junctions
|
|
T_NES: T_NES,
|
|
T_WNE: T_WNE,
|
|
T_WSE: T_WSE,
|
|
T_WNS: T_WNS,
|
|
|
|
// Corridors
|
|
corridor1_EW: CORRIDOR1_EW,
|
|
corridor1_NS: CORRIDOR1_NS,
|
|
corridor2_EW: CORRIDOR2_EW,
|
|
corridor2_NS: CORRIDOR2_NS,
|
|
corridor3_EW: CORRIDOR3_EW,
|
|
corridor3_NS: CORRIDOR3_NS
|
|
};
|
|
|
|
// Collections by type for easy filtering
|
|
export const ROOMS = [
|
|
ROOM_4X4_NORMAL,
|
|
ROOM_4X4_CIRCLE,
|
|
ROOM_4X4_SKELETON,
|
|
ROOM_4X6_ALTAR,
|
|
ROOM_4X6_TOMB,
|
|
ROOM_4X6_STAIRS
|
|
];
|
|
|
|
export const L_SHAPES = [
|
|
L_NE,
|
|
L_SE,
|
|
L_WS,
|
|
L_WN
|
|
];
|
|
|
|
export const T_JUNCTIONS = [
|
|
T_NES,
|
|
T_WNE,
|
|
T_WSE,
|
|
T_WNS
|
|
];
|
|
|
|
export const CORRIDORS = [
|
|
CORRIDOR1_EW,
|
|
CORRIDOR1_NS,
|
|
CORRIDOR2_EW,
|
|
CORRIDOR2_NS,
|
|
CORRIDOR3_EW,
|
|
CORRIDOR3_NS
|
|
];
|
|
|
|
// Helper function to get tile definition by ID
|
|
export function getTileDefinition(tileId) {
|
|
return TILE_DEFINITIONS[tileId] || null;
|
|
}
|
|
|
|
// Helper function to get tiles by type
|
|
export function getTilesByType(tileType) {
|
|
switch (tileType) {
|
|
case 'room':
|
|
return ROOMS;
|
|
case 'L':
|
|
return L_SHAPES;
|
|
case 'T':
|
|
return T_JUNCTIONS;
|
|
case 'corridor':
|
|
return CORRIDORS;
|
|
default:
|
|
return [];
|
|
}
|
|
}
|