Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paycheck Code[Experimental Testmerge] #2294

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions code/__DEFINES/economy.dm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#define STARTING_PAYCHECKS 7
#define STARTING_PAYCHECKS 4

//Experimental change: These are subject to tweaking based on the /tg/ economy overhaul.
//Current design direction: Higher paying jobs are vastly outnumbered by lower paying jobs, so anything above medium hurts inflation, common jobs help inflation
#define PAYCHECK_RESOURCE 0 //Temp fix for making vendors dispense things for free? Couldn't find anything in the code, plus someone's already working on economy, so...
#define PAYCHECK_PRISONER 25
#define PAYCHECK_ASSISTANT 50
#define PAYCHECK_MINIMAL 55
#define PAYCHECK_EASY 60
#define PAYCHECK_PRISONER 1
#define PAYCHECK_ASSISTANT 20
#define PAYCHECK_MINIMAL 25
#define PAYCHECK_EASY 50
#define PAYCHECK_MEDIUM 75
#define PAYCHECK_HARD 100
#define PAYCHECK_COMMAND 200
Expand Down
34 changes: 29 additions & 5 deletions code/controllers/subsystem/economy.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SUBSYSTEM_DEF(economy)
name = "Economy"
wait = 5 MINUTES
wait = 10 MINUTES
init_order = INIT_ORDER_ECONOMY
runlevels = RUNLEVEL_GAME
var/roundstart_paychecks = 5
Expand Down Expand Up @@ -41,6 +41,7 @@ SUBSYSTEM_DEF(economy)
var/pack_price_modifier = 1
var/market_crashing = FALSE


/datum/controller/subsystem/economy/Initialize(timeofday)
var/budget_to_hand_out = round(budget_pool / department_accounts.len)
for(var/A in department_accounts)
Expand All @@ -57,26 +58,32 @@ SUBSYSTEM_DEF(economy)
departmental_payouts()
station_total = 0
station_target_buffer += STATION_TARGET_BUFFER
EmployeePayout()

for(var/account in bank_accounts_by_id)
var/datum/bank_account/bank_account = bank_accounts_by_id[account]
if(bank_account?.account_job)
temporary_total += (bank_account.account_job.paycheck * STARTING_PAYCHECKS)
if(!istype(bank_account, /datum/bank_account/department))
station_total += bank_account.account_balance

station_target = max(round(temporary_total / max(bank_accounts_by_id.len * 2, 1)) + station_target_buffer, 1)
// if(!market_crashing)
// price_update() Fucks up Workshop, I'll figure out how to make it override soon:tm: - Kirie

/**
* Handy proc for obtaining a department's bank account, given the department ID, AKA the define assigned for what department they're under.
* Handy proc for obtaining a department's bank account,
* given the department ID, AKA the define assigned for
* what department they're under.
*/
/datum/controller/subsystem/economy/proc/get_dep_account(dep_id)
for(var/datum/bank_account/department/D in generated_accounts)
if(D.department_id == dep_id)
return D

/**
* Departmental income payments are kept static and linear for every department, and paid out once every 5 minutes, as determined by MAX_GRANT_DPT.
* Departmental income payments are kept static and linear for
* every department, and paid out once every 10 minutes, as determined by MAX_GRANT_DPT.
* Iterates over every department account for the same payment.
*/
/datum/controller/subsystem/economy/proc/departmental_payouts()
Expand All @@ -87,9 +94,26 @@ SUBSYSTEM_DEF(economy)
dept_account.adjust_money(MAX_GRANT_DPT)

/**
* Updates the prices of all station vendors with the inflation_value, increasing/decreasing costs across the station, and alerts the crew.
* Pays all employee accounts. When this
* procc's the employee's bank account will
* ping and announce how much they got.
*/
/datum/controller/subsystem/economy/proc/EmployeePayout()
for(var/account in bank_accounts_by_id)
var/datum/bank_account/bank_account = bank_accounts_by_id[account]
if(istype(bank_account, /datum/bank_account/department))
continue
if(bank_account?.account_job)
bank_account.payday(1, TRUE)

/**
* Updates the prices of all station vendors with the
* inflation_value, increasing/decreasing costs across
* the station, and alerts the crew.
*
* Iterates over the machines list for vending machines, resets their regular and premium product prices (Not contraband), and sends a message to the newscaster network.
* Iterates over the machines list for vending machines,
* resets their regular and premium product prices
* (Not contraband), and sends a message to the newscaster network.
**/
/datum/controller/subsystem/economy/proc/price_update()
for(var/obj/machinery/vending/V in GLOB.machines)
Expand Down
34 changes: 29 additions & 5 deletions code/modules/economy/account.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
if(account_balance < 0)
account_balance = 0

/**
* Returns TRUE if a bank account has more than or equal to the amount, amt.
* Otherwise returns false.
* Arguments:
* * amount - the quantity of credits that will be reconciled with the account balance.
*/
/datum/bank_account/proc/has_money(amt)
return account_balance >= amt

Expand All @@ -77,19 +83,30 @@
return TRUE
return FALSE

/datum/bank_account/proc/payday(amt_of_paychecks, free = FALSE)
/**
* This proc handles passive income gain for players, using their job's paycheck value.
* Funds are taken from the parent department account to hand out to players. This can result in payment brown-outs if too many people are in one department.
* Arguments:
* * amount_of_paychecks - literally the number of salaries, 1 for issuing one salary, 5 for issuing five salaries.
* * free - issuance of free funds, if TRUE then takes funds from the void, if FALSE (default) tries to send from the department's account.
*/
/datum/bank_account/proc/payday(amount_of_paychecks = 1, free = FALSE)
if(!account_job)
return
var/money_to_transfer = round(account_job.paycheck * payday_modifier * amt_of_paychecks)
var/money_to_transfer = round(account_job.paycheck * payday_modifier * amount_of_paychecks)
if(!money_to_transfer)
return FALSE
if(free)
adjust_money(money_to_transfer)
SSblackbox.record_feedback("amount", "free_income", money_to_transfer)
SSeconomy.station_target += money_to_transfer
log_econ("[money_to_transfer] ahn were given to [src.account_holder]'s account from income.")
bank_card_talk("Payday processed, account now holds [account_balance] ahn.")
return TRUE
else
var/datum/bank_account/D = SSeconomy.get_dep_account(account_job.paycheck_department)
if(D)
if(!transfer_money(D, money_to_transfer))
var/datum/bank_account/department_account = SSeconomy.get_dep_account(account_job.paycheck_department)
if(department_account)
if(!transfer_money(department_account, money_to_transfer))
bank_card_talk("ERROR: Payday aborted, departmental funds insufficient.")
return FALSE
else
Expand All @@ -98,6 +115,13 @@
bank_card_talk("ERROR: Payday aborted, unable to contact departmental account.")
return FALSE

/**
* This sends a local chat message to the owner of a bank account, on all ID cards registered to the bank_account.
* If not held, sends out a message to all nearby players.
* Arguments:
* * message - text that will be sent to listeners after the id card icon
* * force - if TRUE ignore checks on client and client prefernces.
*/
/datum/bank_account/proc/bank_card_talk(message, force)
if(!message || !bank_cards.len)
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/jobs/job_types/city/civilian.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Civilian

allow_bureaucratic_error = FALSE
maptype = list("city", "fixers")
paycheck = 170
paycheck = 250
var/static/list/possible_books = null

/datum/job/civilian/equip(mob/living/carbon/human/H, visualsOnly = FALSE, announce = TRUE, latejoin = FALSE, datum/outfit/outfit_override = null, client/preference_source)
Expand Down
1 change: 1 addition & 0 deletions code/modules/jobs/job_types/manager.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
supervisors = "the manager"
selection_color = "#bcbcef"
display_order = JOB_DISPLAY_ORDER_MANAGER
paycheck = PAYCHECK_MEDIUM

exp_requirements = 720
exp_type = EXP_TYPE_CREW
Expand Down
1 change: 1 addition & 0 deletions code/modules/jobs/job_types/rcorp/rabbit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
exp_requirements = 120
supervisors = "the rabbit team captain and the commander"
selection_color = "#d9b555"
paycheck = 0

outfit = /datum/outfit/job/rabbit
display_order = 9
Expand Down
Loading