package mapgens

import (
	"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
	"lab.zaar.be/thefish/alchemyst-go/util"
)

func DefaultGen(l *gamemap.Level) (*gamemap.Level, []gamemap.Room) {

	rng := util.NewRNG()

	//fill with walls
	for i := 0; i < l.W; i ++ {
		for j := 0; j < l.H; j++ {
			l.SetTileByXY(i, j, gamemap.NewWall())
		}
	}

	rooms := GetRandomRoomList(rng, l, maxrooms, minRoomSize, maxRoomSize)

	BlitToLevel(l, rooms)

	for idx, room := range rooms {
		if idx > 0 {
			ConnectRoomCenters(l, room, rooms[idx-1], rng.Range(0, 1))
		}
	}

	return l, rooms
}

