From e7ef0eeb1d5f2daccbf07942f412ac19232abe9d Mon Sep 17 00:00:00 2001 From: sood Date: Sat, 14 May 2016 00:29:40 -0700 Subject: [PATCH] WAGES (#9310) * WAGES * Accounts DB shows wages. * wep * more work, need to fix link to panel doing nothing * Economy panel * Changelog * Fixes * whoops * no schedule * aaaa * changelogs pls --- code/controllers/configuration.dm | 2 + code/game/gamemodes/gameticker.dm | 2 + code/game/gamemodes/scoreboard.dm | 10 ++- code/game/jobs/job_controller.dm | 2 +- code/global.dm | 6 ++ code/modules/Economy/Accounts.dm | 20 ++++-- code/modules/Economy/AdminTools.dm | 98 ++++++++++++++++++++++++++++ code/modules/Economy/Economy.dm | 2 +- code/modules/Economy/Wage-Process.dm | 0 code/modules/Economy/Wages.dm | 28 ++++++++ code/modules/Economy/utils.dm | 6 ++ code/modules/admin/admin.dm | 6 ++ code/modules/admin/topic.dm | 22 +++++++ html/changelogs/Sood-wages.yml | 6 ++ vgstation13.dme | 3 + 15 files changed, 203 insertions(+), 10 deletions(-) create mode 100644 code/modules/Economy/AdminTools.dm create mode 100644 code/modules/Economy/Wage-Process.dm create mode 100644 code/modules/Economy/Wages.dm create mode 100644 html/changelogs/Sood-wages.yml diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 4dfd495aa8d..4f0e5dfa401 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -538,6 +538,8 @@ shut_up_automatic_diagnostic_and_announcement_system = 1 if("enable_roundstart_away_missions") enable_roundstart_away_missions = 1 + if("enable_wages") + roundstart_enable_wages = 1 else diary << "Unknown setting in configuration: '[name]'" diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 5a5da793191..7504c493fc2 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -228,6 +228,8 @@ var/global/datum/controller/gameticker/ticker stat_collection.round_start_time = world.realtime + wageSetup() + return 1 /datum/controller/gameticker diff --git a/code/game/gamemodes/scoreboard.dm b/code/game/gamemodes/scoreboard.dm index 971ab0aee7c..d1d66c5c9ea 100644 --- a/code/game/gamemodes/scoreboard.dm +++ b/code/game/gamemodes/scoreboard.dm @@ -265,6 +265,13 @@ score["crewscore"] -= plaguepoints score["arenafights"] = arena_rounds + var/transfer_total = 0 + for(var/datum/money_account/A in all_money_accounts) + for(var/datum/transaction/T in A.transaction_log) + if(T.amount <= 0) // This way we don't track payouts or starting funds, only money transferred to terminals or between players + transfer_total += abs(T.amount) + score["totaltransfer"] = transfer_total + arena_top_score = 0 for(var/x in arena_leaderboard) if(arena_leaderboard[x] > arena_top_score) @@ -422,7 +429,8 @@ dat += {"Food Eaten: [score["foodeaten"]]
Times a Clown was Abused: [score["clownabuse"]]
Number of Explosions This Shift: [score["explosions"]]
- Number of Arena Rounds: [score["arenafights"]]
"} + Number of Arena Rounds: [score["arenafights"]]
+ Total money trasferred: [score["totaltransfer"]]
"} if(arena_top_score) dat += "Best Arena Fighter (won [arena_top_score] rounds!): [score["arenabest"]]
" diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 91a59083ac0..c080e6b6e91 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -370,7 +370,7 @@ var/global/datum/controller/occupations/job_master var/balance_bank = rand(100,250) balance_wallet = rand(100,250) if(centcomm_account_db) - var/datum/money_account/M = create_account(H.real_name, balance_bank , null) + var/datum/money_account/M = create_account(H.real_name, balance_bank, null, wage_payout = PLAYER_START_WAGE) if(H.mind) var/remembered_info = "" remembered_info += "Your account number is: #[M.account_number]
" diff --git a/code/global.dm b/code/global.dm index 283795d15d8..ec32a630f79 100644 --- a/code/global.dm +++ b/code/global.dm @@ -409,3 +409,9 @@ var/list/grayscale = list(0.3,0.3,0.3,0,0.59,0.59,0.59,0,0.11,0.11,0.11,0,0,0,0, var/adminblob_icon = null var/adminblob_size = 64 var/adminblob_beat = 'sound/effects/blob_pulse.ogg' + +// ECONOMY +// Account default values +#define DEPARTMENT_START_FUNDS 5000 +#define DEPARTMENT_START_WAGE 500 +#define PLAYER_START_WAGE 50 diff --git a/code/modules/Economy/Accounts.dm b/code/modules/Economy/Accounts.dm index 00829ff30ab..ddddfdab9cb 100644 --- a/code/modules/Economy/Accounts.dm +++ b/code/modules/Economy/Accounts.dm @@ -18,7 +18,8 @@ var/global/list/all_money_accounts = list() station_account.owner_name = "[station_name()] Station Account" station_account.account_number = rand(11111, 99999) station_account.remote_access_pin = rand(1111, 9999) - station_account.money = 5000 + station_account.money = DEPARTMENT_START_FUNDS + station_account.wage_gain = DEPARTMENT_START_WAGE //create an entry in the account transaction log for when it was created var/datum/transaction/T = new() @@ -33,14 +34,16 @@ var/global/list/all_money_accounts = list() station_account.transaction_log.Add(T) all_money_accounts.Add(station_account) -/proc/create_department_account(department) +/proc/create_department_account(department, var/recieves_wage = 0) next_account_number = rand(111111, 999999) var/datum/money_account/department_account = new() department_account.owner_name = "[department] Account" department_account.account_number = rand(11111, 99999) department_account.remote_access_pin = rand(1111, 9999) - department_account.money = 5000 + department_account.money = DEPARTMENT_START_FUNDS + if(recieves_wage == 1) + department_account.wage_gain = DEPARTMENT_START_WAGE //create an entry in the account transaction log for when it was created var/datum/transaction/T = new() @@ -60,7 +63,7 @@ var/global/list/all_money_accounts = list() //the current ingame time (hh:mm) can be obtained by calling: //worldtime2text() -/proc/create_account(var/new_owner_name = "Default user", var/starting_funds = 0, var/obj/machinery/account_database/source_db) +/proc/create_account(var/new_owner_name = "Default user", var/starting_funds = 0, var/obj/machinery/account_database/source_db, var/wage_payout = 0) //create a new account @@ -68,6 +71,7 @@ var/global/list/all_money_accounts = list() M.owner_name = new_owner_name M.remote_access_pin = rand(1111, 9999) M.money = starting_funds + M.wage_gain = wage_payout //create an entry in the account transaction log for when it was created var/datum/transaction/T = new() @@ -130,6 +134,7 @@ var/global/list/all_money_accounts = list() //1 - require manual login / account number and pin //2 - require card and manual login var/virtual = 0 + var/wage_gain = 0 // How much an account gains per 'wage' tick. /datum/transaction var/target_name = "" @@ -165,7 +170,7 @@ var/global/list/all_money_accounts = list() if(department_accounts.len == 0) for(var/department in station_departments) - create_department_account(department) + create_department_account(department, recieves_wage = 1) if(!vendor_account) create_department_account("Vendor") vendor_account = department_accounts["Vendor"] @@ -222,8 +227,9 @@ var/global/list/all_money_accounts = list() dat += {"
Return to accounts list
Account number: #[detailed_account_view.account_number]
- Account holder:< /b> [detailed_account_view.owner_name]
+ Account holder: [detailed_account_view.owner_name]
Account balance: $[detailed_account_view.money]
+ Assigned wage payout: $[detailed_account_view.wage_gain]
@@ -392,4 +398,4 @@ var/global/list/all_money_accounts = list() /obj/machinery/account_database/proc/get_account(var/account_number) for(var/datum/money_account/D in all_money_accounts) if(D.account_number == account_number) - return D \ No newline at end of file + return D diff --git a/code/modules/Economy/AdminTools.dm b/code/modules/Economy/AdminTools.dm new file mode 100644 index 00000000000..4a66fb45629 --- /dev/null +++ b/code/modules/Economy/AdminTools.dm @@ -0,0 +1,98 @@ +/datum/admins/proc/EconomyPanel(action, hrefs) + if(!check_rights(R_FUN)) return + + var/dat= "Economy Tools" + var/datum/money_account/detailed_account_view + var/creating_new_account + + if(hrefs["econ_panel"] != "open") + switch(hrefs["econ_panel"]) + if("create_account") + creating_new_account = 1 + if("finalise_create_account") + var/account_name = hrefs["holder_name"] + var/starting_funds = max(text2num(hrefs["starting_funds"]), 0) + create_account(account_name, starting_funds, src) + creating_new_account = 0 + if("view_account_detail") + var/index = text2num(hrefs["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 + if("edit_balance") + var/acc_num = text2num(hrefs["account_num"]) + var/datum/money_account/acc = get_money_account_global(acc_num) + if(acc) + var/new_balance = input(usr, "Select a new balance for this account", "New balance", acc.money) as null|num + if(new_balance && new_balance >= 0) + acc.money = new_balance + detailed_account_view = acc + if("edit_wage_payout") + var/acc_num = text2num(hrefs["account_num"]) + var/datum/money_account/acc = get_money_account_global(acc_num) + if(acc) + var/new_payout = input(usr, "Select a new payout for this account", "New payout", acc.wage_gain) as null|num + if(new_payout && new_payout >= 0) + acc.wage_gain = new_payout + detailed_account_view = acc + + + if(creating_new_account) + + dat += {" + Return to accounts list + + + + Holder name:
+ Initial funds:
+ New accounts are automatically assigned a secret number and pin +
+ "} + else + if(detailed_account_view) + + dat += {" + Return to accounts list
+ Account number: #[detailed_account_view.account_number]
+ Account holder: [detailed_account_view.owner_name]
+ Account balance: $[detailed_account_view.money] Edit
+ Assigned wage payout: $[detailed_account_view.wage_gain] Edit
+
Date
+ + + + + + + + "} + for(var/datum/transaction/T in detailed_account_view.transaction_log) + + dat += {" + + + + + + + "} + dat += "
DateTimeTargetPurposeValueSource terminal ID
[T.date][T.time][T.target_name][T.purpose]$[T.amount][T.source_terminal]
" + else + + dat += {"Create new account

+ "} + for(var/i=1, i<=all_money_accounts.len, i++) + var/datum/money_account/D = all_money_accounts[i] + + dat += {" + + + + + "} + dat += "
#[D.account_number][D.owner_name]$[D.money]View in detail
" + + usr << browse(dat, "window=econ_panel") diff --git a/code/modules/Economy/Economy.dm b/code/modules/Economy/Economy.dm index cf78723a683..43e216076a6 100644 --- a/code/modules/Economy/Economy.dm +++ b/code/modules/Economy/Economy.dm @@ -86,4 +86,4 @@ var/setup_economy = 0 weighted_randomevent_locations[D] = D.viable_random_events.len weighted_mundaneevent_locations[D] = D.viable_mundane_events.len - setup_economy = 1 \ No newline at end of file + setup_economy = 1 diff --git a/code/modules/Economy/Wage-Process.dm b/code/modules/Economy/Wage-Process.dm new file mode 100644 index 00000000000..e69de29bb2d diff --git a/code/modules/Economy/Wages.dm b/code/modules/Economy/Wages.dm new file mode 100644 index 00000000000..f423a933c33 --- /dev/null +++ b/code/modules/Economy/Wages.dm @@ -0,0 +1,28 @@ +var/global/wages_enabled = 0 +var/global/roundstart_enable_wages = 0 + +/proc/wageSetup() + WageLoop() + +/proc/wagePayout() + for(var/datum/money_account/Acc in all_money_accounts) + if(Acc.wage_gain) + Acc.money += Acc.wage_gain + + var/datum/transaction/T = new() + T.purpose = "Nanotrasen employee payroll" + T.amount = "[Acc.wage_gain]" + T.date = current_date_string + T.time = worldtime2text() + T.source_terminal = "Nanotrasen Payroll Server" + Acc.transaction_log.Add(T) + captain_announce("Payroll has been processed. All accounts eligible have have recieved their paycheck as a direct deposit, including department accounts.") + +/proc/WageLoop() + set waitfor = 0 + usr = null + src = null + while(1) + sleep(15 MINUTES) + if(wages_enabled) + wagePayout() diff --git a/code/modules/Economy/utils.dm b/code/modules/Economy/utils.dm index 6428e661370..71b318b4cd7 100644 --- a/code/modules/Economy/utils.dm +++ b/code/modules/Economy/utils.dm @@ -12,6 +12,12 @@ if(!acct) continue return acct +// Added this proc for admin tools. Not even sure we need the above proc as it is +/proc/get_money_account_global(account_number) + for(var/datum/money_account/D in all_money_accounts) + if(D.account_number == account_number) + return D + /obj/proc/get_card_account(var/obj/item/weapon/card/I, var/mob/user=null, var/terminal_name="", var/transaction_purpose="", var/require_pin=0) if(terminal_name=="") diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index a4b914fb7b8..c9931bda230 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -677,6 +677,12 @@ var/global/floorIsLava = 0 Choose a default ZAS setting
"} + if(wages_enabled) + dat += "Disable wages
" + else + dat += "Enable wages
" + dat += "Manage accounts database
" + usr << browse(dat, "window=admin2;size=280x370") return diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 1feb502673e..60faec377ac 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -4078,3 +4078,25 @@ //------------------------------------------------------------------Shuttle stuff end--------------------------------- + + if(href_list["wages_enabled"]) + if(check_rights(R_ADMIN)) + if(ticker.current_state == 1) + to_chat(usr, "Round hasn't started yet!") + return + if(href_list["wages_enabled"] == "enable") + if(wages_enabled) + to_chat(usr, "Wages are already enabled!") + else + wages_enabled = 1 + message_admins("[key_name_admin(usr)] has enabled wages!") + else if(href_list["wages_enabled"] == "false") + if(!wages_enabled) + to_chat(usr, "Wages are already disabled!") + else + wages_enabled = 0 + message_admins("[key_name_admin(usr)] has disabled wages!") + return + if(href_list["econ_panel"]) + var/choice = href_list["econ_panel"] + EconomyPanel(choice, href_list) diff --git a/html/changelogs/Sood-wages.yml b/html/changelogs/Sood-wages.yml new file mode 100644 index 00000000000..b6cd524604d --- /dev/null +++ b/html/changelogs/Sood-wages.yml @@ -0,0 +1,6 @@ +author: Sood +delete-afer: true +changes: + - rscadd: Admins may now toggle wages for all personal and departmental accounts in the game panel. This starts off disabled and must be added to config.txt to be auto-enabled. + - rscadd: Admins can now modify the balance and wage payout of individual accounts, also via game panel. + - tweak: Accounts database machine can now see what an account would earn per paycheck. diff --git a/vgstation13.dme b/vgstation13.dme index a22b7c47c7e..a1a8213279f 100644 --- a/vgstation13.dme +++ b/vgstation13.dme @@ -1053,6 +1053,7 @@ #include "code\modules\detectivework\evidence.dm" #include "code\modules\detectivework\footprints_and_rag.dm" #include "code\modules\Economy\Accounts.dm" +#include "code\modules\Economy\AdminTools.dm" #include "code\modules\Economy\Economy.dm" #include "code\modules\Economy\Economy_Events.dm" #include "code\modules\Economy\Economy_Events_Mundane.dm" @@ -1061,6 +1062,8 @@ #include "code\modules\Economy\Job_Departments.dm" #include "code\modules\Economy\POS.dm" #include "code\modules\Economy\utils.dm" +#include "code\modules\Economy\Wage-Process.dm" +#include "code\modules\Economy\Wages.dm" #include "code\modules\events\alien_infestation.dm" #include "code\modules\events\blob.dm" #include "code\modules\events\bluespaceanomaly.dm"