From 1d05b812d115458ccf82a84bedb4d63bc776d8fd Mon Sep 17 00:00:00 2001 From: Kashargul <144968721+Kashargul@users.noreply.github.com> Date: Thu, 19 Dec 2024 06:42:04 +0100 Subject: [PATCH] moves the timeclock cooldown check to tgui (#16733) * moves the timeclock cooldown check to tgui * . --- code/game/machinery/computer/timeclock_vr.dm | 7 ++++++- tgui/packages/tgui/interfaces/TimeClock.tsx | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/code/game/machinery/computer/timeclock_vr.dm b/code/game/machinery/computer/timeclock_vr.dm index 4e5eba6d71b..a517bcbf7ca 100644 --- a/code/game/machinery/computer/timeclock_vr.dm +++ b/code/game/machinery/computer/timeclock_vr.dm @@ -88,9 +88,11 @@ data["job_datum"] = null data["allow_change_job"] = null data["job_choices"] = null + data["on_cooldown"] = null if(card) data["card"] = "[card]" data["assignment"] = card.assignment + data["card_cooldown"] = getCooldown() var/datum/job/job = job_master.GetJob(card.rank) if(job) data["job_datum"] = list( @@ -216,12 +218,15 @@ /obj/machinery/computer/timeclock/proc/checkCardCooldown(var/mob/user) if(!card) return FALSE - var/time_left = 10 MINUTES - (world.time - card.last_job_switch) + var/time_left = getCooldown() if(time_left > 0) to_chat(user, "You need to wait another [round((time_left/10)/60, 1)] minute\s before you can switch.") return FALSE return TRUE +/obj/machinery/computer/timeclock/proc/getCooldown() + return 10 MINUTES - (world.time - card.last_job_switch) + /obj/machinery/computer/timeclock/proc/checkFace(var/mob/user) if(!card) to_chat(user, span_notice("No ID is inserted.")) diff --git a/tgui/packages/tgui/interfaces/TimeClock.tsx b/tgui/packages/tgui/interfaces/TimeClock.tsx index 71271c8aa5b..2f2e6b484ed 100644 --- a/tgui/packages/tgui/interfaces/TimeClock.tsx +++ b/tgui/packages/tgui/interfaces/TimeClock.tsx @@ -10,6 +10,7 @@ import { NoticeBox, Section, } from '../components'; +import { formatTime } from '../format'; import { Window } from '../layouts'; import { RankIcon } from './common/RankIcon'; @@ -18,6 +19,7 @@ type Data = { department_hours: Record | undefined; user_name: string; assignment: string | null; + card_cooldown: number; job_datum: { title: string; departments: string; @@ -37,6 +39,7 @@ export const TimeClock = (props) => { department_hours, user_name, card, + card_cooldown, assignment, job_datum, allow_change_job, @@ -128,6 +131,13 @@ export const TimeClock = (props) => { department_hours[job_datum.pto_department] > 0 && (