Handheld EFTPOS offering (#27978)

* Handheld EFTPOS offering

* Apply suggestions from code review

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

---------

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
This commit is contained in:
Charlie Nolan
2025-01-24 15:54:36 -08:00
committed by GitHub
parent 72a06a1d8c
commit a809609e0c
8 changed files with 172 additions and 83 deletions
@@ -23,6 +23,8 @@
var/datum/money_account_database/main_station/account_database
///Current money account the EFTPOS is depositing to
var/datum/money_account/linked_account
///Is this a portable unit that you can offer with *payme?
var/can_offer = TRUE
/obj/item/eftpos/Initialize(mapload)
machine_name = "EFTPOS #[rand(101, 999)]"
@@ -80,6 +82,7 @@
)
data["available_accounts"] += list(account_data)
data["can_offer"] = can_offer
return data
@@ -148,21 +151,27 @@
else if(istype(I, /obj/item/card/emag))
access_code = 0
to_chat(user, "[bicon(src)]<span class='notice'>Access code reset to 0.</span>")
if("offer")
if(can_offer)
offer(user)
/obj/item/eftpos/proc/offer(mob/living/user)
user.apply_status_effect(STATUS_EFFECT_OFFERING_EFTPOS)
/obj/item/eftpos/proc/scan_card(obj/item/card/id/C, mob/user, secured = TRUE)
visible_message("<span class='notice'>[user] swipes a card through [src].</span>")
if(!transaction_locked || transaction_paid || !secured)
visible_message("<span class='notice'>[user] swipes a card through [src], but nothing happens.</span>")
return
visible_message("<span class='notice'>[user] swipes a card through [src].</span>")
if(!linked_account)
to_chat(user, "[bicon(src)]<span class='warning'>EFTPOS is not connected to an account.</span>")
visible_message("[bicon(src)]<span class='warning'>[src] buzzes as its display flashes \"EFTPOS is not connected to an account.\"</span>", "<span class='notice'>You hear something buzz.</span>")
return
var/datum/money_account/D = GLOB.station_money_database.find_user_account(C.associated_account_number, include_departments = FALSE)
if(!D)
to_chat(user, "<span class='warning'>Your currently in use card is not connected to a money account.</span>")
visible_message("[bicon(src)]<span class='warning'>[src] buzzes as its display flashes \"Card is not connected to an account.\"</span>", "<span class='notice'>You hear something buzz.</span>")
return
//if security level high enough, prompt for pin
var/attempt_pin
@@ -172,19 +181,19 @@
return
//given the credentials, can the associated account be accessed right now?
if(!GLOB.station_money_database.try_authenticate_login(D, attempt_pin, restricted_bypass = FALSE))
to_chat(user, "[bicon(src)]<span class='warning'>Unable to access account, insufficient access.</span>")
visible_message("[bicon(src)]<span class='warning'>[src] buzzes as its display flashes \"Access denied.\"</span>", "<span class='notice'>You hear something buzz.</span>")
return
if(tgui_alert(user, "Are you sure you want to pay $[transaction_amount] to: [linked_account.account_name]", "Confirm transaction", list("Yes", "No")) != "Yes")
return
if(!Adjacent(user))
if(!Adjacent(user) && !(can_offer && get_dist(user, src) <= 2))
return
//attempt to charge account money
if(!GLOB.station_money_database.charge_account(D, transaction_amount, transaction_purpose, machine_name, FALSE, FALSE))
to_chat(user, "[bicon(src)]<span class='warning'>Insufficient credits in your account!</span>")
visible_message("[bicon(src)]<span class='warning'>[src] buzzes as its display flashes \"Insufficient funds.\"</span>", "<span class='notice'>You hear something buzz.</span>")
return
GLOB.station_money_database.credit_account(linked_account, transaction_amount, transaction_purpose, machine_name, FALSE)
playsound(src, transaction_sound, 50, TRUE)
visible_message("<span class='notice'>[src] chimes!</span>")
visible_message("[bicon(src)]<span class='notice'>[src] chimes as its display reads \"Transaction successful!\"</span>", "<span class='notice'>You hear something chime.</span>")
transaction_paid = TRUE
addtimer(VARSET_CALLBACK(src, transaction_paid, FALSE), 5 SECONDS)
@@ -232,6 +241,7 @@
pickup_sound = 'sound/items/handling/toolbox_pickup.ogg'
transaction_sound = 'sound/machines/checkout.ogg'
attack_verb = list("bounced a check off", "checked-out", "tipped")
can_offer = FALSE
/obj/item/eftpos/register/examine(mob/user)
. = ..()
@@ -234,7 +234,10 @@
return
// If it has any of the highfive statuses, dap, handshake, etc
var/datum/status_effect/effect = has_status_effect_type(STATUS_EFFECT_HIGHFIVE)
if(effect)
if(istype(effect, STATUS_EFFECT_OFFERING_EFTPOS))
to_chat(M, "<span class='warning'>You need to have your ID in hand to scan it!</span>")
return
else if(effect)
M.apply_status_effect(effect.type)
return
// BEGIN HUGCODE - N3X
@@ -404,6 +404,31 @@
status = STATUS_EFFECT_DAP
key_third_person = "daps"
/datum/emote/living/carbon/human/highfive/payme
key = "payme"
status = STATUS_EFFECT_OFFERING_EFTPOS
/datum/emote/living/carbon/human/highfive/payme/run_emote(mob/living/user, params, type_override, intentional)
var/obj/item/eftpos/eftpos = user.is_holding_item_of_type(/obj/item/eftpos)
if(!eftpos)
to_chat(user, "<span class='warning'>You must be holding an EFTPOS to do that!</span>")
return TRUE
if(!eftpos.can_offer)
to_chat(user, "<span class='warning'>[eftpos] is too bulky to hold out to someone!</span>")
return TRUE
if(!eftpos.transaction_locked)
to_chat(user, "<span class='warning'>You must lock [eftpos] before it can accept payments.</span>")
return TRUE
if(user.has_status_effect(status))
user.visible_message("<span class='notice'>[user.name] shakes [eftpos] around slightly, impatiently waiting for someone to scan their card.</span>")
return TRUE
var/datum/result = set_status(user)
if(QDELETED(result))
return TRUE
return TRUE
/datum/emote/living/carbon/human/highfive/handshake
key = "handshake"
key_third_person = "handshakes"