Skip to content

Commit

Permalink
[MIRROR] Prevents Debug ID Card from Polluting Cargo Budget By Doing …
Browse files Browse the repository at this point in the history
…It Right (#1670)

* Prevents Debug ID Card from Polluting Cargo Budget By Doing It Right (#82214)

## About The Pull Request

Fixes #81755

Alright instead of piggybacking off the departmental/non-departmental
distinction and prevent ourselves from constantly abusing the cargo
budget in order to achieve the very-specific effect of not wanting
players to abuse this card in certain contexts let's just leverage the
framework and expand it so that we can snowflake for admin/`holder` use
cases in stuff like debugging code on a local server while preventing
some player from stealing it off a newbie admin and immediately wrecking
the economy (although it is funny).
## Why It's Good For The Game

Probably a bad idea to continue to abuse the cargo budget like this
since the only reason why it's structured that way is just for specific
use-case exemptions in certain contexts - let's just do our own thing
now :3
## Changelog
:cl:
admin: Advanced Debug Cards will still provide a whole lot of access,
but the way the money on those cards work is now a bit different.
Players shouldn't be able to use the money on those cards in any context
though, don't fret about that. Just know that the money printer goes
wrrrr
/:cl:

---------

Co-authored-by: Zephyr <[email protected]>

* Prevents Debug ID Card from Polluting Cargo Budget By Doing It Right

---------

Co-authored-by: san7890 <[email protected]>
Co-authored-by: Zephyr <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Mar 27, 2024
1 parent 120381a commit 2ea2be1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/economy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@

#define NO_FREEBIES "commies go home"

/// The special account ID for admins using debug cards.
#define ADMIN_ACCOUNT_ID "ADMIN!"

//Defines that set what kind of civilian bounties should be applied mid-round.
#define CIV_JOB_BASIC 1
#define CIV_JOB_ROBO 2
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/payment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@

return FALSE

if(!idcard.registered_account.account_job)
if(!idcard.can_be_used_in_payment(user))
atom_parent.say("Departmental accounts have been blacklisted from personal expenses due to embezzlement.")
return FALSE

Expand Down
39 changes: 32 additions & 7 deletions code/game/objects/items/cards_ids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,13 @@

wildcard_access_list |= new_access

/// Helper proc that determines if a card can be used in certain types of payment transactions.
/obj/item/card/id/proc/can_be_used_in_payment(mob/living/user)
if(QDELETED(src) || isnull(registered_account?.account_job) || !isliving(user))
return FALSE

return TRUE

/obj/item/card/id/attack_self(mob/user)
if(Adjacent(user))
var/minor
Expand Down Expand Up @@ -447,8 +454,8 @@
if(!COOLDOWN_FINISHED(src, last_holopay_projection))
balloon_alert(user, "still recharging")
return
if(!registered_account || !registered_account.account_job)
balloon_alert(user, "no account")
if(can_be_used_in_payment(user))
balloon_alert(user, "no account!")
to_chat(user, span_warning("You need a valid bank account to do this."))
return
/// Determines where the holopay will be placed based on tile contents
Expand Down Expand Up @@ -630,9 +637,9 @@
/// Helper proc. Can the user alt-click the ID?
/obj/item/card/id/proc/alt_click_can_use_id(mob/living/user)
if(!isliving(user))
return
return FALSE
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return
return FALSE

return TRUE

Expand Down Expand Up @@ -1226,16 +1233,34 @@

/obj/item/card/id/advanced/debug
name = "\improper Debug ID"
desc = "A debug ID card. Has ALL the all access, you really shouldn't have this."
desc = "A debug ID card. Has ALL the all access and a boatload of money, you really shouldn't have this."
icon_state = "card_centcom"
assigned_icon_state = "assigned_centcom"
trim = /datum/id_trim/admin
wildcard_slots = WILDCARD_LIMIT_ADMIN

/obj/item/card/id/advanced/debug/Initialize(mapload)
. = ..()
registered_account = SSeconomy.get_dep_account(ACCOUNT_CAR)
registered_account.account_job = SSjob.GetJobType(/datum/job/admin) // so we can actually use this account without being filtered as a "departmental" card
registered_account = new(player_account = FALSE)
registered_account.account_id = ADMIN_ACCOUNT_ID // this is so bank_card_talk() can work.
registered_account.account_job = SSjob.GetJobType(/datum/job/admin)
registered_account.account_balance += 999999 // MONEY! We add more money to the account every time we spawn because it's a debug item and infinite money whoopie

/obj/item/card/id/advanced/debug/alt_click_can_use_id(mob/living/user)
. = ..()
if(!. || isnull(user.client?.holder)) // admins only as a safety so people don't steal all the dollars. spawn in a holochip if you want them to get some dosh
registered_account.bank_card_talk(span_warning("Only authorized representatives of Nanotrasen may use this card."), force = TRUE)
return FALSE

return TRUE

/obj/item/card/id/advanced/debug/can_be_used_in_payment(mob/living/user)
. = ..()
if(!. || isnull(user.client?.holder))
registered_account.bank_card_talk(span_warning("Only authorized representatives of Nanotrasen may use this card."), force = TRUE)
return FALSE

return TRUE

/obj/item/card/id/advanced/prisoner
name = "prisoner ID card"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/art/paintings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
if(!id_card)
to_chat(user, span_warning("You don't even have a id and you want to be an art patron?"))
return
if(!id_card.registered_account || !id_card.registered_account.account_job)
if(!id_card.can_be_used_in_payment(user))
to_chat(user, span_warning("No valid non-departmental account found."))
return
var/datum/bank_account/account = id_card.registered_account
Expand Down
2 changes: 1 addition & 1 deletion code/modules/economy/holopay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
/// Account checks
var/obj/item/card/id/id_card
id_card = user.get_idcard(TRUE)
if(!id_card || !id_card.registered_account || !id_card.registered_account.account_job)
if(isnull(id_card) || id_card.can_be_used_in_payment(user))
balloon_alert(user, "invalid account")
to_chat(user, span_warning("You don't have a valid account."))
return FALSE
Expand Down

0 comments on commit 2ea2be1

Please sign in to comment.