mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-21 20:13:45 +01:00
Merge pull request #9255 from variableundefined/EconomyRefactor
Economy Refactor & Changes - Part 1
This commit is contained in:
@@ -118,22 +118,7 @@
|
||||
else
|
||||
// Okay to move the money at this point
|
||||
|
||||
// debit money from the purchaser's account
|
||||
customer_account.money -= token_price
|
||||
|
||||
// create entry in the purchaser's account log
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = "[src.name]"
|
||||
T.purpose = "Purchase of [src.name] credit"
|
||||
if(token_price > 0)
|
||||
T.amount = "([token_price])"
|
||||
else
|
||||
T.amount = "[token_price]"
|
||||
T.source_terminal = src.name
|
||||
T.date = current_date_string
|
||||
T.time = station_time_timestamp()
|
||||
customer_account.transaction_log.Add(T)
|
||||
return 1
|
||||
customer_account.charge(token_price, null, "Purchase of [name] credit", name, name)
|
||||
|
||||
/obj/machinery/arcade/proc/start_play(mob/user as mob)
|
||||
user.set_machine(src)
|
||||
@@ -159,4 +144,4 @@
|
||||
|
||||
/obj/machinery/arcade/Destroy()
|
||||
src.close_game()
|
||||
return ..()
|
||||
return ..()
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
D.account = get_card_account(id, occupant)
|
||||
if(!D.account)
|
||||
return null
|
||||
if(!D.account.charge(100, transaction_purpose = "10 minutes", dest_name = name))
|
||||
if(!D.account.charge(100, null, "10 minutes hotel stay", "Biesel GalaxyNet Terminal [rand(111,1111)]", "[name]"))
|
||||
return null
|
||||
|
||||
D.occupant = occupant
|
||||
@@ -251,7 +251,7 @@
|
||||
if(!D || !D.occupant)
|
||||
return
|
||||
|
||||
if(D.account.charge(100, transaction_purpose = "10 minutes", dest_name = name))
|
||||
if(D.account.charge(100, null, "10 minutes hotel stay extension", "Biesel GalaxyNet Terminal [rand(111,1111)]", "[name]"))
|
||||
D.roomtimer = addtimer(CALLBACK(src, .proc/process_room, roomid), PAY_INTERVAL, TIMER_STOPPABLE)
|
||||
else
|
||||
force_checkout(roomid)
|
||||
@@ -299,4 +299,4 @@
|
||||
return
|
||||
|
||||
S.retal_target = target
|
||||
S.retal = 1
|
||||
S.retal = 1
|
||||
|
||||
@@ -97,18 +97,9 @@ log transactions
|
||||
if(!powered())
|
||||
return
|
||||
var/obj/item/stack/spacecash/C = I
|
||||
authenticated_account.money += C.amount
|
||||
playsound(loc, pick('sound/items/polaroid1.ogg', 'sound/items/polaroid2.ogg'), 50, 1)
|
||||
|
||||
//create a transaction log entry
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = authenticated_account.owner_name
|
||||
T.purpose = "Credit deposit"
|
||||
T.amount = C.amount
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.time = station_time_timestamp()
|
||||
authenticated_account.transaction_log.Add(T)
|
||||
authenticated_account.credit(C.amount, "Credit deposit", machine_id, authenticated_account.owner_name)
|
||||
|
||||
to_chat(user, "<span class='info'>You insert [C] into [src].</span>")
|
||||
SSnanoui.update_uis(src)
|
||||
@@ -175,19 +166,8 @@ 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(linked_db.charge_to_account(target_account_number, authenticated_account.owner_name, transfer_purpose, machine_id, transfer_amount))
|
||||
if(linked_db.charge_to_account(target_account_number, authenticated_account, transfer_purpose, machine_id, transfer_amount))
|
||||
to_chat(usr, "[bicon(src)]<span class='info'>Funds transfer successful.</span>")
|
||||
authenticated_account.money -= transfer_amount
|
||||
|
||||
//create an entry in the account transaction log
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = "Account #[target_account_number]"
|
||||
T.purpose = transfer_purpose
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.time = station_time_timestamp()
|
||||
T.amount = "([transfer_amount])"
|
||||
authenticated_account.transaction_log.Add(T)
|
||||
else
|
||||
to_chat(usr, "[bicon(src)]<span class='warning'>Funds transfer failed.</span>")
|
||||
|
||||
@@ -263,15 +243,7 @@ log transactions
|
||||
authenticated_account.money -= amount
|
||||
withdraw_arbitrary_sum(amount)
|
||||
|
||||
//create an entry in the account transaction log
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = authenticated_account.owner_name
|
||||
T.purpose = "Credit withdrawal"
|
||||
T.amount = "([amount])"
|
||||
T.source_terminal = machine_id
|
||||
T.date = current_date_string
|
||||
T.time = station_time_timestamp()
|
||||
authenticated_account.transaction_log.Add(T)
|
||||
authenticated_account.charge(amount, null, "Credit withdrawal", machine_id, authenticated_account.owner_name)
|
||||
else
|
||||
to_chat(usr, "[bicon(src)]<span class='warning'>You don't have enough funds to do that!</span>")
|
||||
if("balance_statement")
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
var/global/current_date_string
|
||||
#define STATION_CREATION_DATE "2 April, 2555"
|
||||
#define STATION_CREATION_TIME "11:24:30"
|
||||
#define STATION_START_CASH 75000
|
||||
#define STATION_SOURCE_TERMINAL "Biesel GalaxyNet Terminal #227"
|
||||
#define DEPARTMENT_START_CASH 5000
|
||||
|
||||
var/global/num_financial_terminals = 1
|
||||
var/global/datum/money_account/station_account
|
||||
var/global/list/datum/money_account/department_accounts = list()
|
||||
@@ -15,19 +20,13 @@ var/global/list/all_money_accounts = list()
|
||||
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
|
||||
station_account.money = STATION_START_CASH
|
||||
|
||||
//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"
|
||||
station_account.makeTransactionLog(STATION_START_CASH, "Account Creation", STATION_SOURCE_TERMINAL, station_account.owner_name, FALSE,
|
||||
STATION_CREATION_DATE, STATION_CREATION_TIME)
|
||||
|
||||
//add the account
|
||||
station_account.transaction_log.Add(T)
|
||||
all_money_accounts.Add(station_account)
|
||||
|
||||
/proc/create_department_account(department)
|
||||
@@ -37,19 +36,13 @@ var/global/list/all_money_accounts = list()
|
||||
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
|
||||
department_account.money = DEPARTMENT_START_CASH
|
||||
|
||||
//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"
|
||||
department_account.makeTransactionLog(DEPARTMENT_START_CASH, "Account Creation", STATION_SOURCE_TERMINAL, department_account.owner_name, FALSE,
|
||||
STATION_CREATION_DATE, STATION_CREATION_TIME)
|
||||
|
||||
//add the account
|
||||
department_account.transaction_log.Add(T)
|
||||
all_money_accounts.Add(department_account)
|
||||
|
||||
department_accounts[department] = department_account
|
||||
@@ -73,7 +66,7 @@ var/global/list/all_money_accounts = list()
|
||||
if(!source_db)
|
||||
//set a random date, time and location some time over the past few decades
|
||||
T.date = "[num2text(rand(1,31))] [pick(month_names)], [rand(game_year - 20,game_year - 1)]"
|
||||
T.time = "[rand(0,23)]:[rand(0,59)]"
|
||||
T.time = "[rand(0,23)]:[rand(0,59)]:[rand(0,59)]"
|
||||
T.source_terminal = "NTGalaxyNet Terminal #[rand(111,1111)]"
|
||||
|
||||
M.account_number = rand(111111, 999999)
|
||||
@@ -104,7 +97,7 @@ var/global/list/all_money_accounts = list()
|
||||
<i>Date and time:</i> [station_time_timestamp()], [current_date_string]<br><br>
|
||||
<i>Creation terminal ID:</i> [source_db.machine_id]<br>
|
||||
<i>Authorised NT officer overseeing creation:</i> [overseer]<br>"}
|
||||
// END AUTOFIX
|
||||
|
||||
//stamp the paper
|
||||
var/image/stampoverlay = image('icons/obj/bureaucracy.dmi')
|
||||
stampoverlay.icon_state = "paper_stamp-cent"
|
||||
@@ -133,7 +126,6 @@ var/global/list/all_money_accounts = list()
|
||||
|
||||
/datum/money_account/New()
|
||||
..()
|
||||
//security_level = pick (0,1) //Stealing is now slightly viable
|
||||
|
||||
/datum/transaction
|
||||
var/target_name = ""
|
||||
@@ -142,222 +134,14 @@ var/global/list/all_money_accounts = list()
|
||||
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/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")], 2557"
|
||||
|
||||
machine_id = "[station_name()] Acc. DB #[num_financial_terminals++]"
|
||||
|
||||
/obj/machinery/account_database/attack_hand(mob/user as mob)
|
||||
if(ishuman(user) && !user.stat && get_dist(src,user) <= 1)
|
||||
var/dat = "<b>Accounts Database</b><br>"
|
||||
|
||||
// AUTOFIXED BY fix_string_idiocy.py
|
||||
// C:\Users\Rob\Documents\Projects\vgstation13\code\WorkInProgress\Cael_Aislinn\Economy\Accounts.dm:171: dat += "<i>[machine_id]</i><br>"
|
||||
dat += {"<i>[machine_id]</i><br>
|
||||
Confirm identity: <a href='?src=[UID()];choice=insert_card'>[held_card ? held_card : "-----"]</a><br>"}
|
||||
// END AUTOFIX
|
||||
if(access_level > 0)
|
||||
|
||||
// AUTOFIXED BY fix_string_idiocy.py
|
||||
// C:\Users\Rob\Documents\Projects\vgstation13\code\WorkInProgress\Cael_Aislinn\Economy\Accounts.dm:175: dat += "<a href='?src=[UID()];toggle_activated=1'>[activated ? "Disable" : "Enable"] remote access</a><br>"
|
||||
dat += {"<a href='?src=[UID()];toggle_activated=1'>[activated ? "Disable" : "Enable"] remote access</a><br>
|
||||
You may not edit accounts at this terminal, only create and view them.<br>"}
|
||||
// END AUTOFIX
|
||||
if(creating_new_account)
|
||||
|
||||
// AUTOFIXED BY fix_string_idiocy.py
|
||||
// C:\Users\Rob\Documents\Projects\vgstation13\code\WorkInProgress\Cael_Aislinn\Economy\Accounts.dm:178: dat += "<br>"
|
||||
dat += {"<br>
|
||||
<a href='?src=[UID()];choice=view_accounts_list;'>Return to accounts list</a>
|
||||
<form name='create_account' action='?src=[UID()]' method='get'>
|
||||
<input type='hidden' name='src' value='[UID()]'>
|
||||
<input type='hidden' name='choice' value='finalise_create_account'>
|
||||
<b>Holder name:</b> <input type='text' id='holder_name' name='holder_name' style='width:250px; background-color:white;'><br>
|
||||
<b>Initial funds:</b> <input type='text' id='starting_funds' name='starting_funds' style='width:250px; background-color:white;'> (subtracted from station account)<br>
|
||||
<i>New accounts are automatically assigned a secret number and pin, which are printed separately in a sealed package.</i><br>
|
||||
<input type='submit' value='Create'><br>
|
||||
</form>"}
|
||||
// END AUTOFIX
|
||||
else
|
||||
if(detailed_account_view)
|
||||
|
||||
// AUTOFIXED BY fix_string_idiocy.py
|
||||
// C:\Users\Rob\Documents\Projects\vgstation13\code\WorkInProgress\Cael_Aislinn\Economy\Accounts.dm:190: dat += "<br>"
|
||||
dat += {"<br>
|
||||
<a href='?src=[UID()];choice=view_accounts_list;'>Return to accounts list</a><hr>
|
||||
<b>Account number:</b> #[detailed_account_view.account_number]<br>
|
||||
<b>Account holder:</b> [detailed_account_view.owner_name]<br>
|
||||
<b>Account balance:</b> $[detailed_account_view.money]<br>
|
||||
<table border=1 style='width:100%'>
|
||||
<tr>
|
||||
<td><b>Date</b></td>
|
||||
<td><b>Time</b></td>
|
||||
<td><b>Target</b></td>
|
||||
<td><b>Purpose</b></td>
|
||||
<td><b>Value</b></td>
|
||||
<td><b>Source terminal ID</b></td>
|
||||
</tr>"}
|
||||
// END AUTOFIX
|
||||
for(var/datum/transaction/T in detailed_account_view.transaction_log)
|
||||
|
||||
// AUTOFIXED BY fix_string_idiocy.py
|
||||
// C:\Users\Rob\Documents\Projects\vgstation13\code\WorkInProgress\Cael_Aislinn\Economy\Accounts.dm:205: dat += "<tr>"
|
||||
dat += {"<tr>
|
||||
<td>[T.date]</td>
|
||||
<td>[T.time]</td>
|
||||
<td>[T.target_name]</td>
|
||||
<td>[T.purpose]</td>
|
||||
<td>$[T.amount]</td>
|
||||
<td>[T.source_terminal]</td>
|
||||
</tr>"}
|
||||
// END AUTOFIX
|
||||
dat += "</table>"
|
||||
else
|
||||
|
||||
// AUTOFIXED BY fix_string_idiocy.py
|
||||
// C:\Users\Rob\Documents\Projects\vgstation13\code\WorkInProgress\Cael_Aislinn\Economy\Accounts.dm:215: dat += "<a href='?src=[UID()];choice=create_account;'>Create new account</a><br><br>"
|
||||
dat += {"<a href='?src=[UID()];choice=create_account;'>Create new account</a><br><br>
|
||||
<table border=1 style='width:100%'>"}
|
||||
// END AUTOFIX
|
||||
for(var/i=1, i<=all_money_accounts.len, i++)
|
||||
var/datum/money_account/D = all_money_accounts[i]
|
||||
|
||||
// AUTOFIXED BY fix_string_idiocy.py
|
||||
// C:\Users\Rob\Documents\Projects\vgstation13\code\WorkInProgress\Cael_Aislinn\Economy\Accounts.dm:219: dat += "<tr>"
|
||||
dat += {"<tr>
|
||||
<td>#[D.account_number]</td>
|
||||
<td>[D.owner_name]</td>
|
||||
<td><a href='?src=[UID()];choice=view_account_detail;account_index=[i]'>View in detail</a></td>
|
||||
</tr>"}
|
||||
// END AUTOFIX
|
||||
dat += "</table>"
|
||||
|
||||
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/card))
|
||||
var/obj/item/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 = station_time_timestamp()
|
||||
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/card/id))
|
||||
var/obj/item/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/computer/account_database/proc/charge_to_account(var/attempt_account_number, var/source_name, var/purpose, var/terminal_id, var/amount)
|
||||
/obj/machinery/computer/account_database/proc/charge_to_account(attempt_account_number, datum/money_account/source, purpose, terminal_id, amount)
|
||||
if(!activated)
|
||||
return 0
|
||||
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 = station_time_timestamp()
|
||||
T.source_terminal = terminal_id
|
||||
D.transaction_log.Add(T)
|
||||
|
||||
source.charge(amount, D, purpose, terminal_id, "Account #[D.account_number]", "Transfer from [source.owner_name]",
|
||||
"[D.owner_name]")
|
||||
return 1
|
||||
|
||||
return 0
|
||||
@@ -378,3 +162,9 @@ var/global/list/all_money_accounts = list()
|
||||
for(var/datum/money_account/D in all_money_accounts)
|
||||
if(D.account_number == attempt_account_number)
|
||||
return D
|
||||
|
||||
#undef STATION_CREATION_DATE
|
||||
#undef STATION_CREATION_TIME
|
||||
#undef STATION_START_CASH
|
||||
#undef STATION_SOURCE_TERMINAL
|
||||
#undef DEPARTMENT_START_CASH
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
var/global/current_date_string
|
||||
|
||||
/obj/machinery/computer/account_database
|
||||
name = "Accounts Uplink Terminal"
|
||||
@@ -15,34 +16,6 @@
|
||||
|
||||
light_color = LIGHT_COLOR_GREEN
|
||||
|
||||
/obj/machinery/computer/account_database/proc/get_access_level(var/mob/user)
|
||||
if(user.can_admin_interact())
|
||||
return 2
|
||||
if(!held_card)
|
||||
return 0
|
||||
if(access_cent_commander in held_card.access)
|
||||
return 2
|
||||
else if(access_hop in held_card.access || access_captain in held_card.access)
|
||||
return 1
|
||||
|
||||
/obj/machinery/computer/account_database/proc/create_transation(target, reason, amount)
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = target
|
||||
T.purpose = reason
|
||||
T.amount = amount
|
||||
T.date = current_date_string
|
||||
T.time = station_time_timestamp()
|
||||
T.source_terminal = machine_id
|
||||
return T
|
||||
|
||||
/obj/machinery/computer/account_database/proc/accounting_letterhead(report_name)
|
||||
return {"
|
||||
<center><h1><b>[report_name]</b></h1></center>
|
||||
<center><small><i>[station_name()] Accounting Report</i></small></center>
|
||||
<hr>
|
||||
<u>Generated By:</u> [held_card.registered_name], [held_card.assignment]<br>
|
||||
"}
|
||||
|
||||
/obj/machinery/computer/account_database/New()
|
||||
if(!station_account)
|
||||
create_station_account()
|
||||
@@ -55,11 +28,29 @@
|
||||
vendor_account = department_accounts["Vendor"]
|
||||
|
||||
if(!current_date_string)
|
||||
current_date_string = "[time2text(world.timeofday, "DD MM")], [game_year]"
|
||||
current_date_string = "[time2text(world.timeofday, "DD Month")], [game_year]"
|
||||
|
||||
machine_id = "[station_name()] Acc. DB #[num_financial_terminals++]"
|
||||
..()
|
||||
|
||||
/obj/machinery/computer/account_database/proc/get_access_level(var/mob/user)
|
||||
if(user.can_admin_interact())
|
||||
return 2
|
||||
if(!held_card)
|
||||
return 0
|
||||
if(access_cent_commander in held_card.access)
|
||||
return 2
|
||||
else if(access_hop in held_card.access || access_captain in held_card.access)
|
||||
return 1
|
||||
|
||||
/obj/machinery/computer/account_database/proc/accounting_letterhead(report_name)
|
||||
return {"
|
||||
<center><h1><b>[report_name]</b></h1></center>
|
||||
<center><small><i>[station_name()] Accounting Report</i></small></center>
|
||||
<hr>
|
||||
<u>Generated By:</u> [held_card.registered_name], [held_card.assignment]<br>
|
||||
"}
|
||||
|
||||
/obj/machinery/computer/account_database/attackby(obj/O, mob/user, params)
|
||||
if(!istype(O, /obj/item/card/id))
|
||||
return ..()
|
||||
@@ -160,16 +151,6 @@
|
||||
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)
|
||||
detailed_account_view.suspended = !detailed_account_view.suspended
|
||||
@@ -182,14 +163,10 @@
|
||||
starting_funds = Clamp(starting_funds, 0, 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)
|
||||
var/datum/money_account/M = 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/trx = create_transation(account_name, "New account activation", "([starting_funds])")
|
||||
station_account.transaction_log.Add(trx)
|
||||
station_account.charge(starting_funds, null, "New account activation",
|
||||
"", "New account activation", M.owner_name)
|
||||
|
||||
creating_new_account = 0
|
||||
ui.close()
|
||||
@@ -205,19 +182,6 @@
|
||||
detailed_account_view = null
|
||||
creating_new_account = 0
|
||||
|
||||
if("revoke_payroll")
|
||||
var/funds = detailed_account_view.money
|
||||
var/account_trx = create_transation(station_account.owner_name, "Revoke payroll", "([funds])")
|
||||
var/station_trx = create_transation(detailed_account_view.owner_name, "Revoke payroll", funds)
|
||||
|
||||
station_account.money += funds
|
||||
detailed_account_view.money = 0
|
||||
|
||||
detailed_account_view.transaction_log.Add(account_trx)
|
||||
station_account.transaction_log.Add(station_trx)
|
||||
|
||||
callHook("revoke_payroll", list(detailed_account_view))
|
||||
|
||||
if("print")
|
||||
var/text
|
||||
playsound(loc, 'sound/goonstation/machines/printer_thermal.ogg', 50, 1)
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
desc = "Swipe your ID card to make purchases electronically."
|
||||
icon = 'icons/obj/device.dmi'
|
||||
icon_state = "eftpos"
|
||||
var/machine_id = ""
|
||||
var/eftpos_name = "Default EFTPOS scanner"
|
||||
var/machine_name = ""
|
||||
var/transaction_locked = 0
|
||||
var/transaction_paid = 0
|
||||
var/transaction_amount = 0
|
||||
@@ -15,7 +14,7 @@
|
||||
|
||||
/obj/item/eftpos/New()
|
||||
..()
|
||||
machine_id = "[station_name()] EFTPOS #[num_financial_terminals++]"
|
||||
machine_name = "[station_name()] EFTPOS #[num_financial_terminals++]"
|
||||
access_code = rand(1111,111111)
|
||||
reconnect_database()
|
||||
spawn(0)
|
||||
@@ -28,14 +27,10 @@
|
||||
/obj/item/eftpos/proc/print_reference()
|
||||
playsound(loc, 'sound/goonstation/machines/printer_thermal.ogg', 50, 1)
|
||||
var/obj/item/paper/R = new(loc)
|
||||
R.name = "Reference: [eftpos_name]"
|
||||
|
||||
// AUTOFIXED BY fix_string_idiocy.py
|
||||
// C:\Users\Rob\Documents\Projects\vgstation13\code\WorkInProgress\Cael_Aislinn\Economy\EFTPOS.dm:31: R.info = "<b>[eftpos_name] reference</b><br><br>"
|
||||
R.info = {"<b>[eftpos_name] reference</b><br><br>
|
||||
R.name = "Reference: [machine_name]"
|
||||
R.info = {"<b>[machine_name] reference</b><br><br>
|
||||
Access code: [access_code]<br><br>
|
||||
<b>Do not lose or misplace this code.</b><br>"}
|
||||
// END AUTOFIX
|
||||
//stamp the paper
|
||||
var/image/stampoverlay = image('icons/obj/bureaucracy.dmi')
|
||||
stampoverlay.icon_state = "paper_stamp-cent"
|
||||
@@ -86,8 +81,7 @@
|
||||
|
||||
/obj/item/eftpos/ui_data(mob/user, ui_key = "main", datum/topic_state/state = default_state)
|
||||
var/data[0]
|
||||
data["eftpos_name"] = eftpos_name
|
||||
data["machine_id"] = machine_id
|
||||
data["machine_name"] = machine_name
|
||||
data["transaction_locked"] = transaction_locked
|
||||
data["transaction_paid"] = transaction_paid
|
||||
data["transaction_purpose"] = transaction_purpose
|
||||
@@ -112,15 +106,6 @@
|
||||
print_reference()
|
||||
else
|
||||
to_chat(usr, "[bicon(src)]<span class='warning'>Incorrect code entered.</span>")
|
||||
if("change_id")
|
||||
var/attempt_code = text2num(input("Re-enter the current EFTPOS access code", "Confirm EFTPOS code"))
|
||||
if(attempt_code == access_code)
|
||||
var/name = input("Enter a new terminal ID for this device", "Enter new EFTPOS ID") as text|null
|
||||
if(name)
|
||||
eftpos_name = "[name] EFTPOS scanner"
|
||||
print_reference()
|
||||
else
|
||||
to_chat(usr, "[bicon(src)]<span class='warning'>Incorrect code entered.</span>")
|
||||
if("link_account")
|
||||
if(!linked_db)
|
||||
reconnect_database()
|
||||
@@ -179,48 +164,34 @@
|
||||
if(istype(I, /obj/item/card/id))
|
||||
var/obj/item/card/id/C = I
|
||||
visible_message("<span class='info'>[user] swipes a card through [src].</span>")
|
||||
if(transaction_locked && !transaction_paid)
|
||||
if(linked_account)
|
||||
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(transaction_amount <= D.money)
|
||||
playsound(src, 'sound/machines/chime.ogg', 50, 1)
|
||||
visible_message("[bicon(src)] The [src] chimes.")
|
||||
transaction_paid = 1
|
||||
|
||||
//transfer the money
|
||||
D.money -= transaction_amount
|
||||
linked_account.money += transaction_amount
|
||||
if(!transaction_locked || transaction_paid)
|
||||
return
|
||||
|
||||
if(!linked_account)
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>EFTPOS is not connected to an account.</span>")
|
||||
return
|
||||
|
||||
var/confirm = alert("Are you sure you want to pay $[transaction_amount] to Account: [linked_account.owner_name] ", "Confirm transaction", "Yes", "No")
|
||||
if(confirm == "No")
|
||||
return
|
||||
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)
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>Unable to access account. Check security settings and try again.</span>")
|
||||
|
||||
if(transaction_amount > D.money)
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>You don't have that much money!</span>")
|
||||
return
|
||||
|
||||
var/transSuccess = D.charge(transaction_amount, linked_account, transaction_purpose, machine_name, D.owner_name)
|
||||
if(transSuccess == TRUE)
|
||||
playsound(src, 'sound/machines/chime.ogg', 50, 1)
|
||||
visible_message("[bicon(src)] The [src] chimes.")
|
||||
transaction_paid = 1
|
||||
|
||||
//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 = station_time_timestamp()
|
||||
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 = station_time_timestamp()
|
||||
linked_account.transaction_log.Add(T)
|
||||
else
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>You don't have that much money!</span>")
|
||||
else
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>Unable to access account. Check security settings and try again.</span>")
|
||||
else
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>EFTPOS is not connected to an account.</span>")
|
||||
else
|
||||
..()
|
||||
|
||||
//emag?
|
||||
//emag?
|
||||
|
||||
@@ -46,47 +46,69 @@
|
||||
/datum/money_account/proc/fmtBalance()
|
||||
return "$[num2septext(money)]"
|
||||
|
||||
/datum/money_account/proc/charge(var/transaction_amount,var/datum/money_account/dest,var/transaction_purpose, var/terminal_name="", var/terminal_id=0, var/dest_name = "UNKNOWN")
|
||||
// Seperated from charge so they can reuse the code and also because there's many instances where a log will be made without actually making a transaction
|
||||
/datum/money_account/proc/makeTransactionLog(transaction_amount = 0, transaction_purpose, terminal_name = "",
|
||||
dest_name = "UNKNOWN", charging = TRUE, date = current_date_string, time = "")
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = dest_name
|
||||
T.purpose = transaction_purpose
|
||||
if(!charging || transaction_amount == 0)
|
||||
T.amount = "[transaction_amount]"
|
||||
else
|
||||
T.amount = "([transaction_amount])"
|
||||
|
||||
T.source_terminal = terminal_name
|
||||
T.date = date
|
||||
if(time == "")
|
||||
T.time = station_time_timestamp()
|
||||
else
|
||||
T.time = time
|
||||
transaction_log.Add(T)
|
||||
|
||||
// Charge is for transferring money from an account to another. The destination account can possibly not exist (Magical money sink)
|
||||
/datum/money_account/proc/charge(transaction_amount = 0, datum/money_account/dest, transaction_purpose,
|
||||
terminal_name = "", dest_name = "UNKNOWN", dest_purpose, dest_target_name)
|
||||
if(suspended)
|
||||
to_chat(usr, "<span class='warning'>Unable to access source account: account suspended.</span>")
|
||||
return 0
|
||||
|
||||
|
||||
if(transaction_amount <= money)
|
||||
//transfer the money
|
||||
money -= transaction_amount
|
||||
makeTransactionLog(transaction_amount, transaction_purpose, terminal_name, dest_name)
|
||||
if(dest)
|
||||
dest.money += transaction_amount
|
||||
dest.makeTransactionLog(transaction_amount,
|
||||
dest_purpose ? dest_purpose : transaction_purpose, terminal_name, dest_target_name ? dest_target_name : dest_name, FALSE)
|
||||
return 1
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>Insufficient funds in account.</span>")
|
||||
return 0
|
||||
|
||||
// phantom_charge is for when you want to charge an account, without making any corresponding log (e.g. you make it yourself with custom date
|
||||
// or there won't be any log for some IC reasons (hacking)
|
||||
/datum/money_account/proc/phantom_charge(transaction_amount = 0, datum/money_account/dest, suspensionbypass = 0)
|
||||
if(suspended && !suspensionbypass)
|
||||
return 0
|
||||
|
||||
if(transaction_amount <= money)
|
||||
//transfer the money
|
||||
money -= transaction_amount
|
||||
if(dest)
|
||||
dest.money += transaction_amount
|
||||
|
||||
//create entries in the two account transaction logs
|
||||
var/datum/transaction/T
|
||||
if(dest)
|
||||
T = new()
|
||||
T.target_name = owner_name
|
||||
if(terminal_name!="")
|
||||
T.target_name += " (via [terminal_name])"
|
||||
T.purpose = transaction_purpose
|
||||
if(transaction_amount > 0)
|
||||
T.amount = "([transaction_amount])"
|
||||
else
|
||||
T.amount = "[transaction_amount]"
|
||||
if(terminal_id)
|
||||
T.source_terminal = terminal_id
|
||||
T.date = current_date_string
|
||||
T.time = station_time_timestamp()
|
||||
dest.transaction_log.Add(T)
|
||||
//
|
||||
T = new()
|
||||
T.target_name = (!dest) ? dest_name : dest.owner_name
|
||||
if(terminal_name!="")
|
||||
T.target_name += " (via [terminal_name])"
|
||||
T.purpose = transaction_purpose
|
||||
T.amount = "[transaction_amount]"
|
||||
if(terminal_id)
|
||||
T.source_terminal = terminal_id
|
||||
T.date = current_date_string
|
||||
T.time = station_time_timestamp()
|
||||
transaction_log.Add(T)
|
||||
return 1
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>Insufficient funds in account.</span>")
|
||||
return 0
|
||||
return 0
|
||||
|
||||
// Credit is for giving money to an account out of thin air. Suspension does not matter.
|
||||
/datum/money_account/proc/credit(transaction_amount = 0, transaction_purpose,
|
||||
terminal_name = "", dest_name = "UNKNOWN", date = current_date_string, time = "")
|
||||
|
||||
money += transaction_amount
|
||||
makeTransactionLog(transaction_amount, transaction_purpose, terminal_name, dest_name, FALSE, date, time)
|
||||
return 1
|
||||
|
||||
//phantom_credit is like the above without any log
|
||||
/datum/money_account/proc/phantom_credit(transaction_amount = 0)
|
||||
money += transaction_amount
|
||||
return 1
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#define MINIMUM_PERCENTAGE_LOSS 0.5
|
||||
#define VARIABLE_LOSS 2 // Invariant: 1 - VARIABLE_LOSS/10 >= MINIMUM_PERCENTAGE_LOSS
|
||||
|
||||
/var/global/account_hack_attempted = 0
|
||||
|
||||
/datum/event/money_hacker
|
||||
@@ -16,7 +19,7 @@
|
||||
|
||||
/datum/event/money_hacker/announce()
|
||||
var/message = "A brute force hack has been detected (in progress since [station_time_timestamp()]). The target of the attack is: Financial account #[affected_account.account_number], \
|
||||
without intervention this attack will succeed in approximately 10 minutes. Required intervention: temporary suspension of affected accounts until the attack has ceased. \
|
||||
without intervention this attack will succeed in approximately 10 minutes. Required intervention: temporary suspension of affected account until the attack has ceased. \
|
||||
Notifications will be sent as updates occur.<br>"
|
||||
var/my_department = "[station_name()] firewall subroutines"
|
||||
|
||||
@@ -32,35 +35,38 @@
|
||||
|
||||
/datum/event/money_hacker/end()
|
||||
var/message
|
||||
if(affected_account && !affected_account)
|
||||
//hacker wins
|
||||
if(!isnull(affected_account) && !affected_account.suspended)
|
||||
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
|
||||
var/lost = affected_account.money * (MINIMUM_PERCENTAGE_LOSS + rand(0,VARIABLE_LOSS) / 10);
|
||||
|
||||
affected_account.phantom_charge(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/dest_name = pick("","yo brotha from anotha motha","el Presidente","chieF smackDowN")
|
||||
var/amount = pick("","([rand(0,99999)])","alla money","9001$","HOLLA HOLLA GET DOLLA","([lost])")
|
||||
var/purpose = pick("Ne$ ---ount fu%ds init*&lisat@*n","PAY BACK YOUR MUM","Funds withdrawal","pWnAgE","l33t hax","liberationez")
|
||||
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/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("", station_time_timestamp(), time2)
|
||||
T.source_terminal = pick("","[pick("Biesel","New Gibson")] GalaxyNet Terminal #[rand(111,999)]","your mums place","nantrasen high CommanD")
|
||||
var/time = pick("", station_time_timestamp(), time2)
|
||||
var/source_terminal = pick("","[pick("Biesel","New Gibson")] GalaxyNet Terminal #[rand(111,999)]","your mums place","nantrasen high CommanD")
|
||||
|
||||
affected_account.makeTransactionLog(amount, purpose, source_terminal, dest_name, TRUE, date, time)
|
||||
|
||||
affected_account.transaction_log.Add(T)
|
||||
|
||||
else
|
||||
//crew wins
|
||||
message = "The attack has ceased, the affected accounts can now be brought online."
|
||||
message = "The attack has ceased, the affected account can now be brought online."
|
||||
|
||||
var/my_department = "[station_name()] firewall subroutines"
|
||||
|
||||
for(var/obj/machinery/message_server/MS in world)
|
||||
if(!MS.active) continue
|
||||
MS.send_rc_message("Head of Personnel's Desk", my_department, message, "", "", 2)
|
||||
|
||||
#undef MINIMUM_PERCENTAGE_LOSS
|
||||
#undef VARIABLE_LOSS
|
||||
|
||||
@@ -8,19 +8,9 @@
|
||||
if(all_money_accounts.len)
|
||||
var/datum/money_account/D = pick(all_money_accounts)
|
||||
winner_name = D.owner_name
|
||||
if(!D.suspended)
|
||||
D.money += winner_sum
|
||||
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = "Nyx 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
|
||||
D.credit(winner_sum, "Winner!", "Biesel TCD Terminal #[rand(111,333)]", "Nyx Daily Grand Slam -Stellar- Lottery")
|
||||
deposit_success = 1
|
||||
|
||||
/datum/event/money_lotto/announce()
|
||||
var/datum/feed_message/newMsg = new /datum/feed_message
|
||||
|
||||
@@ -282,21 +282,9 @@ obj/machinery/lapvend/attackby(obj/item/I, mob/user)
|
||||
atom_say("Insufficient funds in account.")
|
||||
return 0
|
||||
else
|
||||
var/paid = customer_account.charge(total_price,
|
||||
transaction_purpose = "Purchase of [(devtype == 1) ? "laptop computer" : "tablet microcomputer"].",
|
||||
terminal_name = name,
|
||||
terminal_id = name,
|
||||
dest_name = vendor_account.owner_name)
|
||||
customer_account.charge(total_price, vendor_account,
|
||||
"Purchase of [(devtype == 1) ? "laptop computer" : "tablet microcomputer"].",
|
||||
name, customer_account.owner_name, "Sale of [(devtype == 1) ? "laptop computer" : "tablet microcomputer"].",
|
||||
customer_account.owner_name)
|
||||
|
||||
if(paid)
|
||||
vendor_account.money += total_price
|
||||
var/datum/transaction/T = new()
|
||||
T.target_name = customer_account.owner_name
|
||||
T.purpose = "Purchase of [(devtype == 1) ? "laptop computer" : "tablet microcomputer"]"
|
||||
T.amount = "[total_price]"
|
||||
T.source_terminal = name
|
||||
T.date = current_date_string
|
||||
T.time = station_time_timestamp()
|
||||
vendor_account.transaction_log.Add(T)
|
||||
return 1
|
||||
return 0
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user