Cannot use departmental budget cards as source of credit withdraw (#76113)

Currently you can put cargo's budget card into your PDA, go into NT Pay
and send over the budget to any pay token you want including yours. This
just adds a check to ensure you aren't using that kind of card as
withdrawal source.
This commit is contained in:
Pepsilawn
2023-06-18 10:18:20 +02:00
committed by GitHub
parent 78b7ca9afb
commit dcbe081f64
8 changed files with 16 additions and 10 deletions

View File

@@ -44,6 +44,9 @@
#define ACCOUNT_SEC "SEC" #define ACCOUNT_SEC "SEC"
#define ACCOUNT_SEC_NAME "Defense Budget" #define ACCOUNT_SEC_NAME "Defense Budget"
#define IS_DEPARTMENTAL_CARD(card) (card in SSeconomy.dep_cards)
#define IS_DEPARTMENTAL_ACCOUNT(account) (account in SSeconomy.departmental_accounts)
#define NO_FREEBIES "commies go home" #define NO_FREEBIES "commies go home"
//Defines that set what kind of civilian bounties should be applied mid-round. //Defines that set what kind of civilian bounties should be applied mid-round.

View File

@@ -14,7 +14,7 @@ SUBSYSTEM_DEF(economy)
ACCOUNT_SRV = ACCOUNT_SRV_NAME, ACCOUNT_SRV = ACCOUNT_SRV_NAME,
ACCOUNT_CAR = ACCOUNT_CAR_NAME, ACCOUNT_CAR = ACCOUNT_CAR_NAME,
ACCOUNT_SEC = ACCOUNT_SEC_NAME) ACCOUNT_SEC = ACCOUNT_SEC_NAME)
var/list/generated_accounts = list() var/list/departmental_accounts = list()
/** /**
* Enables extra money charges for things that normally would be free, such as sleepers/cryo/beepsky. * Enables extra money charges for things that normally would be free, such as sleepers/cryo/beepsky.
* Take care when enabling, as players will NOT respond well if the economy is set up for low cash flows. * Take care when enabling, as players will NOT respond well if the economy is set up for low cash flows.
@@ -82,7 +82,7 @@ SUBSYSTEM_DEF(economy)
return SS_INIT_SUCCESS return SS_INIT_SUCCESS
/datum/controller/subsystem/economy/Recover() /datum/controller/subsystem/economy/Recover()
generated_accounts = SSeconomy.generated_accounts departmental_accounts = SSeconomy.departmental_accounts
bank_accounts_by_id = SSeconomy.bank_accounts_by_id bank_accounts_by_id = SSeconomy.bank_accounts_by_id
dep_cards = SSeconomy.dep_cards dep_cards = SSeconomy.dep_cards
@@ -144,7 +144,7 @@ SUBSYSTEM_DEF(economy)
* Handy proc for obtaining a department's bank account, given the department ID, AKA the define assigned for what department they're under. * Handy proc for obtaining a department's bank account, given the department ID, AKA the define assigned for what department they're under.
*/ */
/datum/controller/subsystem/economy/proc/get_dep_account(dep_id) /datum/controller/subsystem/economy/proc/get_dep_account(dep_id)
for(var/datum/bank_account/department/D in generated_accounts) for(var/datum/bank_account/department/D in departmental_accounts)
if(D.department_id == dep_id) if(D.department_id == dep_id)
return D return D

View File

@@ -139,7 +139,7 @@
return FALSE return FALSE
if(my_card) if(my_card)
if(istype(player_card, /obj/item/card/id/departmental_budget)) // Are they using a department ID if(IS_DEPARTMENTAL_CARD(player_card)) // Are they using a department ID
say("You cannot gamble with the department budget!") say("You cannot gamble with the department budget!")
playsound(src, 'sound/machines/buzz-two.ogg', 30, TRUE) playsound(src, 'sound/machines/buzz-two.ogg', 30, TRUE)
return FALSE return FALSE

View File

@@ -111,7 +111,7 @@
/obj/structure/closet/crate/secure/owned/Initialize(mapload, datum/bank_account/_buyer_account) /obj/structure/closet/crate/secure/owned/Initialize(mapload, datum/bank_account/_buyer_account)
. = ..() . = ..()
buyer_account = _buyer_account buyer_account = _buyer_account
if(istype(buyer_account, /datum/bank_account/department)) if(IS_DEPARTMENTAL_ACCOUNT(buyer_account))
department_purchase = TRUE department_purchase = TRUE
department_account = buyer_account department_account = buyer_account

View File

@@ -205,7 +205,7 @@
if(!istype(id_card)) if(!istype(id_card))
say("No ID card detected.") say("No ID card detected.")
return return
if(istype(id_card, /obj/item/card/id/departmental_budget)) if(IS_DEPARTMENTAL_CARD(id_card))
say("The [src] rejects [id_card].") say("The [src] rejects [id_card].")
return return
account = id_card.registered_account account = id_card.registered_account

View File

@@ -132,12 +132,12 @@
var/reason_to = "Transfer: From [from.account_holder]" var/reason_to = "Transfer: From [from.account_holder]"
var/reason_from = "Transfer: To [account_holder]" var/reason_from = "Transfer: To [account_holder]"
if(istype(from, /datum/bank_account/department)) if(IS_DEPARTMENTAL_ACCOUNT(from))
reason_to = "Nanotrasen: Salary" reason_to = "Nanotrasen: Salary"
reason_from = "" reason_from = ""
if(transfer_reason) if(transfer_reason)
reason_to = istype(src, /datum/bank_account/department) ? "" : transfer_reason reason_to = IS_DEPARTMENTAL_ACCOUNT(src) ? "" : transfer_reason
reason_from = transfer_reason reason_from = transfer_reason
adjust_money(amount, reason_to) adjust_money(amount, reason_to)
@@ -268,7 +268,7 @@
department_id = dep_id department_id = dep_id
account_balance = budget account_balance = budget
account_holder = SSeconomy.department_accounts[dep_id] account_holder = SSeconomy.department_accounts[dep_id]
SSeconomy.generated_accounts += src SSeconomy.departmental_accounts += src
/datum/bank_account/remote // Bank account not belonging to the local station /datum/bank_account/remote // Bank account not belonging to the local station
add_to_accounts = FALSE add_to_accounts = FALSE

View File

@@ -218,7 +218,7 @@
if(!istype(id_card)) if(!istype(id_card))
computer.say("No ID card detected.") computer.say("No ID card detected.")
return return
if(istype(id_card, /obj/item/card/id/departmental_budget)) if(IS_DEPARTMENTAL_CARD(id_card))
computer.say("[id_card] cannot be used to make purchases.") computer.say("[id_card] cannot be used to make purchases.")
return return
account = id_card.registered_account account = id_card.registered_account

View File

@@ -20,6 +20,9 @@
/datum/computer_file/program/nt_pay/ui_act(action, list/params, datum/tgui/ui) /datum/computer_file/program/nt_pay/ui_act(action, list/params, datum/tgui/ui)
switch(action) switch(action)
if("Transaction") if("Transaction")
if(IS_DEPARTMENTAL_ACCOUNT(current_user))
return to_chat(usr, span_notice("The app is unable to withdraw from that card."))
token = params["token"] token = params["token"]
money_to_send = params["amount"] money_to_send = params["amount"]
var/datum/bank_account/recipient var/datum/bank_account/recipient