mirror of
https://github.com/quotefox/Hyper-Station-13.git
synced 2026-08-24 05:06:14 +01:00
reworking economy, adding paychecks
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
SUBSYSTEM_DEF(economy)
|
||||
name = "Economy"
|
||||
wait = 5 MINUTES
|
||||
priority = FIRE_PRIORITY_ECONOMY
|
||||
init_order = INIT_ORDER_ECONOMY
|
||||
runlevels = RUNLEVEL_GAME
|
||||
flags = SS_NO_FIRE //Let's not forget this. This subsystem does not use fire and was needlessly using CPU.
|
||||
/// How many "paychecks" someone gets at the creation of the bank account
|
||||
var/roundstart_paychecks = 5
|
||||
var/budget_pool = 35000
|
||||
var/list/generated_accounts = list()
|
||||
var/list/bank_accounts = list() //List of normal accounts (not department accounts)
|
||||
|
||||
/datum/controller/subsystem/economy/fire()
|
||||
for(var/datum/bank_account/account as anything in bank_accounts)
|
||||
account.AddPaycheck(GetPaycheck(account, account.account_job))
|
||||
|
||||
/**
|
||||
* Returns a value of the amount of money a bank account would be getting. It's just some simple multiplication.
|
||||
* Both the bank account and job is allowed to be null here.
|
||||
*
|
||||
* Thanks to the ultimate nature of byond, double-colon accessors, ::, get the default values of the bank account and
|
||||
* job datums if the respective one is null. You can pass zero arguments here and you'd get the "default" amount of a paycheck.
|
||||
*/
|
||||
/datum/controller/subsystem/economy/proc/GetPaycheck(datum/bank_account/account, datum/job/job, multiplier=1)
|
||||
return account::base_pay * job::base_paycheck_multiplier * multiplier
|
||||
|
||||
@@ -1,29 +1,39 @@
|
||||
#define DUMPTIME 3000
|
||||
|
||||
/datum/bank_account
|
||||
var/account_holder = "Some pleb"
|
||||
var/account_balance = 0
|
||||
var/account_offstation_balance = 0
|
||||
var/account_holder = "Some pleboid"
|
||||
var/balance = 0
|
||||
var/account_pin = 0
|
||||
var/account_dna = ""
|
||||
var/datum/job/account_job
|
||||
var/obj/item/card/id/associated_id
|
||||
var/list/bank_cards = list()
|
||||
var/add_to_accounts = TRUE
|
||||
var/transferable = TRUE
|
||||
var/account_id
|
||||
var/withdrawDelay = 0
|
||||
var/account_id = 1
|
||||
var/base_pay = 60
|
||||
|
||||
/datum/bank_account/New(newname, job)
|
||||
if(add_to_accounts)
|
||||
if(!SSeconomy)
|
||||
log_world("Wack")
|
||||
SSeconomy.bank_accounts += src
|
||||
/datum/bank_account/New(newname="Some plebith", datum/job/job)
|
||||
account_holder = newname
|
||||
account_job = job
|
||||
account_id = rand(111111,999999)
|
||||
|
||||
if(!SSeconomy || !SSeconomy.initialized)
|
||||
stack_trace("A new bank account was made without the economy subsystem being initialized first. If this is an issue, change the subsystem's init_order.")
|
||||
return
|
||||
|
||||
SSeconomy.bank_accounts += src
|
||||
balance += SSeconomy.GetPaycheck(src, job, SSeconomy.roundstart_paychecks)
|
||||
|
||||
/// Helper for whenever a paycheck gets processed into this account from the economy SS. Simply adds an amount to the account balance and notifies the user.
|
||||
/datum/bank_account/proc/AddPaycheck(amount, silent=FALSE)
|
||||
balance += amount
|
||||
if(associated_id && !silent)
|
||||
var/local_turf = get_turf(associated_id)
|
||||
var/hearers = ohearers(1, local_turf)
|
||||
for(var/mob/M in hearers)
|
||||
M.playsound_local(local_turf, 'sound/machines/twobeep_high.ogg', 50, vary = TRUE)
|
||||
to_chat(M, "[icon2html(src, associated_id.loc)] <span class='notice>Paycheck processed, your account now holds [balance] credits.</span>")
|
||||
|
||||
/datum/bank_account/Destroy()
|
||||
if(add_to_accounts)
|
||||
if(SSeconomy)
|
||||
SSeconomy.bank_accounts -= src
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
if(idcard.registered_account)
|
||||
if(!idcard.registered_account.account_pin || pin == idcard.registered_account.account_pin)
|
||||
dat += "<p>Balance: <b>$[idcard.registered_account.account_balance]</b>"
|
||||
dat += "<p>Balance: <b>$[idcard.registered_account.balance]</b>"
|
||||
//dat += "<p>Offstation Balance: <b()</b>"
|
||||
dat += "<p>"
|
||||
dat += "<a href='byond://?src=[REF(src)];withdraw=1'>Withdraw</A>"
|
||||
@@ -78,7 +78,7 @@
|
||||
if(held_card)
|
||||
var/obj/item/stack/credits/cred = I
|
||||
var/obj/item/card/id/idcard = held_card
|
||||
idcard.registered_account.account_balance = (idcard.registered_account.account_balance+cred.amount)
|
||||
idcard.registered_account.balance = (idcard.registered_account.balance+cred.amount)
|
||||
to_chat(usr, "<span class='notice'>You insert [cred] into the ATM.</span>")
|
||||
src.ui_interact(usr)
|
||||
del(cred)
|
||||
@@ -138,9 +138,9 @@
|
||||
if(idcard.registered_account)
|
||||
var/amount = input(user, "Choose amount", "Withdraw") as num|null
|
||||
if(amount>0)
|
||||
amount = max(min( round(text2num(amount)), idcard.registered_account.account_balance),0) //make sure they aint taking out more then what they have
|
||||
amount = max(min( round(text2num(amount)), idcard.registered_account.balance),0) //make sure they aint taking out more then what they have
|
||||
to_chat(usr, "<span class='notice'>The machine prints out [amount] credits.</span>")
|
||||
idcard.registered_account.account_balance = (idcard.registered_account.account_balance-amount) //subtract the amount they took out.
|
||||
idcard.registered_account.balance = (idcard.registered_account.balance-amount) //subtract the amount they took out.
|
||||
var/obj/item/stack/credits/C = new /obj/item/stack/credits/(loc)
|
||||
C.amount = amount
|
||||
if(usr.put_in_hands(C))
|
||||
|
||||
Reference in New Issue
Block a user