Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete prices and money interactions for vendors. #75

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions code/game/objects/machinery/vending/marine_vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,6 @@
/obj/item/cell/lasgun/lasrifle = 10, /obj/item/cell/lasgun/volkite/powerpack/marine = 2,
)

prices = list()

/obj/machinery/vending/lasgun/Initialize(mapload)
. = ..()
update_icon()
Expand Down Expand Up @@ -1198,8 +1196,6 @@
),
)

prices = list()

/obj/machinery/vending/armor_supply/valhalla
resistance_flags = INDESTRUCTIBLE
use_power = NO_POWER_USE
Expand Down Expand Up @@ -1407,8 +1403,6 @@
)
)

prices = list()

/obj/machinery/vending/uniform_supply/valhalla
resistance_flags = INDESTRUCTIBLE
use_power = NO_POWER_USE
Expand Down
89 changes: 4 additions & 85 deletions code/game/objects/machinery/vending/vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define MAKE_VENDING_RECORD_DATA(record) list(\
"product_name" = record.product_name,\
"product_color" = record.display_color,\
"prod_price" = record.price,\
"prod_desc" = initial(record.product_path.desc),\
"ref" = REF(record),\
"tab" = record.tab,\
Expand Down Expand Up @@ -111,8 +110,6 @@
var/list/contraband = list()
/// Premium products that are only available when using a coin to pay for it.
var/list/premium = list()
/// Prices for each item, list(/type/path = price), items not in the list don't have a price.
var/list/prices = list()
/// String of slogans separated by semicolons, optional
var/product_slogans = ""
///String of small ad messages in the vending screen - random chance
Expand Down Expand Up @@ -147,10 +144,6 @@
var/shut_up = FALSE
///If the vending machine is hacked, makes the items on contraband list available.
var/extended_inventory = FALSE
/// 1 = requires PIN and checks accounts. 0 = You slide an ID, it vends, SPACE COMMUNISM!
var/check_accounts = 0
///Current cash card.
var/obj/item/spacecash/ewallet/ewallet
///How much tipped we are.
var/tipped_level = 0
///Stops the machine from being hacked to shoot inventory or allow all access
Expand Down Expand Up @@ -257,14 +250,14 @@
var/amount = productlist[entry][typepath]
if(isnull(amount))
amount = 1
var/datum/vending_product/record = new(typepath = typepath, product_amount = amount, product_price = prices[typepath], category = category, tab = entry)
var/datum/vending_product/record = new(typepath = typepath, product_amount = amount, category = category, tab = entry)
recordlist += record
continue
//This item is not tab dependent
var/amount = productlist[entry]
if(isnull(amount))
amount = 1
var/datum/vending_product/record = new(typepath = entry, product_amount = amount, product_price = prices[entry], category = category)
var/datum/vending_product/record = new(typepath = entry, product_amount = amount, category = category)
recordlist += record

///Makes additional tabs/adds to the tabs based on the seasonal_items vendor specification
Expand Down Expand Up @@ -347,17 +340,6 @@

attack_hand(user)

else if(istype(I, /obj/item/card))
var/obj/item/card/C = I
scan_card(C)

else if(istype(I, /obj/item/spacecash/ewallet))
if(!user.transferItemToLoc(I, src))
return

ewallet = I
to_chat(user, span_notice("You insert the [I] into the [src]"))

else if(iswrench(I))
if(!wrenchable)
return
Expand All @@ -381,70 +363,18 @@
var/obj/item/to_stock = I
stock(to_stock, user)

/obj/machinery/vending/proc/scan_card(obj/item/card/I)
if(!currently_vending)
return
if (istype(I, /obj/item/card/id))
var/obj/item/card/id/C = I
visible_message(span_info("[usr] swipes a card through [src]."))
var/datum/money_account/CH = get_account(C.associated_account_number)
if(CH) // Only proceed if card contains proper account number.
if(!CH.suspended)
if(CH.security_level != 0) //If card requires pin authentication (ie seclevel 1 or 2)
var/attempt_pin = tgui_input_number(usr, "Enter pin code", "Vendor transaction")
var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2)
transfer_and_vend(D)
else
//Just Vend it.
transfer_and_vend(CH)
else
to_chat(usr, "[icon2html(src, usr)][span_warning("Connected account has been suspended.")]")
else
to_chat(usr, "[icon2html(src, usr)][span_warning("Error: Unable to access your account. Please contact technical support if problem persists.")]")

/obj/machinery/vending/proc/transfer_and_vend(datum/money_account/acc)
if(!acc)
to_chat(usr, "[icon2html(src, usr)][span_warning("Error: Unable to access your account. Please contact technical support if problem persists.")]")
return

var/transaction_amount = currently_vending.price
if(transaction_amount > acc.money)
to_chat(usr, "[icon2html(src, usr)][span_warning("You don't have that much money!")]")
return

//transfer the money
acc.money -= transaction_amount

//create entries in the two account transaction logs
var/datum/transaction/T = new()
T.purpose = "Purchase of [currently_vending.product_name]"
if(transaction_amount > 0)
T.amount = "([transaction_amount])"
else
T.amount = "[transaction_amount]"
T.source_terminal = src.name
T.date = GLOB.current_date_string
T.time = worldtime2text()
acc.transaction_log.Add(T)

// Vend the item
vend(currently_vending, usr)
currently_vending = null

/obj/machinery/vending/can_interact(mob/user)
. = ..()
if(!.)
return FALSE

if(tipped_level == 2)
user.visible_message(span_notice(" [user] begins to heave the vending machine back into place!"),span_notice(" You start heaving the vending machine back into place.."))
user.visible_message(span_notice("[user] begins to heave the vending machine back into place!"), span_notice("You start heaving the vending machine back into place.."))
if(!do_after(user, 80, IGNORE_HELD_ITEM, src, BUSY_ICON_FRIENDLY))
return FALSE

user.visible_message(span_notice(" [user] rights the [src]!"),span_notice(" You right the [src]!"))
user.visible_message(span_notice("[user] rights the [src]!"), span_notice("You right the [src]!"))
flip_back()
return TRUE

return TRUE

/**
Expand Down Expand Up @@ -548,17 +478,6 @@
stock_vacuum(usr)
. = TRUE

if("cancel_buying")
currently_vending = null
. = TRUE

if("swipe")
if(!ishuman(usr))
return
var/mob/living/carbon/human/H = usr
scan_card(H.wear_id)
. = TRUE

/obj/machinery/vending/proc/vend(datum/vending_product/R, mob/user)
if(!allowed(user) && (!wires.is_cut(WIRE_IDSCAN) || hacking_safety)) //For SECURE VENDING MACHINES YEAH
to_chat(user, span_warning("Access denied."))
Expand Down
13 changes: 0 additions & 13 deletions code/game/objects/machinery/vending/vending_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,6 @@
/obj/item/reagent_containers/food/drinks/cans/waterbottle = -1,
/obj/item/reagent_containers/food/drinks/cans/cola = -1,
)

prices = list(
/obj/item/reagent_containers/food/drinks/cans/souto = 5,
/obj/item/reagent_containers/food/drinks/cans/souto/diet = 5,
/obj/item/reagent_containers/food/drinks/cans/souto/cherry = 5,
/obj/item/reagent_containers/food/drinks/cans/souto/cherry/diet = 5,
/obj/item/reagent_containers/food/drinks/cans/souto/lime = 5,
/obj/item/reagent_containers/food/drinks/cans/souto/lime/diet = 5,
/obj/item/reagent_containers/food/drinks/cans/souto/grape = 5,
/obj/item/reagent_containers/food/drinks/cans/souto/grape/diet = 5,
/obj/item/reagent_containers/food/drinks/cans/waterbottle = 2,
/obj/item/reagent_containers/food/drinks/cans/cola = 10,
)
idle_power_usage = 200

/obj/machinery/vending/medical
Expand Down
35 changes: 1 addition & 34 deletions tgui/packages/tgui/interfaces/Vending.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type VendingStock = {
type VendingRecord = {
product_name: string;
product_color: string;
prod_price: number;
prod_desc: string;
ref: string;
tab: string;
Expand Down Expand Up @@ -63,11 +62,7 @@ export const Vending = (props, context) => {
<Button content="Dismiss" onClick={() => setShowDesc(null)} />
</Modal>
) : (
currently_vending && (
<Modal width="400px">
<Buying vending={currently_vending} />
</Modal>
)
currently_vending
)}
<Window.Content scrollable>
<Section
Expand Down Expand Up @@ -121,31 +116,6 @@ export const Vending = (props, context) => {
);
};

type BuyingModalProps = {
vending: VendingRecord;
};

const Buying = (props: BuyingModalProps, context) => {
const { act, data } = useBackend<VendingData>(context);

const { vending } = props;

return (
<Section title={'You have selected ' + vending.product_name}>
<Box>
Please swipe your ID to pay for the article.
<Divider />
<Button onClick={() => act('swipe')} icon="id-card" ml="6px">
Swipe
</Button>
<Button onClick={() => act('cancel_buying')} icon="times">
Cancel
</Button>
</Box>
</Section>
);
};

type VendingProductEntryProps = {
stock: number;
product_color: string;
Expand Down Expand Up @@ -232,7 +202,6 @@ const Products = (props, context) => {
(showEmpty || !!stock[display_record.product_name]) && (
<ProductEntry
stock={stock[display_record.product_name]}
key={display_record.product_name}
product_color={display_record.product_color}
product_name={display_record.product_name}
prod_desc={display_record.prod_desc}
Expand Down Expand Up @@ -267,7 +236,6 @@ const Hacked = (props, context) => {
return (
<ProductEntry
stock={stock[hidden_record.product_name]}
key={hidden_record.product_name}
product_color={hidden_record.product_color}
product_name={hidden_record.product_name}
prod_desc={hidden_record.prod_desc}
Expand Down Expand Up @@ -309,7 +277,6 @@ const Premium = (props, context) => {
return (
<ProductEntry
stock={stock[coin_record.product_name]}
key={coin_record.product_name}
product_color={coin_record.product_color}
product_name={coin_record.product_name}
prod_desc={coin_record.prod_desc}
Expand Down
Loading