mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-14 16:46:28 +01:00
Add department playtime requirement config, code
This commit is contained in:
@@ -47,23 +47,33 @@ SUBSYSTEM_DEF(persist)
|
||||
|
||||
// Update client whatever
|
||||
var/client/C = M.client
|
||||
var/wait_in_hours = (wait / (1 HOUR)) * J.timeoff_factor
|
||||
var/wait_in_hours = wait / (1 HOUR)
|
||||
var/pto_factored = wait_in_hours * J.timeoff_factor
|
||||
LAZYINITLIST(C.department_hours)
|
||||
LAZYINITLIST(C.play_hours)
|
||||
var/dept_hours = C.department_hours
|
||||
if(isnum(C.department_hours[department_earning]))
|
||||
dept_hours[department_earning] += wait_in_hours
|
||||
var/play_hours = C.play_hours
|
||||
if(isnum(dept_hours[department_earning]))
|
||||
dept_hours[department_earning] += pto_factored
|
||||
else
|
||||
dept_hours[department_earning] = wait_in_hours
|
||||
dept_hours[department_earning] = pto_factored
|
||||
|
||||
//Cap it
|
||||
// If they're earning PTO they must be in a useful job so are earning playtime in that department
|
||||
if(J.timeoff_factor > 0)
|
||||
if(isnum(play_hours[department_earning]))
|
||||
play_hours[department_earning] += wait_in_hours
|
||||
else
|
||||
play_hours[department_earning] = wait_in_hours
|
||||
|
||||
// Cap it
|
||||
dept_hours[department_earning] = min(config.pto_cap, dept_hours[department_earning])
|
||||
|
||||
|
||||
// Okay we figured it out, lets update database!
|
||||
var/sql_ckey = sql_sanitize_text(C.ckey)
|
||||
var/sql_dpt = sql_sanitize_text(department_earning)
|
||||
var/sql_bal = text2num("[C.department_hours[department_earning]]")
|
||||
var/DBQuery/query = dbcon.NewQuery("INSERT INTO vr_player_hours (ckey, department, hours) VALUES ('[sql_ckey]', '[sql_dpt]', [sql_bal]) ON DUPLICATE KEY UPDATE hours = VALUES(hours)")
|
||||
var/sql_total = text2num("[C.play_hours[department_earning]]")
|
||||
var/DBQuery/query = dbcon.NewQuery("INSERT INTO vr_player_hours (ckey, department, hours, total_hours) VALUES ('[sql_ckey]', '[sql_dpt]', [sql_bal], [sql_total]) ON DUPLICATE KEY UPDATE hours = VALUES(hours), total_hours = VALUES(total_hours)")
|
||||
query.Execute()
|
||||
|
||||
if (MC_TICK_CHECK)
|
||||
|
||||
Reference in New Issue
Block a user