FEAT: randomize room number

randomize room number when not set but the night number is set
This commit is contained in:
zomo
2026-07-01 23:48:36 -05:00
parent 262f3d59ec
commit ecf30a9044
4 changed files with 38 additions and 8 deletions
+25
View File
@@ -32,6 +32,31 @@ func AssignExtraRooms(rooms []RoomFolder, roomsPerNight int) {
}
}
func AssignRandomNightRooms(rooms []RoomFolder, roomsPerNight int) {
latestrooms := make(map[int]int)
for _, r := range rooms {
if latestroom, ok := latestrooms[r.Cfg.night]; !ok {
latestrooms[r.Cfg.night] = r.Cfg.room
} else if r.Cfg.room > latestroom {
latestrooms[r.Cfg.night] = r.Cfg.room
}
}
for i, r := range rooms {
if r.Cfg.night <= 0 || r.Cfg.room > 0 {
continue
}
if latestrooms[r.Cfg.night] < 0 {
latestrooms[r.Cfg.night] = 0
}
latestrooms[r.Cfg.night]++
rooms[i].Cfg.room = latestrooms[r.Cfg.night]
}
}
func CheckDuplicateRooms(rooms []RoomFolder) error {
maxnight := 0
maxroom := 0