mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-01-06 07:23:16 +00:00
Merge pull request #5101 from Heroman3003/timeclock-finishing
Implements switching on/off duty midround via timeclock terminals
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
/datum/configuration
|
/datum/configuration
|
||||||
var/list/engine_map // Comma separated list of engines to choose from. Blank means fully random.
|
var/list/engine_map // Comma separated list of engines to choose from. Blank means fully random.
|
||||||
var/time_off = FALSE
|
var/time_off = FALSE
|
||||||
|
var/pto_job_change = FALSE
|
||||||
var/limit_interns = -1 //Unlimited by default
|
var/limit_interns = -1 //Unlimited by default
|
||||||
var/limit_visitors = -1 //Unlimited by default
|
var/limit_visitors = -1 //Unlimited by default
|
||||||
var/pto_cap = 100 //Hours
|
var/pto_cap = 100 //Hours
|
||||||
@@ -52,5 +53,7 @@
|
|||||||
config.pto_cap = text2num(value)
|
config.pto_cap = text2num(value)
|
||||||
if ("time_off")
|
if ("time_off")
|
||||||
config.time_off = TRUE
|
config.time_off = TRUE
|
||||||
|
if ("pto_job_change")
|
||||||
|
config.pto_job_change = TRUE
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
/datum/job/offduty_civilian
|
/datum/job/offduty_civilian
|
||||||
title = "Off-Duty Worker"
|
title = "Off-duty Worker"
|
||||||
latejoin_only = TRUE
|
latejoin_only = TRUE
|
||||||
timeoff_factor = -1
|
timeoff_factor = -1
|
||||||
total_positions = -1
|
total_positions = -1
|
||||||
|
|||||||
@@ -18,6 +18,12 @@
|
|||||||
clicksound = null
|
clicksound = null
|
||||||
|
|
||||||
var/obj/item/weapon/card/id/card // Inserted Id card
|
var/obj/item/weapon/card/id/card // Inserted Id card
|
||||||
|
var/obj/item/device/radio/intercom/announce // Integreated announcer
|
||||||
|
|
||||||
|
|
||||||
|
/obj/machinery/computer/timeclock/New()
|
||||||
|
announce = new /obj/item/device/radio/intercom(src)
|
||||||
|
..()
|
||||||
|
|
||||||
/obj/machinery/computer/timeclock/Destroy()
|
/obj/machinery/computer/timeclock/Destroy()
|
||||||
if(card)
|
if(card)
|
||||||
@@ -84,9 +90,10 @@
|
|||||||
"head_position" = job.head_position,
|
"head_position" = job.head_position,
|
||||||
"timeoff_factor" = job.timeoff_factor
|
"timeoff_factor" = job.timeoff_factor
|
||||||
)
|
)
|
||||||
// TODO - Once job changing is implemented, we will want to list jobs to change into.
|
if(config.time_off && config.pto_job_change)
|
||||||
// if(job && job.timeoff_factor < 0) // Currently are Off Duty, so gotta lookup what on-duty jobs are open
|
data["allow_change_job"] = TRUE
|
||||||
// data["job_choices"] = getOpenOnDutyJobs(user, job.department)
|
if(job && job.timeoff_factor < 0) // Currently are Off Duty, so gotta lookup what on-duty jobs are open
|
||||||
|
data["job_choices"] = getOpenOnDutyJobs(user, job.department)
|
||||||
|
|
||||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||||
if (!ui)
|
if (!ui)
|
||||||
@@ -101,7 +108,7 @@
|
|||||||
src.add_fingerprint(usr)
|
src.add_fingerprint(usr)
|
||||||
|
|
||||||
if (href_list["id"])
|
if (href_list["id"])
|
||||||
if (card)
|
if(card)
|
||||||
usr.put_in_hands(card)
|
usr.put_in_hands(card)
|
||||||
card = null
|
card = null
|
||||||
else
|
else
|
||||||
@@ -110,8 +117,103 @@
|
|||||||
I.forceMove(src)
|
I.forceMove(src)
|
||||||
card = I
|
card = I
|
||||||
update_icon()
|
update_icon()
|
||||||
|
return 1
|
||||||
|
if(href_list["switch-to-onduty"])
|
||||||
|
if(card)
|
||||||
|
if(checkCardCooldown())
|
||||||
|
makeOnDuty(href_list["switch-to-onduty"])
|
||||||
|
usr.put_in_hands(card)
|
||||||
|
card = null
|
||||||
|
update_icon()
|
||||||
|
return 1
|
||||||
|
if(href_list["switch-to-offduty"])
|
||||||
|
if(card)
|
||||||
|
if(checkCardCooldown())
|
||||||
|
makeOffDuty()
|
||||||
|
usr.put_in_hands(card)
|
||||||
|
card = null
|
||||||
|
update_icon()
|
||||||
|
return 1
|
||||||
return 1 // Return 1 to update UI
|
return 1 // Return 1 to update UI
|
||||||
|
|
||||||
|
/obj/machinery/computer/timeclock/proc/getOpenOnDutyJobs(var/mob/user, var/department)
|
||||||
|
var/list/available_jobs = list()
|
||||||
|
for(var/datum/job/job in job_master.occupations)
|
||||||
|
if(job && job.is_position_available() && !job.whitelist_only && !jobban_isbanned(user,job.title) && job.player_old_enough(user.client))
|
||||||
|
if(job.department == department && !job.head_position && job.timeoff_factor > 0 && !(job.title == "Internal Affairs Agent"))
|
||||||
|
available_jobs += job.title
|
||||||
|
if(job.alt_titles)
|
||||||
|
for(var/alt_job in job.alt_titles)
|
||||||
|
available_jobs += alt_job
|
||||||
|
return available_jobs
|
||||||
|
|
||||||
|
/obj/machinery/computer/timeclock/proc/makeOnDuty(var/newjob)
|
||||||
|
var/datum/job/foundjob = null
|
||||||
|
for(var/datum/job/job in job_master.occupations)
|
||||||
|
if(newjob == job.title)
|
||||||
|
foundjob = job
|
||||||
|
break
|
||||||
|
if(newjob in job.alt_titles)
|
||||||
|
foundjob = job
|
||||||
|
break
|
||||||
|
if(!newjob in getOpenOnDutyJobs(usr, job_master.GetJob(card.rank).department))
|
||||||
|
return
|
||||||
|
if(foundjob && card)
|
||||||
|
card.access = foundjob.get_access()
|
||||||
|
card.rank = foundjob.title
|
||||||
|
card.assignment = newjob
|
||||||
|
card.name = text("[card.registered_name]'s ID Card ([card.assignment])")
|
||||||
|
data_core.manifest_modify(card.registered_name, card.assignment)
|
||||||
|
card.last_job_switch = world.time
|
||||||
|
callHook("reassign_employee", list(card))
|
||||||
|
foundjob.current_positions++
|
||||||
|
announce.autosay("[card.registered_name] has moved On-Duty as [card.assignment].", "Employee Oversight")
|
||||||
|
return
|
||||||
|
|
||||||
|
/obj/machinery/computer/timeclock/proc/makeOffDuty()
|
||||||
|
var/datum/job/foundjob = null
|
||||||
|
for(var/datum/job/job in job_master.occupations)
|
||||||
|
if(card.rank == job.title)
|
||||||
|
foundjob = job
|
||||||
|
break
|
||||||
|
if(!foundjob)
|
||||||
|
return
|
||||||
|
var/real_dept = foundjob.department
|
||||||
|
if(real_dept && real_dept == "Command")
|
||||||
|
real_dept = "Civilian"
|
||||||
|
var/datum/job/ptojob = null
|
||||||
|
for(var/datum/job/job in job_master.occupations)
|
||||||
|
if(job.department == real_dept && job.timeoff_factor < 0)
|
||||||
|
ptojob = job
|
||||||
|
break
|
||||||
|
if(ptojob && card)
|
||||||
|
var/oldtitle = card.assignment
|
||||||
|
card.access = ptojob.get_access()
|
||||||
|
card.rank = ptojob.title
|
||||||
|
card.assignment = ptojob.title
|
||||||
|
card.name = text("[card.registered_name]'s ID Card ([card.assignment])")
|
||||||
|
data_core.manifest_modify(card.registered_name, card.assignment)
|
||||||
|
card.last_job_switch = world.time
|
||||||
|
callHook("reassign_employee", list(card))
|
||||||
|
foundjob.current_positions--
|
||||||
|
announce.autosay("[card.registered_name], [oldtitle], has moved Off-Duty.", "Employee Oversight")
|
||||||
|
return
|
||||||
|
|
||||||
|
/obj/machinery/computer/timeclock/proc/checkCardCooldown()
|
||||||
|
if(!card)
|
||||||
|
return FALSE
|
||||||
|
if((world.time - card.last_job_switch) < 15 MINUTES)
|
||||||
|
to_chat(usr, "You need to wait at least 15 minutes after last duty switch.")
|
||||||
|
return FALSE
|
||||||
|
return TRUE
|
||||||
|
|
||||||
|
/obj/item/weapon/card/id
|
||||||
|
var/last_job_switch
|
||||||
|
|
||||||
|
/obj/item/weapon/card/id/New()
|
||||||
|
.=..()
|
||||||
|
last_job_switch = world.time
|
||||||
|
|
||||||
//
|
//
|
||||||
// Frame type for construction
|
// Frame type for construction
|
||||||
//
|
//
|
||||||
@@ -144,4 +246,4 @@
|
|||||||
|
|
||||||
/obj/machinery/computer/timeclock/premade/west
|
/obj/machinery/computer/timeclock/premade/west
|
||||||
dir = 4
|
dir = 4
|
||||||
pixel_x = -26
|
pixel_x = -26
|
||||||
@@ -413,6 +413,9 @@ ENGINE_MAP Supermatter Engine,Edison's Bane
|
|||||||
# Controls if the 'time off' system is used for determining if players can play 'Off-Duty' jobs (requires SQL)
|
# Controls if the 'time off' system is used for determining if players can play 'Off-Duty' jobs (requires SQL)
|
||||||
# TIME_OFF
|
# TIME_OFF
|
||||||
|
|
||||||
|
# If 'time off' system is on, controls whether or not players can switch on/off duty midround using timeclocks
|
||||||
|
# PTO_JOB_CHANGE
|
||||||
|
|
||||||
# Applies a limit to the number of assistants and visitors respectively
|
# Applies a limit to the number of assistants and visitors respectively
|
||||||
# LIMIT_INTERNS 6
|
# LIMIT_INTERNS 6
|
||||||
# LIMIT_VISITORS 6
|
# LIMIT_VISITORS 6
|
||||||
|
|||||||
@@ -56,24 +56,21 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{if data.allow_change_job && data.job_datum && data.job_datum.timeoff_factor != 0 }}
|
{{if data.allow_change_job && data.job_datum && data.job_datum.timeoff_factor != 0 && !(data.assignment == "Terminated")}}
|
||||||
<h3>Employment Actions</h3>
|
<h3>Employment Actions</h3>
|
||||||
<div class='itemGroup'>
|
<div class='itemGroup'>
|
||||||
<div class='item'>
|
<div class='item'>
|
||||||
{{if data.job_datum.head_position }}
|
{{if (data.job_datum.timeoff_factor > 0) }}
|
||||||
<i class='uiIcon16 icon-alert'></i>
|
{{if helper.round(data.department_hours[data.job_datum.department]) > 0 || (data.job_datum.department == "Command" && helper.round(data.department_hours["Civilian"]) > 0)}}
|
||||||
<span class='average'>NT policy does not permit head positions to go off duty mid-shift.</span>
|
{{:helper.link('Go Off-Duty', 'alert', {'switch-to-offduty': 1})}}
|
||||||
{{else (data.job_datum.timeoff_factor > 0) }}
|
|
||||||
{{if helper.round(data.department_hours[data.job_datum.department]) > 0 }}
|
|
||||||
{{:helper.link('Go Off Duty', 'alert', {'switch-to-offduty': 1})}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<i class='uiIcon16 icon-alert-red'></i>
|
<i class='uiIcon16 icon-alert-red'></i>
|
||||||
<span class='bad'>Insufficent Time Off Accrued</span>
|
<span class='bad'>Insufficent Time Off Accrued</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else (data.job_datum.timeoff_factor < 0) }}
|
{{else (data.job_datum.timeoff_factor < 0) }}
|
||||||
{{for data.job_choices }}
|
{{props data.job_choices }}
|
||||||
<div class='itemLabelWide'>{{:value}}</div>
|
<div class='itemLabelWide'>{{:value}}</div>
|
||||||
<div class='itemContentMedium'>{{:helper.link("Issue Guest Pass", 'suitcase', {'guest-pass' : value})}}</div>
|
<div class='itemContentMedium'>{{:helper.link("Go On-Duty", 'suitcase', {'switch-to-onduty' : value})}}</div>
|
||||||
{{empty}}
|
{{empty}}
|
||||||
<div class='notice'>No Open Positions - See Head of Personnel</div>
|
<div class='notice'>No Open Positions - See Head of Personnel</div>
|
||||||
{{/for}}
|
{{/for}}
|
||||||
|
|||||||
Reference in New Issue
Block a user