From fdba7475419c8858108dae5c4889339121110d00 Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Sun, 11 Sep 2022 02:43:31 -0400 Subject: [PATCH] introduce requirement to prevent from being tasked to steal your own item (#11139) --- .../Requirements/NotRoleRequirement.cs | 25 +++++++++++++++ .../Objectives/traitorObjectives.yml | 31 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 Content.Server/Objectives/Requirements/NotRoleRequirement.cs diff --git a/Content.Server/Objectives/Requirements/NotRoleRequirement.cs b/Content.Server/Objectives/Requirements/NotRoleRequirement.cs new file mode 100644 index 0000000000..ac27f4cb6d --- /dev/null +++ b/Content.Server/Objectives/Requirements/NotRoleRequirement.cs @@ -0,0 +1,25 @@ +using Content.Shared.Roles; +using Content.Server.Objectives.Interfaces; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; + +namespace Content.Server.Objectives.Requirements +{ + + [DataDefinition] + public sealed class NotRoleRequirement : IObjectiveRequirement + { + [DataField("roleId", customTypeSerializer:typeof(PrototypeIdSerializer))] + private string roleId = ""; + + /// + /// This requirement is met if the traitor is NOT the roleId, and fails if they are. + /// + public bool CanBeAssigned(Mind.Mind mind) + { + if (mind.CurrentJob == null) // no job no problems + return true; + + return (mind.CurrentJob.Prototype.ID != roleId); + } + } +} diff --git a/Resources/Prototypes/Objectives/traitorObjectives.yml b/Resources/Prototypes/Objectives/traitorObjectives.yml index 1c09bae827..a31704e990 100644 --- a/Resources/Prototypes/Objectives/traitorObjectives.yml +++ b/Resources/Prototypes/Objectives/traitorObjectives.yml @@ -8,6 +8,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: Captain conditions: - !type:StealCondition prototype: CaptainIDCard @@ -71,6 +73,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: ChiefMedicalOfficer conditions: - !type:StealCondition prototype: Hypospray @@ -86,6 +90,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: ResearchDirector conditions: - !type:StealCondition prototype: ClothingOuterHardsuitRd @@ -100,11 +106,24 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: Captain + - !type:NotRoleRequirement + roleId: HeadOfSecurity + - !type:NotRoleRequirement + roleId: HeadOfPersonnel + - !type:NotRoleRequirement + roleId: ChiefEngineer + - !type:NotRoleRequirement + roleId: ChiefMedicalOfficer + - !type:NotRoleRequirement + roleId: ResearchDirector conditions: - !type:StealCondition prototype: NukeDisk owner: objective-condition-steal-station + - type: objective id: IDComputerBoardStealObjective issuer: syndicate @@ -114,6 +133,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: HeadOfPersonnel conditions: - !type:StealCondition prototype: IDComputerCircuitboard @@ -129,6 +150,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: ChiefEngineer conditions: - !type:StealCondition prototype: ClothingShoesBootsMagAdv @@ -143,6 +166,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: Quartermaster conditions: - !type:StealCondition prototype: SupplyComputerCircuitboard @@ -157,6 +182,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: HeadOfPersonnel conditions: - !type:StealCondition prototype: FoodMeatCorgi @@ -172,6 +199,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: Captain conditions: - !type:StealCondition prototype: WeaponAntiqueLaser @@ -187,6 +216,8 @@ - !type:IncompatibleConditionsRequirement conditions: - DieCondition + - !type:NotRoleRequirement + roleId: Captain conditions: - !type:StealCondition prototype: JetpackCaptainFilled