Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ограничения Раса/Роль #1693

Merged
merged 15 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/modules/client/preference/character.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,11 @@
if(restrictions)
html += "<del class='dark'>[rank]</del></td><td class='bad'><b> \[[restrictions]]</b></td></tr>"
continue
// SS220 EDIT START - RACE/JOB BANS
if(job.species_ban(user.client))
html += "<del class='dark'>[rank]</del></td><td class='bad'><b> \[SPECIES BLOCK\]</b></td></tr>"
continue
// SS220 EDIT END - RACE/JOB BANS
if(job.barred_by_disability(user.client))
html += "<del class='dark'>[rank]</del></td><td class='bad'><b> \[DISABILITY\]</b></td></tr>"
continue
Expand Down
93 changes: 93 additions & 0 deletions config/example/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1169,3 +1169,96 @@ endpoint = "https://models.inference.ai.azure.com/chat/completions" # Allows git
model = "gpt-4o"

################################################################

[job_configuration_restriction]

# Should enable job ban for species
allow_to_ban_job_for_species = false

# Job blacklist marks. Add species name to ban job for a specific species. Example: { name = "Captain", species_blacklist = ["Vox"] },
job_species_blacklist = [
msw7007 marked this conversation as resolved.
Show resolved Hide resolved
# Cental Command
{ name = "Nanotrasen Navy Officer", species_blacklist = [] },
{ name = "Special Operations Officer", species_blacklist = [] },
{ name = "Trans-Solar Federation General", species_blacklist = [] },
{ name = "Syndicate Officer", species_blacklist = [] },
# Commmand
{ name = "Captain", species_blacklist = [] },
{ name = "Head of Personnel", species_blacklist = [] },
{ name = "Head of Security", species_blacklist = [] },
{ name = "Chief Engineer", species_blacklist = [] },
{ name = "Research Director", species_blacklist = [] },
{ name = "Chief Medical Officer", species_blacklist = [] },
{ name = "Quartermaster", species_blacklist = [] },
{ name = "Nanotrasen Representative", species_blacklist = [] },
{ name = "Blueshield", species_blacklist = [] },
{ name = "Magistrate", species_blacklist = [] },
# Engineering
{ name = "Life Support Specialist", species_blacklist = [] },
{ name = "Station Engineer", species_blacklist = [] },
{ name = "Trainee Engineer", species_blacklist = [] },
# Medical
{ name = "Chemist", species_blacklist = [] },
{ name = "Paramedic", species_blacklist = [] },
{ name = "Geneticist", species_blacklist = [] },
{ name = "Coroner", species_blacklist = [] },
{ name = "Psychiatrist", species_blacklist = [] },
{ name = "Medical Doctor", species_blacklist = [] },
{ name = "Medical Intern", species_blacklist = [] },
{ name = "Virologist", species_blacklist = [] },
# Science
{ name = "Roboticist", species_blacklist = [] },
{ name = "Scientist", species_blacklist = [] },
{ name = "Student Scientist", species_blacklist = [] },
# Security
{ name = "Detective", species_blacklist = [] },
{ name = "Security Officer", species_blacklist = [] },
{ name = "Security Cadet", species_blacklist = [] },
{ name = "Warden", species_blacklist = [] },
{ name = "Internal Affairs Agent", species_blacklist = [] },
# Service
{ name = "Bartender", species_blacklist = [] },
{ name = "Botanist", species_blacklist = [] },
{ name = "Chaplain", species_blacklist = [] },
{ name = "Chef", species_blacklist = [] },
{ name = "Janitor", species_blacklist = [] },
{ name = "Librarian", species_blacklist = [] },
{ name = "Clown", species_blacklist = [] },
{ name = "Mime", species_blacklist = [] },
# Cargo/Supply
{ name = "Explorer", species_blacklist = [] },
{ name = "Shaft Miner", species_blacklist = [] },
{ name = "Cargo Technician", species_blacklist = [] },
# Silicon
{ name = "AI", species_blacklist = [] },
{ name = "Cyborg", species_blacklist = [] },
# Misc
{ name = "Assistant", species_blacklist = [] },
# Donor
{ name = "Donor", species_blacklist = [] },
{ name = "Prisoner", species_blacklist = [] },
{ name = "Barber", species_blacklist = [] },
{ name = "Bath", species_blacklist = [] },
{ name = "Casino", species_blacklist = [] },
{ name = "Waiter", species_blacklist = [] },
{ name = "Acolyte", species_blacklist = [] },
{ name = "Wrestler", species_blacklist = [] },
{ name = "Musician", species_blacklist = [] },
{ name = "Actor", species_blacklist = [] },
{ name = "Administrator", species_blacklist = [] },
{ name = "Tourist TSF", species_blacklist = [] },
{ name = "Tourist USSP", species_blacklist = [] },
{ name = "Cleaning Manager", species_blacklist = [] },
{ name = "Guard", species_blacklist = [] },
{ name = "Migrant", species_blacklist = [] },
{ name = "Uncertain", species_blacklist = [] },
{ name = "Adjutant", species_blacklist = [] },
{ name = "Representative TSF", species_blacklist = [] },
{ name = "Representative USSP", species_blacklist = [] },
{ name = "Dealer", species_blacklist = [] },
{ name = "VIP Corporate Guest", species_blacklist = [] },
{ name = "Banker", species_blacklist = [] },
{ name = "Security Clown", species_blacklist = [] },
]

################################################################
1 change: 1 addition & 0 deletions modular_ss220/jobs/_jobs.dme
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "_jobs.dm"

#include "code/configuration.dm"
#include "code/card_computer.dm"
#include "code/card_id.dm"
#include "code/departaments.dm"
Expand Down
34 changes: 34 additions & 0 deletions modular_ss220/jobs/code/configuration.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/datum/configuration_section/job_configuration_restriction
var/list/blacklist_species = list()
var/enable_black_list = FALSE

/datum/server_configuration
var/datum/configuration_section/job_configuration_restriction/jobs_restrict

/datum/configuration_section/job_configuration_restriction/load_data(list/data)
CONFIG_LOAD_BOOL(enable_black_list, data["allow_to_ban_job_for_species"])
CONFIG_LOAD_LIST(blacklist_species, data["job_species_blacklist"])

/datum/configuration_section/job_configuration_restriction/proc/sanitize_job_checks()
if(!SSjobs || !GLOB.all_species)
CRASH("Can't check job_configuration_restriction without SSjobs and GLOB.all_species")

for(var/job_info in blacklist_species)
job_exist_in_config(job_info["name"])
for(var/race_info in job_info["species_blacklist"])
race_exist_in_config(race_info, job_info["name"])

/datum/configuration_section/job_configuration_restriction/proc/job_exist_in_config(job_name)
if(job_name in SSjobs.name_occupations)
return TRUE
CRASH("Job [job_name] mentioned in job_configuration_restriction not found in SSjobs.name_occupations")

/datum/configuration_section/job_configuration_restriction/proc/race_exist_in_config(race_name, job_name)
if(race_name in GLOB.all_species)
return TRUE
CRASH("Race [race_name] mentioned in config of job_configuration_restriction for job [job_name] not found in global var of all species GLOB.all_species")

/datum/server_configuration/load_all_sections()
. = ..()
jobs_restrict = new()
safe_load(jobs_restrict, "job_configuration_restriction")
24 changes: 24 additions & 0 deletions modular_ss220/jobs/code/jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,27 @@
if(title in GLOB.all_jobs_ss220)
return TRUE
return FALSE

/datum/job/proc/species_ban(client/C)
if(!GLOB.configuration.jobs_restrict.enable_black_list)
return FALSE

var/list/job_ban = GLOB.configuration.jobs_restrict.blacklist_species
if(!C || !length(job_ban))
return FALSE
for(var/job_data in job_ban)
msw7007 marked this conversation as resolved.
Show resolved Hide resolved
if((title == job_data["name"]) && (C.prefs.active_character.species in job_data["species_blacklist"]))
return TRUE
return FALSE

/mob/new_player/IsJobAvailable(rank)
. = ..()
msw7007 marked this conversation as resolved.
Show resolved Hide resolved
if(!.)
return FALSE
var/datum/job/job = SSjobs.GetJob(rank)
if(job.species_ban(client))
return FALSE

/datum/controller/subsystem/jobs/Initialize()
. = ..()
GLOB.configuration.jobs_restrict.sanitize_job_checks()
Loading