From 955160e9d663a0068f973d20d30b4102a73da570 Mon Sep 17 00:00:00 2001 From: Cael Aislinn Date: Fri, 20 Sep 2013 13:35:49 +1000 Subject: [PATCH] moves and renames economy files to /modules instead of /wip, cleanup and shuffles of a bunch of code, removes "linked_db" (requirement for financial machinery to be connected to an accounts database) Signed-off-by: Cael Aislinn --- baystation12.dme | 17 +- .../Cael_Aislinn/Economy/Accounts.dm | 343 ------------------ code/game/gamemodes/gameticker.dm | 7 - code/game/jobs/job_controller.dm | 45 ++- code/game/machinery/vending.dm | 37 +- .../Mini => modules/Economy}/ATM.dm | 159 ++++---- code/modules/Economy/Accounts.dm | 113 ++++++ code/modules/Economy/Accounts_DB.dm | 169 +++++++++ .../Economy/EFTPOS.dm | 126 +++---- .../Economy/Events.dm} | 3 - .../Economy/Events_Mundane.dm} | 0 .../Economy/Job_Departments.dm | 0 .../Economy.dm => modules/Economy/Misc.dm} | 77 +++- .../Economy/TradeDestinations.dm} | 0 code/modules/events/money_hacker.dm | 141 ++++--- code/modules/events/money_lotto.dm | 28 +- 16 files changed, 601 insertions(+), 664 deletions(-) delete mode 100644 code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm rename code/{WorkInProgress/Mini => modules/Economy}/ATM.dm (69%) create mode 100644 code/modules/Economy/Accounts.dm create mode 100644 code/modules/Economy/Accounts_DB.dm rename code/{WorkInProgress/Cael_Aislinn => modules}/Economy/EFTPOS.dm (74%) rename code/{WorkInProgress/Cael_Aislinn/Economy/Economy_Events.dm => modules/Economy/Events.dm} (99%) rename code/{WorkInProgress/Cael_Aislinn/Economy/Economy_Events_Mundane.dm => modules/Economy/Events_Mundane.dm} (100%) rename code/{WorkInProgress/Cael_Aislinn => modules}/Economy/Job_Departments.dm (100%) rename code/{WorkInProgress/Cael_Aislinn/Economy/Economy.dm => modules/Economy/Misc.dm} (60%) rename code/{WorkInProgress/Cael_Aislinn/Economy/Economy_TradeDestinations.dm => modules/Economy/TradeDestinations.dm} (100%) diff --git a/baystation12.dme b/baystation12.dme index afc009508f5..48b19519b49 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -746,6 +746,15 @@ #include "code\modules\DetectiveWork\evidence.dm" #include "code\modules\DetectiveWork\footprints_and_rag.dm" #include "code\modules\DetectiveWork\scanner.dm" +#include "code\modules\Economy\Accounts.dm" +#include "code\modules\Economy\Accounts_DB.dm" +#include "code\modules\Economy\ATM.dm" +#include "code\modules\Economy\EFTPOS.dm" +#include "code\modules\Economy\Events.dm" +#include "code\modules\Economy\Events_Mundane.dm" +#include "code\modules\Economy\Job_Departments.dm" +#include "code\modules\Economy\Misc.dm" +#include "code\modules\Economy\TradeDestinations.dm" #include "code\modules\events\alien_infestation.dm" #include "code\modules\events\blob.dm" #include "code\modules\events\brand_intelligence.dm" @@ -1242,13 +1251,6 @@ #include "code\WorkInProgress\explosion_particles.dm" #include "code\WorkInProgress\periodic_news.dm" #include "code\WorkInProgress\Apples\artifacts.dm" -#include "code\WorkInProgress\Cael_Aislinn\Economy\Accounts.dm" -#include "code\WorkInProgress\Cael_Aislinn\Economy\Economy.dm" -#include "code\WorkInProgress\Cael_Aislinn\Economy\Economy_Events.dm" -#include "code\WorkInProgress\Cael_Aislinn\Economy\Economy_Events_Mundane.dm" -#include "code\WorkInProgress\Cael_Aislinn\Economy\Economy_TradeDestinations.dm" -#include "code\WorkInProgress\Cael_Aislinn\Economy\EFTPOS.dm" -#include "code\WorkInProgress\Cael_Aislinn\Economy\Job_Departments.dm" #include "code\WorkInProgress\Cael_Aislinn\Jungle\falsewall.dm" #include "code\WorkInProgress\Cael_Aislinn\Jungle\jungle.dm" #include "code\WorkInProgress\Cael_Aislinn\Jungle\jungle_animals.dm" @@ -1285,7 +1287,6 @@ #include "code\WorkInProgress\Cael_Aislinn\Supermatter\ZeroPointLaser.dm" #include "code\WorkInProgress\Chinsky\ashtray.dm" #include "code\WorkInProgress\kilakk\fax.dm" -#include "code\WorkInProgress\Mini\ATM.dm" #include "code\WorkInProgress\Mini\atmos_control.dm" #include "code\WorkInProgress\Ported\policetape.dm" #include "code\WorkInProgress\SkyMarshal\officer_stuff.dm" diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm b/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm deleted file mode 100644 index 464381ab688..00000000000 --- a/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm +++ /dev/null @@ -1,343 +0,0 @@ -var/global/current_date_string -var/global/num_financial_terminals = 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() - -/proc/create_station_account() - if(!station_account) - next_account_number = rand(111111, 999999) - - station_account = new() - station_account.owner_name = "[station_name()] Station Account" - station_account.account_number = rand(111111, 999999) - station_account.remote_access_pin = rand(1000, 9999) - station_account.money = 75000 - - //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 = 75000 - T.date = "2nd April, 2555" - 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) - next_account_number = rand(111111, 999999) - - var/datum/money_account/department_account = new() - department_account.owner_name = "[department] Account" - department_account.account_number = rand(111111, 999999) - department_account.remote_access_pin = rand(1000, 9999) - department_account.money = 5000 - - //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, 2555" - 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) - - //create a new account - var/datum/money_account/M = new() - M.owner_name = new_owner_name - M.remote_access_pin = rand(1000, 9999) - M.money = starting_funds - - //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 - T.date = "[num2text(rand(1,31))] [pick("January","February","March","April","May","June","July","August","September","October","November","December")], 25[rand(10,56)]" - T.time = "[rand(0,24)]:[rand(11,59)]" - T.source_terminal = "NTGalaxyNet Terminal #[rand(111,1111)]" - - M.account_number = rand(111111, 999999) - 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/smallDelivery/P = new /obj/item/smallDelivery(source_db.loc) - - var/obj/item/weapon/paper/R = new /obj/item/weapon/paper(P) - P.wrapped = R - R.name = "Account information: [M.owner_name]" - R.info = "Account details (confidential)


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

" - R.info += "Creation terminal ID: [source_db.machine_id]
" - R.info += "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 - -/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/virology.dmi' - icon_state = "analyser" - density = 1 - 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 - -/obj/machinery/account_database/New() - ..() - if(!station_account) - create_station_account() - - if(department_accounts.len == 0) - for(var/department in station_departments) - create_department_account(department) - if(!vendor_account) - create_department_account("Vendor") - vendor_account = department_accounts["Vendor"] - - if(!current_date_string) - current_date_string = "[num2text(rand(1,31))] [pick("January","February","March","April","May","June","July","August","September","October","November","December")], [game_year]" - - machine_id = "[station_name()] Acc. DB #[num_financial_terminals++]" - -/obj/machinery/account_database/attack_hand(mob/user as mob) - if(get_dist(src,user) <= 1) - var/dat = "Accounts Database
" - dat += "[machine_id]
" - dat += "Confirm identity: [held_card ? held_card : "-----"]
" - - if(access_level > 0) - dat += "[activated ? "Disable" : "Enable"] remote access
" - dat += "You may not edit accounts at this terminal, only create and view them.
" - if(creating_new_account) - dat += "
" - dat += "Return to accounts list" - dat += "
" - dat += "" - dat += "" - dat += "Holder name:
" - dat += "Initial funds: (subtracted from station account)
" - dat += "New accounts are automatically assigned a secret number and pin, which are printed separately in a sealed package.
" - dat += "
" - dat += "
" - else - if(detailed_account_view) - dat += "
" - dat += "Return to accounts list
" - dat += "Account number: #[detailed_account_view.account_number]
" - dat += "Account holder: [detailed_account_view.owner_name]
" - dat += "Account balance: $[detailed_account_view.money]
" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - for(var/datum/transaction/T in detailed_account_view.transaction_log) - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "
DateTimeTargetPurposeValueSource terminal ID
[T.date][T.time][T.target_name][T.purpose]$[T.amount][T.source_terminal]
" - else - dat += "Create new account

" - dat += "" - for(var/i=1, i<=all_money_accounts.len, i++) - var/datum/money_account/D = all_money_accounts[i] - dat += "" - dat += "" - dat += "" - dat += "" - 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(O as obj, user as mob)//TODO:SANITY - if(istype(O, /obj/item/weapon/card)) - var/obj/item/weapon/card/id/idcard = O - if(!held_card) - usr.drop_item() - idcard.loc = 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 - else - ..() - -/obj/machinery/account_database/Topic(var/href, var/href_list) - - 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) - create_account(account_name, starting_funds, src) - if(starting_funds > 0) - //subtract the money - station_account.money -= starting_funds - - //create a transaction log entry - 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) - - creating_new_account = 0 - if("insert_card") - if(held_card) - held_card.loc = src.loc - - if(ishuman(usr) && !usr.get_active_hand()) - usr.put_in_hands(held_card) - held_card = null - access_level = 0 - - else - var/obj/item/I = usr.get_active_hand() - if (istype(I, /obj/item/weapon/card/id)) - var/obj/item/weapon/card/id/C = I - usr.drop_item() - C.loc = src - held_card = C - - 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 - - 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) - 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) - if(!activated) - 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) ) - return D - -/obj/machinery/account_database/proc/get_account(var/account_number) - for(var/datum/money_account/D in all_money_accounts) - if(D.account_number == account_number) - return D - -/obj/machinery/account_database/process() - return 0 diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 4d83aa5eefa..209339db80e 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -106,13 +106,6 @@ var/global/datum/controller/gameticker/ticker else src.mode.announce() - //setup the money accounts - if(!centcomm_account_db) - for(var/obj/machinery/account_database/check_db in machines) - if(check_db.z == 2) - centcomm_account_db = check_db - break - create_characters() //Create player characters and transfer them collect_minds() equip_characters() diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index cb8a73278c6..95a6ec439b8 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -368,35 +368,34 @@ var/global/datum/controller/occupations/job_master H.loc = S.loc //give them an account in the station database - if(centcomm_account_db) - var/datum/money_account/M = create_account(H.real_name, rand(50,500)*10, null) - if(H.mind) - var/remembered_info = "" - remembered_info += "Your account number is: #[M.account_number]
" - remembered_info += "Your account pin is: [M.remote_access_pin]
" - remembered_info += "Your account funds are: $[M.money]
" + var/datum/money_account/M = create_account(H.real_name, rand(50,500)*10, null) + if(H.mind) + var/remembered_info = "" + remembered_info += "Your account number is: #[M.account_number]
" + remembered_info += "Your account pin is: [M.remote_access_pin]
" + remembered_info += "Your account funds are: $[M.money]
" - if(M.transaction_log.len) - var/datum/transaction/T = M.transaction_log[1] - remembered_info += "Your account was created: [T.time], [T.date] at [T.source_terminal]
" - H.mind.store_memory(remembered_info) + if(M.transaction_log.len) + var/datum/transaction/T = M.transaction_log[1] + remembered_info += "Your account was created: [T.time], [T.date] at [T.source_terminal]
" + H.mind.store_memory(remembered_info) - H.mind.initial_account = M + H.mind.initial_account = M - // If they're head, give them the account info for their department - if(H.mind && job.head_position) - var/remembered_info = "" - var/datum/money_account/department_account = department_accounts[job.department] + // If they're head, give them the account info for their department + if(H.mind && job.head_position) + var/remembered_info = "" + var/datum/money_account/department_account = department_accounts[job.department] - if(department_account) - remembered_info += "Your department's account number is: #[department_account.account_number]
" - remembered_info += "Your department's account pin is: [department_account.remote_access_pin]
" - remembered_info += "Your department's account funds are: $[department_account.money]
" + if(department_account) + remembered_info += "Your department's account number is: #[department_account.account_number]
" + remembered_info += "Your department's account pin is: [department_account.remote_access_pin]
" + remembered_info += "Your department's account funds are: $[department_account.money]
" - H.mind.store_memory(remembered_info) + H.mind.store_memory(remembered_info) - spawn(0) - H << "\blueYour account number is: [M.account_number], your account pin is: [M.remote_access_pin]" + spawn(0) + H << "\blueYour account number is: [M.account_number], your account pin is: [M.remote_access_pin]" var/alt_title = null if(H.mind) diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index 9439757282a..77fe35c4d34 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -52,9 +52,6 @@ var/const/WIRE_SHOCK = 3 var/const/WIRE_SHOOTINV = 4 - var/obj/machinery/account_database/linked_db - var/datum/money_account/linked_account - /obj/machinery/vending/New() ..() spawn(4) @@ -71,19 +68,10 @@ src.build_inventory(premium, 0, 1) power_change() - reconnect_database() - linked_account = vendor_account - return return -/obj/machinery/vending/proc/reconnect_database() - for(var/obj/machinery/account_database/DB in world) - if(DB.z == src.z) - linked_db = DB - break - /obj/machinery/vending/ex_act(severity) switch(severity) if(1.0) @@ -158,17 +146,8 @@ user << "\blue You insert the [W] into the [src]" return else if(istype(W, /obj/item/weapon/card) && currently_vending) - //attempt to connect to a new db, and if that doesn't work then fail - if(!linked_db) - reconnect_database() - if(linked_db) - if(linked_account) - var/obj/item/weapon/card/I = W - scan_card(I) - else - usr << "\icon[src]Unable to connect to linked account." - else - usr << "\icon[src]Unable to connect to accounts database." + var/obj/item/weapon/card/I = W + scan_card(I) else ..() @@ -177,20 +156,20 @@ if (istype(I, /obj/item/weapon/card/id)) var/obj/item/weapon/card/id/C = I visible_message("[usr] swipes a card through [src].") - if(linked_account) + if(vendor_account) var/attempt_pin = input("Enter pin code", "Vendor transaction") as num - var/datum/money_account/D = linked_db.attempt_account_access(C.associated_account_number, attempt_pin, 2) + var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2) if(D) var/transaction_amount = currently_vending.price if(transaction_amount <= D.money) //transfer the money D.money -= transaction_amount - linked_account.money += transaction_amount + vendor_account.money += transaction_amount //create entries in the two account transaction logs var/datum/transaction/T = new() - T.target_name = "[linked_account.owner_name] (via [src.name])" + T.target_name = "[vendor_account.owner_name] (via [src.name])" T.purpose = "Purchase of [currently_vending.product_name]" if(transaction_amount > 0) T.amount = "([transaction_amount])" @@ -208,7 +187,7 @@ T.source_terminal = src.name T.date = current_date_string T.time = worldtime2text() - linked_account.transaction_log.Add(T) + vendor_account.transaction_log.Add(T) // Vend the item src.vend(src.currently_vending, usr) @@ -218,7 +197,7 @@ else usr << "\icon[src]Unable to access account. Check security settings and try again." else - usr << "\icon[src]EFTPOS is not connected to an account." + usr << "\icon[src]Unable to access vendor account. Please record the machine ID and call CentComm Support." /obj/machinery/vending/attack_paw(mob/user as mob) return attack_hand(user) diff --git a/code/WorkInProgress/Mini/ATM.dm b/code/modules/Economy/ATM.dm similarity index 69% rename from code/WorkInProgress/Mini/ATM.dm rename to code/modules/Economy/ATM.dm index dc8f9150686..b43c73ca669 100644 --- a/code/WorkInProgress/Mini/ATM.dm +++ b/code/modules/Economy/ATM.dm @@ -22,7 +22,6 @@ log transactions anchored = 1 use_power = 1 idle_power_usage = 10 - var/obj/machinery/account_database/linked_db var/datum/money_account/authenticated_account var/number_incorrect_tries = 0 var/previous_account_number = 0 @@ -38,20 +37,10 @@ log transactions ..() machine_id = "[station_name()] RT #[num_financial_terminals++]" -/obj/machinery/atm/initialize() - ..() - reconnect_database() - /obj/machinery/atm/process() if(stat & NOPOWER) return - if(linked_db && ( (linked_db.stat & NOPOWER) || !linked_db.activated ) ) - linked_db = null - authenticated_account = null - src.visible_message("\red \icon[src] [src] buzzes rudely, \"Connection to remote database lost.\"") - updateDialog() - if(ticks_left_timeout > 0) ticks_left_timeout-- if(ticks_left_timeout <= 0) @@ -69,12 +58,6 @@ log transactions playsound(loc, 'sound/items/polaroid2.ogg', 50, 1) break -/obj/machinery/atm/proc/reconnect_database() - for(var/obj/machinery/account_database/DB in world) //Hotfix until someone finds out why it isn't in 'machines' - if( DB.z == src.z && !(DB.stat & NOPOWER) && DB.activated ) - linked_db = DB - break - /obj/machinery/atm/attackby(obj/item/I as obj, mob/user as mob) if(istype(I, /obj/item/weapon/card)) var/obj/item/weapon/card/id/idcard = I @@ -126,69 +109,72 @@ log transactions if(ticks_left_locked_down > 0) dat += "Maximum number of pin attempts exceeded! Access to this ATM has been temporarily disabled." else if(authenticated_account) - switch(view_screen) - if(CHANGE_SECURITY_LEVEL) - dat += "Select a new security level for this account:

" - var/text = "Zero - Either the account number or card is required to access this account. EFTPOS transactions will require a card and ask for a pin, but not verify the pin is correct." - if(authenticated_account.security_level != 0) - text = "[text]" - dat += "[text]
" - text = "One - An account number and pin must be manually entered to access this account and process transactions." - if(authenticated_account.security_level != 1) - text = "[text]" - dat += "[text]
" - text = "Two - In addition to account number and pin, a card is required to access this account and process transactions." - if(authenticated_account.security_level != 2) - text = "[text]" - dat += "[text]

" - dat += "Back" - if(VIEW_TRANSACTION_LOGS) - dat += "Transaction logs
" - dat += "Back" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - for(var/datum/transaction/T in authenticated_account.transaction_log) + if(authenticated_account.suspended) + dat += "\redAccess to this account has been suspended, and the funds within frozen." + else + switch(view_screen) + if(CHANGE_SECURITY_LEVEL) + dat += "Select a new security level for this account:

" + var/text = "Zero - Either the account number or card is required to access this account. EFTPOS transactions will require a card and ask for a pin, but not verify the pin is correct." + if(authenticated_account.security_level != 0) + text = "[text]" + dat += "[text]
" + text = "One - An account number and pin must be manually entered to access this account and process transactions." + if(authenticated_account.security_level != 1) + text = "[text]" + dat += "[text]
" + text = "Two - In addition to account number and pin, a card is required to access this account and process transactions." + if(authenticated_account.security_level != 2) + text = "[text]" + dat += "[text]

" + dat += "Back" + if(VIEW_TRANSACTION_LOGS) + dat += "Transaction logs
" + dat += "Back" + dat += "
DateTimeTargetPurposeValueSource terminal ID
" dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" - dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" dat += "" - dat += "
[T.date][T.time][T.target_name][T.purpose]$[T.amount][T.source_terminal]DateTimeTargetPurposeValueSource terminal ID
" - if(TRANSFER_FUNDS) - dat += "Account balance: $[authenticated_account.money]
" - dat += "Back

" - dat += "
" - dat += "" - dat += "" - dat += "Target account number:
" - dat += "Funds to transfer:
" - dat += "Transaction purpose:
" - dat += "
" - dat += "
" - else - dat += "Welcome, [authenticated_account.owner_name].
" - dat += "Account balance: $[authenticated_account.money]" - dat += "
" - dat += "" - dat += "" - dat += "
" - dat += "
" - dat += "Change account security level
" - dat += "Make transfer
" - dat += "View transaction log
" - dat += "Print balance statement
" - dat += "Logout
" - else if(linked_db) + for(var/datum/transaction/T in authenticated_account.transaction_log) + dat += "" + dat += "[T.date]" + dat += "[T.time]" + dat += "[T.target_name]" + dat += "[T.purpose]" + dat += "$[T.amount]" + dat += "[T.source_terminal]" + dat += "" + dat += "" + if(TRANSFER_FUNDS) + dat += "Account balance: $[authenticated_account.money]
" + dat += "Back

" + dat += "
" + dat += "" + dat += "" + dat += "Target account number:
" + dat += "Funds to transfer:
" + dat += "Transaction purpose:
" + dat += "
" + dat += "
" + else + dat += "Welcome, [authenticated_account.owner_name].
" + dat += "Account balance: $[authenticated_account.money]" + dat += "
" + dat += "" + dat += "" + dat += "
" + dat += "
" + dat += "Change account security level
" + dat += "Make transfer
" + dat += "View transaction log
" + dat += "Print balance statement
" + dat += "Logout
" + else dat += "
" dat += "" dat += "" @@ -196,9 +182,6 @@ log transactions dat += "PIN:
" dat += "
" dat += "
" - else - dat += "Unable to connect to accounts database, please retry and if the issue persists contact NanoTrasen IT support." - reconnect_database() user << browse(dat,"window=atm;size=550x650") else @@ -208,14 +191,14 @@ log transactions if(href_list["choice"]) switch(href_list["choice"]) if("transfer") - if(authenticated_account && linked_db) + if(authenticated_account) var/transfer_amount = text2num(href_list["funds_amount"]) if(transfer_amount <= 0) alert("That is not a valid amount.") else if(transfer_amount <= authenticated_account.money) var/target_account_number = text2num(href_list["target_acc_number"]) var/transfer_purpose = href_list["purpose"] - if(linked_db.charge_to_account(target_account_number, authenticated_account.owner_name, transfer_purpose, machine_id, transfer_amount)) + if(charge_to_account(target_account_number, authenticated_account.owner_name, transfer_purpose, machine_id, transfer_amount)) usr << "\icon[src]Funds transfer successful." authenticated_account.money -= transfer_amount @@ -240,13 +223,13 @@ log transactions var/new_sec_level = max( min(text2num(href_list["new_security_level"]), 2), 0) authenticated_account.security_level = new_sec_level if("attempt_auth") - if(linked_db && !ticks_left_locked_down) + if(!ticks_left_locked_down) var/tried_account_num = text2num(href_list["account_num"]) if(!tried_account_num) tried_account_num = held_card.associated_account_number var/tried_pin = text2num(href_list["account_pin"]) - authenticated_account = linked_db.attempt_account_access(tried_account_num, tried_pin, held_card && held_card.associated_account_number == tried_account_num ? 2 : 1) + authenticated_account = attempt_account_access(tried_account_num, tried_pin, held_card && held_card.associated_account_number == tried_account_num ? 2 : 1) if(!authenticated_account) number_incorrect_tries++ if(previous_account_number == tried_account_num) @@ -256,7 +239,7 @@ log transactions playsound(src, 'sound/machines/buzz-two.ogg', 50, 1) //create an entry in the account transaction log - var/datum/money_account/failed_account = linked_db.get_account(tried_account_num) + var/datum/money_account/failed_account = get_account(tried_account_num) if(failed_account) var/datum/transaction/T = new() T.target_name = failed_account.owner_name @@ -386,7 +369,7 @@ log transactions //stolen wholesale and then edited a bit from newscasters, which are awesome and by Agouri /obj/machinery/atm/proc/scan_user(mob/living/carbon/human/human_user as mob) - if(!authenticated_account && linked_db) + if(!authenticated_account) if(human_user.wear_id) var/obj/item/weapon/card/id/I if(istype(human_user.wear_id, /obj/item/weapon/card/id) ) @@ -395,7 +378,7 @@ log transactions var/obj/item/device/pda/P = human_user.wear_id I = P.id if(I) - authenticated_account = linked_db.attempt_account_access(I.associated_account_number) + authenticated_account = attempt_account_access(I.associated_account_number) if(authenticated_account) human_user << "\blue \icon[src] Access granted. Welcome user '[authenticated_account.owner_name].'" diff --git a/code/modules/Economy/Accounts.dm b/code/modules/Economy/Accounts.dm new file mode 100644 index 00000000000..00f947a2d7e --- /dev/null +++ b/code/modules/Economy/Accounts.dm @@ -0,0 +1,113 @@ + +/datum/money_account + var/owner_name = "" + var/account_number = 0 + var/remote_access_pin = 0 + var/money = 0 + var/list/transaction_log = list() + var/suspended = 0 + 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 + +/datum/transaction + var/target_name = "" + var/purpose = "" + var/amount = 0 + var/date = "" + var/time = "" + var/source_terminal = "" + +/proc/create_account(var/new_owner_name = "Default user", var/starting_funds = 0, var/obj/machinery/account_database/source_db) + + //create a new account + var/datum/money_account/M = new() + M.owner_name = new_owner_name + M.remote_access_pin = rand(1111, 111111) + M.money = starting_funds + + //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 + T.date = "[num2text(rand(1,31))] [pick("January","February","March","April","May","June","July","August","September","October","November","December")], 25[rand(10,56)]" + T.time = "[rand(0,24)]:[rand(11,59)]" + T.source_terminal = "NTGalaxyNet Terminal #[rand(111,1111)]" + + M.account_number = rand(111111, 999999) + 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/smallDelivery/P = new /obj/item/smallDelivery(source_db.loc) + + var/obj/item/weapon/paper/R = new /obj/item/weapon/paper(P) + P.wrapped = R + R.name = "Account information: [M.owner_name]" + R.info = "Account details (confidential)


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

" + R.info += "Creation terminal ID: [source_db.machine_id]
" + R.info += "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 + +/proc/charge_to_account(var/attempt_account_number, var/source_name, var/purpose, var/terminal_id, var/amount) + for(var/datum/money_account/D in all_money_accounts) + if(D.account_number == attempt_account_number && !D.suspended) + 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 + break + + 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 +/proc/attempt_account_access(var/attempt_account_number, var/attempt_pin_number, var/security_level_passed = 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) ) + return D + break + +/proc/get_account(var/account_number) + for(var/datum/money_account/D in all_money_accounts) + if(D.account_number == account_number) + return D diff --git a/code/modules/Economy/Accounts_DB.dm b/code/modules/Economy/Accounts_DB.dm new file mode 100644 index 00000000000..70bf8ee125f --- /dev/null +++ b/code/modules/Economy/Accounts_DB.dm @@ -0,0 +1,169 @@ + +/obj/machinery/account_database + name = "Accounts uplink console" + desc = "Access transaction logs, account data and all kinds of other financial records." + icon = 'icons/obj/computer.dmi' + icon_state = "aiupload" + density = 1 + req_one_access = list(access_hop, access_captain, access_cent_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 + +/obj/machinery/account_database/New() + ..() + machine_id = "[station_name()] Acc. DB #[num_financial_terminals++]" + +/obj/machinery/account_database/attack_hand(mob/user as mob) + if(get_dist(src,user) <= 1) + var/dat = "Accounts Database
" + dat += "[machine_id]
" + dat += "Confirm identity: [held_card ? held_card : "-----"]
" + + if(access_level > 0) + dat += "You may not edit accounts at this terminal, only create and view them.
" + if(creating_new_account) + dat += "
" + dat += "Return to accounts list" + dat += "
" + dat += "" + dat += "" + dat += "Holder name:
" + dat += "Initial funds: (subtracted from station account)
" + dat += "New accounts are automatically assigned a secret number and pin, which are printed separately in a sealed package.
" + dat += "
" + dat += "
" + else + if(detailed_account_view) + dat += "
" + dat += "Return to accounts list
" + dat += "Account number: #[detailed_account_view.account_number]
" + dat += "Account holder: [detailed_account_view.owner_name]
" + dat += "Account balance: $[detailed_account_view.money]
" + if(access_level > 1) + dat += "Silently add funds (no transaction log)
" + dat += "Silently remove funds (no transaction log)
" + dat += "[detailed_account_view.suspended ? "Unsuspend account" : "Suspend account"]
" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + for(var/datum/transaction/T in detailed_account_view.transaction_log) + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "
DateTimeTargetPurposeValueSource terminal ID
[T.date][T.time][T.target_name][T.purpose]$[T.amount][T.source_terminal]
" + else + dat += "Create new account

" + dat += "" + for(var/i=1, i<=all_money_accounts.len, i++) + var/datum/money_account/D = all_money_accounts[i] + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "" + dat += "
#[D.account_number][D.owner_name][D.suspended ? "SUSPENDED" : ""]View in detail
" + + user << browse(dat,"window=account_db;size=700x650") + else + user << browse(null,"window=account_db") + +/obj/machinery/account_database/attackby(O as obj, user as mob)//TODO:SANITY + if(istype(O, /obj/item/weapon/card)) + var/obj/item/weapon/card/id/idcard = O + if(!held_card) + usr.drop_item() + idcard.loc = 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 + else + ..() + +/obj/machinery/account_database/Topic(var/href, var/href_list) + + if(href_list["choice"]) + switch(href_list["choice"]) + if("create_account") + creating_new_account = 1 + if("add_funds") + var/amount = input("Enter the amount you wish to add", "Silently add funds") as num + if(detailed_account_view) + detailed_account_view.money += amount + if("remove_funds") + var/amount = input("Enter the amount you wish to remove", "Silently remove funds") as num + if(detailed_account_view) + detailed_account_view.money -= amount + if("toggle_suspension") + if(detailed_account_view) + if(detailed_account_view.suspended) + detailed_account_view.suspended = 0 + else + detailed_account_view.suspended = 1 + if("finalise_create_account") + var/account_name = href_list["holder_name"] + var/starting_funds = max(text2num(href_list["starting_funds"]), 0) + create_account(account_name, starting_funds, src) + if(starting_funds > 0) + //subtract the money + station_account.money -= starting_funds + + //create a transaction log entry + 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) + + creating_new_account = 0 + if("insert_card") + if(held_card) + held_card.loc = src.loc + + if(ishuman(usr) && !usr.get_active_hand()) + usr.put_in_hands(held_card) + held_card = null + access_level = 0 + + else + var/obj/item/I = usr.get_active_hand() + if (istype(I, /obj/item/weapon/card/id)) + var/obj/item/weapon/card/id/C = I + usr.drop_item() + C.loc = src + held_card = C + + 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 + + src.attack_hand(usr) diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/EFTPOS.dm b/code/modules/Economy/EFTPOS.dm similarity index 74% rename from code/WorkInProgress/Cael_Aislinn/Economy/EFTPOS.dm rename to code/modules/Economy/EFTPOS.dm index af06c1dfd82..12f941bd1cf 100644 --- a/code/WorkInProgress/Cael_Aislinn/Economy/EFTPOS.dm +++ b/code/modules/Economy/EFTPOS.dm @@ -10,14 +10,12 @@ var/transaction_amount = 0 var/transaction_purpose = "Default charge" var/access_code = 0 - var/obj/machinery/account_database/linked_db var/datum/money_account/linked_account /obj/item/device/eftpos/New() ..() machine_id = "[station_name()] EFTPOS #[num_financial_terminals++]" access_code = rand(1111,111111) - reconnect_database() spawn(0) print_reference() @@ -69,16 +67,6 @@ D.wrapped = R D.name = "small parcel - 'EFTPOS access code'" -/obj/item/device/eftpos/proc/reconnect_database() - var/turf/location = get_turf(src) - if(!location) - return - - for(var/obj/machinery/account_database/DB in machines) //Hotfix until someone finds out why it isn't in 'machines' - if(DB.z == location.z) - linked_db = DB - break - /obj/item/device/eftpos/attack_self(mob/user as mob) if(get_dist(src,user) <= 1) var/dat = "[eftpos_name]
" @@ -109,17 +97,11 @@ /obj/item/device/eftpos/attackby(O as obj, user as mob) if(istype(O, /obj/item/weapon/card)) - //attempt to connect to a new db, and if that doesn't work then fail - if(!linked_db) - reconnect_database() - if(linked_db) - if(linked_account) - var/obj/item/weapon/card/I = O - scan_card(I) - else - usr << "\icon[src]Unable to connect to linked account." + if(linked_account) + var/obj/item/weapon/card/I = O + scan_card(I) else - usr << "\icon[src]Unable to connect to accounts database." + usr << "\icon[src]Unable to connect to linked account." else ..() @@ -145,14 +127,12 @@ else usr << "\icon[src]Incorrect code entered." if("link_account") - if(!linked_db) - reconnect_database() - if(linked_db) - var/attempt_account_num = input("Enter account number to pay EFTPOS charges into", "New account number") as num - var/attempt_pin = input("Enter pin code", "Account pin") as num - linked_account = linked_db.attempt_account_access(attempt_account_num, attempt_pin, 1) - else - usr << "\icon[src]Unable to connect to accounts database." + var/attempt_account_num = input("Enter account number to pay EFTPOS charges into", "New account number") as num + var/attempt_pin = input("Enter pin code", "Account pin") as num + linked_account = attempt_account_access(attempt_account_num, attempt_pin, 1) + if(linked_account.suspended) + linked_account = null + usr << "\icon[src]Account has been suspended." if("trans_purpose") transaction_purpose = input("Enter reason for EFTPOS transaction", "Transaction purpose") if("trans_value") @@ -172,10 +152,7 @@ else usr << "\icon[src] No account connected to send transactions to." if("scan_card") - //attempt to connect to a new db, and if that doesn't work then fail - if(!linked_db) - reconnect_database() - if(linked_db && linked_account) + if(linked_account) var/obj/item/I = usr.get_active_hand() if (istype(I, /obj/item/weapon/card)) scan_card(I) @@ -201,45 +178,62 @@ visible_message("[usr] swipes a card through [src].") if(transaction_locked && !transaction_paid) if(linked_account) - var/attempt_pin = input("Enter pin code", "EFTPOS transaction") as num - var/datum/money_account/D = linked_db.attempt_account_access(C.associated_account_number, attempt_pin, 2) - if(D) - if(transaction_amount <= D.money) - playsound(src, 'sound/machines/chime.ogg', 50, 1) - src.visible_message("\icon[src] The [src] chimes.") - transaction_paid = 1 + if(!linked_account.suspended) + var/attempt_pin = input("Enter pin code", "EFTPOS transaction") as num + var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2) + if(D) + if(!D.suspended) + if(transaction_amount <= D.money) + playsound(src, 'sound/machines/chime.ogg', 50, 1) + src.visible_message("\icon[src] The [src] chimes.") + transaction_paid = 1 - //transfer the money - D.money -= transaction_amount - linked_account.money += transaction_amount + //transfer the money + D.money -= transaction_amount + linked_account.money += transaction_amount - //create entries in the two account transaction logs - var/datum/transaction/T = new() - T.target_name = "[linked_account.owner_name] (via [eftpos_name])" - T.purpose = transaction_purpose - if(transaction_amount > 0) - T.amount = "([transaction_amount])" + //create entries in the two account transaction logs + var/datum/transaction/T = new() + T.target_name = "[linked_account.owner_name] (via [eftpos_name])" + T.purpose = transaction_purpose + if(transaction_amount > 0) + T.amount = "([transaction_amount])" + else + T.amount = "[transaction_amount]" + T.source_terminal = machine_id + T.date = current_date_string + T.time = worldtime2text() + D.transaction_log.Add(T) + // + T = new() + T.target_name = D.owner_name + T.purpose = transaction_purpose + T.amount = "[transaction_amount]" + T.source_terminal = machine_id + T.date = current_date_string + T.time = worldtime2text() + linked_account.transaction_log.Add(T) + else + usr << "\icon[src]You don't have that much money!" else - T.amount = "[transaction_amount]" - T.source_terminal = machine_id - T.date = current_date_string - T.time = worldtime2text() - D.transaction_log.Add(T) - // - T = new() - T.target_name = D.owner_name - T.purpose = transaction_purpose - T.amount = "[transaction_amount]" - T.source_terminal = machine_id - T.date = current_date_string - T.time = worldtime2text() - linked_account.transaction_log.Add(T) + usr << "\icon[src]Your account has been suspended." else - usr << "\icon[src]You don't have that much money!" + usr << "\icon[src]Unable to access account. Check security settings and try again." else - usr << "\icon[src]Unable to access account. Check security settings and try again." + usr << "\icon[src]Connected account has been suspended." else usr << "\icon[src]EFTPOS is not connected to an account." + else if (istype(I, /obj/item/weapon/card/emag)) + if(transaction_locked) + if(transaction_paid) + usr << "\icon[src]You stealthily swipe [I] through [src]." + transaction_locked = 0 + transaction_paid = 0 + else + visible_message("[usr] swipes a card through [src].") + playsound(src, 'sound/machines/chime.ogg', 50, 1) + src.visible_message("\icon[src] The [src] chimes.") + transaction_paid = 1 else ..() diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/Economy_Events.dm b/code/modules/Economy/Events.dm similarity index 99% rename from code/WorkInProgress/Cael_Aislinn/Economy/Economy_Events.dm rename to code/modules/Economy/Events.dm index 2aa5cc42d1e..bd5e3c0a1e6 100644 --- a/code/WorkInProgress/Cael_Aislinn/Economy/Economy_Events.dm +++ b/code/modules/Economy/Events.dm @@ -8,9 +8,6 @@ var/datum/trade_destination/affected_dest /datum/event/economic_event/start() - if(!setup_economy) - setup_economy() - affected_dest = pickweight(weighted_randomevent_locations) if(affected_dest.viable_random_events.len) endWhen = rand(60,300) diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/Economy_Events_Mundane.dm b/code/modules/Economy/Events_Mundane.dm similarity index 100% rename from code/WorkInProgress/Cael_Aislinn/Economy/Economy_Events_Mundane.dm rename to code/modules/Economy/Events_Mundane.dm diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/Job_Departments.dm b/code/modules/Economy/Job_Departments.dm similarity index 100% rename from code/WorkInProgress/Cael_Aislinn/Economy/Job_Departments.dm rename to code/modules/Economy/Job_Departments.dm diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/Economy.dm b/code/modules/Economy/Misc.dm similarity index 60% rename from code/WorkInProgress/Cael_Aislinn/Economy/Economy.dm rename to code/modules/Economy/Misc.dm index 84000d1b46f..ffe8a114717 100644 --- a/code/WorkInProgress/Cael_Aislinn/Economy/Economy.dm +++ b/code/modules/Economy/Misc.dm @@ -44,7 +44,7 @@ #define ROBOTICS 13 #define BIOMEDICAL 14 -#define EVA 15 +#define GEAR_EVA 15 //---- The following corporations are friendly with NanoTrasen and loosely enable trade and travel: //Corporation NanoTrasen - Generalised / high tech research and plasma exploitation. @@ -63,10 +63,20 @@ //Destroyers are medium sized vessels, often used for escorting larger ships but able to go toe-to-toe with them if need be. //Frigates are medium sized vessels, often used for escorting larger ships. They will rapidly find themselves outclassed if forced to face heavy warships head on. -var/setup_economy = 0 +var/global/current_date_string + +var/global/datum/money_account/vendor_account +var/global/datum/money_account/station_account +var/global/list/datum/money_account/department_accounts = list() +var/global/num_financial_terminals = 1 +var/global/next_account_number = 0 +var/global/list/all_money_accounts = list() +var/global/economy_init = 0 + /proc/setup_economy() - if(setup_economy) - return + if(economy_init) + return 2 + var/datum/feed_channel/newChannel = new /datum/feed_channel newChannel.channel_name = "Tau Ceti Daily" newChannel.author = "CentComm Minister of Information" @@ -86,4 +96,61 @@ var/setup_economy = 0 weighted_randomevent_locations[D] = D.viable_random_events.len weighted_mundaneevent_locations[D] = D.viable_mundane_events.len - setup_economy = 1 \ No newline at end of file + create_station_account() + + for(var/department in station_departments) + create_department_account(department) + create_department_account("Vendor") + vendor_account = department_accounts["Vendor"] + + current_date_string = "[num2text(rand(1,31))] [pick("January","February","March","April","May","June","July","August","September","October","November","December")], 2557" + + economy_init = 1 + return 1 + +/proc/create_station_account() + if(!station_account) + next_account_number = rand(111111, 999999) + + station_account = new() + station_account.owner_name = "[station_name()] Station Account" + station_account.account_number = rand(111111, 999999) + station_account.remote_access_pin = rand(1111, 111111) + station_account.money = 75000 + + //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 = 75000 + T.date = "2nd April, 2555" + 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) + next_account_number = rand(111111, 999999) + + var/datum/money_account/department_account = new() + department_account.owner_name = "[department] Account" + department_account.account_number = rand(111111, 999999) + department_account.remote_access_pin = rand(1111, 111111) + department_account.money = 5000 + + //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, 2555" + 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 diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/Economy_TradeDestinations.dm b/code/modules/Economy/TradeDestinations.dm similarity index 100% rename from code/WorkInProgress/Cael_Aislinn/Economy/Economy_TradeDestinations.dm rename to code/modules/Economy/TradeDestinations.dm diff --git a/code/modules/events/money_hacker.dm b/code/modules/events/money_hacker.dm index 5171f22fe8f..5fbc323a292 100644 --- a/code/modules/events/money_hacker.dm +++ b/code/modules/events/money_hacker.dm @@ -1,35 +1,22 @@ /var/global/account_hack_attempted = 0 /datum/event/money_hacker - endWhen = 10000 - var/time_duration = 0 - var/time_start = 0 var/datum/money_account/affected_account - var/obj/machinery/account_database/affected_db + endWhen = 100 + var/end_time /datum/event/money_hacker/setup() + end_time = world.time + 6000 if(all_money_accounts.len) - for(var/obj/machinery/account_database/DB in world) - if( DB.z == 1 && !(DB.stat&NOPOWER) && DB.activated ) - affected_db = DB - break - if(affected_db) affected_account = pick(all_money_accounts) + + account_hack_attempted = 1 else kill() - return - - time_start = world.time - time_duration = rand(3000, 18000) - endWhen = time_duration * 10 //a big enough buffer so that we should timeout before we run out of ticks - account_hack_attempted = 1 - -/datum/event/money_hacker/start() - return /datum/event/money_hacker/announce() var/message = "A brute force hack has been detected (in progress since [worldtime2text()]). The target of the attack is: Financial account #[affected_account.account_number], \ - without intervention this attack will succeed in [time_duration / 600] minutes. Required intervention: complete shutdown of affected accounts databases until the attack has ceased. \ + without intervention this attack will succeed in approximately 10 minutes. Required intervention: temporary suspension of affected accounts until the attack has ceased. \ Notifications will be sent as updates occur.
" var/my_department = "[station_name()] firewall subroutines" var/sending = message + "Message dispatched by [my_department]." @@ -58,64 +45,62 @@ Console.messages += "High Priority message from [my_department]
[sending]" /datum/event/money_hacker/tick() - if(world.time > time_start + time_duration) - var/message - if(affected_account && affected_db && affected_db.activated && !(affected_db.stat & (NOPOWER|BROKEN)) ) - //hacker wins - message = "The hack attempt has succeeded." + if(world.time >= end_time) + endWhen = activeFor + else + endWhen = activeFor + 10 - //subtract the money - var/lost = affected_account.money * 0.8 + (rand(2,4) - 2) / 10 - affected_account.money -= lost - - //create a taunting log entry - var/datum/transaction/T = new() - T.target_name = pick("","yo brotha from anotha motha","el Presidente","chieF smackDowN") - T.purpose = pick("Ne$ ---ount fu%ds init*&lisat@*n","PAY BACK YOUR MUM","Funds withdrawal","pWnAgE","l33t hax","liberationez") - T.amount = pick("","([rand(0,99999)])","alla money","9001$","HOLLA HOLLA GET DOLLA","([lost])") - var/date1 = "31 December, 1999" - var/date2 = "[num2text(rand(1,31))] [pick("January","February","March","April","May","June","July","August","September","October","November","December")], [rand(1000,3000)]" - T.date = pick("", current_date_string, date1, date2) - var/time1 = rand(0, 99999999) - var/time2 = "[round(time1 / 36000)+12]:[(time1 / 600 % 60) < 10 ? add_zero(time1 / 600 % 60, 1) : time1 / 600 % 60]" - T.time = pick("", worldtime2text(), time2) - T.source_terminal = pick("","[pick("Biesel","New Gibson")] GalaxyNet Terminal #[rand(111,999)]","your mums place","nantrasen high CommanD") - - affected_account.transaction_log.Add(T) - - else - //crew wins - message = "The attack has ceased, the affected databases can now be brought online." - - var/my_department = "[station_name()] firewall subroutines" - var/sending = message + "Message dispatched by [my_department]." - - var/pass = 0 - for(var/obj/machinery/message_server/MS in world) - if(!MS.active) continue - // /obj/machinery/message_server/proc/send_rc_message(var/recipient = "",var/sender = "",var/message = "",var/stamp = "", var/id_auth = "", var/priority = 1) - MS.send_rc_message("Engineering/Security/Bridge", my_department, message, "", "", 2) - pass = 1 - - if(pass) - var/keyed_dpt1 = ckey("Engineering") - var/keyed_dpt2 = ckey("Security") - var/keyed_dpt3 = ckey("Bridge") - for (var/obj/machinery/requests_console/Console in allConsoles) - var/keyed_department = ckey(Console.department) - if(keyed_department == keyed_dpt1 || keyed_department == keyed_dpt2 || keyed_department == keyed_dpt3) - if(Console.newmessagepriority < 2) - Console.newmessagepriority = 2 - Console.icon_state = "req_comp2" - if(!Console.silent) - playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) - for (var/mob/O in hearers(5, Console.loc)) - O.show_message(text("\icon[Console] *The Requests Console beeps: 'PRIORITY Alert in [my_department]'")) - Console.messages += "High Priority message from [my_department]
[sending]" - - kill() - -//shouldn't ever hit this, but this is here just in case /datum/event/money_hacker/end() - if(affected_account && affected_db) - endWhen += time_duration + var/message + if(affected_account && !affected_account) + //hacker wins + message = "The hack attempt has succeeded." + + //subtract the money + var/lost = affected_account.money * 0.8 + (rand(2,4) - 2) / 10 + affected_account.money -= lost + + //create a taunting log entry + var/datum/transaction/T = new() + T.target_name = pick("","yo brotha from anotha motha","el Presidente","chieF smackDowN") + T.purpose = pick("Ne$ ---ount fu%ds init*&lisat@*n","PAY BACK YOUR MUM","Funds withdrawal","pWnAgE","l33t hax","liberationez") + T.amount = pick("","([rand(0,99999)])","alla money","9001$","HOLLA HOLLA GET DOLLA","([lost])") + var/date1 = "31 December, 1999" + var/date2 = "[num2text(rand(1,31))] [pick("January","February","March","April","May","June","July","August","September","October","November","December")], [rand(1000,3000)]" + T.date = pick("", current_date_string, date1, date2) + var/time1 = rand(0, 99999999) + var/time2 = "[round(time1 / 36000)+12]:[(time1 / 600 % 60) < 10 ? add_zero(time1 / 600 % 60, 1) : time1 / 600 % 60]" + T.time = pick("", worldtime2text(), time2) + T.source_terminal = pick("","[pick("Biesel","New Gibson")] GalaxyNet Terminal #[rand(111,999)]","your mums place","nantrasen high CommanD") + + affected_account.transaction_log.Add(T) + + else + //crew wins + message = "The attack has ceased, the affected accounts can now be brought online." + + var/my_department = "[station_name()] firewall subroutines" + var/sending = message + "Message dispatched by [my_department]." + + var/pass = 0 + for(var/obj/machinery/message_server/MS in world) + if(!MS.active) continue + // /obj/machinery/message_server/proc/send_rc_message(var/recipient = "",var/sender = "",var/message = "",var/stamp = "", var/id_auth = "", var/priority = 1) + MS.send_rc_message("Engineering/Security/Bridge", my_department, message, "", "", 2) + pass = 1 + + if(pass) + var/keyed_dpt1 = ckey("Engineering") + var/keyed_dpt2 = ckey("Security") + var/keyed_dpt3 = ckey("Bridge") + for (var/obj/machinery/requests_console/Console in allConsoles) + var/keyed_department = ckey(Console.department) + if(keyed_department == keyed_dpt1 || keyed_department == keyed_dpt2 || keyed_department == keyed_dpt3) + if(Console.newmessagepriority < 2) + Console.newmessagepriority = 2 + Console.icon_state = "req_comp2" + if(!Console.silent) + playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) + for (var/mob/O in hearers(5, Console.loc)) + O.show_message(text("\icon[Console] *The Requests Console beeps: 'PRIORITY Alert in [my_department]'")) + Console.messages += "High Priority message from [my_department]
[sending]" diff --git a/code/modules/events/money_lotto.dm b/code/modules/events/money_lotto.dm index 3ac17a7f4c6..9acffed1f6e 100644 --- a/code/modules/events/money_lotto.dm +++ b/code/modules/events/money_lotto.dm @@ -1,6 +1,4 @@ /datum/event/money_lotto - endWhen = 301 - announceWhen = 300 var/winner_name = "John Smith" var/winner_sum = 0 var/deposit_success = 0 @@ -9,18 +7,20 @@ winner_sum = pick(5000, 10000, 50000, 100000, 500000, 1000000, 1500000) if(all_money_accounts.len) var/datum/money_account/D = pick(all_money_accounts) - D.money += winner_sum + winner_name = D.owner_name + if(!D.suspended) + D.money += winner_sum - var/datum/transaction/T = new() - T.target_name = "Tau Ceti Daily Grand Slam -Stellar- Lottery" - T.purpose = "Winner!" - T.amount = winner_sum - T.date = current_date_string - T.time = worldtime2text() - T.source_terminal = "Biesel TCD Terminal #[rand(111,333)]" - D.transaction_log.Add(T) - else - kill() + var/datum/transaction/T = new() + T.target_name = "Tau Ceti Daily Grand Slam -Stellar- Lottery" + T.purpose = "Winner!" + T.amount = winner_sum + T.date = current_date_string + T.time = worldtime2text() + T.source_terminal = "Biesel TCD Terminal #[rand(111,333)]" + D.transaction_log.Add(T) + + deposit_success = 1 /datum/event/money_lotto/announce() var/datum/feed_message/newMsg = new /datum/feed_message @@ -29,7 +29,7 @@ newMsg.body = "TC Daily wishes to congratulate [winner_name] for recieving the Tau Ceti Stellar Slam Lottery, and receiving the out of this world sum of [winner_sum] credits!" if(!deposit_success) - newMsg.body += "
Unfortunately, we were unable to verify the account details provided, so we were unable to transfer the money. Send a cheque containing the sum of $500 to TCD 'Stellar Slam' office on Biesel Prime containing updated details, and it'll be resent within the month." + newMsg.body += "
Unfortunately, we were unable to verify the account details provided, so we were unable to transfer the money. Send a cheque containing the sum of $500 to TCD 'Stellar Slam' office on Biesel Prime containing updated details, and your winnings'll be resent within the month." for(var/datum/feed_channel/FC in news_network.network_channels) if(FC.channel_name == "Tau Ceti Daily")