feat: seed-based dungeon generation for deterministic floors

Thread *rand.Rand through GenerateFloor, splitBSP, and RandomRoomType
so floors can be reproduced from a seed. This enables daily challenges
in Phase 3. All callers now create a local rng instance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 15:39:21 +09:00
parent 7f29995833
commit 65c062a1f7
5 changed files with 64 additions and 30 deletions

View File

@@ -3,6 +3,7 @@ package game
import (
"fmt"
"log/slog"
"math/rand"
"sync"
"time"
@@ -204,7 +205,7 @@ func (s *GameSession) AddPlayer(p *entity.Player) {
func (s *GameSession) StartFloor() {
s.mu.Lock()
defer s.mu.Unlock()
s.state.Floor = dungeon.GenerateFloor(s.state.FloorNum)
s.state.Floor = dungeon.GenerateFloor(s.state.FloorNum, rand.New(rand.NewSource(time.Now().UnixNano())))
s.state.Phase = PhaseExploring
s.state.TurnNum = 0