Converts Economy to a Subsystem (#5253)

Converts Economy to a Subsystem and cleans it up a bit
This commit is contained in:
Werner
2018-11-03 15:34:22 +02:00
committed by Erki
parent 866da21d57
commit a42e6a118b
19 changed files with 361 additions and 327 deletions
+3 -3
View File
@@ -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)
+4 -4
View File
@@ -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!\"")
+10 -6
View File
@@ -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())