extends Node2D

class_name Board

const hex_prefab = preload("res://Prefabs/Hex.tscn")

const Y_OFFSET = Vector2(Hex.HALFWIDTH, Hex.HEIGHT)
const X_OFFSET = Vector2(Hex.WIDTH, 0)

export(Array, Vector2) var indices = [Vector2.ZERO]
export(Dictionary) var distribution = {
	"hills": 0,
	"forest": 0,
	"mountains": 0,
	"fields": 0,
	"pasture": 0,
	"desert": 1,
}
export(Array, int) var chits = []

func _ready():
	var tiles = []
	for tile in distribution:
		for _i in range(distribution[tile]):
			tiles.append(tile)
	randomize()
	tiles.shuffle()
	for index in indices:
		var hex = hex_prefab.instance()
		hex.name = "Hex#%d#%d" % [index.x, index.y]
		hex.translate(X_OFFSET * index.x)
		hex.translate(Y_OFFSET * index.y)
		add_child(hex)
		hex.type = tiles.pop_front()
		hex.index = index
