Files
Catacombs/dungeon/room.go
tolelom 26784479b7 feat: BSP dungeon generation with 2D ASCII tile map
Replace list-based room display with proper 2D tile map using Binary
Space Partitioning. Rooms are carved into a 60x20 grid, connected by
L-shaped corridors, and rendered with ANSI-colored ASCII art including
fog of war visibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 00:57:16 +09:00

62 lines
895 B
Go

package dungeon
import "math/rand"
type RoomType int
const (
RoomCombat RoomType = iota
RoomTreasure
RoomShop
RoomEvent
RoomEmpty
RoomBoss
)
func (r RoomType) String() string {
return [...]string{"Combat", "Treasure", "Shop", "Event", "Empty", "Boss"}[r]
}
type Tile int
const (
TileWall Tile = iota
TileFloor
TileCorridor
TileDoor
)
type Room struct {
Type RoomType
X, Y int // top-left in tile space
W, H int // dimensions in tiles
Visited bool
Cleared bool
Neighbors []int
}
type Floor struct {
Number int
Rooms []*Room
CurrentRoom int
Tiles [][]Tile
Width int
Height int
}
func RandomRoomType() RoomType {
r := rand.Float64() * 100
switch {
case r < 45:
return RoomCombat
case r < 60:
return RoomTreasure
case r < 70:
return RoomShop
case r < 85:
return RoomEvent
default:
return RoomEmpty
}
}