From a43dddf3cbb2df4045e395c1c8dcb6c4ed5c6b05 Mon Sep 17 00:00:00 2001 From: Jamie D Date: Sun, 10 May 2020 22:51:53 +0100 Subject: [PATCH] Fixes agent id's and adds bank accounts to them --- code/game/objects/items/cards_ids.dm | 71 ++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/code/game/objects/items/cards_ids.dm b/code/game/objects/items/cards_ids.dm index 1bb5b687dd24..b27cb7a72def 100644 --- a/code/game/objects/items/cards_ids.dm +++ b/code/game/objects/items/cards_ids.dm @@ -290,6 +290,7 @@ update_label("John Doe", "Clowny") name = "agent card" access = list(ACCESS_MAINT_TUNNELS, ACCESS_SYNDICATE) var/anyone = FALSE //Can anyone forge the ID or just syndicate? + var/forged = FALSE //have we set a custom name and job assignment, or will we use what we're given when we chameleon change? /obj/item/card/id/syndicate/Initialize() . = ..() @@ -310,24 +311,25 @@ update_label("John Doe", "Clowny") /obj/item/card/id/syndicate/attack_self(mob/user) if(isliving(user) && user.mind) + var/first_use = registered_name ? FALSE : TRUE if(!(user.mind.special_role || anyone)) //Unless anyone is allowed, only syndies can use the card, to stop metagaming. - if(!registered_name) //If a non-syndie is the first to forge an unassigned agent ID, then anyone can forge it. + if(first_use) //If a non-syndie is the first to forge an unassigned agent ID, then anyone can forge it. anyone = TRUE else return ..() - var/popup_input = alert(user, "Choose Action", "Agent ID", "Show", "Forge/Reset") + var/popup_input = alert(user, "Choose Action", "Agent ID", "Show", "Forge/Reset", "Change Account ID") if(user.incapacitated()) return - if(popup_input == "Forge/Reset" && !registered_name) + if(popup_input == "Forge/Reset" && !forged) var/input_name = stripped_input(user, "What name would you like to put on this card? Leave blank to randomise.", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name), MAX_NAME_LEN) input_name = reject_bad_name(input_name) if(!input_name) // Invalid/blank names give a randomly generated one. if(user.gender == FEMALE) - input_name = "[pick(GLOB.first_names_male)] [pick(GLOB.last_names)]" - else input_name = "[pick(GLOB.first_names_female)] [pick(GLOB.last_names)]" + else + input_name = "[pick(GLOB.first_names_male)] [pick(GLOB.last_names)]" var/target_occupation = stripped_input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", assignment ? assignment : "Assistant", MAX_MESSAGE_LEN) if(!target_occupation) @@ -336,10 +338,69 @@ update_label("John Doe", "Clowny") registered_name = input_name assignment = target_occupation update_label() + forged = TRUE to_chat(user, "You successfully forge the ID card.") + log_game("[key_name(user)] has forged \the [initial(name)] with name \"[registered_name]\" and occupation \"[assignment]\".") + + // First time use automatically sets the account id to the user. + if (first_use && !registered_account) + if(ishuman(user)) + var/mob/living/carbon/human/accountowner = user + + for(var/bank_account in SSeconomy.bank_accounts) + var/datum/bank_account/account = bank_account + if(account.account_id == accountowner.account_id) + account.bank_cards += src + registered_account = account + to_chat(user, "Your account number has been automatically assigned.") + return + else if (popup_input == "Forge/Reset" && forged) + registered_name = initial(registered_name) + assignment = initial(assignment) + log_game("[key_name(user)] has reset \the [initial(name)] named \"[src]\" to default.") + update_label() + forged = FALSE + to_chat(user, "You successfully reset the ID card.") + return + else if (popup_input == "Change Account ID") + set_new_account(user) return return ..() +// Returns true if new account was set. +/obj/item/card/id/proc/set_new_account(mob/living/user) + . = FALSE + var/datum/bank_account/old_account = registered_account + + var/new_bank_id = input(user, "Enter your account ID number.", "Account Reclamation", 111111) as num | null + + if (isnull(new_bank_id)) + return + + if(!alt_click_can_use_id(user)) + return + if(!new_bank_id || new_bank_id < 111111 || new_bank_id > 999999) + to_chat(user, "The account ID number needs to be between 111111 and 999999.") + return + if (registered_account && registered_account.account_id == new_bank_id) + to_chat(user, "The account ID was already assigned to this card.") + return + + for(var/A in SSeconomy.bank_accounts) + var/datum/bank_account/B = A + if(B.account_id == new_bank_id) + if (old_account) + old_account.bank_cards -= src + + B.bank_cards += src + registered_account = B + to_chat(user, "The provided account has been linked to this ID card.") + + return TRUE + + to_chat(user, "The account ID number provided is invalid.") + return + /obj/item/card/id/syndicate/anyone anyone = TRUE