Merchant bulk buy function (#7587)

Adds additional function to the merchant software - Bulk Buy.

Activating this function prompts the user to enter a number.

    If text is SOMEHOW entered, returns IC error message.
    If number lesser than 1 is entered, returns IC error message.
    Expects numbers equal or greater to 1.

Function then executes standard money-purchase function using a loop. This loop executes X amount of times where X is the number user entered, ensuring they purchase the amount of items they want to buy up to as much money as they actually have

    This makes sure they cannot abuse this to buy more things than they can afford.

This function greatly reduces lag caused by server spawning excess amount of items and makes merchant much more pleasant to play.

Compiled without errors, tested on up-to-date private server, worked as expected.
This commit is contained in:
Nerrathiel
2019-12-07 22:48:29 +01:00
committed by Erki
parent e281223c8f
commit ead72eee56
3 changed files with 67 additions and 2 deletions
+24 -1
View File
@@ -81,6 +81,26 @@
bank -= response
return
last_comms = "PAD NOT CONNECTED"
/datum/computer_file/program/merchant/proc/bulk_offer(var/datum/trader/T, var/num)
var/BulkAmount = input("How many items? (Buy 1-50 items. 0 to cancel.)") as num
if(istext(BulkAmount))
last_comms = "ERROR: NUMBER EXPECTED"
return
if(BulkAmount < 0 || BulkAmount > 50)
last_comms = "ERROR: POSITIVE NUMBER UP TO 50 EXPECTED"
return
if(pad)
for(var/BulkCounter = 0, BulkCounter < BulkAmount, BulkCounter++)
var/response = T.offer_money_for_trade(num, bank)
if(istext(response))
last_comms = T.get_response(response, "No thank you.")
else
last_comms = T.get_response("trade_complete", "Thank you!")
T.trade(null,num, get_turf(pad))
bank -= response
return
last_comms = "PAD NOT CONNECTED"
/datum/computer_file/program/merchant/proc/bribe(var/datum/trader/T, var/amt)
if(bank < amt)
@@ -216,6 +236,9 @@
if(href_list["PRG_offer_money_for_item"])
. = 1
offer_money(T, text2num(href_list["PRG_offer_money_for_item"])+1)
if (href_list["PRG_bulk_money_for_item"])
. = 1
bulk_offer(T, text2num(href_list["PRG_bulk_money_for_item"])+1)
if(href_list["PRG_what_do_you_want"])
. = 1
last_comms = T.what_do_you_want()
@@ -224,4 +247,4 @@
sell_items(T)
if(href_list["PRG_bribe"])
. = 1
bribe(T, text2num(href_list["PRG_bribe"]))
bribe(T, text2num(href_list["PRG_bribe"]))