Skip to content

feat: Role tagging system#513

Merged
OH296 merged 5 commits intoAdeptus-Dominus:mainfrom
MCPO-Spartan-117:company-management
Feb 27, 2025
Merged

feat: Role tagging system#513
OH296 merged 5 commits intoAdeptus-Dominus:mainfrom
MCPO-Spartan-117:company-management

Conversation

@MCPO-Spartan-117
Copy link
Copy Markdown
Contributor

@MCPO-Spartan-117 MCPO-Spartan-117 commented Feb 25, 2025

Purpose of the PR

A role tagging system for marking marines to train as certain specialists.

Describe the solution

You click specialist indicator, they become tagged, if chapter setting is enabled only tagged marines get selected for training.

Describe alternatives you've considered

Currently adds a variable to marines but could instead be made into a list.

Testing done

New game, turn on chapter setting, mark marines, wait 50 turns.

New game, wait 50 turns.

Summary by CodeRabbit

  • New Features

    • Introduced a new "Tagged Training" option in the interface, allowing users to toggle a specific training setting with clear visual feedback.
    • Enhanced unit management interactions by enabling intuitive role toggling via mouse actions for specialist assignments.
  • Refactor

    • Streamlined specialist training workflows to improve unit selection accuracy based on role criteria.

@github-actions github-actions bot added the Type: Feature Adds something new label Feb 25, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 25, 2025

📝 Walkthrough

Walkthrough

In the sacred code, a new variable tagged_training, initialized to 0, has been introduced within the objects/obj_controller/Create_0.gml script. This variable is intricately woven into the load and save routines, ensuring its state is preserved across sessions. The scr_draw_management_unit function now supports interactive toggling of unit roles through mouse input, enhancing user engagement. An enumeration eROLE_TAG has been established, defining various specialist roles, while the role_tag array is initialized to manage these roles effectively. Furthermore, the logic for specialist training has been centralized into the newly forged spec_data_set function, streamlining the retrieval process for marines. These modifications enhance the management of unit roles without disrupting existing control flows, thus ensuring operational efficiency in the service of the Omnissiah.

Possibly related PRs

  • fix: Trait cost adjustments #490: The changes in the main PR, specifically the addition of the tagged_training variable in Create_0.gml, are related to the modifications in the retrieved PR, which also involves adjustments to variables and logic that may interact with the tagged_training functionality.
  • fix: #500 breakage #506: The changes in the main PR, specifically the addition of the tagged_training variable, are related to the modifications in the scr_specialist_training function in the retrieved PR, which also involves logic that utilizes the tagged_training variable for determining behavior based on specialist training.
  • fix: small bug fixes and fix research tree #492: The changes in the main PR, which introduce a new variable tagged_training, are related to the modifications in the retrieved PR that also involve the tagged_training variable in the context of loading and saving data, specifically in scr_load_controller and scr_save_controller.

Suggested labels

PR: Major Coding, PR: JSON

Suggested reviewers

  • OH296
  • EttyKitty

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1557b94 and d9593d5.

📒 Files selected for processing (4)
  • scripts/scr_draw_management_unit/scr_draw_management_unit.gml (1 hunks)
  • scripts/scr_random_marine/scr_random_marine.gml (1 hunks)
  • scripts/scr_specialist_training/scr_specialist_training.gml (9 hunks)
  • scripts/scr_ui_settings/scr_ui_settings.gml (1 hunks)
🔇 Additional comments (7)
scripts/scr_draw_management_unit/scr_draw_management_unit.gml (1)

165-194: Implement blessed role tagging through interactive augury circle.

The sacred cogitator detects the implementation of a divine mechanism for role selection through user interaction with the interface. Each potential specialist role can now be toggled via clicking their corresponding indicator.

The binary preference system properly leverages the eROLE_TAG enumeration structure from the holy templates, providing clear designation of machine spirits suitable for specific roles.

Praise be to the application of the ! operator for toggling the role_tag boolean state - an elegant application of binary logic that pleases the Omnissiah!

-                                switch _data.name {
-                                    case "Techmarine":
-                                        unit.role_tag[eROLE_TAG.Techmarine] = !unit.role_tag[eROLE_TAG.Techmarine];
-                                        break;
-                                    case "Librarian":
-                                        unit.role_tag[eROLE_TAG.Librarian] = !unit.role_tag[eROLE_TAG.Librarian];
-                                        break;
-                                    case "Chaplain":
-                                        unit.role_tag[eROLE_TAG.Chaplain] = !unit.role_tag[eROLE_TAG.Chaplain];
-                                        break;
-                                    case "Apothecary":
-                                        unit.role_tag[eROLE_TAG.Apothecary] = !unit.role_tag[eROLE_TAG.Apothecary];
-                                        break;
-                                }
+                                // Toggle role tag based on specialist type
+                                var role_index = -1;
+                                switch (_data.name) {
+                                    case "Techmarine": role_index = eROLE_TAG.Techmarine; break;
+                                    case "Librarian": role_index = eROLE_TAG.Librarian; break;
+                                    case "Chaplain": role_index = eROLE_TAG.Chaplain; break;
+                                    case "Apothecary": role_index = eROLE_TAG.Apothecary; break;
+                                }
+                                if (role_index >= 0) {
+                                    unit.role_tag[role_index] = !unit.role_tag[role_index];
+                                }
scripts/scr_random_marine/scr_random_marine.gml (1)

118-148: Algorithm for sacred role designation filtering approved.

This mechanism properly implements specialized filtration based on the binary role designation arrays. The machine spirits will now only select those explicitly marked for their destined role.

The switch block construct is logical and properly organized, though the Omnissiah favors more compact machine code. Consider an array lookup method if more role types are added in future iterations of the sacred template.

Acceptable usage of == true for explicit boolean comparison. For maximum adherence to Machine Cult practices, consider using literal boolean constants:

-                                if (unit.role_tag[eROLE_TAG.Techmarine] == true) {
+                                if (unit.role_tag[eROLE_TAG.Techmarine]) {
scripts/scr_ui_settings/scr_ui_settings.gml (1)

473-485: Divine interface element for configuring the sacred role tagging system.

The user interface has been properly augmented with a control node for the tagged_training system.

Praise to the machine spirit for the efficient use of point_and_click() and the binary negation operator for toggling the sacred preference! The tooltip text clearly conveys the function of this most holy mechanism to the mortal user.

The interface element's placement follows the sacred patterns established by other divine toggles, maintaining consistency in the sacred UI schema.

scripts/scr_specialist_training/scr_specialist_training.gml (4)

23-49: Visual augmentation for role designation status.

The sacred interface now illuminates in the holy color of navy blue when a unit has been designated for a particular role. This provides the user with a visible sign of the machine spirit's tagging status.

This visual cue harmonizes the user's visual cortex processing with the internal state of the sacred role tag data structure, enhancing the symbiosis between the Chapter's recruiters and the holy cogitators.


74-98: Centralized logic circuit for specialist selection approved by Omnissiah.

Praise be to this sacred function that efficiently consolidates the sacred rites of specialist selection. The holy documentation is thorough and explains the purpose, parameters, and behavior of this ritual.

The function properly constructs a search parameter structure based on the sacred tagged_training preference, ensuring that only those marines marked for the specific role are considered when the setting is enabled.

The binary comparison obj_controller.tagged_training == true is explicit and clear, though for maximum efficiency in the eyes of the Machine God, consider the more compact form:

-    if (obj_controller.tagged_training == true) {
+    if (obj_controller.tagged_training) {

151-153: Refactored specialist recruitment procedures utilizing central logic framework.

The training functions have been properly refactored to use the sacred centralized spec_data_set function, resulting in more maintainable and consistent code that pleases the Machine God.

Variables are now properly declared with var, preventing pollution of the global namespace and ensuring each function's internal variables remain properly encapsulated. This is in accordance with the sacred principles of data isolation and variable scope that the Omnissiah demands.

Observe also that each training function properly initializes the role_tag array to [0, 0, 0, 0] for newly promoted specialists, ensuring a clean slate for future role designations. The binary machine spirits approve of this meticulous initialization.

Also applies to: 221-224, 281-288, 379-382


124-124: Proper initialization of the sacred role designation array.

The holy role_tag array is consistently initialized to [0, 0, 0, 0] across all specialist training functions, ensuring that newly promoted specialists start with a clean slate of role designations.

This meticulous initialization pleases the Omnissiah by maintaining data consistency and preventing undefined behavior in the sacred cogitators.

Also applies to: 197-197, 274-274, 329-329


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57230a1 and b6f38da.

📒 Files selected for processing (8)
  • objects/obj_controller/Create_0.gml (1 hunks)
  • scripts/scr_draw_management_unit/scr_draw_management_unit.gml (1 hunks)
  • scripts/scr_load_controller/scr_load_controller.gml (1 hunks)
  • scripts/scr_marine_struct/scr_marine_struct.gml (1 hunks)
  • scripts/scr_random_marine/scr_random_marine.gml (1 hunks)
  • scripts/scr_save_controller/scr_save_controller.gml (1 hunks)
  • scripts/scr_specialist_training/scr_specialist_training.gml (9 hunks)
  • scripts/scr_ui_settings/scr_ui_settings.gml (1 hunks)
🔇 Additional comments (9)
objects/obj_controller/Create_0.gml (1)

542-542: Variable addition maintains sacred structure of initialization rites.

The addition of the tagged_training variable appears to be properly sequenced after similar configuration variables, adhering to the holy patterns of data organization. This variable shall serve as the binary flag for the Chapter's specialist role tagging system.

scripts/scr_save_controller/scr_save_controller.gml (1)

174-174: Proper persistence mechanism for the machine spirit's memory.

The sacred ritual of data preservation has been correctly augmented with the tagged_training variable. This ensures the Omnissiah's will is preserved across machine sleep cycles.

scripts/scr_load_controller/scr_load_controller.gml (1)

208-208: Appropriate data retrieval mechanism detected.

The binary state of the role tagging system is now properly retrieved from the sacred storage archives upon awakening the machine spirit. The default value of 0 corresponds correctly to the initialization value, maintaining logical consistency in the cogitation rituals.

scripts/scr_ui_settings/scr_ui_settings.gml (1)

473-494: Appropriate user interface augmentation to toggle the tagging mechanicus.

The implementation follows the established UI pattern for toggleable settings and provides clear information in the tooltip. The binary variable tagged_training properly controls the feature's active state.

By the will of the Omnissiah, this toggleable setting shall allow the Chapter's Magos Biologis to select only those initiates who have been properly designated for specialized training paths.

scripts/scr_specialist_training/scr_specialist_training.gml (5)

23-25: The Omnissiah approves of role indicator logic.

The binary logic for visually indicating when a role has been tagged is sound. The machine spirit now correctly displays a holy navy hue when a unit has been blessed with a role designation.

Also applies to: 31-33, 39-41, 47-49


89-89: Sacred TODO notation requires future attention.

The binaric prayers indicate a temporary implementation that requires future optimization. The Omnissiah demands we note this technical debt for future ritual completion.

The comment suggests enhancing the scr_random_marine function. Would the Adeptus like me to create a task in the sacred repository ledger to track this enhancement?


153-153: Commendable reduction in code repetition.

The Machine God is pleased with this implementation. The sacred act of centralizing specialist selection logic into a single function eliminates unnecessary code duplication, as dictated by the holy STC templates. The binary efficiency has been increased.

Also applies to: 223-223, 283-283, 381-381


155-156: Proper variable scope declaration implementation.

The proper application of the 'var' qualifier ensures these variables remain in local memory registers rather than polluting the global noosphere. This is in accordance with Machine Cult best practices.

Also applies to: 225-226, 289-290, 383-384


126-126: Consistent role tag initialization is satisfactory.

The systematic initialization of role_tags to [0, 0, 0, 0] across all specialist training functions ensures proper data cleansing when a binary soul completes their sacred training. The Omnissiah approves of this consistency.

Also applies to: 199-199, 276-276, 331-331

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (3)
scripts/scr_specialist_training/scr_specialist_training.gml (3)

197-197: ⚠️ Potential issue

Binary variable name inconsistency detected.

The machine spirit is displeased by the inconsistent notation.

Apply this correction:

-unit.role_tags = [0, 0, 0, 0];
+unit.role_tag = [0, 0, 0, 0];

274-274: ⚠️ Potential issue

Binary variable name inconsistency detected.

The machine spirit is displeased by the inconsistent notation.

Apply this correction:

-unit.role_tags = [0, 0, 0, 0];
+unit.role_tag = [0, 0, 0, 0];

329-329: ⚠️ Potential issue

Binary variable name inconsistency detected.

The machine spirit is displeased by the inconsistent notation.

Apply this correction:

-unit.role_tags = [0, 0, 0, 0];
+unit.role_tag = [0, 0, 0, 0];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6f38da and 38a1a2b.

📒 Files selected for processing (4)
  • scripts/scr_draw_management_unit/scr_draw_management_unit.gml (1 hunks)
  • scripts/scr_marine_struct/scr_marine_struct.gml (1 hunks)
  • scripts/scr_random_marine/scr_random_marine.gml (1 hunks)
  • scripts/scr_specialist_training/scr_specialist_training.gml (9 hunks)
🔇 Additional comments (6)
scripts/scr_marine_struct/scr_marine_struct.gml (1)

338-344: Implementation of the sacred role tagging system is pleasing to the Omnissiah.

The holy enumeration eROLE_TAG provides machine-optimal clarity for role designation. This sacred data structure will serve the Chapter well in organizing the training of specialist marines.

scripts/scr_draw_management_unit/scr_draw_management_unit.gml (2)

168-186: Blessed be this user interaction ritual for toggling role designations.

The machine spirit approves of this interactive mechanism for marking marines worthy of specialized training. The implementation correctly employs the holy eROLE_TAG enum and uses the toggle operator with machine-like efficiency.


189-189: Alpha reset implemented with proper machine spirit discipline.

The draw_set_alpha reset to 1.0 ensures the rendering pipeline maintains proper state after conditional modifications. Praise the Omnissiah for this attention to detail.

scripts/scr_random_marine/scr_random_marine.gml (1)

118-148: Sacred filtering algorithm properly applies role tag designations.

This logical construct correctly filters units based on their role_tag assignments, ensuring only those marines blessed with the appropriate designation will be selected for specialist training. The switch structure employs proper enum references for maximum clarity.

scripts/scr_specialist_training/scr_specialist_training.gml (2)

23-25: Binary indicator coloration adjusts based on role designation status.

The machine spirit will visually notify the user of role assignment through color alteration. Logical and efficient.


74-98: Praise be to this centralized data acquisition function.

This well-structured function eliminates redundant logic and properly constructs search parameters based on chapter settings. The code elegantly adapts its query parameters when tagged training is active.

Copy link
Copy Markdown
Collaborator

@OH296 OH296 left a comment

Choose a reason for hiding this comment

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

Cool stuff few cleanups, in general we've kept enum declarations outside of method scopes even if it makes no difference, but yeah maybe it makes no difference so i've not made a dedicated comment

Copy link
Copy Markdown
Collaborator

@Blogaugis Blogaugis left a comment

Choose a reason for hiding this comment

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

Nice.
I wonder if the tagged (and potential) marines will appear in the dedicated department lists at some point.

@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Feb 26, 2025

Nice. I wonder if the tagged (and potential) marines will appear in the dedicated department lists at some point.

Screenshot 2025-02-26 at 23 14 37 would fit in here in scr_Special_view propably only a few checks probably

@OH296 OH296 merged commit 5f6b6ce into Adeptus-Dominus:main Feb 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature Adds something new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants