Files
Bubberstation/code/modules/admin/smites/dock_pay.dm
Watermelon914 375a20e49b Refactors most spans into span procs (#59645)
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs.
Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines.

Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing.
Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc.

(Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
2021-06-14 13:03:53 -07:00

32 lines
1.4 KiB
Plaintext

/// Docks the target's pay
/datum/smite/dock_pay
name = "Dock Pay"
/datum/smite/dock_pay/effect(client/user, mob/living/target)
. = ..()
if (!iscarbon(target))
to_chat(user, span_warning("This must be used on a carbon mob."), confidential = TRUE)
return
var/mob/living/carbon/dude = target
var/obj/item/card/id/card = dude.get_idcard(TRUE)
if (!card)
to_chat(user, span_warning("[dude] does not have an ID card on!"), confidential = TRUE)
return
if (!card.registered_account)
to_chat(user, span_warning("[dude] does not have an ID card with an account!"), confidential = TRUE)
return
if (card.registered_account.account_balance == 0)
to_chat(user, span_warning("ID Card lacks any funds. No pay to dock."))
return
var/new_cost = input("How much pay are we docking? Current balance: [card.registered_account.account_balance] credits.", "BUDGET CUTS") as num|null
if (!new_cost)
return
if (!(card.registered_account.has_money(new_cost)))
to_chat(user, span_warning("ID Card lacked funds. Emptying account."))
card.registered_account.bank_card_talk("[new_cost] credits deducted from your account based on performance review.")
card.registered_account.account_balance = 0
else
card.registered_account.account_balance = card.registered_account.account_balance - new_cost
card.registered_account.bank_card_talk("[new_cost] credits deducted from your account based on performance review.")
SEND_SOUND(target, 'sound/machines/buzz-sigh.ogg')