###############################################################################
# shops.des: The file for minivaults centered around a single shops. The
#            generic vaults, with the 'shop' tag, can be placed by themselves
#            or in sets of multiple shops throughout valid levels. The themed
#            vaults are excluded from the latter, but are collected here for
#            ease of reference.
#
# <<1>>      Generic
# <<2>>      Themed
# <<3>>      Multi
#
###############################################################################

lua {{
crawl_require('dlua/vault.lua')

MAX_RANDOM_SHOPS = 5

-- If a level gets shops, how many there are.
-- Just one most of the time; expected value is 1.42.
function num_shops()
    if crawl.x_chance_in_y(5, 6) then
        return 1
    else
        return crawl.random_range(2, MAX_RANDOM_SHOPS)
    end
end

function ks_shop_vault(e, glyphs)
  if e.is_validating() then
    e.subst('O = B')
    return
  end

  local is_shop = false
  local is_altar = false

  local params = dgn.map_parameters()
  if params ~= nil then
    local tag = unpack(params)
    if tag ~= nil then
      if tag == "shop" then
        is_shop = true
      elseif string.find(tag, "temple_overflow_generic_") ~= nil then
        is_altar = true
      end
    end
  end

  if is_shop then
    e.kfeat('O = any shop')
  elseif is_altar then
    e.subst('O = B')
  else
    e.tags('extra decor')
    e.subst('O = ' .. glyphs)
  end
end
}}

# XXX: Don't change the name of this vault!
# Gozag code uses it to find out where shops can normally place.
NAME: serial_shops
TAGS: allow_dup extra luniq
DEPTH: D, Depths, Orc, Elf, Shoals, Snake, Vaults
CHANCE: 15% (D)
CHANCE: 20% (Depths)
CHANCE: 30% (Orc)
CHANCE: 40% (Elf, Vaults)
CHANCE: 20% (Shoals, Snake)
{{
hook("post_place", function()
    local num = num_shops()

    if you.absdepth() > 10 and you.absdepth() <= 27
      and crawl.one_chance_in(30 - (you.absdepth() - 1))
    then
        dgn.place_maps { tag = "bzr_entry", count = 1 }
        num = num - 1
    end

    dgn.place_maps { tag = "shop", count = num }
end)
}}
MAP
ENDMAP

###############################################################################
# <<1>> Generic.
#       Tagged shop, may only contain a single shop. No threats.
#

NAME:   shop
TAGS:   allow_dup extra shop transparent
WEIGHT: 100
KFEAT:  O = any shop
MAP
O
ENDMAP

NAME:   shop_fountains
TAGS:   allow_dup extra shop transparent
KFEAT:  O = any shop
MAP
T.T
.O.
T.T
ENDMAP

NAME:   shop_statue
TAGS:   allow_dup extra shop
KFEAT:  O = any shop
MAP
@G.O.<.G@
ENDMAP

NAME:   shop_coins
TAGS:   allow_dup extra shop transparent
WEIGHT: 3
KFEAT:  O = any shop
MAP
$$$
$O$
$$$
ENDMAP

NAME:   shop_scrolls
TAGS:   allow_dup extra shop transparent
WEIGHT: 1
KFEAT:  O = scroll shop
ITEM:   nothing w:30 / scroll of noise w:10
MAP
ddd
dOd
ddd
ENDMAP

NAME: nicolae_shop_behind_doors
TAGS: allow_dup extra shop transparent
KFEAT: O = any shop
MAP
x+x
+O+
x+x
ENDMAP

NAME: nicolae_shop_crystal
TAGS: allow_dup extra shop transparent
KFEAT: O = any shop
MAP
b.b
.O.
b.b
ENDMAP

NAME: nicolae_shop_statue_plus
TAGS: allow_dup extra shop
KFEAT: O = any shop
MAP
   @
   G
   <
@G.O.G@
   .
   G
   @
ENDMAP

NAME: nicolae_shop_stone
TAGS: allow_dup extra shop transparent
KFEAT: O = any shop
MAP
  c
 ...
c.O.c
 ...
  c
ENDMAP

NAME: nicolae_shop_trees
TAGS: allow_dup extra shop transparent
KFEAT: O = any shop
MAP
  t
t.O.t
  t
ENDMAP

NAME: nicolae_shop_waterfront
TAGS: allow_dup extra shop no_pool_fixup
KFEAT: O = any shop
SUBST: v = wW
MAP
 www
wwvvW
wwO.@
wwvvW
 www
ENDMAP

NAME: nicolae_shop_overgrown_old_shop
TAGS: allow_dup extra shop transparent
WEIGHT: 5
KFEAT: O = antiques shop / antique weapon shop w:5 / antique armour shop w:5
NSUBST: 1 = . / 1
MONS: plant / nothing w:3
MAP
.....
.111.
.1O1.
.111.
.....
ENDMAP

# A shop owner has copied a temple entry for their shop. Is nothing sacred?
# (minmay_temple_entry_statues_fountains)
NAME: nicolae_shop_temple_entry_statues_fountains
TAGS: allow_dup extra shop transparent
WEIGHT: 5
SUBST: T = TV
KFEAT: O = any shop
MAP
G.G.G
.T.T.
G.O.G
.T.T.
G.G.G
ENDMAP

NAME: nicolae_shop_window_shopping
TAGS: allow_dup extra shop transparent
WEIGHT: 5
KFEAT: O = any shop
MAP
xxm.
+Om@
xxm.
ENDMAP

NAME: nicolae_shop_competitors_out_of_business
TAGS: allow_dup extra shop transparent
WEIGHT: 3
KFEAT: O = any shop
KFEAT: A = abandoned_shop
MAP
O.A
...
A.A
ENDMAP

####
# These three vaults were originally plain minivaults.
# They can still place as plain minivaults, in which case they have no
# shops.
NAME:  kennysheep_mini
TAGS:  shop temple_overflow_generic_1
DEPTH: D:4-, Depths, !D:$, !Depths:$
: ks_random_setup(_G)
: ks_shop_vault(_G, '{}CC')
MAP
cDc
FOF
c+c
ENDMAP

NAME:  kennysheep_mini_moat
TAGS:  shop temple_overflow_generic_1
DEPTH: D:4-, Depths, !D:$, !Depths:$
: ks_random_setup(_G)
SUBST: . : @
: ks_shop_vault(_G, '{}CC')
MAP
wwEww
wcDcw
HFOFH
wc+cw
ww@ww
ENDMAP

NAME:  kennysheep_little_box
TAGS:  shop temple_overflow_generic_1
DEPTH: D:4-, Depths, !D:$, !Depths:$
: ks_random_setup(_G)
: ks_shop_vault(_G, '{}C....')
MAP
cccDccc
cwwEwwc
cwt.twc
FH.O.HF
cwt.twc
cww.wwc
ccc+ccc
ENDMAP

NAME:  nicolae_diamond_shop
TAGS:  allow_dup extra shop transparent no_pool_fixup
KFEAT: O = any shop
SUBST: x : xcvbtGwl
MAP
...x...
..x.x..
.x...x.
x..O..x
.x...x.
..x.x..
...x...
ENDMAP

NAME:  nicolae_lakefront_shop
TAGS:  allow_dup extra shop transparent no_pool_fixup
KFEAT: O = any shop
SUBST: G : GTUtwx, w : wl
MAP
xxxxxxxx
x.....Gx
..www..x
.wwwww.x
@wwwwwOx
.wwwww.x
..www..x
x.....Gx
xxxxxxxx
ENDMAP

NAME:  nicolae_square_shop
TAGS:  allow_dup extra shop transparent
KFEAT: O = any shop
SUBST: c : cvbn
MAP
   ..cc
 cc..cc
 cc....
...O...
....cc
cc..cc
cc..
ENDMAP

NAME:    nicolae_inconvenience_store
TAGS:    extra shop transparent no_pool_fixup
DEPTH:   D:4-, Depths
WEIGHT:  5
KFEAT:   a = iron_grate
KFEAT:   O = any shop
SHUFFLE: xm/cn/va/ll/ww
MAP
.............
.xxxxxmxxxxx.
.x...........
.x.xxxmxxxxx.
.x.x.......x.
.x.x.xmxxx.x.
.x.x.x...x.x.
.m.m.mOm.m.m.
.x.x.xmx.x.x.
.x.x.....x.x.
.x.xxxmxxx.x.
.x.........x.
.xxxxxmxxxxx.
.............
ENDMAP

NAME:    nicolae_stop_n_shop_1
TAGS:    allow_dup extra shop transparent
DEPTH:   D:4-, !D:$, Depths:2-, !Depths:$, Shoals:2-, !Shoals:$, Snake:2-, \
         !Snake:$, Elf:2-, !Elf:$
KFEAT:   O = any shop
SHUFFLE: {}/[]/()
SUBST:   D : G., E : G., F : G.
MAP
D...E
.....
..}...F
.......
E...O...E
  .......
  F...{..
    .....
    E...D
ENDMAP

NAME:    nicolae_stop_n_shop_2
TAGS:    allow_dup extra shop transparent
DEPTH:   D:4-, !D:$, Depths:2-, !Depths:$, Shoals:2-, !Shoals:$, Snake:2-, \
         !Snake:$, Elf:2-, !Elf:$
KFEAT:   O = any shop
SHUFFLE: {}/[]/()
SUBST:   D : G_, E : G_, F : G_
CLEAR:   _
MAP
  E F E
 .......
D.}.O.{.D
 .......
  E F E
ENDMAP

NAME:  nicolae_take_the_stairs
TAGS:  shop extra
DEPTH: D:4-, !D:$, Depths, !Depths:$, Shoals, !Shoals:$, Snake, !Snake:$, \
       Elf, !Elf:$
KFEAT: O = any shop
SUBST: } = }])
MAP
.ccccccc.
.n.....n.
@n.O.}.n@
.n.....n.
.ccccccc.
ENDMAP

###############################################################################
# <<2>> Themed.
#       Not tagged shop, but still contains one. Can have threats, and can have
#       have a specific custom item list. Even if the below examples don't show
#       it, try to have some restraint with additions here.
#

#####################################################
# Custom venom shop
NAME:    guppyfry_shop_venom
TAGS:    no_monster_gen transparent
DEPTH:   D:4-, Depths
MONS:    ball python w:5 / adder / water moccasin, place:Snake:1
KFEAT:   v = general shop type:Serpentskin suffix:Sales count:7 ; \
         w:8 dart ego:poisoned | w:4 dart ego:curare | \
         w:3 ring of poison resistance | w:6 randbook disc:poison | \
         w:2 staff of poison | w:4 any weapon ego:venom | \
         w:4 any armour ego:poison_resistance | w:1 swamp dragon scales
SUBST:   ? = 2..
: if you.absdepth() < 13 then
SUBST:   2 = 1
: end
MAP
xxxxx
x???x
+?v?+
x???x
xxxxx
ENDMAP

#####################################################
# Custom earth shop
NAME:    guppyfry_shop_earth
TAGS:    no_monster_gen transparent
DEPTH:   D:11-, Depths
KMONS:   1 = gargoyle / basilisk / earth elemental / cyclops w:3
KMONS:   2 = stone giant / catoblepas / deep troll earth mage / boulder beetle / \
             iron dragon w:4
ITEM:    stone
KFEAT:   v = general shop type:Pet suffix:Rocks count:7 ; \
         w:15 stone | w:15 large rock | w:8 hunting sling | w:1 fustibalus | \
         w:8 sling bullet | w:7 tin of tremorstones | w:8 wand of digging | \
         w:5 randbook disc:earth | w:2 book of the earth | \
         w:2 book of geomancy | w:2 book of stone | w:2 book of iron | \
         w:2 book of the moon | w:2 book of blasting |\
         w:4 staff of earth | w:1 crystal plate armour
SUBST:   ? = 2d.
: if you.absdepth() < 16 then
SUBST:   2 = 1
: end
MAP
.......
.xx+xx.
.x???x.
.m?v?m.
.x???x.
.xx+xx.
.......
ENDMAP

#####################################################
# Custom blood shop
NAME:    guppyfry_shop_blood
TAGS:    no_monster_gen transparent
DEPTH:   D:12-, Depths
KMONS:   1 = vampire / bat
KMONS:   2 = vampire / vampire mage / vampire knight
KFEAT:   v = general shop type:Blood suffix:Bar count:7 ; \
         w:70 nothing | w:10 any weapon ego:vampirism | \
         w:9 randbook disc:necromancy | w:1 book of annihilations
SUBST:   ? = 2.Y
: if you.in_branch("D") then
SUBST:   2 = 1
: end
MAP
xxxxx
x???x
+?v?+
x???x
xxxxx
ENDMAP

#####################################################
# Sells only evil items.
NAME: nicolae_evil_shop
WEIGHT: 2
TAGS: transparent
DEPTH: D:6-, Depths
SUBST: G : YlG
# I couldn't decide on just one alliterative name.
: local shopname = util.random_from({"type:Blasphemy suffix:Boutique",
:   "type:Evil suffix:Emporium", "type:Profane suffix:Products",
:   "type:Sacrilege suffix:Store", "type:Wicked suffix:Wares"})
: kfeat("s = general shop " .. shopname .. " ; \
:   any weapon ego:draining w:15 | any weapon ego:pain | \
:   any weapon ego:vampirism | any weapon ego:chaos w:1 | demon blade w:5 | \
:   demon trident w:5 | demon whip w:5 | scroll of torment | staff of death | \
:   book of necromancy | book of death | book of unlife | \
:   book of pain | book of decay | \
:   randbook disc:necromancy w:5 | necronomicon w:1 | grand grimoire w:1 | \
:   sceptre_of_torment w:1 | scythe_of_curses w:1 | majin-bo w:1 | \
:   black_knights_barding w:1 | obsidian_axe w:1 | damnation w:1 | \
:   sword_of_zonguldrok w:1")
: if not you.in_branch("D") then
KFEAT: a = altar_kikubaaqudgha / altar_yredelemnul / altar_makhleb / \
           altar_beogh w:1 / altar_lugonu w:1
: end
MAP
...   ...
.G.a.s.G.
...   ...
ENDMAP

#####################################################
# Items related to the good gods thematically; healing, silver, holy wrath,
# etc.
NAME: nicolae_good_shop
WEIGHT: 2
DEPTH: D:6-, Depths
TAGS: no_monster_gen no_trap_gen transparent
SHUFFLE: _s
KFEAT: s = general shop type:Hallowed suffix:Reliquary ; \
   potion of heal wounds | potion of curing | \
   boomerang ego:silver w:2 | javelin ego:silver w:2 | \
   any weapon ego:holy_wrath | scroll of holy word |\
   amulet of faith w:2 | ring of positive energy w:5 |\
   any armour ego:positive_energy w:5
: if not you.in_branch("D") then
KFEAT: _ = altar_the_shining_one / altar_zin / altar_elyvilon
: end
KPROP: 1 = no_tele_into
KMASK: 1 = opaque
MONS: angel
MAP
nnn
n1n
nnn
._.
...
.s.
ENDMAP

#####################################################
# All bardings, all the time.
NAME: nicolae_barding_shop
DEPTH: D:8-, Depths, Snake, !Snake:$
WEIGHT: 1
TAGS: transparent
: if you.in_branch("Snake") then
KMONS: s = naga w:50 / naga warrior
: else
KMONS: s = centaur w:50 / centaur warrior
: end
KFEAT: s = armour shop type:Specialty suffix:Armours count:3 use_all ; \
   barding | barding | barding good_item
MAP
.......
..xxx..
.x...x.
.x.s.x.
.x...x.
..xxx..
.......
ENDMAP

#####################################################
# Sells conjurations-heavy books, destructive wands, etc.
NAME: nicolae_blasting_shop
DEPTH: D:8-, Depths
TAGS: no_monster_gen no_item_gen transparent extra
MARKER: s = lua:fog_machine { cloud_type = "flame", \
             pow_min = 3, pow_max = 5, delay_min = 50, delay_max = 90, \
             start_clouds = 1, size = 3, walk_dist = 0, spread_rate= 0 }
KFEAT: s = general shop type:Demolitions suffix:Depot ; \
   book of conjurations | book of power | book of annihilations | \
   book of blasting |\
   randbook disc:conjuration | book of storms | book of lightning | \
   wand of iceblast | wand of flame | wand of mindburst | \
   condenser vane | staff of conjuration | \
   wand of acid | lightning rod | phial of floods | scroll of immolation | \
   book of flames | book of fire | book of air | manual of conjurations | \
   manual of evocations
FTILE: ' = floor_rough_red
COLOUR: ' = red
MAP
  ...
 ..x..
..'''..
.x's'x.
..'''..
 ..x..
  ...
ENDMAP

#####################################################
# Contains only four items: two evocable items/wands, a staff, and a randbook,
# associated with one of each of the four elemental schools.
NAME: nicolae_elemental_shop
TAGS: no_monster_gen no_item_gen no_pool_fixup transparent extra
DEPTH: D:4-, Depths
SHUFFLE: AB
NSUBST: A = a / l / w / x
SUBST: B = .
KPROP: l = no_cloud_gen
MARKER: a = lua:fog_machine { cloud_type = "thin mist", \
            pow_min = 100, pow_max = 100, delay = 1, \
            size = 1, walk_dist = 0, start_clouds = 1 }
{{
  local evocables = {"wand of flame","wand of iceblast",
                     "lightning rod","tin of tremorstones"}
  local staffs    = {"staff of fire","staff of cold",
                     "staff of air","staff of earth"}
  local randbooks = {"randbook disc:fire","randbook disc:ice",
                     "randbook disc:air","randbook disc:earth"}
  local choices   = {1, 2, 3, 4}
  local i, j, temp
  for i = 4, 2, -1 do
     j = crawl.random_range(1,i)
     temp = choices[j] ; choices[j] = choices[i] ; choices[i] = temp
  end
  local inventory = evocables[choices[1]] .. " | " .. evocables[choices[2]] ..
           " | " .. staffs[choices[3]] .. " | " .. randbooks[choices[4]]
  kfeat("s = general shop type:Elemental suffix:Accessories count:4 use_all ; "
         .. inventory )
}}
MAP
.......
.B.A.B.
.......
.A.s.A.
.......
.B.A.B.
.......
ENDMAP

# Sells only randbooks. All unique first editions with goofy names.
NAME: nicolae_rare_books
TAGS: transparent extra
DEPTH: Elf, Depths
KFEAT: S = book shop type:One-of-a-Kind suffix:Books count:5 ; \
       any fixed theme book | any fixed level book
MAP
 c.c
.....
c.S.c
.....
 c.c
ENDMAP

# Why not take a chance on an unidentified artefact?
NAME: nicolae_antique_artefacts
TAGS: transparent extra
DEPTH: D:10-, Depths
WEIGHT: 1
SHUFFLE: -m
SUBST: - = .
KFEAT: m = iron_grate
KFEAT: S = antiques shop type:Antique suffix:Artefacts count:6 ; \
   any weapon randart | any armour randart | any jewellery randart w:4
MAP
.......
.-vmv-.
.v...v.
.m.S.m.
.v...v.
.-vmv-.
.......
ENDMAP

# Get away from it all.
NAME: nicolae_island_escapes
DEPTH: D:7-, !D:$, Depths, !Depths:$, Shoals, !Shoals:$, Swamp, !Swamp:$
TAGS: no_item_gen no_monster_gen water_ok no_tide no_pool_fixup
WEIGHT: 5
SHUFFLE: Aa/Bb
SUBST: Aa = t, B = ..t, b = .
KFEAT: S = general shop type:Island suffix:Escapes count:7 ; \
 scroll of blinking | scroll of teleportation w:15 | scroll of fog w:8 | \
 potion of flight | potion of invisibility w:8 | potion of haste w:3 | \
 ring of flight w:5 | wand of digging w:4
MAP
  wwwwwwwww
 wwwwwwwwwww
 wwwwwwwwwww
 wwwwBABwwww
@wwwa...Awww
@wwwb.S>Bwww
@wwwa...Awww
 wwwwBABwwww
 wwwwwwwwwww
 wwwwwwwwwww
  wwwwwwwww
ENDMAP

# Eat the purple.
NAME: nicolae_transmutations_shop
TAGS: transparent no_item_gen no_monster_gen extra
DEPTH: D:8-, Depths, Zot
COLOUR: m = magenta
TILE: m = dngn_transparent_wall_magenta
KFEAT: S = general shop type:Changing suffix:Room count:7 ; \
   potion of mutation | potion of lignification | book of changes w:5 | \
   wand of polymorph | book of transfigurations w:5 | book of alchemy w:5 \
   | randbook disc:transmutation w:5 | plutonium_sword w:1
MARKER: F = lua:fog_machine { cloud_type = "mutagenic fog", pow_min = 50, \
   pow_max = 50, delay = 1, size = 1, walk_dist = 0, start_clouds = 1, \
   spread_rate = 0, excl_rad = 0 }
MAP
.........
.mmmmmmm.
.mFFFFFm.
.m....Fm.
....S.Fm.
.m....Fm.
.mFFFFFm.
.mmmmmmm.
.........
ENDMAP

NAME:   doesnt_shop_hydraphobe
DEPTH:  D:5-11
WEIGHT: 5
TAGS:   transparent no_pool_fixup
KPROP:  -1wP = no_tele_into
KMASK:  -w = no_monster_gen
KMASK:  -1wP = no_item_gen
KMASK:  -1wP = opaque
MONS:   hydra
KMONS:  P = plant
KFEAT:  P = shallow_water
KFEAT:  S = weapon shop type:Hydra suffix:Hut count:7 ; falchion ego:flaming | \
    long sword ego:flaming | scimitar ego:flaming | great sword ego:flaming | \
    hand axe ego:flaming | broad axe ego:flaming | war axe ego:flaming | \
    battleaxe ego:flaming | lajatang ego:flaming | halberd ego:flaming | \
    scythe ego:flaming | glaive ego:flaming | hand crossbow ego:freezing | \
    arbalest ego:freezing | shortbow ego:freezing | longbow ego:freezing
FTILE:  -1wP = floor_lair
COLOUR: -1 = brown
MAP
.......
.ccccc.
.cwP1c.
.c---c.
.cnnnc.
.......
...S...
.......
ENDMAP

# Get your favourite rare base type early in the game! As long as you don't mind
# enchanting and branding it yourself...
NAME:    minmay_shop_damaged
TAGS:    transparent extra
# not interesting after Lair
DEPTH:   D:4-10
KFEAT:   S = general shop type:Lightly-Used suffix:Armoury ; \
             damaged ego:none demon whip | \
             damaged ego:none eveningstar | \
             damaged ego:none quick blade | \
             damaged ego:none demon blade | \
             damaged ego:none double sword | \
             damaged ego:none triple sword | \
             damaged ego:none executioner's axe | \
             damaged ego:none demon trident | \
             damaged ego:none bardiche | \
             damaged ego:none lajatang | \
             damaged ego:none fustibalus | \
             damaged ego:none triple crossbow | \
             damaged ego:none longbow | \
             damaged ego:none crystal plate armour | \
             damaged ego:none barding | \
             damaged ego:none pearl dragon scales | \
             damaged ego:none gold dragon scales
MAP
S
ENDMAP

NAME:    minmay_shop_chei
TAGS:    transparent extra
DEPTH:   D:7-
WEIGHT:  5
KFEAT:   _ = altar_cheibriados
# Determine items and their enchantment for the shop.
{{
-- The enchantment bonus for ponderousness only gets applied to naturally
-- generated items, so I have to duplicate it here in order to get the same
-- distribution of enchantments as naturally generated plate of ponderousness.
local plateEnchant = 3 + crawl.random2(3) + crawl.random2(8) +
    (crawl.x_chance_in_y(21 + you.absdepth(), 300) and crawl.random2(3) or 0)
if plateEnchant > 10 then plateEnchant = 10 end

-- And that enchantment bonus is too good for CPA, so use a super complicated
-- custom formula for the CPA's enchantment.
local cpaEnchant = crawl.random2(6)

-- Don't want to have the same items every time, but also don't want to pick
-- the same unrandart twice. So build a custom list...
local items = {"black knight's barding",
               "hat of pondering",
               "crystal plate armour ego:ponderousness plus:" .. cpaEnchant,
               "plate armour ego:ponderousness plus:" .. plateEnchant}
local itemCount = crawl.random2(2) + 1
local chosen = {}
local kstr =
    "S = armour shop name:Cheibriados type:Comfort suffix:Zone use_all ; "
local i = 0
while i < itemCount do
    local itm = items[crawl.random2(#items) + 1]
    if not (chosen[itm]) then
        i = i + 1
        chosen[itm] = true
        kstr = kstr .. itm
        if i < itemCount then kstr = kstr .. " | " end
    end
end
kfeat(kstr)
}}
MAP
 ...
.._..
.G.G.
..S..
 ...
ENDMAP

NAME:   minmay_shop_enchanted_jewellery
DEPTH:  D:4-, Depths, Orc, Elf, Shoals, Snake, Vaults
TAGS:   transparent extra
WEIGHT: 5
KFEAT:  S = jewellery shop ; \
            ring of strength | \
            ring of dexterity | \
            ring of intelligence | \
            amulet of reflection | \
            ring of evasion | \
            ring of protection | \
            ring of slaying w:3
MAP
S
ENDMAP

NAME:   minmay_shop_mayhem
DEPTH:  D:4-, Depths, Orc, Elf, Shoals, Snake, Vaults
TAGS:   transparent extra
WEIGHT: 3
# Only deals in items that damage multiple targets, only has spellbooks in which
# ALL of the spells damage multiple targets.
{{
local kstr = "S = general shop type:Mayhem suffix:Merchandise ; " ..
             "hand axe w:5 | " ..
             "war axe | " ..
             "broad axe w:5 | " ..
             "battleaxe | " ..
             "executioner's axe w:2 | " ..
             "book of fire w:5 | " ..
             "the unrestrained analects w:5 | " ..
             "wand of iceblast"

-- Unfortunately this can still result in the unrandart being picked twice or
-- more in the shop (resulting in the shop having regular clubs/great maces).
-- unrandart axes aren't included here since one of the above axes can already
-- get turned into them.
if not you.unrands("devastator") then
      kstr = kstr .. "|devastator w:1"
end
if not you.unrands("firestarter") then
      kstr = kstr .. "|firestarter w:1"
end

kfeat(kstr)
}}
MAP
S
ENDMAP

NAME:   minmay_shop_mass
DEPTH:  D:4-, Depths, Orc, Elf, Shoals, Snake, Vaults
TAGS:   transparent extra
WEIGHT: 3
# Only deals in items that are probably really heavy.
KFEAT:  S = general shop type:Mass suffix:Market ; \
        large rock w:30 | \
        giant club w:20 | \
        giant spiked club | \
        great mace | \
        executioner's axe w:2 | \
        triple sword w:2 | \
        bardiche w:5 | \
        plate armour w:20 | \
        tower shield | \
        crystal plate armour w:1
MAP
S
ENDMAP

# top tier equipment for a single gold... if you're on zot:5
NAME:   hellmonk_bargain_basement
DEPTH:  Zot:5
WEIGHT: 3
KFEAT:  S = general shop type:Last-Chance suffix:Deals greed:0 count:7 ; \
 any ring randart w:15 | any amulet randart w:15 | quick blade randart | \
 pearl dragon scales randart | executioner's axe randart | \
 triple sword randart | triple crossbow randart | longbow randart | \
 fustibalus randart | bardiche randart | eveningstar randart | \
 crystal plate armour randart | any armour good_item randart w:50
MAP
  t
 ...
T.S.T
 ...
  T
ENDMAP

# The last holdout in a failed strip mall. A chance to pick up items at a
# potentially very steep discount... if there's anything good left, that is.
# The greed can range from 0 to 9 with an average of 4.5.
# The item count can range from 1 to 7 with an average of 4.
# There is a 0.2% chance of rolling greed = 0, which makes everything in the
# store cost one gold. Hopefully it's not just +0 robes and scrolls of noise.
NAME:   nicolae_shop_clearance
TAGS:   transparent
DEPTH:  D:4-, Depths, Orc, Elf, Snake, Shoals, Vaults, Zot
{{
local greed = crawl.roll_dice(9, 2) - 9
local count = crawl.roll_dice(6, 2) - 5
kfeat("S = general shop type:CLEARANCE_SALE! suffix:EVERYTHING_MUST_GO! \
           greed:" .. greed .. " count:" .. count)
}}
KFEAT:  D = abandoned_shop
NSUBST: D = S / D
MAP
xxxxxxx
xD.D.Dx
.......
...V...
.......
xD.D.Dx
xxxxxxx
ENDMAP

NAME:   nicolae_shop_firing_range
TAGS:   transparent no_monster_gen no_item_gen no_tide
DEPTH:  D:4-, Depths, Orc, Elf, Shoals, Snake, Vaults
KMONS:  DE = training dummy
KITEM:  D = arrow q:1 / bolt q:1 / sling bullet q:1 / nothing w:20, \
            arrow q:1 / bolt q:1 / sling bullet q:1 / nothing w:20, \
            arrow q:1 / bolt q:1 / sling bullet q:1 / nothing w:20
KITEM:  H = arrow q:1 / bolt q:1 / sling bullet q:1 / javelin q:1 / dart q:1
KITEM:  E = throwing net q:1
# Launchers are weighted so they have the same total weight as the projectiles.
# The slightly-higher weights go to the better weapons, because I'm nice.
KFEAT:  S = weapon shop type:Firing suffix:Range ; dart | throwing net | \
        sling bullet | boomerang | javelin | large rock | arrow | bolt | \
        hunting sling w:11 | fustibalus w:12 | shortbow w:11 | longbow w:12 | \
        hand crossbow w:11 | arbalest w:11 | triple crossbow w:12 | \
        manual of throwing w:1 | manual of slings w:1 | manual of bows w:1 | \
        manual of crossbows w:1
NSUBST: D = E / D
SUBST:  ' = H .:25
MAP
.....
.xxxxxxxx
.x'''''Dx
.S'''''Dx
.x'''''Dx
.xxxxxxxx
.....
ENDMAP

# Gadget shops are back! Well, one gadget shop is back.
NAME:    nicolae_shop_gadgets
TAGS:    transparent
DEPTH:   D:4-, Depths, Orc, Elf, Shoals, Snake, Vaults
KFEAT:   S = general shop type:Gadget suffix:Gallery count:8 ; \
         any wand | any misc
SHUFFLE: cvmb
MAP
cc.vv
c...v
..S..
m...b
mm.bb
ENDMAP

# Sells wands with 66% more charges than the usual item-generation maximum,
# with a matching 66% markup (rounded up to 70% because of how greed works.)
NAME:    nicolae_shop_overcharged_wands
TAGS:    transparent
DEPTH:   D:4-, Depths, Orc, Elf, Shoals, Snake, Vaults
KFEAT:   S = general shop type:Overcharged suffix:Wands greed:17 count:6 ; \
         wand of digging charges:15 | wand of iceblast charges:25 | \
         wand of acid charges:25 | wand of charming charges:25 | \
         wand of paralysis charges:25 | wand of polymorph charges:25 | \
         wand of mindburst charges:40 | wand of flame charges:55
SHUFFLE: bv/bc/cv/bm/vm/cm
MAP
.......
..b.v..
.b...v.
...S...
.v...b.
..v.b..
.......
ENDMAP

NAME:  nicolae_shop_self_help
TAGS:  transparent no_pool_fixup
DEPTH: D:4-, Depths, Orc, Elf, Shoals, Snake, Vaults
KFEAT: S = book shop type:Self-Improvement suffix:Boutique count:4 ; \
           any manual
SUBST: T : TUw
MAP
 ww.ww
www.www
wwT.Tww
...S...
wwT.Tww
www.www
 ww.ww
ENDMAP

NAME:   nicolae_shop_sticking_my_neck_out
TAGS:   transparent
DEPTH:  D:4-, Depths, Elf, Snake
KFEAT:  S = general shop type:Neck suffix:Hole count:7 use_all ; \
        cloak | cloak | scarf | scarf | any amulet | any amulet | any amulet
MAP
cc     cc
..c   c..
...ccc...
....S....
...ccc...
..c   c..
cc     cc
ENDMAP

###############################################################################
# <<3>> Multi
#       Not tagged shop, and has no threats. Contain possibly multiple shops in
#       a somewhat generic theme. Kept here for a certain ease of reference.
#

# 3 shops
NAME:    minmay_shop_grove
TAGS:    extra luniq_floating_shops transparent
DEPTH:   D:4-, Depths, Elf, Snake
ORIENT:  float
MONS:    plant / bush w:2
KFEAT:   B = book shop
KFEAT:   C = jewellery shop
SUBST:   1 : 1.
SUBST:   1 = 1:9 .:1
SUBST:   x : xc v:2 b:2
SHUFFLE: BC
# The empty arch is intentional!
MAP
  xxxxxxx
 xxtttttxx
xxtt1.1ttxx
xtt..B..ttx
xt.C...C.tx
xt1..T..1tx
xt11...11tx
xttttAttttx
xxxxx@xxxxx
ENDMAP

# 1 (33%) or 4 (66%) shops
NAME:    minmay_shop_grid_forest
TAGS:    extra luniq_floating_shops transparent
DEPTH:   D:4-, Depths, Elf, Snake
KFEAT:   A = any shop
SHUFFLE: ABC
SUBST:   t : t:11 x:1 c:1 b:1 v:1
SUBST:   B : .:12 C:6 x:1 c:1 b:1 v:1 G:1 T:1
SUBST:   C : T:12 x:1 c:1 b:1 v:1 G:1 t:1
MAP
.........
.t.t.t.t.
..B.C.B..
.t.t.t.t.
..C.A.C..
.t.t.t.t.
..B.C.B..
.t.t.t.t.
.........
ENDMAP

# 1 (25%), 2 (25%), or 3 (50%) shops
NAME:    minmay_shop_star
TAGS:    extra luniq_floating_shops transparent
DEPTH:   D:4-, Depths, Elf, Snake
ORIENT:  float
KFEAT:   A = any shop
SHUFFLE: AB
SUBST:   b : x:20 cv b:5 .:5 m:5 G:5 t:5
SUBST:   A : A:90 .xcvbmGtT
SUBST:   B = A
MAP
       x@x
       x.x
      xx.xx
      x...x
xxxxxxxb.bxxxxxxx
@.....b...b.....@
xxx.....A.....xxx
  xxx.b...b.xxx
    xxx.B.xxx
  xxx.b...b.xxx
xxx.....A.....xxx
@.....b...b.....@
xxxxxxxb.bxxxxxxx
      x...x
      xx.xx
       x.x
       x@x
ENDMAP

# 2 (50%) or 4 (50%) shops
NAME:    minmay_shoptagon
TAGS:    extra luniq_floating_shops transparent
DEPTH:   D:4-, Depths, Elf, Snake
ORIENT:  float
KFEAT:   A = any shop
SUBST:   a : . m:1 G:1
SUBST:   b : xcvbmGt
SUBST:   d : .:60 cvbmGt
SHUFFLE: AB, CD
SUBST:   C : .:80 xcvbmGtT
SUBST:   D : .:80 xcvbmGtT
SUBST:   B : A.
MAP
    xxx@xxx
   xxd...dxx
  xxd..D..dxx
 xxd.......dxx
xxd....B....dxx
xd...C...C...dx
x.....aaa.....x
@.D.A.aba.A.D.@
x.....aaa.....x
xd...C...C...dx
xxd....B....dxx
 xxd.......dxx
  xxd..D..dxx
   xxd...dxx
    xxx@xxx
ENDMAP

NAME:  nicolae_specific_store
TAGS:  extra transparent no_pool_fixup
DEPTH: D:4-, Depths, Orc, Elf, Shoals, Snake
KFEAT: D = general shop type:General suffix:Store
KFEAT: E = general shop type:Specific suffix:Store count:1
SUBST: G : GTUtwx, x : x:120 c:60 bv.
MAP
xx...xx
xG...Gx
xD...Ex
xG...Gx
xx...xx
ENDMAP

# Chance of X shops: 1: 15%, 2: 30%, 3: 30%, 4: 15%, 5: 5%, 6 : 5%
NAME:    nicolae_wooded_promenade
TAGS:    extra luniq_floating_shops transparent no_pool_fixup
DEPTH:   D:4-, Depths, Elf, Snake
KFEAT:   s = any shop
# s = shop, y and z = two different kinds of features
# Unshuffled corresponds to ysyzyz
SHUFFLE: DEFHJK/ysyyzy/syyyyz/syzzys/syyzzs/yszzsy/ysyzsz/sysyzy/syszyz/ \
         ysyszs/ysyszs/sssyzy/sssyzy/ssyzzs/ssysyz/syssys/ssyyss/sssysy/ \
         ssssys/ssssss
SUBST:   DFJ = y, HK = z, E = s, y : GGTTUt, z : GGTTUt, - : ww.
MAP
    xxxxxxxxxxx
    xtttttttttx
    xt.......tx
    xt.D.E.F.tx
    @.........@
wwwwwwwww-wwwwwwwww
wwwwwwwww-wwwwwwwww
    @.........@
    xt.H.J.K.tx
    xt.......tx
    xtttttttttx
    xxxxxxxxxxx
ENDMAP
