mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
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
This commit is contained in:
@@ -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]'"
|
||||
|
||||
|
||||
@@ -228,6 +228,8 @@ var/global/datum/controller/gameticker/ticker
|
||||
|
||||
stat_collection.round_start_time = world.realtime
|
||||
|
||||
wageSetup()
|
||||
|
||||
return 1
|
||||
|
||||
/datum/controller/gameticker
|
||||
|
||||
@@ -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 += {"<B>Food Eaten:</b> [score["foodeaten"]]<BR>
|
||||
<B>Times a Clown was Abused:</B> [score["clownabuse"]]<BR>
|
||||
<B>Number of Explosions This Shift:</B> [score["explosions"]]<BR>
|
||||
<B>Number of Arena Rounds:</B> [score["arenafights"]]<BR>"}
|
||||
<B>Number of Arena Rounds:</B> [score["arenafights"]]<BR>
|
||||
<B>Total money trasferred:</B> [score["totaltransfer"]]<BR>"}
|
||||
|
||||
if(arena_top_score)
|
||||
dat += "<B>Best Arena Fighter (won [arena_top_score] rounds!):</B> [score["arenabest"]]<BR>"
|
||||
|
||||
@@ -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 += "<b>Your account number is:</b> #[M.account_number]<br>"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 += {"<br>
|
||||
<a href='?src=\ref[src];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 holder:</b> [detailed_account_view.owner_name]<br>
|
||||
<b>Account balance:</b> $[detailed_account_view.money]<br>
|
||||
<b>Assigned wage payout:</b> $[detailed_account_view.wage_gain]<br>
|
||||
<table border=1 style='width:100%'>
|
||||
<tr>
|
||||
<td><b>Date</b></td>
|
||||
@@ -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
|
||||
return D
|
||||
|
||||
98
code/modules/Economy/AdminTools.dm
Normal file
98
code/modules/Economy/AdminTools.dm
Normal file
@@ -0,0 +1,98 @@
|
||||
/datum/admins/proc/EconomyPanel(action, hrefs)
|
||||
if(!check_rights(R_FUN)) return
|
||||
|
||||
var/dat= "<head><title>Economy Tools</title></head>"
|
||||
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 += {"
|
||||
<a href='?src=\ref[src];econ_panel=view_accounts_list;'>Return to accounts list</a>
|
||||
<form name='create_account' action='?src=\ref[src]' method='get'>
|
||||
<input type='hidden' name='src' value='\ref[src]'>
|
||||
<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;'><br>
|
||||
<i>New accounts are automatically assigned a secret number and pin</i>
|
||||
<input type='submit' value='Create'><br>
|
||||
</form>"}
|
||||
else
|
||||
if(detailed_account_view)
|
||||
|
||||
dat += {"
|
||||
<a href='?src=\ref[src];econ_panel=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] <a href='?src=\ref[src];econ_panel=edit_balance;account_num=[detailed_account_view.account_number]'>Edit</a><br>
|
||||
<b>Assigned wage payout:</b> $[detailed_account_view.wage_gain] <a href='?src=\ref[src];econ_panel=edit_wage_payout;account_num=[detailed_account_view.account_number]'>Edit</a><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>"}
|
||||
for(var/datum/transaction/T in detailed_account_view.transaction_log)
|
||||
|
||||
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>"}
|
||||
dat += "</table>"
|
||||
else
|
||||
|
||||
dat += {"<a href='?src=\ref[src];econ_panel=create_account;'>Create new account</a><br><br>
|
||||
<table border=1 style='width:100%'>"}
|
||||
for(var/i=1, i<=all_money_accounts.len, i++)
|
||||
var/datum/money_account/D = all_money_accounts[i]
|
||||
|
||||
dat += {"<tr>
|
||||
<td>#[D.account_number]</td>
|
||||
<td>[D.owner_name]</td>
|
||||
<td>$[D.money]</td>
|
||||
<td><a href='?src=\ref[src];econ_panel=view_account_detail;account_index=[i]'>View in detail</a></td>
|
||||
</tr>"}
|
||||
dat += "</table>"
|
||||
|
||||
usr << browse(dat, "window=econ_panel")
|
||||
@@ -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
|
||||
setup_economy = 1
|
||||
|
||||
0
code/modules/Economy/Wage-Process.dm
Normal file
0
code/modules/Economy/Wage-Process.dm
Normal file
28
code/modules/Economy/Wages.dm
Normal file
28
code/modules/Economy/Wages.dm
Normal file
@@ -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()
|
||||
@@ -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=="")
|
||||
|
||||
@@ -677,6 +677,12 @@ var/global/floorIsLava = 0
|
||||
<A href='?src=\ref[src];vsc=default'>Choose a default ZAS setting</A><br>
|
||||
"}
|
||||
|
||||
if(wages_enabled)
|
||||
dat += "<A href='?src=\ref[src];wages_enabled=disable'>Disable wages</A><br>"
|
||||
else
|
||||
dat += "<A href='?src=\ref[src];wages_enabled=enable'>Enable wages</A><br>"
|
||||
dat += "<A href ='?src=\ref[src];econ_panel=open'>Manage accounts database</A><br>"
|
||||
|
||||
usr << browse(dat, "window=admin2;size=280x370")
|
||||
return
|
||||
|
||||
|
||||
@@ -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("<span class='notice'>[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("<span class='notice'>[key_name_admin(usr)] has disabled wages!")
|
||||
return
|
||||
if(href_list["econ_panel"])
|
||||
var/choice = href_list["econ_panel"]
|
||||
EconomyPanel(choice, href_list)
|
||||
|
||||
6
html/changelogs/Sood-wages.yml
Normal file
6
html/changelogs/Sood-wages.yml
Normal file
@@ -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.
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user