var/global/current_date_string var/global/num_financial_terminals = 1 var/global/num_financial_database = 1 var/global/num_vending_machines = 1 var/global/num_pda_terminals = 1 var/global/num_merch_computers = 1 var/global/datum/money_account/station_account var/global/list/datum/money_account/department_accounts = list() var/global/next_account_number = 0 var/global/obj/machinery/account_database/centcomm_account_db var/global/datum/money_account/vendor_account var/global/list/all_money_accounts = list() var/global/datum/money_account/trader_account var/global/allowable_payroll_amount = DEPARTMENT_START_WAGE*8 //Station, command, engineering, medical, security, science, cargo, and civilian /proc/create_station_account() if(!station_account) next_account_number = rand(11111, 99999) station_account = new() station_account.owner_name = "[station_name()] Station Account" station_account.account_number = rand(11111, 99999) station_account.remote_access_pin = rand(1111, 9999) station_account.money = DEPARTMENT_START_FUNDS station_account.wage_gain = DEPARTMENT_START_WAGE //create an entry in the account transaction log for when it was created var/datum/transaction/T = new() T.target_name = station_account.owner_name T.purpose = "Account creation" T.amount = 750 T.date = "2nd April, [game_year]" T.time = "11:24" T.source_terminal = "Biesel GalaxyNet Terminal #277" //add the account station_account.transaction_log.Add(T) all_money_accounts.Add(station_account) /proc/create_department_account(department, var/recieves_wage = 0) next_account_number = rand(111111, 999999) var/datum/money_account/department_account = new() department_account.owner_name = "[department] Account" department_account.account_number = rand(11111, 99999) department_account.remote_access_pin = rand(1111, 9999) department_account.money = DEPARTMENT_START_FUNDS if(recieves_wage == 1) department_account.wage_gain = DEPARTMENT_START_WAGE //create an entry in the account transaction log for when it was created var/datum/transaction/T = new() T.target_name = department_account.owner_name T.purpose = "Account creation" T.amount = department_account.money T.date = "2nd April, [game_year]" T.time = "11:24" T.source_terminal = "Biesel GalaxyNet Terminal #277" //add the account department_account.transaction_log.Add(T) all_money_accounts.Add(department_account) department_accounts[department] = department_account //the current ingame time (hh:mm) can be obtained by calling: //worldtime2text() /proc/create_account(var/new_owner_name = "Default user", var/starting_funds = 0, var/obj/machinery/account_database/source_db, var/wage_payout = 0, var/security_pref = 1, var/makehidden = FALSE) //create a new account var/datum/money_account/M = new() M.owner_name = new_owner_name M.remote_access_pin = rand(1111, 9999) M.money = starting_funds M.wage_gain = wage_payout M.security_level = security_pref M.hidden = makehidden //create an entry in the account transaction log for when it was created var/datum/transaction/T = new() T.target_name = new_owner_name T.purpose = "Account creation" T.amount = starting_funds if(!source_db) //set a random date, time and location some time over the past few decades var/DD = text2num(time2text(world.timeofday, "DD")) //For muh lore we'll pretend that Nanotrasen changed its account policy T.date = "[(DD == 1) ? "31" : "[DD-1]"] [time2text(world.timeofday, "Month")], [game_year]" //shortly before the events of the round, T.time = "[rand(0,24)]:[rand(11,59)]" //prompting everyone to get a new account one day prior. T.source_terminal = "NTGalaxyNet Terminal #[multinum_display(rand(111,1111),4)]" //The point being to partly to justify the transaction history being empty at the beginning of the round. M.account_number = rand(11111, 99999) else T.date = current_date_string T.time = worldtime2text() T.source_terminal = source_db.machine_id M.account_number = next_account_number next_account_number += rand(1,25) //create a sealed package containing the account details var/obj/item/delivery/P = new /obj/item/delivery(source_db.loc) var/obj/item/weapon/paper/R = new /obj/item/weapon/paper(P) R.name = "Account information: [M.owner_name]" R.info = {"Account details (confidential)


Account holder: [M.owner_name]
Account number: [M.account_number]
Account pin: [M.remote_access_pin]
Starting balance: $[M.money]
Date and time: [worldtime2text()], [current_date_string]

Creation terminal ID: [source_db.machine_id]
Authorised NT officer overseeing creation: [source_db.held_card.registered_name]
"} //stamp the paper var/image/stampoverlay = image('icons/obj/bureaucracy.dmi') stampoverlay.icon_state = "paper_stamp-cent" if(!R.stamped) R.stamped = new R.stamped += /obj/item/weapon/stamp R.overlays += stampoverlay R.stamps += "
This paper has been stamped by the Accounts Database." //add the account M.transaction_log.Add(T) all_money_accounts.Add(M) return M /datum/money_account var/owner_name = "" var/account_number = 0 var/remote_access_pin = 0 var/money = 0 var/list/transaction_log = list() var/security_level = 1 //0 - auto-identify from worn ID, require only account number //1 - require manual login / account number and pin //2 - require card and manual login var/virtual = 0 var/wage_gain = 0 // How much an account gains per 'wage' tick. var/disabled = 0 var/hidden = FALSE // 0 Unlocked // 1 User locked // 2 Admin locked /datum/transaction var/target_name = "" var/purpose = "" var/amount = 0 var/date = "" var/time = "" var/source_terminal = "" /obj/machinery/account_database name = "accounts database" desc = "Holds transaction logs, account data and all kinds of other financial records." icon = 'icons/obj/stationobjs.dmi' icon_state = "account_db" density = TRUE anchored = TRUE req_one_access = list(access_hop, access_captain) var/receipt_num var/machine_id = "" var/obj/item/weapon/card/id/held_card var/access_level = 0 var/datum/money_account/detailed_account_view var/creating_new_account = 0 var/activated = 1 machine_flags = EMAGGABLE | WRENCHMOVE | FIXED2WORK | EJECTNOTDEL /obj/machinery/account_database/New(loc) ..(loc) if(!station_account) create_station_account() if(department_accounts.len == 0) for(var/department in station_departments) create_department_account(department, recieves_wage = 1) if(!vendor_account) vendor_account = create_account("Vendor", 0, null, 0, 1, TRUE) if(!current_date_string) current_date_string = "[time2text(world.timeofday, "DD")] [time2text(world.timeofday, "Month")], [game_year]" machine_id = "[station_name()] Account Database #[multinum_display(num_financial_database,4)]" num_financial_database++ account_DBs += src if(ticker) initialize() /obj/machinery/account_database/initialize() ..() if(z == CENTCOMM_Z && isnull(centcomm_account_db)) centcomm_account_db = src /obj/machinery/account_database/Destroy() if(centcomm_account_db == src) centcomm_account_db = null ..() /obj/machinery/account_database/attack_hand(mob/user as mob) . = ..() if(.) return if(isAdminGhost(user) || (ishuman(user) && !user.stat && get_dist(src,user) <= 1)) var/dat = "Accounts Database
" dat += {"[machine_id]
Confirm identity: [held_card ? held_card : "-----"]
"} if(access_level > 0 || isAdminGhost(user)) dat += {"[activated ? "Disable" : "Enable"] remote access
Combined department and personnel budget is currently [global.allowable_payroll_amount] credits. A total of [global.requested_payroll_amount] credits were requested during the last payroll cycle.
"} if(creating_new_account) dat += {"
Return to accounts list
Holder name:
Initial funds: (subtracted from station account.)
New accounts are automatically assigned a secret number and pin, which are printed separately in a sealed package.
Ensure that the station account has enough money to create the account, or it will not be created
"} else if(detailed_account_view) dat += {"
Return to accounts list
Account number: #[detailed_account_view.account_number]
Account holder: [detailed_account_view.owner_name]
Account balance: $[detailed_account_view.money]
Assigned wage payout: $[detailed_account_view.wage_gain] Edit
Account status: "} switch(detailed_account_view.disabled) if(0) dat += "Enabled" if(1) dat += "User Disabled" if(2) dat += "Administratively Disabled" else dat += "???ERROR???" dat += {"
Administratively [detailed_account_view.disabled ? "enable" : "disable"] account
"} for(var/datum/transaction/T in detailed_account_view.transaction_log) dat += {""} dat += "
Date Time Target Purpose Value Source terminal ID
[T.date] [T.time] [T.target_name] [T.purpose] $[T.amount] [T.source_terminal]
" else dat += {"Create new account

"} for(var/i=1, i<=all_money_accounts.len, i++) var/datum/money_account/D = all_money_accounts[i] if(D.hidden) continue dat += {""} dat += "
#[D.account_number] [D.owner_name] View in detail
" user << browse(dat,"window=account_db;size=700x650") else user << browse(null,"window=account_db") /obj/machinery/account_database/attackby(var/obj/O, var/mob/user) . = ..() if(.) return if(isID(O)) var/obj/item/weapon/card/id/idcard = O if(access_level == 3) return attack_hand(user) if(!held_card) if(usr.drop_item(O, src)) held_card = idcard if(access_cent_captain in idcard.access) access_level = 2 else if((access_hop in idcard.access) || (access_captain in idcard.access)) access_level = 1 /obj/machinery/account_database/emag(mob/user) if(emagged) emagged = 0 access_level = 0 if(held_card) var/obj/item/weapon/card/id/C = held_card if(access_cent_captain in C.access) access_level = 2 else if((access_hop in C.access) || (access_captain in C.access)) access_level = 1 attack_hand(user) to_chat(user, "You re-enable the security checks of [src].") else emagged = 1 access_level = 3 to_chat(user, "You disable the security checks of [src].") return /obj/machinery/account_database/Topic(var/href, var/href_list) if(..()) return 1 if(href_list["toggle_activated"]) activated = !activated if(href_list["choice"]) switch(href_list["choice"]) if("create_account") creating_new_account = 1 if("finalise_create_account") var/account_name = href_list["holder_name"] var/starting_funds = max(text2num(href_list["starting_funds"]), 0) if ((station_account.money - starting_funds) > 0) station_account.money -= starting_funds if(starting_funds >0) //Create a transaction log entry if you need to var/datum/transaction/T = new() T.target_name = account_name T.purpose = "New account funds initialisation" T.amount = "([starting_funds])" T.date = current_date_string T.time = worldtime2text() T.source_terminal = machine_id station_account.transaction_log.Add(T) create_account(account_name, starting_funds, src) creating_new_account = 0 if("insert_card") if(held_card) held_card.forceMove(src.loc) if(ishuman(usr) && !usr.get_active_hand()) usr.put_in_hands(held_card) held_card = null if(access_level < 3) access_level = 0 else var/obj/item/I = usr.get_active_hand() if(isEmag(I)) emag(usr) return if (istype(I, /obj/item/weapon/card/id)) var/obj/item/weapon/card/id/C = I if(usr.drop_item(C, src)) held_card = C if(access_level < 3) if(access_cent_captain in C.access) access_level = 2 else if((access_hop in C.access) || (access_captain in C.access)) access_level = 1 if("view_account_detail") var/index = text2num(href_list["account_index"]) if(index && index <= all_money_accounts.len) detailed_account_view = all_money_accounts[index] if("view_accounts_list") detailed_account_view = null creating_new_account = 0 if("toggle_account") if(detailed_account_view) detailed_account_view.disabled = detailed_account_view.disabled ? 0 : 2 if("edit_wage_payout") var/acc_num = text2num(href_list["account_num"]) var/datum/money_account/acc = get_money_account_global(acc_num) if(acc) var/new_payout = input(usr, "Select a new payout for this account", "New payout", acc.wage_gain) as null|num if(new_payout >= 0 && new_payout != null) acc.wage_gain = round(new_payout) detailed_account_view = acc src.attack_hand(usr) /obj/machinery/account_database/proc/charge_to_account(var/attempt_account_number, var/source_name, var/purpose, var/terminal_id, var/amount) if(!activated || !attempt_account_number) return 0 for(var/datum/money_account/D in all_money_accounts) if(D.account_number == attempt_account_number) D.money += amount //create a transaction log entry var/datum/transaction/T = new() T.target_name = source_name T.purpose = purpose if(amount < 0) T.amount = "-[amount]" else T.amount = "[amount]" T.date = current_date_string T.time = worldtime2text() T.source_terminal = terminal_id D.transaction_log.Add(T) return 1 return 0 //this returns the first account datum that matches the supplied accnum/pin combination, it returns null if the combination did not match any account /obj/machinery/account_database/proc/attempt_account_access(var/attempt_account_number, var/attempt_pin_number, var/security_level_passed = 0,var/pin_needed=1) if(!activated || !attempt_account_number) return 0 for(var/datum/money_account/D in all_money_accounts) if(D.account_number == attempt_account_number) if( D.security_level <= security_level_passed && (!D.security_level || D.remote_access_pin == attempt_pin_number || !pin_needed) ) return D /obj/machinery/account_database/proc/get_account(var/account_number) if(!account_number) // Don't bother searching if there's no account number. return null for(var/datum/money_account/D in all_money_accounts) if(D.account_number == account_number) return D