--dofile("../defs/item_slot_defs.lua")

Shop = class("Shop")

function Shop:new()
	local shop = instance(self)	
	return shop
end

function Shop:set_container(con)
	self.container = con
end

function Shop:set_inventory(inv)
	self.inventory = inv
end


function Shop:set_location_name(name)
	self.location_name = name
	self:refresh_display_name()
end

function Shop:set_name(name)
	self.name = name
	self:refresh_display_name()
end

function Shop:refresh_display_name()
	local name = self.name
	if self.location_name then
		name = self.location_name.. "'s "..name
	end
	self.display_name = name	
end

function Shop:get_display_name()
	return self.display_name
end

function Shop:fill_stock(rules)
	local slots = self.inventory:get_slots_of_type("for_sale")
	for index, slot in pairs(slots) do
		if not slot:get_item() then
			local item = self.container:generate_one_stock(rules)
			if item then
				--yay
				slot:set_item(item)
			end
		end
	end
end