Skip to content

Commit

Permalink
Payrolls test
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDinamit committed Feb 14, 2024
1 parent e7a005f commit a18a0e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions code/controllers/subsystems/supply.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ SUBSYSTEM_DEF(supply)
name = "Supply"
priority = SS_PRIORITY_SUPPLY
flags = SS_NO_FIRE
runlevels = RUNLEVEL_GAME|RUNLEVEL_POSTGAME
wait = 30 MINUTES

/// Budget for trading stations with spawn_always at FALSE
var/trade_stations_budget = 5
Expand Down Expand Up @@ -65,6 +67,10 @@ SUBSYSTEM_DEF(supply)
DeInitTradeStations()
. = ..()

/datum/controller/subsystem/supply/fire()
for(var/datum/money_account/A in all_money_accounts)
A.PayrollTick()

/datum/controller/subsystem/supply/proc/GetFaction(fac)
if(!(fac in factions))
return null
Expand Down
13 changes: 13 additions & 0 deletions code/modules/economy/Accounts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//1 - require manual login / account number and pin
//2 - require card and manual login
var/account_type = ACCOUNT_TYPE_PERSONAL
/// Associative list of money accounts which we pay into every 30 minutes; account_number = money
var/list/payroll_accounts = list()

/datum/money_account/New(var/account_type)
account_type = account_type ? account_type : ACCOUNT_TYPE_PERSONAL
Expand Down Expand Up @@ -38,6 +40,17 @@
var/datum/transaction/T = new(src, to_account, amount, purpose)
return T.perform()

// Called by supply subsystem fire() proc every ~30 minutes
/datum/money_account/proc/PayrollTick()
listclearnulls(payroll_accounts)
for(var/datum/money_account/A in payroll_accounts)
if(!payroll_accounts[A])
payroll_accounts[A] = 0
continue
var/pay = payroll_accounts[A]
if(!pay || pay > money)
continue
transfer(A, pay, "Payroll from [account_name]")

/proc/create_account(var/account_name = "Default account name", var/owner_name, var/starting_funds = 0, var/account_type = ACCOUNT_TYPE_PERSONAL, var/obj/machinery/computer/account_database/source_db)

Expand Down

0 comments on commit a18a0e2

Please sign in to comment.