From 972d3f5e19b5217769fb2b0f208b01991dd0a309 Mon Sep 17 00:00:00 2001 From: DragonTrance Date: Wed, 8 Jun 2022 17:18:54 -0400 Subject: [PATCH] fixing shit, todo: accounts for anyone --- code/modules/jobs/job_types/job.dm | 29 ++++++++++--------- .../code/controllers/subsystem/economy.dm | 4 +-- hyperstation/code/modules/economy/account.dm | 15 ++++------ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/code/modules/jobs/job_types/job.dm b/code/modules/jobs/job_types/job.dm index ed11b8e30..eadf53fdc 100644 --- a/code/modules/jobs/job_types/job.dm +++ b/code/modules/jobs/job_types/job.dm @@ -106,20 +106,20 @@ //Equip the rest of the gear H.dna.species.before_equip_job(src, H, visualsOnly) + if(!visualsOnly) + generate_bank_account(H) //TODO: accounts assigned to IDs. makes this less ugly + if(outfit_override || outfit) H.equipOutfit(outfit_override ? outfit_override : outfit, visualsOnly) - H.dna.species.after_equip_job(src, H, visualsOnly) - if(!visualsOnly && announce) - generate_bank_account() - if(announce) - announce(H) + announce(H) + + H.dna.species.after_equip_job(src, H, visualsOnly) /// Generates a bank account for the person who's getting this job datum /datum/job/proc/generate_bank_account(mob/living/carbon/human/reciever) - var/datum/bank_account/bank_account = new(reciever.real_name, src) - return bank_account + return new/datum/bank_account(reciever, src) /datum/job/proc/get_access() if(!config) //Needed for robots. @@ -234,8 +234,8 @@ else H.real_name = "[J.title] #[rand(10000, 99999)]" - var/obj/item/card/id/C = H.wear_id var/client/preference_source = H.client + var/obj/item/card/id/C = H.wear_id if(istype(C)) C.access = J.get_access() shuffle_inplace(C.access) // Shuffle access list to make NTNet passkeys less predictable @@ -246,11 +246,14 @@ else C.update_label() - for(var/A in SSeconomy.bank_accounts) - var/datum/bank_account/B = A - if(B.account_id == H.account_id) - C.registered_account = B - B.bank_cards += C + for(var/datum/bank_account/account as anything in SSeconomy.bank_accounts) + if(account.account_id == H.account_id) + C.registered_account = account + account.bank_cards += C + //Todo: remove bank_cards, have accounts for everyone who knows the pin to an ID. monkey go ook ook (he's rich) + //one card should have one account, sorta like how real cards work + //ping cyanosis if bank_cards is still here + account.associated_id = C //Also make this better to work with break H.sec_hud_set_ID() diff --git a/hyperstation/code/controllers/subsystem/economy.dm b/hyperstation/code/controllers/subsystem/economy.dm index 69dee7c8c..ca1fa5201 100644 --- a/hyperstation/code/controllers/subsystem/economy.dm +++ b/hyperstation/code/controllers/subsystem/economy.dm @@ -3,14 +3,14 @@ SUBSYSTEM_DEF(economy) wait = 5 MINUTES priority = FIRE_PRIORITY_ECONOMY init_order = INIT_ORDER_ECONOMY - runlevels = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME /// How many "paychecks" someone gets at the creation of the bank account var/roundstart_paychecks = 5 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)) + account.GivePaycheck(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. diff --git a/hyperstation/code/modules/economy/account.dm b/hyperstation/code/modules/economy/account.dm index 011df17a2..2caab9c8f 100644 --- a/hyperstation/code/modules/economy/account.dm +++ b/hyperstation/code/modules/economy/account.dm @@ -1,5 +1,3 @@ -#define DUMPTIME 3000 - /datum/bank_account var/account_holder = "Some pleboid" var/balance = 0 @@ -10,10 +8,10 @@ var/account_id = 1 var/base_pay = 60 -/datum/bank_account/New(newname="Some plebith", datum/job/job) - account_holder = newname +/datum/bank_account/New(mob/living/carbon/human/new_holder, datum/job/job) + account_holder = new_holder.real_name account_job = job - account_id = rand(111111,999999) + new_holder.account_id = 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.") @@ -23,14 +21,13 @@ 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) +/datum/bank_account/proc/GivePaycheck(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) + for(var/mob/M in get_hearers_in_view(1, local_turf)) M.playsound_local(local_turf, 'sound/machines/twobeep_high.ogg', 50, vary = TRUE) - to_chat(M, "[icon2html(src, associated_id.loc)] [icon2html(associated_id, M)] Paycheck processed, your account now holds [balance] credits.") /datum/bank_account/Destroy() if(SSeconomy)