Skip to content

Commit

Permalink
Clocking out opens your job slot (#2047) (#2964)
Browse files Browse the repository at this point in the history
Clocking out opens the job slot

Co-authored-by: FlufflesTheDog <[email protected]>
  • Loading branch information
Steals-The-PRs and FlufflesTheDog authored Apr 19, 2024
1 parent bca6f6c commit 21d44c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions modular_nova/modules/cryosleep/code/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,14 @@
if(!job)
return FALSE
job.current_positions = max(0, job.current_positions - 1)

/// Used for clocking back in, re-claiming the previously freed role. Returns false if no slot is available.
/datum/controller/subsystem/job/proc/OccupyRole(rank)
if(!rank)
return FALSE
JobDebug("Occupying role: [rank]")
var/datum/job/job = GetJob(rank)
if(!job || job.current_positions >= job.total_positions)
return FALSE
job.current_positions = job.current_positions + 1
return TRUE
7 changes: 3 additions & 4 deletions modular_nova/modules/time_clock/code/console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/time_clock, 28)
var/current_assignment = inserted_id.assignment
var/datum/id_trim/job/current_trim = inserted_id.trim
var/datum/job/clocked_out_job = current_trim.job
clocked_out_job.current_positions = max(0, clocked_out_job.current_positions - 1)

SSjob.FreeRole(clocked_out_job.title)
radio.talk_into(src, "[inserted_id.registered_name], [current_assignment] has gone off-duty.", announcement_channel)
update_static_data_for_all_viewers()

Expand All @@ -139,10 +138,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/time_clock, 28)
return FALSE

var/datum/job/clocked_in_job = id_component.stored_trim.job
if(!clocked_in_job || (clocked_in_job.total_positions <= clocked_in_job.current_positions))
if(!SSjob.OccupyRole(clocked_in_job.title))
say("[capitalize(clocked_in_job.title)] has no free slots available, unable to clock in!")
return FALSE

clocked_in_job.current_positions++

SSid_access.apply_trim_to_card(inserted_id, id_component.stored_trim.type, TRUE)
inserted_id.assignment = id_component.stored_assignment
Expand Down
3 changes: 2 additions & 1 deletion modular_nova/modules/time_clock/code/console_tgui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
switch(action)
if("clock_in_or_out")
if(off_duty_check())
clock_in()
if(!(clock_in()))
return
log_admin("[key_name(usr)] clocked in as \an [inserted_id.assignment].")

var/datum/mind/user_mind = usr.mind
Expand Down

0 comments on commit 21d44c7

Please sign in to comment.