Skip to content

Commit

Permalink
Ограничения Раса/Роль (#1693)
Browse files Browse the repository at this point in the history
<!-- Пишите **НИЖЕ** заголовков и **ВЫШЕ** комментариев, иначе что то
может пойти не так. -->
<!-- Вы можете прочитать Contributing.MD, если хотите узнать больше. -->

## Что этот PR делает

Добавляет систему механического ограничения расы для ролей (джобок).
Используется конфиг (для возможности различной настройки на разных
серверах для разных рас (пример приведен в конфиге)).
Используется переменная для общего включения/выключения системы.

UPD: готовый вариант конфига по таблице для прайма
```toml
[job_configuration_restriction]

# Should enable job ban for species
allow_to_ban_job_for_species = true

# Job blacklist marks. Add species name to ban job for a specific species. Example: { name = "Captain", species_blacklist = ["Vox"] },
job_species_blacklist = [
	# Cental Command
	{ name = "Nanotrasen Navy Officer", species_blacklist = ["Unathi", "Slime People", "Vox", "Drask", "Grey", "Diona", "Machine", "Kidan", "Plasmaman", "Vulpkanin", "Nucleation", "Nian"] },
	{ name = "Special Operations Officer", species_blacklist = ["Unathi", "Slime People", "Vox", "Drask", "Grey", "Diona", "Machine", "Kidan", "Plasmaman", "Vulpkanin", "Nucleation", "Nian"] },
	{ name = "Trans-Solar Federation General", species_blacklist = ["Unathi", "Slime People", "Slime People", "Vox", "Drask", "Plasmaman", "Nian"] },
	{ name = "Syndicate Officer", species_blacklist = [] },
	# Commmand
	{ name = "Captain", species_blacklist = ["Unathi", "Diona", "Vulpkanin", "Tajaran", "Kidan", "Grey", "Plasmaman", "Slime People", "Drask", "Vox", "Nian"] },
	{ name = "Head of Personnel", species_blacklist = ["Unathi", "Diona", "Grey", "Plasmaman", "Vox", "Nian"] },
	{ name = "Head of Security", species_blacklist = [ "Vox",  "Slime People", "Diona", "Grey", "Kidan", "Plasmaman", "Nian", "Nucleation"] },
	{ name = "Chief Engineer", species_blacklist = ["Kidan", "Vox"] },
	{ name = "Research Director", species_blacklist = ["Kidan", "Slime People", "Vox"] },
	{ name = "Chief Medical Officer", species_blacklist = ["Kidan"] },
	{ name = "Quartermaster", species_blacklist = ["Vulpkanin", "Kidan"] },
	{ name = "Nanotrasen Representative", species_blacklist = ["Unathi", "Vulpkanin", "Diona", "Tajaran", "Kidan", "Grey", "Plasmaman", "Slime People", "Drask", "Vox",  "Nian"] },
	{ name = "Blueshield", species_blacklist = ["Unathi", "Vulpkanin", "Diona", "Tajaran", "Kidan", "Grey", "Plasmaman", "Slime People", "Drask", "Vox", "Nian", "Nucleation"] },
	{ name = "Magistrate", species_blacklist = ["Unathi", "Vulpkanin", "Diona", "Tajaran", "Kidan", "Grey", "Plasmaman", "Slime People", "Drask", "Vox", "Nian"] },
	# Engineering
	{ name = "Life Support Specialist", species_blacklist = ["Drask"] },
	{ name = "Station Engineer", species_blacklist = [] },
	{ name = "Trainee Engineer", species_blacklist = [] },
	# Medical
	{ name = "Chemist", species_blacklist = [] },
	{ name = "Paramedic", species_blacklist = [] },
	{ name = "Geneticist", species_blacklist = ["Kidan", "Plasmaman", "Drask"] },
	{ name = "Coroner", species_blacklist = [] },
	{ name = "Psychiatrist", species_blacklist = [] },
	{ name = "Medical Doctor", species_blacklist = [] },
	{ name = "Medical Intern", species_blacklist = [] },
	{ name = "Virologist", species_blacklist = ["Plasmaman"] },
	# Science
	{ name = "Roboticist", species_blacklist = ["Diona", "Drask"] },
	{ name = "Scientist", species_blacklist = ["Drask", ] },
	{ name = "Student Scientist", species_blacklist = ["Drask"] },
	# Security
	{ name = "Detective", species_blacklist = ["Diona", "Kidan", "Grey", "Plasmaman"] },
	{ name = "Security Officer", species_blacklist = ["Diona", "Kidan", "Grey", "Plasmaman", "Nian", "Nucleation"] },
	{ name = "Security Cadet", species_blacklist = ["Diona", "Kidan", "Grey", "Plasmaman", "Nucleation"] },
	{ name = "Warden", species_blacklist = ["Diona", "Kidan", "Grey", "Plasmaman", "Nian", "Nucleation"] },
	{ name = "Internal Affairs Agent", species_blacklist = ["Unathi", "Vulpkanin", "Diona", "Tajaran", "Kidan", "Grey", "Plasmaman", "Vox"] },
	# Service
	{ name = "Bartender", species_blacklist = [] },
	{ name = "Botanist", species_blacklist = [] },
	{ name = "Chaplain", species_blacklist = ["Grey"] },
	{ name = "Chef", species_blacklist = ["Vox"] },
	{ name = "Janitor", species_blacklist = [] },
	{ name = "Librarian", species_blacklist = [] },
	{ name = "Clown", species_blacklist = ["Grey"] },
	{ name = "Mime", species_blacklist = ["Grey"] },
	# Cargo/Supply
	{ name = "Explorer", species_blacklist = [] },
	{ name = "Shaft Miner", species_blacklist = ["Grey", "Plasmaman", "Nian"] },
	{ 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 = [] },
]

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

```

<!-- Вкратце опишите изменения, которые вносите. -->
<!-- Опишите **все** изменения, так как противное может сказаться на
рассмотрении этого PR'а! -->
<!-- Если вы исправляете Issue, добавьте "Fixes #xxxx" (где xxxx - номер
Issue) где-нибудь в описании PR'а. Это автоматически закроет Issue после
принятия PR'а. -->

## Почему это хорошо для игры

Позволит механически поддержить правила Пары, а так-же будет полезно для
ГБСов.

<!-- Опишите, почему, по вашему, следует добавить эти изменения в игру.
-->

## Изображения изменений

![image](https://github.com/user-attachments/assets/ea54ef89-8521-4101-85a3-003ce441bac8)

![image](https://github.com/user-attachments/assets/58311256-f31b-4e38-971c-5ed2e38a2dae)

<!-- Если вы не меняли карту или спрайты, можете опустить эту секцию.
Если хотите, можете вставить видео. -->

## Тестирование

Локальный сервер:
Внес изменения в список ограничений (капитан - воксы и включил систему).
Запустил игру - выбрал вокса - в настройках приоритета рас работает
ограничение, при попытке присоединится заблокированная роль не
отображается в списке.
Не останавливая сервер выбрал человека - все доступно и в меню и в
присоединении.
Внес изменения в конфиг снова (выключил систему не убирая ограничения
капитан - воксы).
Запустил игру - выбрал вокса или хумана - обоим было все доступно.

<!-- Как вы тестировали свой PR, если делали это вовсе? -->

## Changelog

:cl:
add: Добавляется система ограничения раса/роль
/:cl:

<!-- Оба :cl:'а должны быть на месте, что-бы чейнджлог работал! Вы
можете написать свой ник справа от первого :cl:, если хотите. Иначе
будет использован ваш ник на ГитХабе. -->
<!-- Вы можете использовать несколько записей с одинаковым префиксом
(Они используются только для иконки в игре) и удалить ненужные. Помните,
что чейнджлог должен быть понятен обычным игроком. -->
<!-- Если чейнджлог не влияет на игроков(например, это рефактор), вы
можете исключить всю секцию. -->
  • Loading branch information
msw7007 authored Dec 13, 2024
1 parent d6c16bb commit 8201f88
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
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 = [
# 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)
if((title == job_data["name"]) && (C.prefs.active_character.species in job_data["species_blacklist"]))
return TRUE
return FALSE

/mob/new_player/IsJobAvailable(rank)
. = ..()
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()

0 comments on commit 8201f88

Please sign in to comment.