mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
Adds required jobs support to gamemodes (#44026)
* Adds required_jobs support to gamemodes * alos needs to be checked with no players present * early return
This commit is contained in:
@@ -228,7 +228,7 @@ SUBSYSTEM_DEF(job)
|
||||
* fills var "assigned_role" for all ready players.
|
||||
* This proc must not have any side effect besides of modifying "assigned_role".
|
||||
**/
|
||||
/datum/controller/subsystem/job/proc/DivideOccupations()
|
||||
/datum/controller/subsystem/job/proc/DivideOccupations(list/required_jobs)
|
||||
//Setup new player list and get the jobs list
|
||||
JobDebug("Running DO")
|
||||
|
||||
@@ -248,7 +248,7 @@ SUBSYSTEM_DEF(job)
|
||||
|
||||
JobDebug("DO, Len: [unassigned.len]")
|
||||
if(unassigned.len == 0)
|
||||
return TRUE
|
||||
return validate_required_jobs(required_jobs)
|
||||
|
||||
//Scale number of open security officer slots to population
|
||||
setup_officer_positions()
|
||||
@@ -354,7 +354,26 @@ SUBSYSTEM_DEF(job)
|
||||
if(!GiveRandomJob(player))
|
||||
if(!AssignRole(player, SSjob.overflow_role)) //If everything is already filled, make them an assistant
|
||||
return FALSE //Living on the edge, the forced antagonist couldn't be assigned to overflow role (bans, client age) - just reroll
|
||||
return TRUE
|
||||
|
||||
return validate_required_jobs(required_jobs)
|
||||
|
||||
/datum/controller/subsystem/job/proc/validate_required_jobs(list/required_jobs)
|
||||
if(!required_jobs.len)
|
||||
return TRUE
|
||||
for(var/required_group in required_jobs)
|
||||
var/group_ok = TRUE
|
||||
for(var/rank in required_group)
|
||||
var/datum/job/J = GetJob(rank)
|
||||
if(!J)
|
||||
SSticker.mode.setup_error = "Invalid job [rank] in gamemode required jobs."
|
||||
return FALSE
|
||||
if(J.current_positions < required_group[rank])
|
||||
group_ok = FALSE
|
||||
break
|
||||
if(group_ok)
|
||||
return TRUE
|
||||
SSticker.mode.setup_error = "Required jobs not present."
|
||||
return FALSE
|
||||
|
||||
//We couldn't find a job from prefs for this guy.
|
||||
/datum/controller/subsystem/job/proc/HandleUnassigned(mob/dead/new_player/player)
|
||||
|
||||
@@ -230,7 +230,7 @@ SUBSYSTEM_DEF(ticker)
|
||||
var/can_continue = 0
|
||||
can_continue = src.mode.pre_setup() //Choose antagonists
|
||||
CHECK_TICK
|
||||
can_continue = can_continue && SSjob.DivideOccupations() //Distribute jobs
|
||||
can_continue = can_continue && SSjob.DivideOccupations(mode.required_jobs) //Distribute jobs
|
||||
CHECK_TICK
|
||||
|
||||
if(!GLOB.Debug2)
|
||||
|
||||
Reference in New Issue
Block a user