-
Notifications
You must be signed in to change notification settings - Fork 69
[Feature] Event "Wacky law" #196
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using Content.Server._Arcane.StationEvents.Events; | ||
| using Content.Shared.Dataset; | ||
| using Robust.Shared.Prototypes; | ||
|
|
||
| namespace Content.Server._Arcane.StationEvents.Components; | ||
|
|
||
| [RegisterComponent] | ||
| [Access(typeof(WackyLawRule))] | ||
| public sealed partial class WackyLawComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// Dataset of objects for event "wacky law" | ||
| /// </summary> | ||
| [DataField] | ||
| public ProtoId<DatasetPrototype> ItemDataset = "ArcaneItem"; | ||
|
|
||
| /// <summary> | ||
| /// Beverage Dataset for event "wacky law" (use text instead of IDs) | ||
| /// </summary> | ||
| [DataField] | ||
| public ProtoId<DatasetPrototype> HalfProhibitionDataset = "ArcaneHalfProhibition"; | ||
|
|
||
| /// <summary> | ||
| /// Department Dataset for event "wacky law" | ||
| /// </summary> | ||
| [DataField] | ||
| public ProtoId<DatasetPrototype> DepartmentDataset = "ArcaneDepartments"; | ||
|
|
||
| /// <summary> | ||
| /// Laws dataset for event "wacky law" | ||
| /// </summary> | ||
| [DataField] | ||
| public ProtoId<DatasetPrototype> LawsDataset = "ArcaneLaws"; | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
|
||
| using System.Collections.Generic; | ||
| using Content.Server.Fax; | ||
| using Content.Server.StationEvents.Events; | ||
| using Content.Server._Arcane.StationEvents.Components; | ||
| using Content.Shared.Dataset; | ||
| using Content.Shared.Fax.Components; | ||
| using Content.Shared.GameTicking.Components; | ||
| using Content.Shared.Paper; | ||
| using Content.Shared.Roles; | ||
| using Robust.Shared.Maths; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.Random; | ||
|
|
||
| namespace Content.Server._Arcane.StationEvents.Events; | ||
|
|
||
| /// <summary> | ||
| /// An event related to a strange law from the Central Command. I tried to set it up so that new laws could be added without having to edit the code. The dataset file contains instructions. | ||
| /// </summary> | ||
| public sealed class WackyLawRule : StationEventSystem<WackyLawComponent> | ||
| { | ||
| [Dependency] private readonly IRobustRandom _random = default!; | ||
| [Dependency] private readonly FaxSystem _fax = default!; | ||
| [Dependency] private readonly IPrototypeManager _proto = default!; | ||
|
|
||
| private string GetDepartmentText(string department) | ||
| { | ||
| if (department == "All") | ||
| return Loc.GetString("wacky-law-department-all"); | ||
|
|
||
| var name = _proto.TryIndex<DepartmentPrototype>(department, out var dept) | ||
| ? Loc.GetString(dept.Name) | ||
| : department; | ||
|
|
||
| return Loc.GetString(name); | ||
| } | ||
|
Comment on lines
+27
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Не локализуйте имя отдела второй раз. На строке 33 Верните первое локализованное значение. Затем оберните его через 🤖 Prompt for AI Agents |
||
| private string PickRandomEntityName(ProtoId<DatasetPrototype> datasetId) | ||
| { | ||
| var dataset = _proto.Index(datasetId); | ||
| var protoId = _random.Pick(dataset.Values); | ||
|
|
||
| if (_proto.TryIndex<EntityPrototype>(protoId, out var proto) && !string.IsNullOrEmpty(proto.Name)) | ||
| return Loc.GetString(proto.Name); | ||
|
|
||
| return protoId; | ||
| } | ||
|
|
||
| protected override void Started(EntityUid uid, WackyLawComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) | ||
| { | ||
| base.Started(uid, component, gameRule, args); | ||
|
|
||
| if (!TryGetRandomStation(out var station)) | ||
| return; | ||
| var lawEntry = _random.Pick(_proto.Index(component.LawsDataset).Values); | ||
| var lawParts = lawEntry.Split('|', 2); | ||
| var contentLoc = lawParts[0]; | ||
| var itemName = string.Empty; | ||
| if (lawParts.Length == 2 && _proto.TryIndex<DatasetPrototype>(lawParts[1], out _)) | ||
| itemName = PickRandomEntityName(lawParts[1]); | ||
|
|
||
| var departmentEntry = _random.Pick(_proto.Index(component.DepartmentDataset).Values); | ||
| var departmentText = GetDepartmentText(departmentEntry); | ||
| var content = Loc.GetString( | ||
| contentLoc, | ||
| ("station", MetaData(station.Value).EntityName), | ||
| ("item", itemName), | ||
| ("department", departmentText) | ||
| ); | ||
|
|
||
| var documentRelease = new FaxPrintout( | ||
| content, | ||
| "Указ Центрального Командования", | ||
| label: null, | ||
| prototypeId: "PaperOffice", | ||
| stampState: "paper_stamp-centcom", | ||
| stampedBy: new List<StampDisplayInfo> | ||
| { | ||
| new() | ||
| { | ||
| StampedName = Loc.GetString("stamp-component-stamped-name-centcom"), | ||
| StampedColor = Color.Green, | ||
| } | ||
| }, | ||
| locked: true | ||
| ); | ||
|
|
||
| var faxQuery = EntityQueryEnumerator<FaxMachineComponent>(); | ||
| while (faxQuery.MoveNext(out var faxUid, out var faxComp)) | ||
| { | ||
| if (!faxComp.ReceiveAllStationGoals && !(faxComp.ReceiveStationGoal && StationSystem.GetOwningStation(faxUid) == station.Value)) | ||
| continue; | ||
|
|
||
| _fax.Receive(faxUid, documentRelease, null, faxComp); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Locales must contain { $station}, { $item}, { $department} | ||
|
|
||
| station-event-wacky-law-announcement = Внимание, экипаж. Центральное Командование издало новый указ для вашей станции. Копия документа выслана на факс Капитана станции. Слава НТ. | ||
|
|
||
| wacky-law-paper-name = указ Центрального Командования | ||
|
|
||
| wacky-law-department-all = весь персонал станции | ||
|
|
||
| # compulsion to wear an item | ||
|
|
||
| wacky-law-content-force-item = ███░███░░░░██░░░░ | ||
| ░██░████░░░██░░░░ [head=3]Бланк документа[/head] | ||
| ░░█░██░██░░██░█░░ [head=3]НаноТрейзен[/head] | ||
| ░░░░██░░██░██░██░ [bold]ЦК-КОМ[/bold] | ||
| ░░░░██░░░████░ | ||
| ================================================[bold] | ||
| УКАЗ | ||
| ================================================[/bold] | ||
| Настоящим указом Центральное Командование ПРЕДПИСЫВАЕТ: | ||
| С момента получения документа сотрудники станции { $station } ОБЯЗАНЫ носить при себе следующий предмет: [bold]{ $item }[/bold]. | ||
| Данный указ распространяется на { $department } | ||
| Отсутствие указанного предмета при себе приравнивается к нарушению корпоративного законодательства и подлежит рассмотрению службой безопасности. | ||
| Контроль исполнения возлагается на капитана и службу безопасности станции. Указ вступает в силу немедленно. | ||
| Слава НаноТрейзен! | ||
| ================================================[italic] | ||
| Место для печати[/italic] | ||
|
|
||
| # Prohibition on Carrying an Item | ||
|
|
||
| wacky-law-content-ban-item = ███░███░░░░██░░░░ | ||
| ░██░████░░░██░░░░ [head=3]Бланк документа[/head] | ||
| ░░█░██░██░░██░█░░ [head=3]НаноТрейзен[/head] | ||
| ░░░░██░░██░██░██░ [bold]ЦК-КОМ[/bold] | ||
| ░░░░██░░░████░ | ||
| ================================================[bold] | ||
| УКАЗ | ||
| ================================================[/bold] | ||
| Настоящим указом Центральное Командование ЗАПРЕЩАЕТ: | ||
| С момента получения документа ношение, хранение и использование предмета [bold]{ $item }[/bold] на территории станции { $station } строго воспрещается. | ||
| Данный указ распространяется на { $department } | ||
| Все обнаруженные экземпляры подлежат изъятию службой безопасности и утилизации. | ||
| Контроль исполнения возлагается на капитана и службу безопасности станции. Указ вступает в силу немедленно. | ||
| Слава НаноТрейзен! | ||
| ================================================[italic] | ||
| Место для печати[/italic] | ||
|
|
||
| # semi-dry law (ban on alcohol at the bar) | ||
|
|
||
| wacky-law-content-half-prohibition = ███░███░░░░██░░░░ | ||
| ░██░████░░░██░░░░ [head=3]Бланк документа[/head] | ||
| ░░█░██░██░░██░█░░ [head=3]НаноТрейзен[/head] | ||
| ░░░░██░░██░██░██░ [bold]ЦК-КОМ[/bold] | ||
| ░░░░██░░░████░ | ||
| ================================================[bold] | ||
| УКАЗ | ||
| ================================================[/bold] | ||
| В рамках программы повышения трудоспособности экипажа Центральное Командование вводит ЧАСТИЧНЫЙ запрет: | ||
| Барменам воспрещается подавать сотрудникам { $department } { $item } | ||
| Нарушители подлежат взысканию по корпоративному законодательству. | ||
| Указ вступает в силу немедленно. | ||
| Слава НаноТрейзен! | ||
| ================================================[italic] | ||
| Место для печати[/italic] | ||
|
|
||
| # Prohibition | ||
|
|
||
| wacky-law-content-full-prohibition = ███░███░░░░██░░░░ | ||
| ░██░████░░░██░░░░ [head=3]Бланк документа[/head] | ||
| ░░█░██░██░░██░█░░ [head=3]НаноТрейзен[/head] | ||
| ░░░░██░░██░██░██░ [bold]ЦК-КОМ[/bold] | ||
| ░░░░██░░░████░ | ||
| ================================================[bold] | ||
| УКАЗ | ||
| ================================================[/bold] | ||
| В целях поддержания трудовой дисциплины Центральное Командование вводит СУХОЙ ЗАКОН: | ||
| С момента получения документа хранение, распитие, продажа и передача любых алкогольных напитков на территории станции { $station } строго запрещается до конца смены. | ||
| Бар и иные точки раздачи алкоголя подлежат чуткому надзору сил безопасности станции. | ||
| Нарушители задерживаются службой безопасности. Указ вступает в силу немедленно. | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| Слава НаноТрейзен! | ||
| ================================================[italic] | ||
| Место для печати[/italic] | ||
|
Comment on lines
+3
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Завершите локализацию события. Событие содержит только
As per coding guidelines: “Every player-facing string must be localized.” 📍 Affects 3 files
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # To add a new rule, you need to specify its locale from the FTL and the dataset that will be used. | ||
| # All of this needs to be specified in “ArcaneLaws”; if the law does not specify the use of any particular dataset, just leave the locale as is. | ||
| # To increase the hit rate, add it to the dataset again | ||
|
4Gebura marked this conversation as resolved.
|
||
|
|
||
| - type: dataset | ||
| id: ArcaneItem | ||
| values: | ||
| - ClothingUniformJumpsuitColorTeal | ||
| - ClothingSocksAssBlastUSAThigh | ||
| - ClothingHandsBDSMgloves | ||
| - ClothingJumpsuitBDSMress | ||
| - ClothingUniformJumpsuitTurtleneckWhite | ||
| - ClothingUniformJumpsuitColorWhite | ||
| - ClothingOuterHospitalGown | ||
| - ClothingHeadHatWitch | ||
| - ClothingUniformJumpskirtMaidLong | ||
| - ClothingOuterWinterRobo | ||
| - ClothingHandsGlovesCaptain | ||
| - ClothingUniformJumpsuitRoboticist | ||
| - ClothingUniformJumpsuitAviator | ||
| - ClothingCloakHOSRed | ||
| - ClothingShoesBootsWinterMed | ||
| - ClothingHandsGlovesNitrile | ||
| - ClothingEyesHudBeer | ||
| - ClothingSocksBeer | ||
| - ClothingUniformJumpskirtJanimaid | ||
| - ClothingBeltJanitor | ||
| - ClothingHandsGlovesJanitor | ||
| - ClothingHandsGlovesRobohands | ||
| - ClothingUniformJumpskirtMaidPink | ||
| - BlowPink | ||
| - BlowGreen | ||
| - BlowPurple | ||
| - PussyVulpaBlue | ||
| - PussyVulpaBlue | ||
| - OnaholeGreen | ||
| - SlimeDildo | ||
| - DogDildo | ||
| - ClothingWristsClockworkSlab | ||
| - ClothingNeckStoleChaplain | ||
| - ClothingSocksThinThigh | ||
| - ClothingShoesColorBlack | ||
| - ClothingSocksThigh | ||
| - ClothingSocksCandyCaneGreenThigh | ||
| - ClothingUnderwearPantiesCommie | ||
| - ClothingUnderwearPantiesFishnetLowerAlt | ||
|
|
||
| - type: dataset | ||
| id: ArcaneHalfProhibition | ||
| values: | ||
| - "Вермут" | ||
| - "Вино" | ||
| - "Виски" | ||
| - "Водка" | ||
| - "Джин" | ||
| - "Коньяк" | ||
| - "Кофейный ликёр" | ||
| - "Медовуха" | ||
| - "Пиво" | ||
| - "Ром" | ||
| - "Текила" | ||
| - "Эль" | ||
|
|
||
| - type: dataset | ||
| id: ArcaneDepartments | ||
| values: | ||
| - All | ||
| - Cargo | ||
| - Command | ||
| - Engineering | ||
| - Medical | ||
| - Science | ||
| - Security | ||
| - Service | ||
|
|
||
| - type: dataset | ||
| id: ArcaneLaws | ||
| values: | ||
| - "wacky-law-content-force-item|ArcaneItem" | ||
| - "wacky-law-content-ban-item|ArcaneItem" | ||
| - "wacky-law-content-half-prohibition|ArcaneHalfProhibition" | ||
| - "wacky-law-content-full-prohibition" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Подключите поля датасетов к исполнению или удалите их.
ItemDatasetиHalfProhibitionDatasetобъявлены как настраиваемые[DataField], ноWackyLawRule.Startedих не читает. Для законов с предметом и напитком система получаетArcaneItemиArcaneHalfProhibitionизArcaneLaws. Поэтому переопределение этих полей в прототипе игрового правила не действует.Выберите один контракт: передавайте эти поля в систему или удалите неиспользуемые поля.
Контракт сверен с
WackyLawRule.StartedиResources/Prototypes/_Arcane/Datasets/Events/wackylaw.yml.🤖 Prompt for AI Agents