FEAT: check for duplicate room assignments

This commit is contained in:
zomo
2026-04-14 21:23:07 -05:00
parent 54b774cade
commit 93493c2af7
2 changed files with 44 additions and 1 deletions
+34
View File
@@ -1,5 +1,9 @@
package main
import (
"fmt"
)
func AssignExtraRooms(rooms []RoomFolder, roomsPerNight int) {
latestnight := 0
@@ -27,3 +31,33 @@ func AssignExtraRooms(rooms []RoomFolder, roomsPerNight int) {
}
}
}
func CheckDuplicateRooms(rooms []RoomFolder) error {
maxnight := 0
maxroom := 0
for _, r := range rooms {
if r.Cfg.night > maxnight {
maxnight = r.Cfg.night
}
if r.Cfg.room > maxroom {
maxroom = r.Cfg.room
}
}
assignments := make([][]string, maxnight)
for night := range maxnight {
assignments[night] = make([]string, maxroom)
}
for _, r := range rooms {
if r.Cfg.night > 0 && r.Cfg.room > 0 {
if assignments[r.Cfg.night-1][r.Cfg.room-1] != "" {
return fmt.Errorf("duplicate room assignment for Room %d Night %d: %s, %s", r.Cfg.night, r.Cfg.room, assignments[r.Cfg.night][r.Cfg.room], r.Path)
}
assignments[r.Cfg.night-1][r.Cfg.room-1] = r.Path
}
}
return nil
}