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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paystand Modifications #41588

Merged
merged 4 commits into from Dec 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 54 additions & 16 deletions code/modules/economy/pay_stand.dm
Expand Up @@ -5,54 +5,82 @@
icon_state = "card_scanner"
density = TRUE
anchored = TRUE
var/price = 0
var/locked = FALSE
var/obj/item/card/id/my_card
var/obj/item/assembly/signaler/signaler //attached signaler, let people attach signalers that get activated if the user's transaction limit is achieved.
var/signaler_threshold = 0 //signaler threshold amount
var/amount_deposited = 0 //keep track of the amount deposited over time so you can pay multiple times to reach the signaler threshold

/obj/machinery/paystand/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/card/id))
if(W == my_card)
locked = !locked
to_chat(user, "<span class='notice'>You [src.locked ? "lock" : "unlock"] the bolts on the paystand.</span>")
return
if(!my_card)
var/obj/item/card/id/assistant_mains_need_to_die = W
if(assistant_mains_need_to_die.registered_account)
var/msg = stripped_input(user, "Name of pay stand:", "Paystand Naming", "[user]'s Awesome Paystand")
if(!msg)
return
var/price2 = input(user, "Enter price.", "Paystand Pricing", 25) as num
if(!price2 || price2 < 0)
return
name = "[msg] ($[price2])"
desc = "Owned by [assistant_mains_need_to_die.registered_account.account_holder]. Pays directly into [user.p_their()] account when swiped with an ID card."
price = price2
name = msg
desc = "Owned by [assistant_mains_need_to_die.registered_account.account_holder], pays directly into [user.p_their()] account."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: make desc customizable

my_card = assistant_mains_need_to_die
to_chat(user, "You link the stand to your account.")
return
var/obj/item/card/id/vbucks = W
if(vbucks.registered_account)
if(vbucks.registered_account.adjust_money(-price))
purchase(vbucks.registered_account.account_holder)
var/momsdebitcard = input(user, "How much would you like to deposit?", "Money Deposit") as null|num
if(momsdebitcard < 1)
to_chat(user, "<span class='warning'>ERROR: Invalid amount designated.</span>")
return
if(vbucks.registered_account.adjust_money(-momsdebitcard))
purchase(vbucks.registered_account.account_holder, momsdebitcard)
to_chat(user, "Thanks for purchasing! The vendor has been informed.")
return
else
to_chat(user, "You trying to punk me, kid? Come back when you have the cash.")
to_chat(user, "<span class='warning'>ERROR: Account has insufficient funds to make transaction.</span>")
return
else
to_chat(user, "You're going to need an actual bank account for that one, buddy.")
to_chat(user, "<span class='warning'>ERROR: No bank account assigned to identification card.</span>")
return
if(istype(W, /obj/item/holochip))
var/obj/item/holochip/H = W
if(H.spend(price, FALSE))
purchase(user)
var/cashmoney = input(user, "How much would you like to deposit?", "Money Deposit") as null|num
if(H.spend(cashmoney, FALSE))
purchase(user, cashmoney)
to_chat(user, "Thanks for purchasing! The vendor has been informed.")
return
else
to_chat(user, "You trying to punk me, kid? Come back when you have the cash.")
to_chat(user, "<span class='warning'>ERROR: Insufficient funds to make transaction.</span>")
return
if(istype(W, /obj/item/stack/spacecash))
to_chat(user, "What is this, the 2000s? We only take card here.")
return
if(istype(W, /obj/item/coin))
to_chat(user, "What is this, the 1800s? We only take card here.")
return

if(istype(W, /obj/item/assembly/signaler))
if(signaler.secured)
to_chat(user, "<span class='warning'>The signaler needs to be in attachable mode to add it to the paystand!</span>")
return
if(!my_card)
to_chat(user, "<span class='warning'>ERROR: No identification card has been assigned to this paystand yet!</span>")
return
if(!signaler)
var/cash_limit = input(user, "Enter the minimum amount of cash needed to deposit before the signaler is activated.", "Signaler Activation Threshold") as null|num
if(cash_limit < 1)
to_chat(user, "<span class='warning'>ERROR: Invalid amount designated.</span>")
return
if(cash_limit)
W.forceMove(src)
signaler = W
signaler_threshold = cash_limit
to_chat(user, "You attach the signaler to the paystand.")
desc += " A signaler appears to be attached to the scanner."
else
to_chat(user, "<span class='warning'>A signaler is already attached to this unit!</span>")

if(default_deconstruction_screwdriver(user, "card_scanner", "card_scanner", W))
return

Expand All @@ -67,7 +95,17 @@
else
return ..()

/obj/machinery/paystand/proc/purchase(buyer)
/obj/machinery/paystand/proc/purchase(buyer, price)
my_card.registered_account.adjust_money(price)
my_card.registered_account.bank_card_talk("Purchase made at your vendor by [buyer] for [price] credits.")
amount_deposited = amount_deposited + price
if(signaler && amount_deposited >= signaler_threshold)
signaler.activate()
amount_deposited = 0

/obj/machinery/paystand/default_unfasten_wrench(mob/user, obj/item/I, time = 20)
if(locked)
to_chat(user, "<span class='warning'>The anchored bolts on this paystand are currently locked!</span>")
return
. = ..()