extends BaseInventory

var rand:RandomNumberGenerator = RandomNumberGenerator.new()


func _ready():
	rand.randomize()


func _on_raceCar_road_entered(road):
	if is_network_master():
		if player != null:
			if player.is_in_group("first"):
				if route.get_last_road().get_index() <= (road.get_index() +2):
					type = rand.randi_range(0,roads.size() -2) # TODO: remove special, loop need fixes!
					index = rand.randi_range(0, roads[type].size() -1)
					route.rpc("add_road", roads[type][index], player.get_index())


func set_player(new_player:Player):
	player = new_player
	player.race_car.connect("road_entered",self,"_on_raceCar_road_entered")