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

(Готово) new jobs block #810

Merged
merged 14 commits into from
Mar 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public bool CheckSpeciesRestrict(JobPrototype job, HumanoidCharacterProfile prof

if (species is not null)
{
if (JobRequirements.TryRequirementsSpeciesMet(job, species, out var reason, _prototypeManager))
if (JobRequirements.TryRequirementsSpeciesMet(job, species, profile.Sex, out var reason, _prototypeManager))
return true;

reasons.Add(reason.ToMarkup());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
// Created specially for SS200 with love by Alan Wake (https://github.com/aw-c)

using Content.Shared.Roles;
using Robust.Shared.Prototypes;
using Content.Shared.Humanoid.Prototypes;
Expand All @@ -21,7 +22,7 @@ public bool IsAllowed(ICommonSession player, string jobId)
{
var profile = (_serverPreferences.GetPreferences(player.UserId).SelectedCharacter as HumanoidCharacterProfile)!;
var species = _prototypes.Index<SpeciesPrototype>(profile.Species);
if (JobRequirements.TryRequirementsSpeciesMet(job, species, out _, _prototypes))
if (JobRequirements.TryRequirementsSpeciesMet(job, species, profile.Sex, out _, _prototypes))
return true;
}
return false;
Expand Down
5 changes: 3 additions & 2 deletions Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic;
using Content.Shared.Roles;

namespace Content.Shared.Humanoid.Prototypes;
Expand Down Expand Up @@ -135,8 +136,8 @@ public sealed partial class SpeciesPrototype : IPrototype
public string ButtScanTexture = "/Textures/SS220/Interface/Butts/human.png";

//SS220 Species-Job-Requirement
[DataField("blockedJobs", required: false, customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
public List<string> BlockedJobs { get; } = new();
[DataField(customTypeSerializer: typeof(DictionarySerializer<string, string[]>))]
public Dictionary<string, string[]> BlockedJobsByAccessor { get; } = new();
}

public enum SpeciesNaming : byte
Expand Down
34 changes: 32 additions & 2 deletions Content.Shared/Roles/JobRequirements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Humanoid;

namespace Content.Shared.Roles
{
Expand Down Expand Up @@ -76,16 +77,45 @@ public static class JobRequirements
public static bool TryRequirementsSpeciesMet(
JobPrototype job,
SpeciesPrototype species,
Sex selected_sex,
[NotNullWhen(false)] out FormattedMessage? reason,
IPrototypeManager prototypes)
{
reason = null;

if (species.BlockedJobs is not null && species.BlockedJobs.Contains(job.ID))
if (species.BlockedJobsByAccessor.ContainsKey(job.ID))
{
if (species.BlockedJobsByAccessor[job.ID] is null || species.BlockedJobsByAccessor[job.ID].Length == 0)
goto not_allowed;

foreach (var looking_sex in species.BlockedJobsByAccessor[job.ID])
{
Sex sex = 0;
switch (looking_sex)
{
case "female":
sex = Sex.Female;
break;
case "male":
sex = Sex.Male;
break;
case "unsexed":
sex = Sex.Unsexed;
break;
}

if (selected_sex == sex)
goto not_allowed;
}

return true;

not_allowed:

reason = FormattedMessage.FromMarkup(Loc.GetString("role-restrict-specie"));
return false;
}

return true;
}
//SS220 Species-Job-Requirement end
Expand Down Expand Up @@ -181,7 +211,7 @@ public static bool TryRequirementMet(
return true;

reason = FormattedMessage.FromMarkup(Loc.GetString(
"role-timer-overall-insufficient",
"role-timer-overall-insufficient",
("time", Math.Ceiling(overallDiff))));
return false;
}
Expand Down
33 changes: 16 additions & 17 deletions Resources/Prototypes/SS220/spo9k/Species/felinid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@
youngAge: 20
oldAge: 40
maxAge: 40
blockedJobs:
- Captain
- BlueShield
- HeadOfPersonnel
- Quartermaster
- ChiefEngineer
- Chemist
- ChiefMedicalOfficer
- Paramedic
- ResearchDirector
- Brigmedic
- Detective
- HeadOfSecurity
- SecurityCadet
- SecurityOfficer
- Warden
- Boxer
blockedJobsByAccessor: # we are deny all sex if don't put anytihng inside the [], but when we put something inside, we deny just this sex
#Командование
Captain: [ ]
HeadOfPersonnel: [ ]
ChiefEngineer: [ ]
ResearchDirector: [ ]
HeadOfSecurity: [ ]
ChiefMedicalOfficer: [ ]
#ЦК
IAA: [ ]
BlueShield: [ ]
#Служба Безопасности
SecurityCadet: [ ]
SecurityOfficer: [ ]
Warden: [ ]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

боксёр

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему ты вообще решил что у них боксер должен быть ограничен? Они же имею ограничения только по полит причинам.

- type: markingPoints
id: MobFelinidMarkingLimits
points:
Expand Down
46 changes: 44 additions & 2 deletions Resources/Prototypes/Species/arachnid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,50 @@
femaleFirstNames: names_arachnid_first
maleLastNames: names_arachnid_last # Corvax-LastnameGender
femaleLastNames: names_arachnid_last # Corvax-LastnameGender
sexes:
- Unsexed
blockedJobsByAccessor: #SS220-Job-Restrictions-start
#Командование
Captain: [ ]
HeadOfPersonnel: [ male ]
HeadOfSecurity: [ male ]
ChiefEngineer: [ male ]
Quartermaster: [ male ]
ChiefMedicalOfficer: [ male ]
#ЦК
IAA: [ ]
BlueShield: [ male ]
#Служба Безопасности
Warden: [ male ]
SecurityOfficer: [ male ]
SecurityPilot: [ male ]
SecurityCadet: [ male ]
Brigmedic: [ famele ]
#Инженерный отдел
AtmosphericTechnician: [ famele ]
StationEngineer: [ female ]
TechnicalAssistant: [ female ]
#Медицинский отдел
Psychologist: [ female ]
Chemist: [ female ]
MedicalDoctor: [ female ]
MedicalIntern: [ female ]
Paramedic: [ female ]
#Научный отдел
Scientist: [ female ]
ResearchAssistant: [ female ]
#Отдел снабжения
CargoTechnician: [ female ]
SalvageSpecialist: [ female ]
#Сервис
Janitor: [ female ]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Janitor: [ female ]

повторяется ниже

Chef: [ female ]
Bartender: [ female ]
Detective: [ male ]
Librarian: [ female ]
Janitor: [ female ]
Botanist: [ female ]
Clown: [ ]
Mime: [ ]
#SS220-Job-Restrictions-end

- type: speciesBaseSprites
id: MobArachnidSprites
Expand Down
25 changes: 25 additions & 0 deletions Resources/Prototypes/Species/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@
femaleLastNames: DionaLast # Corvax-LastnameGender
naming: TheFirstofLast
buttScanTexture: /Textures/SS220/Interface/Butts/diona.png
blockedJobs: #SS220-Job-Restrictions-start
#Командование
- Captain
- HeadOfSecurity
- Quartermaster
#ЦК
- BlueShield
- IAA
#Служба Безопасности
- Warden
- SecurityOfficer
- SecurityPilot
- SecurityCadet
- Brigmedic
#Медицинский отдел
- Paramedic
#Отдел снабжения
- Quartermaster
- CargoTechnician
- SalvageSpecialist
#Сервис
- Detective
- Chef
- Boxer
#SS220-Job-Restrictions-end

- type: speciesBaseSprites
id: MobDionaSprites
Expand Down
11 changes: 11 additions & 0 deletions Resources/Prototypes/Species/dwarf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@
markingLimits: MobHumanMarkingLimits
dollPrototype: MobDwarfDummy
skinColoration: HumanToned
blockedJobs: #SS220-Job-Restrictions-start
#Командование
- Captain
- HeadOfPersonnel
- HeadOfSecurity
- ResearchDirector
#ЦК
- IAA
#Сервис
- Chaplain
#SS220-Job-Restrictions-end
12 changes: 12 additions & 0 deletions Resources/Prototypes/Species/moth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
femaleFirstNames: names_moth_first_female
maleLastNames: names_moth_last_male
femaleLastNames: names_moth_last_female
blockedJobs: #SS220-Job-Restrictions-start
#Командование
- Captain
- HeadOfSecurity
- ChiefEngineer
#ЦК
- BlueShield
- IAA
#Инженерный отдел
- StationEngineer
- TechnicalAssistant
#SS220-Job-Restrictions-end

- type: speciesBaseSprites
id: MobMothSprites
Expand Down
14 changes: 14 additions & 0 deletions Resources/Prototypes/Species/reptilian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
femaleFirstNames: names_reptilian_female
naming: FirstDashFirst
buttScanTexture: /Textures/SS220/Interface/Butts/unathi.png
blockedJobs: #SS220-Job-Restrictions-start
#Командование
- Captain
#ЦК
- IAA
#Служба Безопасности
- Brigmedic
#Медицинский отдел
- Psychologist
#Сервис
- Chef
- Bartender
- Botanist
#SS220-Job-Restrictions-end

- type: speciesBaseSprites
id: MobReptilianSprites
Expand Down
13 changes: 13 additions & 0 deletions Resources/Prototypes/Species/slime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
dollPrototype: MobSlimePersonDummy
skinColoration: Hues
buttScanTexture: /Textures/SS220/Interface/Butts/slime.png
blockedJobs: #SS220-Job-Restrictions-start
#Командование
- Captain
#ЦК
- IAA
#Медицинский отдел
- Chemist
#Сервис
- Janitor
- Chef
- Bartender
- Botanist
#SS220-Job-Restrictions-end

- type: speciesBaseSprites
id: MobSlimeSprites
Expand Down
Loading