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:
@@ -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
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ func (s *GameSession) advanceFloor() {
|
||||
return
|
||||
}
|
||||
s.state.FloorNum++
|
||||
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.CombatTurn = 0
|
||||
s.addLog(fmt.Sprintf("Descending to B%d...", s.state.FloorNum))
|
||||
|
||||
Reference in New Issue
Block a user