diff --git a/assets/scripts/nethack/dungeon.js b/assets/scripts/nethack/dungeon.js index 095d9ae..75d06e0 100644 --- a/assets/scripts/nethack/dungeon.js +++ b/assets/scripts/nethack/dungeon.js @@ -360,8 +360,6 @@ class TunnelGenerator { let fromRoom = rooms[i]; let toRoom = rooms[i + offset]; - console.log(`Connecting rooms ${i} to ${i + offset}:`, fromRoom.bounds, toRoom.bounds); - let [fromPoint, toPoint] = this.#findPointFromRoomToRoom(fromRoom, toRoom); for (let neighbor of fromPoint.neighbors()) { @@ -433,87 +431,60 @@ class TunnelGenerator { let steps = 0; while (curX !== toX || curY !== toY) { if (steps++ > MAX_STEPS) { - console.log("Exceeded max step count for this corridor"); return false; } curX += dx; curY += dy; - console.groupCollapsed(`${steps}: (${curX}, ${curY})`); - console.log(`dx = ${dx}, dy = ${dy}`); - if (curX >= this.#grid.width - 1 || curX <= 0 || curY <= 0 || curY >= this.#grid.height - 1) { - console.error(`Out of bounds: (${curX}, ${curY})`); - console.groupEnd(); return false; } let cell = this.#grid.cellAt(curX, curY); if (cell.isEmpty()) { - console.log("Digging corridor"); cell.corridor(); } else if (!cell.isCorridor()) { - console.error("Found a weird cell type:", cell.character); - console.groupEnd(); return false; } let dix = Math.abs(curX - toX); let diy = Math.abs(curY - toY); - console.log(`1. dix = ${dix}, diy = ${diy}`); - if (dix > diy && diy) { const random = randomInt(dix - diy + 1); - console.log(`Randomness: ${random}`); if (!random) { dix = 0; } } else if (diy > dix && dix) { const random = randomInt(dix - diy + 1); - console.log(`Randomness: ${random}`); if (!random) { diy = 0; } } - console.log(`2. dix = ${dix}, diy = ${diy}`); - if (dy && dix > diy) { const ddx = curX > toX ? -1 : 1; - console.log(`ddx = ${ddx}`); let cell = this.#grid.cellAt(curX + ddx, curY); - console.log(`Checking cell at (${curX + ddx}, ${curY})`, cell.character); if (cell.isEmpty() || cell.isCorridor()) { dx = ddx; dy = 0; - - console.log(`Adjusted dx = ${dx}, dy = ${dy}`); - console.groupEnd(); continue; } } else if (dx && diy > dix) { const ddy = curY > toY ? -1 : 1; - console.log(`ddy = ${ddy}`); let cell = this.#grid.cellAt(curX, curY + ddy); - console.log(`Checking cell at (${curX}, ${curY + ddy})`, cell.character); if (cell.isEmpty() || cell.isCorridor()) { dy = ddy; dx = 0; - - console.log(`Adjusted dx = ${dx}, dy = ${dy}`); - console.groupEnd(); continue; } } cell = this.#grid.cellAt(curX + dx, curY + dy); - console.log(`2. Checking cell at (${curX + dx}, ${curY + dy})`, cell.character); if (cell.isEmpty() || cell.isCorridor()) { - console.groupEnd(); continue; } @@ -525,20 +496,13 @@ class TunnelGenerator { dx = toX < curX ? -1 : 1; } - console.log(`Adjusting dx = ${dx}, dy = ${dy}`); - cell = this.#grid.cellAt(curX + dx, curY + dy); - console.log(`3. Checking cell at (${curX + dx}, ${curY + dy})`, cell.character); if (cell.isEmpty() || cell.isCorridor()) { - console.groupEnd(); continue; } dy = -dy; dx = -dx; - console.log(`Adjusting dx = ${dx}, dy = ${dy}`); - - console.groupEnd(); } return true;