mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 19:44:58 +01:00
Job refactor 2: less hardcoded lists (#60578)
* Job refactor 2: less hardcoded lists * Obsessed can happen
This commit is contained in:
@@ -18,41 +18,19 @@
|
||||
return
|
||||
|
||||
/datum/crew_manifest/ui_data(mob/user)
|
||||
var/list/positions = list(
|
||||
"Command" = list("exceptions" = list(), "open" = 0),
|
||||
"Security" = list("exceptions" = list(), "open" = 0),
|
||||
"Engineering" = list("exceptions" = list(), "open" = 0),
|
||||
"Medical" = list("exceptions" = list(), "open" = 0),
|
||||
"Misc" = list("exceptions" = list(), "open" = 0),
|
||||
"Science" = list("exceptions" = list(), "open" = 0),
|
||||
"Supply" = list("exceptions" = list(), "open" = 0),
|
||||
"Service" = list("exceptions" = list(), "open" = 0),
|
||||
"Silicon" = list("exceptions" = list(), "open" = 0)
|
||||
)
|
||||
var/list/departments = list(
|
||||
list("flag" = DEPARTMENT_COMMAND, "name" = "Command"),
|
||||
list("flag" = DEPARTMENT_SECURITY, "name" = "Security"),
|
||||
list("flag" = DEPARTMENT_ENGINEERING, "name" = "Engineering"),
|
||||
list("flag" = DEPARTMENT_MEDICAL, "name" = "Medical"),
|
||||
list("flag" = DEPARTMENT_SCIENCE, "name" = "Science"),
|
||||
list("flag" = DEPARTMENT_CARGO, "name" = "Supply"),
|
||||
list("flag" = DEPARTMENT_SERVICE, "name" = "Service"),
|
||||
list("flag" = DEPARTMENT_SILICON, "name" = "Silicon")
|
||||
)
|
||||
|
||||
for(var/job in SSjob.joinable_occupations)
|
||||
// Check if there are additional open positions or if there is no limit
|
||||
if ((job["total_positions"] > 0 && job["total_positions"] > job["current_positions"]) || (job["total_positions"] == -1))
|
||||
for(var/department in departments)
|
||||
// Check if the job is part of a department using its flag
|
||||
// Will return true for Research Director if the department is Science or Command, for example
|
||||
if(job["departments"] & department["flag"])
|
||||
if(job["total_positions"] == -1)
|
||||
// Add job to list of exceptions, meaning it does not have a position limit
|
||||
positions[department["name"]]["exceptions"] += list(job["title"])
|
||||
else
|
||||
// Add open positions to current department
|
||||
positions[department["name"]]["open"] += (job["total_positions"] - job["current_positions"])
|
||||
var/list/positions = list()
|
||||
for(var/datum/job_department/department as anything in SSjob.joinable_departments)
|
||||
var/open = 0
|
||||
var/list/exceptions = list()
|
||||
for(var/datum/job/job as anything in department.department_jobs)
|
||||
if(job.total_positions == -1)
|
||||
exceptions += job.title
|
||||
continue
|
||||
var/open_slots = job.total_positions - job.current_positions
|
||||
if(open_slots < 1)
|
||||
continue
|
||||
open += open_slots
|
||||
positions[department.department_name] = list("exceptions" = exceptions, "open" = open)
|
||||
|
||||
return list(
|
||||
"manifest" = GLOB.data_core.get_manifest(),
|
||||
|
||||
@@ -407,26 +407,25 @@
|
||||
SSjob.prioritized_jobs -= prioritized_job
|
||||
dat += "<table><tr><td valign='top'>"
|
||||
var/column_counter = 0
|
||||
// render each category's available jobs
|
||||
for(var/category in GLOB.position_categories)
|
||||
// position_categories contains category names mapped to available jobs and an appropriate color
|
||||
var/cat_color = GLOB.position_categories[category]["color"]
|
||||
dat += "<fieldset style='width: 185px; border: 2px solid [cat_color]; display: inline'>"
|
||||
dat += "<legend align='center' style='color: [cat_color]'>[category]</legend>"
|
||||
var/list/dept_dat = list()
|
||||
for(var/job in GLOB.position_categories[category]["jobs"])
|
||||
var/datum/job/job_datum = SSjob.name_occupations[job]
|
||||
if(job_datum && IsJobUnavailable(job_datum.title, TRUE) == JOB_AVAILABLE)
|
||||
var/command_bold = ""
|
||||
if(job in GLOB.command_positions)
|
||||
command_bold = " command"
|
||||
if(job_datum in SSjob.prioritized_jobs)
|
||||
dept_dat += "<a class='job[command_bold]' href='byond://?src=[REF(src)];SelectedJob=[job_datum.title]'><span class='priority'>[job_datum.title] ([job_datum.current_positions])</span></a>"
|
||||
else
|
||||
dept_dat += "<a class='job[command_bold]' href='byond://?src=[REF(src)];SelectedJob=[job_datum.title]'>[job_datum.title] ([job_datum.current_positions])</a>"
|
||||
if(!dept_dat.len)
|
||||
dept_dat += "<span class='nopositions'>No positions open.</span>"
|
||||
dat += jointext(dept_dat, "")
|
||||
|
||||
for(var/datum/job_department/department as anything in SSjob.joinable_departments)
|
||||
var/department_color = department.latejoin_color
|
||||
dat += "<fieldset style='width: 185px; border: 2px solid [department_color]; display: inline'>"
|
||||
dat += "<legend align='center' style='color: [department_color]'>[department.department_name]</legend>"
|
||||
var/list/dept_data = list()
|
||||
for(var/datum/job/job_datum as anything in department.department_jobs)
|
||||
if(IsJobUnavailable(job_datum.title, TRUE) != JOB_AVAILABLE)
|
||||
continue
|
||||
var/command_bold = ""
|
||||
if(job_datum.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND)
|
||||
command_bold = " command"
|
||||
if(job_datum in SSjob.prioritized_jobs)
|
||||
dept_data += "<a class='job[command_bold]' href='byond://?src=[REF(src)];SelectedJob=[job_datum.title]'><span class='priority'>[job_datum.title] ([job_datum.current_positions])</span></a>"
|
||||
else
|
||||
dept_data += "<a class='job[command_bold]' href='byond://?src=[REF(src)];SelectedJob=[job_datum.title]'>[job_datum.title] ([job_datum.current_positions])</a>"
|
||||
if(!length(dept_data))
|
||||
dept_data += "<span class='nopositions'>No positions open.</span>"
|
||||
dat += dept_data.Join()
|
||||
dat += "</fieldset><br>"
|
||||
column_counter++
|
||||
if(column_counter > 0 && (column_counter % 3 == 0))
|
||||
|
||||
Reference in New Issue
Block a user