mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-27 22:16:23 +01:00
Timeclock Usage Upgrade
Allows you to switch to off-duty mid-round and, depending on whether there's an HOP, back on duty with non-command level jobs available.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
//TFF 19/5/19 - Port VOREStation's completed Timeclock code
|
||||
/////////////////////////////////////////////
|
||||
//Time Clock Terminal////////////////////////
|
||||
/////////////////////////////////////////////
|
||||
@@ -17,6 +18,12 @@
|
||||
circuit = /obj/item/weapon/circuitboard/timeclock
|
||||
|
||||
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()
|
||||
if(card)
|
||||
@@ -80,12 +87,12 @@
|
||||
"department" = job.department,
|
||||
"selection_color" = job.selection_color,
|
||||
"economic_modifier" = job.economic_modifier,
|
||||
"head_position" = job.head_position,
|
||||
"timeoff_factor" = job.timeoff_factor
|
||||
)
|
||||
// TODO - Once job changing is implemented, we will want to list jobs to change into.
|
||||
// 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)
|
||||
if(config.time_off && config.pto_job_change)
|
||||
data["allow_change_job"] = TRUE
|
||||
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 = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
@@ -100,7 +107,7 @@
|
||||
src.add_fingerprint(usr)
|
||||
|
||||
if (href_list["id"])
|
||||
if (card)
|
||||
if(card)
|
||||
usr.put_in_hands(card)
|
||||
card = null
|
||||
else
|
||||
@@ -109,8 +116,126 @@
|
||||
I.forceMove(src)
|
||||
card = I
|
||||
update_icon()
|
||||
return 1
|
||||
if(href_list["switch-to-onduty"])
|
||||
if(card)
|
||||
if(checkFace())
|
||||
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(checkFace())
|
||||
if(checkCardCooldown())
|
||||
makeOffDuty()
|
||||
usr.put_in_hands(card)
|
||||
card = null
|
||||
update_icon()
|
||||
return 1
|
||||
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.disallow_jobhop && job.timeoff_factor > 0)
|
||||
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++
|
||||
var/mob/living/carbon/human/H = usr
|
||||
H.mind.assigned_role = foundjob.title
|
||||
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))
|
||||
var/mob/living/carbon/human/H = usr
|
||||
H.mind.assigned_role = ptojob.title
|
||||
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. It has only been [world.time - card.last_job_switch] minutes since you have had your job changed.")
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/computer/timeclock/proc/checkFace()
|
||||
if(!card)
|
||||
to_chat(usr, "<span class='notice'>No ID is inserted.</span>")
|
||||
return FALSE
|
||||
var/mob/living/carbon/human/H = usr
|
||||
if(!(istype(H)))
|
||||
to_chat(usr, "<span class='warning'>Invalid user detected. Access denied.</span>")
|
||||
return FALSE
|
||||
else if((H.wear_mask && (H.wear_mask.flags_inv & HIDEFACE)) || (H.head && (H.head.flags_inv & HIDEFACE))) //Face hiding bad
|
||||
to_chat(usr, "<span class='warning'>Facial recognition scan failed due to physical obstructions. Access denied.</span>")
|
||||
return FALSE
|
||||
else if(H.get_face_name() == "Unknown" || !(H.real_name == card.registered_name))
|
||||
to_chat(usr, "<span class='warning'>Facial recognition scan failed. Access denied.</span>")
|
||||
return FALSE
|
||||
else
|
||||
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
|
||||
//
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
author: TheFurryFeline
|
||||
|
||||
delete-after: True
|
||||
|
||||
changes:
|
||||
- rscadd: "Implements full version of timeclocks: you'll be able to switch off or on duty without needing an HOP on the shift, unless the job is in Command or IAA. For those, you will need the HOP or a CD to change your job."
|
||||
@@ -56,24 +56,21 @@
|
||||
{{/if}}
|
||||
</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>
|
||||
<div class='itemGroup'>
|
||||
<div class='item'>
|
||||
{{if data.job_datum.head_position }}
|
||||
<i class='uiIcon16 icon-alert'></i>
|
||||
<span class='average'>NT policy does not permit head positions to go off duty mid-shift.</span>
|
||||
{{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})}}
|
||||
{{if (data.job_datum.timeoff_factor > 0) }}
|
||||
{{if helper.round(data.department_hours[data.job_datum.department]) > 0 || (data.job_datum.department == "Command" && helper.round(data.department_hours["Civilian"]) > 0)}}
|
||||
{{:helper.link('Go Off-Duty', 'alert', {'switch-to-offduty': 1})}}
|
||||
{{else}}
|
||||
<i class='uiIcon16 icon-alert-red'></i>
|
||||
<span class='bad'>Insufficent Time Off Accrued</span>
|
||||
{{/if}}
|
||||
{{else (data.job_datum.timeoff_factor < 0) }}
|
||||
{{for data.job_choices }}
|
||||
{{props data.job_choices }}
|
||||
<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}}
|
||||
<div class='notice'>No Open Positions - See Head of Personnel</div>
|
||||
{{/for}}
|
||||
|
||||
Reference in New Issue
Block a user