-------------------------- Basic shops --------------------------
new_store
{
	define_as = "store.STORE_GENERAL"
	name = "General Store"
	display = '1' color = color.LIGHT_UMBER
	max_obj = 24
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	item_kinds =
	{
                { chance=100 item="& Ration~ of Food" },
                { chance=100 item="& Hard Biscuit~" },
                { chance=90 item="& Strip~ of Venison" },
                { chance=70 item="& Pint~ of Fine Wine" },
                { chance=80 item="& Pint~ of Fine Ale" },
                { chance=60 item="& Shovel~" },
                { chance=50 item="& Pick~" },
                { chance=100 item="& Iron Spike~" },
		{ chance=100 item="& torch~ #" },
		{ chance=100 item="& torch~ #" },
		{ chance=100 item="& torch~ #" },
		{ chance=100 item="& torch~ #" },
		{ chance=100 item="& torch~ #" },
		{ chance=100 item="& filthy rag~" },
		{ chance=100 item="& filthy rag~" },
		{ chance=100 item="& filthy rag~" },
		{ chance=25 item="& lantern~ #" },
		{ chance=100 item="& flask~ of oil" },
		{ chance=100 item="& flask~ of oil" },
		{ chance=100 item="& flask~ of oil" },
		{ chance=100 item="& flask~ of oil" },
		{ chance=100 item="& flask~ of oil" },
		{ chance=100 item="& bodkin arrow~" },
		{ chance=100 item="& bodkin arrow~" },
		{ chance=100 item="& sling stone~" },
		{ chance=100 item="& sling stone~" },
		{ chance=100 item="& cotton cloak~" },
	}
	buy =
	{
		TV_CORPSE,
		TV_FOOD,
		TV_LITE,
		TV_FUEL,
		TV_SPIKE,
		TV_SHOT,
		TV_ARROW,
		TV_CLOAK,
		TV_BOTTLE,
	},
}

new_store
{
	define_as = "store.STORE_ARMOURY"
	name = "Armoury"
	display = '2' color = color.SLATE
	max_obj = 24
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	item_kinds =
	{
		{ chance=100 item="& robe~" },
		{ chance=100 item="& soft leather jacket~" },
		{ chance=100 item="& splint mail~" },
		{ chance=100 item="& metal scale mail~" },
		{ chance=100 item="& chain mail~" },
		{ chance=100 item="& leather cap~" },
		{ chance=100 item="& partial helm~" },
		{ chance=100 item="& set~ of leather gloves" },
		{ chance=100 item="& wooden shield~" },
		{ chance=100 item="& buckler~" },
	}
	buy =
	{
		TV_BOOTS,
		TV_GLOVES,
		TV_LIGHT_HELM,
		TV_HEAVY_HELM,
		TV_SHIELD,
		TV_CLOAK,
		TV_LIGHT_ARMOUR,
		TV_HEAVY_ARMOUR,
	},
}

new_store
{
	define_as = "store.STORE_WEAPONS"
	name = "Weaponsmith"
	display = '3' color = color.WHITE
	max_obj = 24
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	item_kinds =
	{
		{ chance=100 item="& pike~" },
		{ chance=100 item="& pike~" },
		{ chance=100 item="& glaive~" },
		{ chance=100 item="& fauchard~" },
		{ chance=100 item="& flint axe~" },
		{ chance=100 item="& flint axe~" },
		{ chance=100 item="& biscayan axe~" },
		{ chance=100 item="& woodsman axe~" },
		{ chance=100 item="& club~" },
		{ chance=100 item="& club~" },
		{ chance=100 item="& hand hammer~" },
		{ chance=100 item="& flail~" },
		{ chance=100 item="& knife~" },
		{ chance=100 item="& knife~" },
		{ chance=100 item="& misericorde~" },
		{ chance=100 item="& main gauche~" },
		{ chance=100 item="& rapier~" },
		{ chance=100 item="& rapier~" },
		{ chance=100 item="& schiavona~" },
		{ chance=100 item="& sabre~" },
		{ chance=100 item="& short bow~" },
		{ chance=100 item="& short bow~" },
		{ chance=100 item="& bodkin arrow~" },
		{ chance=100 item="& bodkin arrow~" },
		{ chance=100 item="& short sling~" },
		{ chance=100 item="& short sling~" },
		{ chance=100 item="& sling stone~" },
		{ chance=100 item="& sling stone~" },

	}
	buy =
	{
		TV_SHOT,
		TV_ARROW,
		TV_BOW,
		TV_SLING,
		TV_HAFTED,
		TV_POLEARM,
		TV_SWORD,
		TV_KNIFE,
		TV_AXE,
		TV_MSTAFF,
	},
}

new_store
{
	define_as = "store.STORE_TEMPLE"
	name = "Temple"
	display = '4' color = color.GREEN
	max_obj = 24
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	item_kinds =
	{
		{ chance=100 item="& club~" },
		{ chance=100 item="& hand hammer~" },
		{ chance=100 item="& flail~" },
		{ chance=100 item="valarin favor" },
		{ chance=100 item="valarin favor" },
		{ chance=100 item="valarin favor" },
		{ chance=100 item="valarin favor" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="remove curse" },
		{ chance=100 item="remove curse" },
		{ chance=100 item="remove curse" },
		{ chance=100 item="greater remove curse" },
		{ chance=100 item="light healing" },
		{ chance=100 item="light healing" },
		{ chance=100 item="light healing" },
		{ chance=100 item="light healing" },
		{ chance=100 item="light healing" },
		{ chance=100 item="light curing" },
		{ chance=100 item="light curing" },
		{ chance=100 item="light curing" },
		{ chance=100 item="light curing" },
		{ chance=100 item="light curing" },
		{ chance=100 item="restore memories" },
		{ chance=100 item="restore memories" },
		{ chance=100 item="restore memories" },
		{ chance=100 item="healing" },
		{ chance=100 item="healing" },
		{ chance=100 item="curing" },
		{ chance=100 item="curing" },
		{ chance=100 item="curing" },
		{ chance=100 item="curing" },
		{ chance=100 item="curing" },
	}
	buy = function (obj)
		if obj.tval == TV_BOOK and obj.sval == 255 and (can_spell_random(obj.pval) == "prayer") then return true
		elseif obj.tval == TV_SCROLL then return true
		elseif obj.tval == TV_POTION then return true
		elseif obj.tval == TV_HAFTED then return true
		elseif obj.tval == TV_POLEARM and obj.flags[FLAG_BLESSED] then return true
		elseif obj.tval == TV_SWORD and obj.flags[FLAG_BLESSED] then return true
		elseif obj.tval == TV_KNIFE and obj.flags[FLAG_BLESSED] then return true
		elseif obj.tval == TV_AXE and obj.flags[FLAG_BLESSED] then return true
		end
	end
}
--I:100:Cure Light Wounds
--I:100:Cure Serious Wounds
--I:100:Cure Serious Wounds

new_store
{
	define_as = "store.STORE_ALCHEMY"
	name = "Alchemy shop"
	display = '5' color = color.BLUE
	max_obj = 24
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	item_kinds =
	{
		{ chance=100 item="identification" },
		{ chance=100 item="identification" },
		{ chance=100 item="identification" },
		{ chance=100 item="identification" },
		{ chance=100 item="identification" },
		{ chance=100 item="light" },
		{ chance=100 item="phase door" },
		{ chance=100 item="phase door" },
		{ chance=100 item="confuse monster" },
		{ chance=100 item="magic mapping" },
		{ chance=100 item="detect objects" },
		{ chance=100 item="detect traps" },
		{ chance=100 item="detect traps" },
		{ chance=100 item="detect traps" },
		{ chance=100 item="detect traps" },
		{ chance=100 item="detect invisible monsters" },
		{ chance=100 item="recharging" },
		{ chance=100 item="recharging" },
		{ chance=100 item="satisfy hunger" },
		{ chance=100 item="satisfy hunger" },
		{ chance=100 item="satisfy hunger" },
		{ chance=100 item="satisfy hunger" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="word of recall" },
		{ chance=100 item="greater identification" },
		{ chance=100 item="greater identification" },
		{ chance=100 item="greater identification" },
		{ chance=100 item="greater identification" },
		{ chance=100 item="greater identification" },
		{ chance=100 item="greater identification" },
		{ chance=100 item="restore strength" },
		{ chance=100 item="restore strength" },
		{ chance=100 item="restore intelligence" },
		{ chance=100 item="restore intelligence" },
		{ chance=100 item="restore dexterity" },
		{ chance=100 item="restore dexterity" },
		{ chance=100 item="restore wisdom" },
		{ chance=100 item="restore wisdom" },
		{ chance=100 item="restore constitution" },
		{ chance=100 item="restore constitution" },
		{ chance=100 item="restore charisma" },
	}
	buy =
	{
		TV_SCROLL,
		TV_POTION,
		TV_BOTTLE,
	},
}
--I:100:Restore Strength
--I:100:Restore Constitution
--I:100:Restore Strength
--I:100:Restore Constitution

new_store
{
	define_as = "store.STORE_MAGIC"
	name = "Magic shop"
	display = '6' color = color.RED
	max_obj = 24
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	item_kinds =
	{
                { chance=100 item="Protection" },
                { chance=100 item="Levitation" },
                { chance=100 item="Protection" },
                { chance=100 item="Fire Resistance" },
                { chance=100 item="Cold Resistance" },
                { chance=100 item={TV_RING, SV_RING_SLOW_DIGEST} },
                { chance=100 item={TV_AMULET, SV_AMULET_SLOW_DIGEST} },
                { chance=100 item="Acid Resistance" },
                { chance=100 item="Lightning Resistance" },
                { chance=100 item="Searching" },
                { chance=100 item="& book~ of #" },
                { chance=100 item="& lesser wand~ of #" },
                { chance=100 item="& lesser wand~ of #" },
                { chance=100 item="& lesser wand~ of #" },
                { chance=100 item="& lesser wand~ of #" },
                { chance=100 item="& wand~ of #" },
--                { chance=100 item={TV_ORB,3} },
--                { chance=100 item={TV_ORB,5} },
--                { chance=100 item={TV_ORB,8} },
--                { chance=100 item={TV_ORB,9} },
--                { chance=100 item={TV_ORB,14} },
--                { chance=60 item={TV_ORB,15} },
--                { chance=60 item={TV_ORB,16} },
--                { chance=60 item={TV_ORB,17} },
	}
	buy = function (obj)
		local buy =
		{
			[TV_AMULET] = true,
			[TV_RING] = true,
			[TV_ORB] = true,
			[TV_WAND] = true,
			[TV_SCROLL] = true,
			[TV_POTION] = true,
			[TV_MSTAFF] = true,
			--[TV_RANDART] = true,
		}

		if obj.tval == TV_BOOK and obj.sval == 255 and (can_spell_random(obj.pval) == "magic") then return true
		elseif obj.tval == TV_BOOK and obj.sval ~= 255 then return true
		elseif buy[obj.tval] == true then return true
		end
	end
}
-- Book
-- Wands
-- Staves

new_store
{
	define_as = "store.STORE_MARKET"
	name = "Black Market"
	display = '7' color = color.LIGHT_DARK
	max_obj = 24
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	store_maker = "full_random"
	flags =
	{
		LEVEL=function() return rng.range(25, 50) end
		STORE_MAINTAIN_TURNS = 500
	}
	buy = function(obj) return true end
}

new_store
{
	define_as = "store.STORE_HOME"
	name = "Home"
	display = '8' color = color.YELLOW
	max_obj = 24
	store_make_num = 0
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_DROP,	store.ACTION_GET,
		    store.ACTION_NONE,	store.NONE }
	owners = store.OWNER_PLAYER
	flags = { FREE=1 STORE_MAINTAIN_TURNS=0 }
}

new_store
{
	define_as = "store.STORE_BOOKS"
	name = "Book Store"
	display = '9' color = color.ORANGE
	max_obj = 24
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	item_kinds = {
		{ chance=100 item="& book~ of beginner cantrips"},
		{ chance=100 item="& book~ of #"},
		{ chance=100 item="& book~ of #"},
		{ chance=100 item="& book~ of #"},
	}
	flags = {
		LEVEL = function() return 30 end
	}

	buy =
	{
		TV_BOOK,
	},
}

new_store
{
	define_as = "store.STORE_PETS"
	name = "Pet Shop"
	display = '+' color = color.BLUE
	max_obj = 12
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	flags =
	{
                LEVEL=function() return rng.range(25, 50) end
	}
	item_kinds =
	{
		{ chance=100 item="summon symbiote" },
                { chance=100 item="& Hard Biscuit~" },
	}
}

new_store
{
	define_as = "store.STORE_BEASTMASTER"
	name = "Beastmaster Shanty"
	display = '+' color = color.GREEN
	max_obj = 0
	actions = { store.ACTION_BOUNTY_QUEST,	store.ACTION_NONE,
		    store.ACTION_RESEARCH_MON,	store.ACTION_NONE,
		    store.ACTION_NONE,	store.ACTION_NONE }
	owners = store.OWNER_BEASTMASTER
}

-------------------------- Bree shops --------------------------
new_store
{
	define_as = "store.BREE_MAYOR"
	name = "Mayor's Office"
	display = '+' color = color.ORANGE
	max_obj = 0
	actions = { store.ACTION_CHAT,	store.ACTION_NONE,
		    store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_NONE,	store.ACTION_NONE }
	owners = store.OWNER_MARLO
}

new_store
{
	define_as = "store.SOOTHSAYER"
	name = "The Soothsayer"
	display = '+' color = color.LIGHT_BLUE
	max_obj = 2
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_NONE,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	flags =
	{
                RANDOM=1
	}
	item_kinds =
	{
--                { chance=100 item="Divination" },
	}

}

new_store
{
	define_as = "store.INN_PRANCING_PONY"
	name = "The Prancing Pony"
	display = '+' color = color.WHITE
	max_obj        = 5
	store_make_num = 5 * 99
	actions = { store.ACTION_REST,	store.ACTION_NONE,
		    store.ACTION_SELL,	store.ACTION_BUY,
		    store.ACTION_NONE,	store.ACTION_EXAMINE }
	owners = store.OWNER_DEFAULT
	item_kinds =
	{
                { chance=100 item="& Ration~ of Food" },
                { chance=100 item="& Hard Biscuit~" },
                { chance=100 item="& Strip~ of Venison" },
                { chance=100 item="& Pint~ of Fine Wine" },
                { chance=100 item="& Pint~ of Fine Ale" },
	}

}

new_store
{
	define_as = "store.MUSEUM_MATHOM"
	name = "The Mathom-house"
	display = '+' color = color.GREEN
	max_obj = 1200
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_DROP,	store.ACTION_NONE,
		    store.ACTION_EXAMINE,	store.ACTION_NONE }
	owners = store.OWNER_DEFAULT
	flags =
	{
                MUSEUM=1 FREE=1 STORE_MAINTAIN_TURNS=0
	}

}

-------------------------- AMulet: Portable Hole --------------------------
new_store
{
	define_as = "store.STORE_MAGIC_HOME"
	name = "Portable Hole"
	display = '8' color = color.YELLOW
	max_obj = 5
	store_make_num = 0
	actions = { store.ACTION_NONE,	store.ACTION_NONE,
		    store.ACTION_DROP,	store.ACTION_GET,
		    store.ACTION_NONE,	store.ACTION_NONE }
	owners = store.OWNER_PLAYER
	flags = { FREE=1 STORE_MAINTAIN_TURNS=0 }
}


-------------------------- Lothlorien shops --------------------------
