Add department playtime requirement config, code

This commit is contained in:
Aronai Sieyes
2020-05-08 17:57:56 -04:00
parent 5a42a3a76e
commit ea8a068025
17 changed files with 83 additions and 13 deletions

View File

@@ -11,6 +11,7 @@
var/static/pto_cap = 100 //Hours
var/static/require_flavor = FALSE
var/static/ipqualityscore_apikey //API key for ipqualityscore.com
var/static/use_playtime_restriction_for_jobs = FALSE
/hook/startup/proc/read_vs_config()
var/list/Lines = file2list("config/config.txt")
@@ -61,4 +62,6 @@
config.require_flavor = TRUE
if ("ipqualityscore_apikey")
config.ipqualityscore_apikey = value
if ("use_playtime_restriction_for_jobs")
config.use_playtime_restriction_for_jobs = TRUE
return 1

View File

@@ -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)