Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit c70ea40

Browse files
authored
cook capitalism (#22852)
1 parent 201a9b7 commit c70ea40

File tree

2 files changed

+48
-16
lines changed

2 files changed

+48
-16
lines changed

code/modules/vending/_vending.dm

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
203203
/// used for narcing on underages
204204
var/obj/item/radio/alertradio
205205

206+
/// payout account (weakref) for custom items
207+
var/datum/weakref/custom_payout_account
208+
206209
/obj/item/circuitboard
207210
///determines if the circuit board originated from a vendor off station or not.
208211
var/onstation = TRUE
@@ -288,6 +291,17 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
288291
return
289292
set_light(powered() ? MINIMUM_USEFUL_LIGHT_RANGE : 0)
290293

294+
/obj/machinery/vending/update_desc()
295+
. = ..()
296+
desc = initial(desc)
297+
if(custom_payout_account)
298+
var/datum/bank_account/account = custom_payout_account.resolve()
299+
if(istype(account))
300+
desc += "\n"
301+
desc += span_notice("Custom orders are paid out to <b>[account.account_holder]</b>.")
302+
desc += "\n"
303+
desc += span_notice("Custom orders are priced at <b>[chef_price]</b> credits.")
304+
291305
/obj/machinery/vending/update_icon_state()
292306
if(stat & BROKEN)
293307
icon_state = "[initial(icon_state)]-broken"
@@ -657,6 +671,28 @@ GLOBAL_LIST_EMPTY(vending_products)
657671
P.amount++
658672
loaded_items++
659673

674+
if(custom_payout_account && custom_payout_account.resolve())
675+
return
676+
677+
var/obj/item/card/id/id_card = user.get_idcard()
678+
if(!istype(id_card))
679+
return
680+
681+
var/datum/bank_account/account = id_card.registered_account
682+
if(!istype(account))
683+
return
684+
685+
custom_payout_account = WEAKREF(account)
686+
// at the time of writing, tgui_input_number is nonfunctional
687+
// 10s timeout so people cant change price while a customer is shopping
688+
tgui_input_text_async(user, "Set a price for custom items (1-9999)", "Custom Price", "10", 4, FALSE, CALLBACK(src, PROC_REF(chef_price_update)), 10 SECONDS)
689+
690+
/obj/machinery/vending/proc/chef_price_update(entry)
691+
var/input_text = text2num(entry)
692+
if(isnum(input_text) && input_text >= 1 && input_text <= 9999)
693+
chef_price = input_text
694+
update_desc()
695+
660696
/obj/machinery/vending/exchange_parts(mob/user, obj/item/storage/part_replacer/W)
661697
if(!istype(W))
662698
return FALSE
@@ -884,7 +920,7 @@ GLOBAL_LIST_EMPTY(vending_products)
884920
vend_ready = FALSE //One thing at a time!!
885921

886922
// Charge the user
887-
if (!charge_user(chef_price, P.full_name, FALSE))
923+
if (!charge_user(chef_price, P.full_name, TRUE, TRUE))
888924
vend_ready = TRUE
889925
return
890926

@@ -905,7 +941,7 @@ GLOBAL_LIST_EMPTY(vending_products)
905941
* Charge the user during a vend
906942
* Returns false if the user could not buy this item
907943
*/
908-
/obj/machinery/vending/proc/charge_user(price, item_name, always_charge)
944+
/obj/machinery/vending/proc/charge_user(price, item_name, always_charge, pay_custom = FALSE)
909945
var/mob/living/L
910946
if(isliving(usr))
911947
L = usr
@@ -929,9 +965,15 @@ GLOBAL_LIST_EMPTY(vending_products)
929965
say("You do not possess the funds to purchase \the [item_name].")
930966
flick(icon_deny,src)
931967
return FALSE
932-
var/datum/bank_account/D = SSeconomy.get_dep_account(payment_department)
933-
if(D)
934-
D.adjust_money(price)
968+
if(pay_custom)
969+
var/datum/bank_account/custom_account = custom_payout_account.resolve()
970+
if(istype(custom_account))
971+
custom_account.adjust_money(price)
972+
custom_account.bank_card_talk("\A [item_name] was purchased for [price] credits!")
973+
else
974+
var/datum/bank_account/D = SSeconomy.get_dep_account(payment_department)
975+
if(D)
976+
D.adjust_money(price)
935977

936978
return TRUE
937979

tgui/packages/tgui/interfaces/Vending.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ const VendingRow = (props, context) => {
2424
// yogs end
2525
);
2626

27-
const customFree = (
28-
!data.onstation
29-
|| (
30-
data.user
31-
&& data.department
32-
&& data.department === data.user.department
33-
)
34-
|| data.ignores_capitalism
35-
);
36-
3727
return (
3828
<Table.Row>
3929
<Table.Cell collapsing>
@@ -80,7 +70,7 @@ const VendingRow = (props, context) => {
8070
|| !data.user
8171
|| (!free && product.price > data.user.cash)
8272
)}
83-
content={customFree ? 'FREE' : product.price + ' cr'}
73+
content={product.price + ' cr'}
8474
onClick={() => act('vend_custom', {
8575
'item': product.name,
8676
})} />

0 commit comments

Comments
 (0)