mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-01-05 23:11:52 +00:00
Converts Economy to a Subsystem (#5253)
Converts Economy to a Subsystem and cleans it up a bit
This commit is contained in:
@@ -157,6 +157,7 @@
|
||||
#include "code\controllers\subsystems\battle_monsters.dm"
|
||||
#include "code\controllers\subsystems\cargo.dm"
|
||||
#include "code\controllers\subsystems\chemistry.dm"
|
||||
#include "code\controllers\subsystems\economy.dm"
|
||||
#include "code\controllers\subsystems\effects.dm"
|
||||
#include "code\controllers\subsystems\emergency_shuttle.dm"
|
||||
#include "code\controllers\subsystems\event.dm"
|
||||
@@ -1344,7 +1345,6 @@
|
||||
#include "code\modules\detectivework\tools\storage.dm"
|
||||
#include "code\modules\detectivework\tools\swabs.dm"
|
||||
#include "code\modules\detectivework\tools\uvlight.dm"
|
||||
#include "code\modules\economy\Accounts.dm"
|
||||
#include "code\modules\economy\Accounts_DB.dm"
|
||||
#include "code\modules\economy\ATM.dm"
|
||||
#include "code\modules\economy\cash.dm"
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#define SS_INIT_MISC_FIRST 22
|
||||
#define SS_INIT_SEEDS 21 // Plant controller setup.
|
||||
#define SS_INIT_MAPLOAD 20 // DMM parsing and load. Unless you know what you're doing, make sure this remains first.
|
||||
#define SS_INIT_JOBS 19
|
||||
#define SS_INIT_MAPFINALIZE 18 // Asteroid generation.
|
||||
#define SS_INIT_SHUTTLE 17 // Shuttle setup.
|
||||
#define SS_INIT_PARALLAX 16 // Parallax image cache generation. Must run before ghosts are able to join.
|
||||
#define SS_INIT_HOLOMAP 15
|
||||
#define SS_INIT_ATOMS 14 // World initialization. Will trigger lighting updates. Observers can join after this loads.
|
||||
#define SS_INIT_POWER 13 // Initial powernet build.
|
||||
#define SS_INIT_MISC_FIRST 23
|
||||
#define SS_INIT_SEEDS 22 // Plant controller setup.
|
||||
#define SS_INIT_MAPLOAD 21 // DMM parsing and load. Unless you know what you're doing, make sure this remains first.
|
||||
#define SS_INIT_JOBS 20
|
||||
#define SS_INIT_MAPFINALIZE 10 // Asteroid generation.
|
||||
#define SS_INIT_SHUTTLE 18 // Shuttle setup.
|
||||
#define SS_INIT_PARALLAX 17 // Parallax image cache generation. Must run before ghosts are able to join.
|
||||
#define SS_INIT_HOLOMAP 16
|
||||
#define SS_INIT_ATOMS 15 // World initialization. Will trigger lighting updates. Observers can join after this loads.
|
||||
#define SS_INIT_POWER 14 // Initial powernet build.
|
||||
#define SS_INIT_ECONOMY 13 // Cargo needs economy set up
|
||||
#define SS_INIT_CARGO 12 // Random warehouse generation. Runs after SSatoms because it assumes objects are initialized when it runs.
|
||||
#define SS_INIT_PIPENET 11 // Initial pipenet build.
|
||||
#define SS_INIT_MACHINERY 10 // Machinery prune and powernet build.
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
#define SUPPLY_STATION_AREATYPE /area/supply/station //Type of the supply shuttle area for station
|
||||
#define SUPPLY_DOCK_AREATYPE /area/supply/dock //Type of the supply shuttle area for dock
|
||||
|
||||
/proc/fetch_supply_account()
|
||||
SScargo.supply_account = department_accounts["Cargo"]
|
||||
|
||||
var/datum/controller/subsystem/cargo/SScargo
|
||||
|
||||
/datum/controller/subsystem/cargo
|
||||
@@ -67,8 +64,7 @@ var/datum/controller/subsystem/cargo/SScargo
|
||||
ordernum = rand(1,8000)
|
||||
shipmentnum = rand(500,700)
|
||||
|
||||
//Fetch the cargo account once the round is started - TODO-CARGO: Repalce that once economy gets its own subsystem
|
||||
SSticker.OnRoundstart(CALLBACK(GLOBAL_PROC, .proc/fetch_supply_account))
|
||||
supply_account = SSeconomy.get_department_account("Cargo")
|
||||
|
||||
//Load in the cargo items config
|
||||
if(config.cargo_load_items_from == "sql")
|
||||
@@ -534,7 +530,7 @@ var/datum/controller/subsystem/cargo/SScargo
|
||||
if(!supply_account)
|
||||
log_debug("SScargo: Warning Tried to charge supply account but supply acount doesnt exist")
|
||||
return 0
|
||||
return charge_to_account(supply_account.account_number, "[commstation_name()] - Supply", "[charge_text]", "[commstation_name()] - Banking System", -charge_credits)
|
||||
return SSeconomy.charge_to_account(supply_account.account_number, "[commstation_name()] - Supply", "[charge_text]", "[commstation_name()] - Banking System", -charge_credits)
|
||||
//Gets the pending shipment costs for the items that are about to be shipped to the station
|
||||
/datum/controller/subsystem/cargo/proc/get_pending_shipment_cost(var/status="approved")
|
||||
//Loop through all the orders marked as shipped and get the suppliers into a list of involved suppliers
|
||||
|
||||
253
code/controllers/subsystems/economy.dm
Normal file
253
code/controllers/subsystems/economy.dm
Normal file
@@ -0,0 +1,253 @@
|
||||
var/datum/controller/subsystem/economy/SSeconomy
|
||||
|
||||
/datum/controller/subsystem/economy
|
||||
name = "Economy"
|
||||
wait = 30 SECONDS
|
||||
flags = SS_NO_FIRE
|
||||
init_order = SS_INIT_ECONOMY
|
||||
var/datum/money_account/station_account
|
||||
var/list/department_accounts = list()
|
||||
var/list/all_money_accounts = list()
|
||||
var/num_financial_terminals = 1
|
||||
var/next_account_number = 0
|
||||
|
||||
/datum/controller/subsystem/economy/New()
|
||||
NEW_SS_GLOBAL(SSeconomy)
|
||||
|
||||
/datum/controller/subsystem/economy/Initialize(timeofday)
|
||||
for(var/loc_type in typesof(/datum/trade_destination) - /datum/trade_destination)
|
||||
var/datum/trade_destination/D = new loc_type
|
||||
weighted_randomevent_locations[D] = D.viable_random_events.len
|
||||
weighted_mundaneevent_locations[D] = D.viable_mundane_events.len
|
||||
|
||||
create_station_account()
|
||||
|
||||
for(var/department in station_departments)
|
||||
create_department_account(department)
|
||||
create_department_account("Vendor")
|
||||
|
||||
..()
|
||||
|
||||
/datum/controller/subsystem/economy/Recover()
|
||||
src.station_account = SSeconomy.station_account
|
||||
src.department_accounts = SSeconomy.department_accounts
|
||||
src.all_money_accounts = SSeconomy.all_money_accounts
|
||||
src.num_financial_terminals = SSeconomy.num_financial_terminals
|
||||
src.next_account_number = SSeconomy.next_account_number
|
||||
|
||||
|
||||
/**
|
||||
* Account Creation
|
||||
*/
|
||||
//Create the station Account
|
||||
/datum/controller/subsystem/economy/proc/create_station_account()
|
||||
if(station_account)
|
||||
return FALSE
|
||||
|
||||
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, 2454"
|
||||
T.time = "11:24"
|
||||
T.source_terminal = "Biesel GalaxyNet Terminal #277"
|
||||
|
||||
//add the account
|
||||
add_transaction_log(station_account,T)
|
||||
all_money_accounts.Add(station_account)
|
||||
return TRUE
|
||||
|
||||
//Create a departmental account
|
||||
/datum/controller/subsystem/economy/proc/create_department_account(department)
|
||||
if(department_accounts[department])
|
||||
return FALSE
|
||||
|
||||
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, 2454"
|
||||
T.time = "11:24"
|
||||
T.source_terminal = "Biesel GalaxyNet Terminal #277"
|
||||
|
||||
//add the account
|
||||
add_transaction_log(department_account,T)
|
||||
all_money_accounts.Add(department_account)
|
||||
|
||||
department_accounts[department] = department_account
|
||||
return TRUE
|
||||
|
||||
//Create a "normal" player account
|
||||
/datum/controller/subsystem/economy/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")], 24[rand(10,48)]"
|
||||
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 = worlddate2text()
|
||||
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
|
||||
var/pname = "Account information: [M.owner_name]"
|
||||
var/info = "<b>Account details (confidential)</b><br><hr><br>"
|
||||
info += "<i>Account holder:</i> [M.owner_name]<br>"
|
||||
info += "<i>Account number:</i> [M.account_number]<br>"
|
||||
info += "<i>Account pin:</i> [M.remote_access_pin]<br>"
|
||||
info += "<i>Starting balance:</i> $[M.money]<br>"
|
||||
info += "<i>Date and time:</i> [worldtime2text()], [worlddate2text()]<br><br>"
|
||||
info += "<i>Creation terminal ID:</i> [source_db.machine_id]<br>"
|
||||
info += "<i>Authorised NT officer overseeing creation:</i> [source_db.held_card.registered_name]<br>"
|
||||
|
||||
R.set_content_unsafe(pname, info)
|
||||
|
||||
//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.add_overlay(stampoverlay)
|
||||
R.stamps += "<HR><i>This paper has been stamped by the Accounts Database.</i>"
|
||||
|
||||
//add the account
|
||||
add_transaction_log(M,T)
|
||||
all_money_accounts.Add(M)
|
||||
|
||||
return M
|
||||
|
||||
|
||||
//Charge a account
|
||||
/datum/controller/subsystem/economy/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 = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
T.source_terminal = terminal_id
|
||||
add_transaction_log(D,T)
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
/**
|
||||
* Various Getters (Account, Department-Account, ...)
|
||||
*/
|
||||
//attempts to access a account by supplying a account number / pin number and passed securilty level check
|
||||
/datum/controller/subsystem/economy/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
|
||||
|
||||
//gets a account by account number
|
||||
/datum/controller/subsystem/economy/proc/get_account(var/account_number)
|
||||
for(var/datum/money_account/D in all_money_accounts)
|
||||
if(D.account_number == account_number)
|
||||
return D
|
||||
return 0
|
||||
|
||||
//gets a departmental account by name
|
||||
/datum/controller/subsystem/economy/proc/get_department_account(var/department)
|
||||
if(department_accounts[department])
|
||||
return department_accounts[department]
|
||||
return
|
||||
|
||||
/**
|
||||
* Logging functions
|
||||
*/
|
||||
//adds a transaction log to a specific account
|
||||
/datum/controller/subsystem/economy/proc/add_transaction_log(var/datum/money_account/bank_account, var/datum/transaction/T)
|
||||
//Thats there as a place to hook the persistant transaction logs into
|
||||
bank_account.transactions.Add(T)
|
||||
|
||||
//log a failed access attempt
|
||||
/datum/controller/subsystem/economy/proc/bank_log_unauthorized(var/datum/money_account/bank_account, var/machine_id = "Unknown machine ID")
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = bank_account.owner_name
|
||||
T.purpose = "Unauthorised login attempt"
|
||||
T.source_terminal = machine_id
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
add_transaction_log(bank_account,T)
|
||||
return
|
||||
|
||||
//Log a successful access
|
||||
/datum/controller/subsystem/economy/proc/bank_log_access(var/datum/money_account/bank_account, var/machine_id = "Unknown machine ID")
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = bank_account.owner_name
|
||||
T.purpose = "Remote terminal access"
|
||||
T.source_terminal = machine_id
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
add_transaction_log(bank_account,T)
|
||||
return
|
||||
|
||||
|
||||
/datum/money_account
|
||||
var/owner_name = ""
|
||||
var/account_number = 0
|
||||
var/remote_access_pin = 0
|
||||
var/money = 0
|
||||
var/list/transactions = list()
|
||||
var/suspended = 0
|
||||
var/security_level = 0 //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 = ""
|
||||
@@ -356,6 +356,8 @@
|
||||
SearchVar(CURRENT_TICKLIMIT)
|
||||
SearchVar(SSalarm)
|
||||
SearchVar(SSchemistry)
|
||||
SearchVar(SScargo)
|
||||
SearchVar(SSeconomy)
|
||||
SearchVar(SSeffects)
|
||||
SearchVar(emergency_shuttle)
|
||||
SearchVar(SSevents)
|
||||
@@ -718,14 +720,6 @@
|
||||
SearchVar(breach_brute_descriptors)
|
||||
SearchVar(breach_burn_descriptors)
|
||||
SearchVar(FINGERPRINT_COMPLETE)
|
||||
SearchVar(current_date_string)
|
||||
SearchVar(vendor_account)
|
||||
SearchVar(station_account)
|
||||
SearchVar(department_accounts)
|
||||
SearchVar(num_financial_terminals)
|
||||
SearchVar(next_account_number)
|
||||
SearchVar(all_money_accounts)
|
||||
SearchVar(economy_init)
|
||||
SearchVar(weighted_randomevent_locations)
|
||||
SearchVar(weighted_mundaneevent_locations)
|
||||
SearchVar(severity_to_string)
|
||||
|
||||
@@ -363,7 +363,7 @@
|
||||
// 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]
|
||||
var/datum/money_account/department_account = SSeconomy.get_department_account(job.department)
|
||||
|
||||
if(department_account)
|
||||
remembered_info += "<b>Your department's account number is:</b> #[department_account.account_number]<br>"
|
||||
|
||||
@@ -424,7 +424,6 @@ var/datum/controller/subsystem/ticker/SSticker
|
||||
else
|
||||
src.mode.announce()
|
||||
|
||||
setup_economy()
|
||||
current_state = GAME_STATE_PLAYING
|
||||
create_characters() //Create player characters and transfer them
|
||||
collect_minds()
|
||||
|
||||
@@ -86,15 +86,15 @@
|
||||
PROCLOG_WEIRD("species [H.species || "NULL"] did not have a set economic_modifier!")
|
||||
|
||||
var/money_amount = (rand(5,50) + rand(5, 50)) * loyalty * economic_modifier * species_modifier
|
||||
var/datum/money_account/M = create_account(H.real_name, money_amount, null)
|
||||
var/datum/money_account/M = SSeconomy.create_account(H.real_name, money_amount, null)
|
||||
if(H.mind)
|
||||
var/remembered_info = ""
|
||||
remembered_info += "<b>Your account number is:</b> #[M.account_number]<br>"
|
||||
remembered_info += "<b>Your account pin is:</b> [M.remote_access_pin]<br>"
|
||||
remembered_info += "<b>Your account funds are:</b> $[M.money]<br>"
|
||||
|
||||
if(M.transaction_log.len)
|
||||
var/datum/transaction/T = M.transaction_log[1]
|
||||
if(M.transactions.len)
|
||||
var/datum/transaction/T = M.transactions[1]
|
||||
remembered_info += "<b>Your account was created:</b> [T.time], [T.date] at [T.source_terminal]<br>"
|
||||
H.mind.store_memory(remembered_info)
|
||||
|
||||
|
||||
@@ -487,14 +487,14 @@
|
||||
return
|
||||
|
||||
//Try to resole the security account first
|
||||
var/datum/money_account/security_account = department_accounts["Security"]
|
||||
var/datum/money_account/security_account = SSeconomy.get_department_account("Security")
|
||||
if(!security_account)
|
||||
buzz("\The [src] buzzes, \"Could not get security account!\"")
|
||||
return
|
||||
|
||||
var/obj/item/weapon/card/id/card = incident.card.resolve()
|
||||
//Let´s get the account of the suspect and verify they have enough money
|
||||
var/datum/money_account/suspect_account = get_account(card.associated_account_number)
|
||||
var/datum/money_account/suspect_account = SSeconomy.get_account(card.associated_account_number)
|
||||
if(!suspect_account)
|
||||
buzz("\The [src] buzzes, \"Could not get suspect account!\"")
|
||||
return
|
||||
@@ -503,8 +503,8 @@
|
||||
buzz("\The [src] buzzes, \"There is not enough money in the account to pay the fine!\"")
|
||||
return
|
||||
|
||||
charge_to_account(suspect_account.account_number,security_account.owner_name,"Incident: [incident.UID]","Sentencing Console",-incident.fine)
|
||||
charge_to_account(security_account.account_number,suspect_account.owner_name,"Incident: [incident.UID]Fine","Sentencing Console",incident.fine)
|
||||
SSeconomy.charge_to_account(suspect_account.account_number,security_account.owner_name,"Incident: [incident.UID]","Sentencing Console",-incident.fine)
|
||||
SSeconomy.charge_to_account(security_account.account_number,suspect_account.owner_name,"Incident: [incident.UID]Fine","Sentencing Console",incident.fine)
|
||||
print_incident_overview(incident.renderGuilty(user,1))
|
||||
|
||||
ping("\The [src] pings, \"[card.registered_name] has been fined for their crimes!\"")
|
||||
|
||||
@@ -184,6 +184,7 @@
|
||||
/obj/machinery/vending/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
|
||||
var/obj/item/weapon/card/id/I = W.GetID()
|
||||
var/datum/money_account/vendor_account = SSeconomy.get_department_account("Vendor")
|
||||
|
||||
if (currently_vending && vendor_account && !vendor_account.suspended)
|
||||
var/paid = 0
|
||||
@@ -361,7 +362,8 @@
|
||||
visible_message("<span class='info'>\The [usr] swipes \the [I] through \the [src].</span>")
|
||||
else
|
||||
visible_message("<span class='info'>\The [usr] swipes \the [ID_container] through \the [src].</span>")
|
||||
var/datum/money_account/customer_account = get_account(I.associated_account_number)
|
||||
var/datum/money_account/vendor_account = SSeconomy.get_department_account("Vendor")
|
||||
var/datum/money_account/customer_account = SSeconomy.get_account(I.associated_account_number)
|
||||
if (!customer_account)
|
||||
//Allow BSTs to take stuff from vendors, for debugging and adminbus purposes
|
||||
if (istype(I, /obj/item/weapon/card/id/bst))
|
||||
@@ -380,7 +382,7 @@
|
||||
// empty at high security levels
|
||||
if(customer_account.security_level != 0) //If card requires pin authentication (ie seclevel 1 or 2)
|
||||
var/attempt_pin = input("Enter pin code", "Vendor transaction") as num
|
||||
customer_account = attempt_account_access(I.associated_account_number, attempt_pin, 2)
|
||||
customer_account = SSeconomy.attempt_account_access(I.associated_account_number, attempt_pin, 2)
|
||||
|
||||
if(!customer_account)
|
||||
src.status_message = "Unable to access account: incorrect credentials."
|
||||
@@ -406,9 +408,9 @@
|
||||
else
|
||||
T.amount = "[currently_vending.price]"
|
||||
T.source_terminal = src.name
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
customer_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(customer_account,T)
|
||||
|
||||
// Give the vendor the money. We use the account owner name, which means
|
||||
// that purchases made with stolen/borrowed card will look like the card
|
||||
@@ -422,6 +424,7 @@
|
||||
* Called after the money has already been taken from the customer.
|
||||
*/
|
||||
/obj/machinery/vending/proc/credit_purchase(var/target as text)
|
||||
var/datum/money_account/vendor_account = SSeconomy.get_department_account("Vendor")
|
||||
vendor_account.money += currently_vending.price
|
||||
|
||||
var/datum/transaction/T = new()
|
||||
@@ -429,9 +432,9 @@
|
||||
T.purpose = "Purchase of [currently_vending.product_name]"
|
||||
T.amount = "[currently_vending.price]"
|
||||
T.source_terminal = src.name
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
vendor_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(vendor_account,T)
|
||||
|
||||
/obj/machinery/vending/attack_ai(mob/user as mob)
|
||||
return attack_hand(user)
|
||||
@@ -498,6 +501,7 @@
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/vending/Topic(href, href_list)
|
||||
var/datum/money_account/vendor_account = SSeconomy.get_department_account("Vendor")
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
return
|
||||
if(usr.stat || usr.restrained())
|
||||
|
||||
@@ -35,7 +35,7 @@ log transactions
|
||||
|
||||
/obj/machinery/atm/Initialize()
|
||||
. = ..()
|
||||
machine_id = "[station_name()] RT #[num_financial_terminals++]"
|
||||
machine_id = "[station_name()] RT #[SSeconomy.num_financial_terminals++]"
|
||||
|
||||
/obj/machinery/atm/Destroy()
|
||||
authenticated_account = null
|
||||
@@ -114,9 +114,10 @@ log transactions
|
||||
T.purpose = "Credit deposit"
|
||||
T.amount = I:worth
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
authenticated_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(authenticated_account,T)
|
||||
|
||||
|
||||
user << "<span class='info'>You insert [I] into [src].</span>"
|
||||
src.attack_hand(user)
|
||||
@@ -174,7 +175,7 @@ log transactions
|
||||
dat += "<td><b>Value</b></td>"
|
||||
dat += "<td><b>Source terminal ID</b></td>"
|
||||
dat += "</tr>"
|
||||
for(var/datum/transaction/T in authenticated_account.transaction_log)
|
||||
for(var/datum/transaction/T in authenticated_account.transactions)
|
||||
dat += "<tr>"
|
||||
dat += "<td>[T.date]</td>"
|
||||
dat += "<td>[T.time]</td>"
|
||||
@@ -235,7 +236,7 @@ log transactions
|
||||
else if(transfer_amount <= authenticated_account.money)
|
||||
var/target_account_number = text2num(href_list["target_acc_number"])
|
||||
var/transfer_purpose = href_list["purpose"]
|
||||
if(charge_to_account(target_account_number, authenticated_account.owner_name, transfer_purpose, machine_id, transfer_amount))
|
||||
if(SSeconomy.charge_to_account(target_account_number, authenticated_account.owner_name, transfer_purpose, machine_id, transfer_amount))
|
||||
usr << "\icon[src]<span class='info'>Funds transfer successful.</span>"
|
||||
authenticated_account.money -= transfer_amount
|
||||
|
||||
@@ -244,10 +245,10 @@ log transactions
|
||||
T.target_name = "Account #[target_account_number]"
|
||||
T.purpose = transfer_purpose
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
T.amount = "([transfer_amount])"
|
||||
authenticated_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(authenticated_account,T)
|
||||
else
|
||||
usr << "\icon[src]<span class='warning'>Funds transfer failed.</span>"
|
||||
|
||||
@@ -269,7 +270,7 @@ log transactions
|
||||
if (!tried_account_num && held_card)
|
||||
tried_account_num = held_card.associated_account_number
|
||||
var/tried_pin = text2num(href_list["account_pin"])
|
||||
var/datum/money_account/potential_account = get_account(tried_account_num)
|
||||
var/datum/money_account/potential_account = SSeconomy.get_account(tried_account_num)
|
||||
if (!potential_account)
|
||||
usr << "<span class='warning'>\icon[src] Account number not found.</span>"
|
||||
number_incorrect_tries++
|
||||
@@ -277,21 +278,21 @@ log transactions
|
||||
return
|
||||
switch (potential_account.security_level+1) //checks the security level of an account number to see what checks to do
|
||||
if (1) // Security level zero
|
||||
authenticated_account = attempt_account_access(tried_account_num, tried_pin, potential_account.security_level)
|
||||
authenticated_account = SSeconomy.attempt_account_access(tried_account_num, tried_pin, potential_account.security_level)
|
||||
// It should be impossible to fail at this point
|
||||
if (2) // Security level one
|
||||
authenticated_account = attempt_account_access(text2num(href_list["account_num"]), tried_pin, potential_account.security_level)
|
||||
authenticated_account = SSeconomy.attempt_account_access(text2num(href_list["account_num"]), tried_pin, potential_account.security_level)
|
||||
if (3) // Security level two
|
||||
if (held_card)
|
||||
if (text2num(href_list["account_num"]) != held_card.associated_account_number)
|
||||
else authenticated_account = attempt_account_access(tried_account_num, tried_pin, potential_account.security_level)
|
||||
else authenticated_account = SSeconomy.attempt_account_access(tried_account_num, tried_pin, potential_account.security_level)
|
||||
else usr << "<span class='warning'>Account card not found.</span>"
|
||||
if (!authenticated_account)
|
||||
number_incorrect_tries++
|
||||
usr << "<span class='warning'>\icon[src] Incorrect pin/account combination entered, [(max_pin_attempts+1) - number_incorrect_tries] attempts remaining.</span>"
|
||||
handle_lockdown(tried_account_num)
|
||||
else
|
||||
bank_log_access(authenticated_account, machine_id)
|
||||
SSeconomy.bank_log_access(authenticated_account, machine_id)
|
||||
number_incorrect_tries = 0
|
||||
playsound(src, 'sound/machines/twobeep.ogg', 50, 1)
|
||||
ticks_left_timeout = 120
|
||||
@@ -320,9 +321,9 @@ log transactions
|
||||
T.purpose = "Credit withdrawal"
|
||||
T.amount = "([amount])"
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
authenticated_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(authenticated_account,T)
|
||||
else
|
||||
usr << "\icon[src]<span class='warning'>You don't have enough funds to do that!</span>"
|
||||
if("withdrawal")
|
||||
@@ -345,9 +346,9 @@ log transactions
|
||||
T.purpose = "Credit withdrawal"
|
||||
T.amount = "([amount])"
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
authenticated_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(authenticated_account,T)
|
||||
else
|
||||
usr << "\icon[src]<span class='warning'>You don't have enough funds to do that!</span>"
|
||||
if("balance_statement")
|
||||
@@ -358,7 +359,7 @@ log transactions
|
||||
info += "<i>Account holder:</i> [authenticated_account.owner_name]<br>"
|
||||
info += "<i>Account number:</i> [authenticated_account.account_number]<br>"
|
||||
info += "<i>Balance:</i> $[authenticated_account.money]<br>"
|
||||
info += "<i>Date and time:</i> [worldtime2text()], [current_date_string]<br><br>"
|
||||
info += "<i>Date and time:</i> [worldtime2text()], [worlddate2text()]<br><br>"
|
||||
info += "<i>Service terminal ID:</i> [machine_id]<br>"
|
||||
R.set_content_unsafe(pname, info)
|
||||
|
||||
@@ -385,7 +386,7 @@ log transactions
|
||||
var/info = "<b>Transaction logs</b><br>"
|
||||
info += "<i>Account holder:</i> [authenticated_account.owner_name]<br>"
|
||||
info += "<i>Account number:</i> [authenticated_account.account_number]<br>"
|
||||
info += "<i>Date and time:</i> [worldtime2text()], [current_date_string]<br><br>"
|
||||
info += "<i>Date and time:</i> [worldtime2text()], [worlddate2text()]<br><br>"
|
||||
info += "<i>Service terminal ID:</i> [machine_id]<br>"
|
||||
info += "<table border=1 style='width:100%'>"
|
||||
info += "<tr>"
|
||||
@@ -396,7 +397,7 @@ log transactions
|
||||
info += "<td><b>Value</b></td>"
|
||||
info += "<td><b>Source terminal ID</b></td>"
|
||||
info += "</tr>"
|
||||
for(var/datum/transaction/T in authenticated_account.transaction_log)
|
||||
for(var/datum/transaction/T in authenticated_account.transactions)
|
||||
info += "<tr>"
|
||||
info += "<td>[T.date]</td>"
|
||||
info += "<td>[T.time]</td>"
|
||||
@@ -454,7 +455,7 @@ log transactions
|
||||
var/obj/item/device/pda/P = human_user.wear_id
|
||||
I = P.id
|
||||
if(I)
|
||||
authenticated_account = attempt_account_access(I.associated_account_number)
|
||||
authenticated_account = SSeconomy.attempt_account_access(I.associated_account_number)
|
||||
if(authenticated_account)
|
||||
human_user << "<span class='notice'>\icon[src] Access granted. Welcome user '[authenticated_account.owner_name].'</span>"
|
||||
|
||||
@@ -463,9 +464,9 @@ log transactions
|
||||
T.target_name = authenticated_account.owner_name
|
||||
T.purpose = "Remote terminal access"
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
authenticated_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(authenticated_account,T)
|
||||
|
||||
view_screen = NO_SCREEN
|
||||
|
||||
@@ -478,7 +479,7 @@ log transactions
|
||||
playsound(src, 'sound/machines/buzz-two.ogg', 50, 1)
|
||||
global_announcer.autosay("An ATM has gone into lockdown in [t.name].", machine_id)
|
||||
if (tried_account_num)
|
||||
bank_log_unauthorized(get_account(tried_account_num), machine_id)
|
||||
SSeconomy.bank_log_unauthorized(SSeconomy.get_account(tried_account_num), machine_id)
|
||||
view_screen = NO_SCREEN
|
||||
else playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 1)
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
|
||||
/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 = 0 //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")], 24[rand(10,48)]"
|
||||
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
|
||||
var/pname = "Account information: [M.owner_name]"
|
||||
var/info = "<b>Account details (confidential)</b><br><hr><br>"
|
||||
info += "<i>Account holder:</i> [M.owner_name]<br>"
|
||||
info += "<i>Account number:</i> [M.account_number]<br>"
|
||||
info += "<i>Account pin:</i> [M.remote_access_pin]<br>"
|
||||
info += "<i>Starting balance:</i> $[M.money]<br>"
|
||||
info += "<i>Date and time:</i> [worldtime2text()], [current_date_string]<br><br>"
|
||||
info += "<i>Creation terminal ID:</i> [source_db.machine_id]<br>"
|
||||
info += "<i>Authorised NT officer overseeing creation:</i> [source_db.held_card.registered_name]<br>"
|
||||
|
||||
R.set_content_unsafe(pname, info)
|
||||
|
||||
//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.add_overlay(stampoverlay)
|
||||
R.stamps += "<HR><i>This paper has been stamped by the Accounts Database.</i>"
|
||||
|
||||
//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
|
||||
|
||||
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
|
||||
return 0
|
||||
|
||||
/proc/bank_log_unauthorized(var/datum/money_account/bank_account, var/machine_id = "Unknown machine ID")
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = bank_account.owner_name
|
||||
T.purpose = "Unauthorised login attempt"
|
||||
T.source_terminal = machine_id
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
bank_account.transaction_log.Add(T)
|
||||
return
|
||||
|
||||
/proc/bank_log_access(var/datum/money_account/bank_account, var/machine_id = "Unknown machine ID")
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = bank_account.owner_name
|
||||
T.purpose = "Remote terminal access"
|
||||
T.source_terminal = machine_id
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
bank_account.transaction_log.Add(T)
|
||||
return
|
||||
@@ -27,7 +27,7 @@
|
||||
T.target_name = target
|
||||
T.purpose = reason
|
||||
T.amount = amount
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
T.source_terminal = machine_id
|
||||
return T
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
/obj/machinery/account_database/Initialize()
|
||||
. = ..()
|
||||
machine_id = "[station_name()] Acc. DB #[num_financial_terminals++]"
|
||||
machine_id = "[station_name()] Acc. DB #[SSeconomy.num_financial_terminals++]"
|
||||
|
||||
/obj/machinery/account_database/attackby(obj/O, mob/user)
|
||||
if(!istype(O, /obj/item/weapon/card/id))
|
||||
@@ -71,7 +71,7 @@
|
||||
data["machine_id"] = machine_id
|
||||
data["creating_new_account"] = creating_new_account
|
||||
data["detailed_account_view"] = !!detailed_account_view
|
||||
data["station_account_number"] = station_account.account_number
|
||||
data["station_account_number"] = SSeconomy.station_account.account_number
|
||||
data["transactions"] = null
|
||||
data["accounts"] = null
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
data["suspended"] = detailed_account_view.suspended
|
||||
|
||||
var/list/trx[0]
|
||||
for (var/datum/transaction/T in detailed_account_view.transaction_log)
|
||||
for (var/datum/transaction/T in detailed_account_view.transactions)
|
||||
trx.Add(list(list(\
|
||||
"date" = T.date, \
|
||||
"time" = T.time, \
|
||||
@@ -95,8 +95,8 @@
|
||||
data["transactions"] = trx
|
||||
|
||||
var/list/accounts[0]
|
||||
for(var/i=1, i<=all_money_accounts.len, i++)
|
||||
var/datum/money_account/D = all_money_accounts[i]
|
||||
for(var/i=1, i<=SSeconomy.all_money_accounts.len, i++)
|
||||
var/datum/money_account/D = SSeconomy.all_money_accounts[i]
|
||||
accounts.Add(list(list(\
|
||||
"account_number"=D.account_number,\
|
||||
"owner_name"=D.owner_name,\
|
||||
@@ -142,17 +142,17 @@
|
||||
var/account_name = href_list["holder_name"]
|
||||
var/starting_funds = max(text2num(href_list["starting_funds"]), 0)
|
||||
|
||||
starting_funds = Clamp(starting_funds, 0, station_account.money) // Not authorized to put the station in debt.
|
||||
starting_funds = Clamp(starting_funds, 0, SSeconomy.station_account.money) // Not authorized to put the station in debt.
|
||||
starting_funds = min(starting_funds, fund_cap) // Not authorized to give more than the fund cap.
|
||||
|
||||
create_account(account_name, starting_funds, src)
|
||||
SSeconomy.create_account(account_name, starting_funds, src)
|
||||
if(starting_funds > 0)
|
||||
//subtract the money
|
||||
station_account.money -= starting_funds
|
||||
SSeconomy.station_account.money -= starting_funds
|
||||
|
||||
//create a transaction log entry
|
||||
var/trx = create_transation(account_name, "New account activation", "([starting_funds])")
|
||||
station_account.transaction_log.Add(trx)
|
||||
var/datum/transaction/trx = create_transation(account_name, "New account activation", "([starting_funds])")
|
||||
SSeconomy.add_transaction_log(SSeconomy.station_account,trx)
|
||||
|
||||
creating_new_account = 0
|
||||
ui.close()
|
||||
@@ -175,8 +175,8 @@
|
||||
|
||||
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(index && index <= SSeconomy.all_money_accounts.len)
|
||||
detailed_account_view = SSeconomy.all_money_accounts[index]
|
||||
|
||||
if("view_accounts_list")
|
||||
detailed_account_view = null
|
||||
@@ -184,14 +184,14 @@
|
||||
|
||||
if("revoke_payroll")
|
||||
var/funds = detailed_account_view.money
|
||||
var/account_trx = create_transation(station_account.owner_name, "Revoke payroll", "([funds])")
|
||||
var/account_trx = create_transation(SSeconomy.station_account.owner_name, "Revoke payroll", "([funds])")
|
||||
var/station_trx = create_transation(detailed_account_view.owner_name, "Revoke payroll", funds)
|
||||
|
||||
station_account.money += funds
|
||||
SSeconomy.station_account.money += funds
|
||||
detailed_account_view.money = 0
|
||||
|
||||
detailed_account_view.transaction_log.Add(account_trx)
|
||||
station_account.transaction_log.Add(station_trx)
|
||||
SSeconomy.add_transaction_log(detailed_account_view,account_trx)
|
||||
SSeconomy.add_transaction_log(SSeconomy.station_account,station_trx)
|
||||
|
||||
callHook("revoke_payroll", list(detailed_account_view))
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
<u>Holder:</u> [detailed_account_view.owner_name]<br>
|
||||
<u>Balance:</u> $[detailed_account_view.money]<br>
|
||||
<u>Status:</u> [detailed_account_view.suspended ? "Suspended" : "Active"]<br>
|
||||
<u>Transactions:</u> ([detailed_account_view.transaction_log.len])<br>
|
||||
<u>Transactions:</u> ([detailed_account_view.transactions.len])<br>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -221,7 +221,7 @@
|
||||
<tbody>
|
||||
"}
|
||||
|
||||
for (var/datum/transaction/T in detailed_account_view.transaction_log)
|
||||
for (var/datum/transaction/T in detailed_account_view.transactions)
|
||||
text += {"
|
||||
<tr>
|
||||
<td>[T.date] [T.time]</td>
|
||||
@@ -254,8 +254,8 @@
|
||||
<tbody>
|
||||
"}
|
||||
|
||||
for(var/i=1, i<=all_money_accounts.len, i++)
|
||||
var/datum/money_account/D = all_money_accounts[i]
|
||||
for(var/i=1, i<=SSeconomy.all_money_accounts.len, i++)
|
||||
var/datum/money_account/D = SSeconomy.all_money_accounts[i]
|
||||
text += {"
|
||||
<tr>
|
||||
<td>#[D.account_number]</td>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
/obj/item/device/eftpos/New()
|
||||
..()
|
||||
machine_id = "[station_name()] EFTPOS #[num_financial_terminals++]"
|
||||
machine_id = "[station_name()] EFTPOS #[SSeconomy.num_financial_terminals++]"
|
||||
access_code = rand(1111,111111)
|
||||
spawn(0)
|
||||
print_reference()
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
//by default, connect to the station account
|
||||
//the user of the EFTPOS device can change the target account though, and no-one will be the wiser (except whoever's being charged)
|
||||
linked_account = station_account
|
||||
linked_account = SSeconomy.station_account
|
||||
|
||||
/obj/item/device/eftpos/proc/print_reference()
|
||||
var/obj/item/weapon/paper/R = new(src.loc)
|
||||
@@ -140,9 +140,9 @@
|
||||
T.purpose = (transaction_purpose ? transaction_purpose : "None supplied.")
|
||||
T.amount = transaction_amount
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
linked_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(linked_account,T)
|
||||
else
|
||||
usr << "\icon[src]<span class='warning'>\The [O] doesn't have that much money!</span>"
|
||||
else
|
||||
@@ -177,7 +177,7 @@
|
||||
if("link_account")
|
||||
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)
|
||||
linked_account = SSeconomy.attempt_account_access(attempt_account_num, attempt_pin, 1)
|
||||
if(linked_account)
|
||||
if(linked_account.suspended)
|
||||
linked_account = null
|
||||
@@ -239,11 +239,11 @@
|
||||
if(linked_account)
|
||||
if(!linked_account.suspended)
|
||||
var/attempt_pin = ""
|
||||
var/datum/money_account/D = get_account(C.associated_account_number)
|
||||
var/datum/money_account/D = SSeconomy.get_account(C.associated_account_number)
|
||||
if(D.security_level)
|
||||
attempt_pin = input("Enter pin code", "EFTPOS transaction") as num
|
||||
D = null
|
||||
D = attempt_account_access(C.associated_account_number, attempt_pin, 2)
|
||||
D = SSeconomy.attempt_account_access(C.associated_account_number, attempt_pin, 2)
|
||||
if(D)
|
||||
if(!D.suspended)
|
||||
if(transaction_amount <= D.money)
|
||||
@@ -264,18 +264,18 @@
|
||||
else
|
||||
T.amount = "[transaction_amount]"
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
D.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(D,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.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
linked_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(linked_account,T)
|
||||
else
|
||||
usr << "\icon[src]<span class='warning'>You don't have that much money!</span>"
|
||||
else
|
||||
|
||||
@@ -62,81 +62,3 @@
|
||||
//Yachts are fast civilian craft, often used for pleasure or smuggling.
|
||||
//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/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(economy_init)
|
||||
return 2
|
||||
|
||||
for(var/loc_type in typesof(/datum/trade_destination) - /datum/trade_destination)
|
||||
var/datum/trade_destination/D = new loc_type
|
||||
weighted_randomevent_locations[D] = D.viable_random_events.len
|
||||
weighted_mundaneevent_locations[D] = D.viable_mundane_events.len
|
||||
|
||||
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")], [game_year]"
|
||||
|
||||
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, 2454"
|
||||
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, 2454"
|
||||
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
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
/datum/event/money_hacker/setup()
|
||||
end_time = world.time + 6000
|
||||
if(all_money_accounts.len)
|
||||
affected_account = pick(all_money_accounts)
|
||||
if(SSeconomy.all_money_accounts.len)
|
||||
affected_account = pick(SSeconomy.all_money_accounts)
|
||||
|
||||
account_hack_attempted = 1
|
||||
else
|
||||
@@ -48,13 +48,12 @@
|
||||
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)
|
||||
T.date = pick("", worlddate2text(), 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)
|
||||
SSeconomy.add_transaction_log(affected_account,T)
|
||||
|
||||
else
|
||||
//crew wins
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
/datum/event/money_lotto/start()
|
||||
winner_sum = pick(1, 50, 100, 500, 1000, 2000, 5000)
|
||||
if(all_money_accounts.len)
|
||||
var/datum/money_account/D = pick(all_money_accounts)
|
||||
if(SSeconomy.all_money_accounts.len)
|
||||
var/datum/money_account/D = pick(SSeconomy.all_money_accounts)
|
||||
winner_name = D.owner_name
|
||||
if(!D.suspended)
|
||||
D.money += winner_sum
|
||||
@@ -15,10 +15,10 @@
|
||||
T.target_name = "Tau Ceti Daily Grand Slam -Stellar- Lottery"
|
||||
T.purpose = "Winner!"
|
||||
T.amount = winner_sum
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
T.source_terminal = "Biesel TCD Terminal #[rand(111,333)]"
|
||||
D.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(D,T)
|
||||
|
||||
deposit_success = 1
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
var/transaction_amount = order_details["price_customer"];
|
||||
var/transaction_purpose = "Cargo Order #[order_details["order_id"]]";
|
||||
|
||||
var/datum/money_account/D = get_account(id_card.associated_account_number)
|
||||
var/datum/money_account/D = SSeconomy.get_account(id_card.associated_account_number)
|
||||
if(!D)
|
||||
status_message = "Unable to access account. Check security settings and try again."
|
||||
return 1
|
||||
@@ -94,7 +94,7 @@
|
||||
if(D.security_level)
|
||||
attempt_pin = input("Enter pin code", "EFTPOS transaction") as num
|
||||
D = null
|
||||
D = attempt_account_access(id_card.associated_account_number, attempt_pin, 2)
|
||||
D = SSeconomy.attempt_account_access(id_card.associated_account_number, attempt_pin, 2)
|
||||
if(D)
|
||||
if(!D.suspended)
|
||||
if(transaction_amount <= D.money)
|
||||
@@ -113,18 +113,18 @@
|
||||
else
|
||||
T.amount = "[transaction_amount]"
|
||||
T.source_terminal = "Modular Computer #[program.computer.network_card.identification_id]"
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
D.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(D,T)
|
||||
//
|
||||
T = new()
|
||||
T.target_name = D.owner_name
|
||||
T.purpose = transaction_purpose
|
||||
T.amount = "[transaction_amount]"
|
||||
T.source_terminal = "Modular Computer #[program.computer.network_card.identification_id]"
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
SScargo.supply_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(SScargo.supply_account,T)
|
||||
|
||||
//Check if we have delivered it aswell or only paid
|
||||
if(order_details["status"] == "shipped")
|
||||
|
||||
@@ -297,14 +297,14 @@ obj/machinery/lapvend/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
else
|
||||
visible_message("<span class='info'>\The [usr] swipes \the [ID_container] through \the [src].</span>")
|
||||
if(I)
|
||||
var/datum/money_account/customer_account = get_account(I.associated_account_number)
|
||||
var/datum/money_account/customer_account = SSeconomy.get_account(I.associated_account_number)
|
||||
if (!customer_account || customer_account.suspended)
|
||||
ping("Connection error. Unable to connect to account.")
|
||||
return 0
|
||||
|
||||
if(customer_account.security_level != 0) //If card requires pin authentication (ie seclevel 1 or 2)
|
||||
var/attempt_pin = input("Enter pin code", "Vendor transaction") as num
|
||||
customer_account = attempt_account_access(I.associated_account_number, attempt_pin, 2)
|
||||
customer_account = SSeconomy.attempt_account_access(I.associated_account_number, attempt_pin, 2)
|
||||
|
||||
if(!customer_account)
|
||||
ping("Unable to access account: incorrect credentials.")
|
||||
@@ -320,9 +320,9 @@ obj/machinery/lapvend/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
T.purpose = "Purchase of [(devtype == 1) ? "laptop computer" : "tablet microcomputer"]."
|
||||
T.amount = total_price
|
||||
T.source_terminal = src.name
|
||||
T.date = current_date_string
|
||||
T.date = worlddate2text()
|
||||
T.time = worldtime2text()
|
||||
customer_account.transaction_log.Add(T)
|
||||
SSeconomy.add_transaction_log(customer_account,T)
|
||||
return 1
|
||||
else if(S)
|
||||
if(total_price > S.worth)
|
||||
|
||||
Reference in New Issue
Block a user