Added Y/N confirmation when buying or selling items at stores.

This commit is contained in:
Martin Haye 2021-10-13 06:47:20 -07:00
parent 435e8e1473
commit 3fda48bbc0

View File

@ -203,6 +203,15 @@ def askQuantity(nMax, setSize)#1
return num
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Used by buy/sell. Different from the main getYN function in not clearing the text window
def storeAskYN()#1
byte sel
rawDisplayStr("? (Y/N)")
sel = getUpperKey
return sel == 'Y'
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def browseItem(num)#0
word pItem, price, compSkip, pComp, quantity
@ -214,7 +223,16 @@ def browseItem(num)#0
displayItemBrowse(pItem, price, matchEquipped(pItem, compSkip))
displayItemMenu(price, compSkip or matchEquipped(pItem, 1+compSkip))
sel = getUpperKey()
if sel == 'B' and price <= global=>w_gold
if sel == 'B'
if price > global=>w_gold
displayMsg("Need more gold.", True, 400) // beep, pause 400
return
fin
displayMsg("Buy ", False, 0) // no beep, no pause
pItemutilModule()=>itemutil_displayItemName(pItem)
if !storeAskYN; return; fin
pComp = scanForNamedObj(pPlayer=>p_items, pItem=>s_name)
if pComp
if pItem->t_type == TYPE_FANCY_ITEM and pItem=>w_count > 0
@ -354,6 +372,10 @@ def sellItem(num)#0
pItem = pageItems[num]
price = pagePrices[num]
displayMsg("Sell ", False, 0) // no beep, no pause
pItemutilModule()=>itemutil_displayItemName(pItem)
if !storeAskYN; return; fin
// For countable items, sell in sets of w_storeAmount
if pItem->t_type == TYPE_FANCY_ITEM and pItem=>w_count
if pItem=>w_count < pItem=>w_storeAmount
@ -381,6 +403,7 @@ def sellItem(num)#0
displayMsg("Sold for ", FALSE, 0)
rawDisplayf1("%d gold.", gain)
pause(800)
return
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -412,7 +435,10 @@ def _sellToStore(profitPercent)#1
elsif choice >= 'A' and (choice-'A' < nItemsOnPage)
sellItem(choice-'A')
totalItems = iterateSellables(9999, 0)
if totalItems <= pageNum * PAGE_SIZE // sold last item on pg 2
if totalItems == 0
break
fin
if pageNum > 0 and totalItems <= pageNum * PAGE_SIZE // sold last item on pg >= 2
pageNum--
fin
elsif choice == $1B // Esc