Skip to content

feat: Specialist assignment buttons for companies and a refactor#648

Merged
EttyKitty merged 23 commits intoAdeptus-Dominus:mainfrom
Frost-bit-jpg:company-roles-assignment
Apr 1, 2025
Merged

feat: Specialist assignment buttons for companies and a refactor#648
EttyKitty merged 23 commits intoAdeptus-Dominus:mainfrom
Frost-bit-jpg:company-roles-assignment

Conversation

@Frost-bit-jpg
Copy link
Copy Markdown
Contributor

@Frost-bit-jpg Frost-bit-jpg commented Mar 29, 2025

Purpose of changes

  • Removes the need to use transfer to assign support command.

Describe the solution

  • Specialists can now be selected with the same buttons as captains and other command squad marines.
  • special_role_slot_open function.
  • Refactor role_groups and is_specialist functions.

Describe alternatives you've considered

None

Testing done

Loading executing marines then reassigning the roles.
Assigning on empty companies.
Reading on attack and raid tooltip/

Related links

None

Custom player notes entry

Use the PR title.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Enhanced specialist role functionality with additional options for flexibility.
    • Expanded unit roles by introducing new positions for chaplain, apothecary, techmarine, and librarian.
    • Added new promotion paths for specialised roles and improved UI prompts for assigning vacant roles.
  • Refactor

    • Standardised role labels for improved consistency in role detection and unit management.
    • Refined internal role checks and calculations to enhance overall gameplay.

Walkthrough

Hail, brethren of the Omnissiah! This pull request brings forth refinements to the role management apparatus within the code, introducing new parameters—include_trainee and include_heads—to the role_groups and is_specialist functions. The updated functions now allow conditional inclusion of trainee and head roles, and references to specialist roles have been standardised from the plural "libs" to the singular "lib". In addition, the constructor of the CompanyStruct has been enhanced with four new role properties (chaplain, apothecary, tech_marine, and lib) to better allocate unit responsibilities. Promotion logic in task selection and UI rendering have been extended to handle these added roles, including the introduction of a dedicated function, special_role_slot_open, to streamline role selection processes. Various scripts have undergone minimal adjustments to align with this updated role nomenclature and function signatures.

Possibly related issues

Possibly related PRs


🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@github-actions github-actions bot added Size: Medium Type: Feature Adds something new labels Mar 29, 2025
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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b851492 and 46e94d8.

📒 Files selected for processing (4)
  • scripts/is_specialist/is_specialist.gml (1 hunks)
  • scripts/scr_company_struct/scr_company_struct.gml (2 hunks)
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml (2 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.gml`: Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ga...

**/*.gml: Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
`**/*.gml`: Color codes in the code shouldn't have any spaces in their id. I.e., color code `# 80 bf40` will crash the game.

**/*.gml: Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.

  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
🔇 Additional comments (5)
scripts/is_specialist/is_specialist.gml (1)

193-216: Functioning logic added for new specialist candidate types.

By the Omnissiah's grace, this code extension follows an efficient pattern of the existing logic architecture. New specialist candidate types have been appropriately categorized and initialized in accordance with the Machine God's patterns. The special case check for "Iron Hands" is a logical adaptation to accommodate the sacred chapter's unique requirements.

01001101 01100001 01111001 00100000 01110100 01101000 01100101 00100000 01001111 01101101 01101110 01101001 01110011 01110011 01101001 01100001 01101000 00100000 01100001 01110000 01110000 01110010 01101111 01110110 01100101

scripts/scr_company_struct/scr_company_struct.gml (2)

148-151: Data structure expansion for new unit roles.

The binary cogitators have been augmented with new data storage variables. These additional properties follow the STC template of the existing architecture. Praise be to the Omnissiah for such consistent data structuring.


185-196: Logic implemented for role assignment processing.

The sacred algorithms that populate company data structures have been extended with binary precision. Each new specialist role is accurately extracted from the company units through proper classification checks. This implementation follows the Machine Cult's doctrine of consistent pattern recognition.

scripts/scr_ui_manage/scr_ui_manage.gml (2)

658-661: New tracking variables for specialist roles.

The blessed cogitator variables have been added to monitor the presence of Chaplain, Apothecary, Tech Marine, and Librarian roles within the company data structure. These additions maintain binary harmony with the existing variable patterns.


664-664: Logical condition expansion for specialist role checks.

The sacred conditional operator has been appropriately augmented to include the verification of new specialist roles. This modification extends the binary logic to trigger appropriate UI responses when these positions are unfilled.

@Blogaugis
Copy link
Copy Markdown
Collaborator

Chaplains not included?

@Frost-bit-jpg
Copy link
Copy Markdown
Contributor Author

They are i simply forgot to put them in title

@EttyKitty EttyKitty changed the title feat: Roles assignment for Tech marine, Apothecary, Librarian across companies. feat: Specialist selection for company command squads Mar 29, 2025
@EttyKitty EttyKitty changed the title feat: Specialist selection for company command squads feat: Specialist assignments for company command squads Mar 29, 2025
OH296
OH296 previously approved these changes Mar 29, 2025
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.

Ok looking good some of this needs rationalising as it's looking a bit spaghettish but i can handle that

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 29, 2025
@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Mar 30, 2025

made a pr to your branch Frost-bit-jpg#3 with some minor tweaks

@Frost-bit-jpg Frost-bit-jpg dismissed stale reviews from OH296 and coderabbitai[bot] via 9b5dcd7 March 31, 2025 23:24
@github-actions github-actions bot added the Area: Sprites Changes to sprites/images or their under-the-hood functionality label Mar 31, 2025
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 46e94d8 and 9b5dcd7.

📒 Files selected for processing (7)
  • scripts/is_specialist/is_specialist.gml (4 hunks)
  • scripts/scr_company_struct/scr_company_struct.gml (2 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (2 hunks)
  • sprites/spr_scout_colors/spr_scout_colors.yy (1 hunks)
  • sprites/spr_scout_complex/spr_scout_complex.yy (1 hunks)
  • sprites/spr_scout_heads/spr_scout_heads.yy (1 hunks)
  • sprites/spr_scout_new/spr_scout_new.yy (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_company_struct/scr_company_struct.gml
`**/*.gml`: - Always suggest adding JSDoc to every function and method that doesn't have it.

**/*.gml: - Always suggest adding JSDoc to every function and method that doesn't have it.

  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_company_struct/scr_company_struct.gml
`**/*.gml`: - Readability and maintainability are always the top priority throughout the code. - DRY principle is also very important.

**/*.gml: - Readability and maintainability are always the top priority throughout the code.

  • DRY principle is also very important.
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_company_struct/scr_company_struct.gml
🔇 Additional comments (7)
sprites/spr_scout_heads/spr_scout_heads.yy (1)

67-68: Dimensions added to sequence data structure - The Omnissiah approves.

The addition of precise dimensional parameters to the sequence data structure represents a logical enhancement. The Machine Spirit now possesses explicit knowledge of its dimensional boundaries, with height at 232.0 and width at 167.0 units. This standardization across sprite configurations will promote harmony in the visual protocols.

Praise be to the Omnissiah for this consistent implementation of dimensional parameters.

sprites/spr_scout_colors/spr_scout_colors.yy (1)

77-78: Sequence dimensional parameters added - Binary blessing confirmed.

The sacred incantation of dimensional parameters has been correctly applied to this visual asset. The sequence object now contains the sanctified values of seqHeight (232.0) and seqWidth (167.0), maintaining consistency with other sprite configurations in this repository.

This standardization of dimensional parameters across multiple sprite assets indicates proper adherence to the sacred STC templates. The Machine Spirit will be pleased with this uniformity.

sprites/spr_scout_new/spr_scout_new.yy (1)

74-75: Dimensional parameters added to sequence - Mechanicum standardization protocol enforced.

The addition of the precise dimensional parameters to this sprite configuration aligns with the modifications observed in the other sprite assets. This systematic implementation of seqHeight (232.0) and seqWidth (167.0) demonstrates adherence to standardized rendering protocols.

By the will of the Omnissiah, these consistent dimensional parameters shall ensure proper visual representation across all sprite assets. The pattern recognition satisfies the Machine God.

sprites/spr_scout_complex/spr_scout_complex.yy (1)

66-67: Sequence dimensional parameters added - Blessed standardization complete.

The sacred dimensions have been added to the final sprite configuration, completing the pattern of modifications across all sprite assets. The addition of seqHeight (232.0) and seqWidth (167.0) maintains the holy consistency required by the Omnissiah.

This systematic implementation of dimensional parameters across all sprite configurations represents a logical and efficient approach to sprite management. The Machine Spirit shall now correctly interpret the dimensional boundaries of all these visual assets.

01010000 01110010 01100001 01101001 01110011 01100101 00100000 01110100 01101000 01100101 00100000 01001111 01101101 01101110 01101001 01110011 01110011 01101001 01100001 01101000

scripts/is_specialist/is_specialist.gml (1)

140-142: Binary logic pathways for hierarchy inclusion implemented.

The conditional blocks for including head roles in various specialist types follow a consistent pattern, appropriately guarded by the new include_heads parameter. This maintains proper separation of concerns in the code's sacred architecture.

Also applies to: 149-151, 163-165, 177-179

scripts/scr_ui_manage/scr_ui_manage.gml (2)

682-686: Additional role tracking variables established.

The Omnissiah approves of these logical extensions to track the presence of Chaplain, Apothecary, Tech Marine, and Librarian roles, following the established pattern of existing role tracking variables.


688-688: Condition expanded to check for all sacred specialist roles.

The updated condition now correctly includes checks for all specialist roles, ensuring proper activation of role selection prompts when any specialist role is missing.

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

🔭 Outside diff range comments (1)
scripts/is_specialist/is_specialist.gml (1)

221-285: 🛠️ Refactor suggestion

Expand the collect_role_group function's documentation to reflect its divine purpose.

This complex function lacks proper documentation to explain its operation, especially with the new parameter usage in the IsSpecialist call.

Adorn this function with the sacred JSDoc inscriptions to improve future maintenance:

+/**
+ * Collects units that match specified role groups and conditions.
+ * @param {string|array} group - The role group to filter by, or "all" to ignore filtering. Can also be an array to filter for multiple groups.
+ * @param {string|array} location - The location to filter by. Can be a string with a system name or an array [location_name, planet_number, ship_number].
+ * @param {boolean} opposite - If true, roles defined in the group argument are ignored and all others are collected.
+ * @param {object} search_conditions - Additional conditions for filtering.
+ * @param {string|array} search_conditions.companies - The companies to search in, either an int or an array of company numbers, or "all".
+ * @param {array} [search_conditions.stat] - Stat conditions to filter by.
+ * @param {string} [search_conditions.job] - Job to filter by.
+ * @param {number} [search_conditions.max] - Maximum number of units to collect.
+ * @return {array} An array of units that match the specified conditions.
+ */
 function collect_role_group(group="standard", location="", opposite=false, search_conditions = {companies:"all"}){
♻️ Duplicate comments (1)
scripts/is_specialist/is_specialist.gml (1)

100-100: 🛠️ Refactor suggestion

By the Omnissiah's decree, document the sacred parameters for posterity.

The function signature has been expanded with include_heads, a parameter of machine logic that would benefit from proper documentation. The Machine Spirit demands clarity in all inputs to facilitate future maintenance and divine understanding.

Adorn this function with the sacred JSDoc inscriptions as follows:

+/**
+ * Determines if a unit role is considered a specialist of a given type.
+ * @param {string} unit_role - The role to check
+ * @param {string} [type="standard"] - The specialist group to check against
+ * @param {boolean} [include_trainee=false] - Whether to include trainee roles
+ * @param {boolean} [include_heads=true] - Whether to include head roles like "Chief Librarian"
+ * @return {boolean} True if the unit_role is a specialist of the specified type
+ */
 function is_specialist(unit_role, type="standard", include_trainee=false, include_heads=true) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9b5dcd7 and c6c3e52.

📒 Files selected for processing (1)
  • scripts/is_specialist/is_specialist.gml (4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • scripts/is_specialist/is_specialist.gml
`**/*.gml`: - Always suggest adding JSDoc to every function and method that doesn't have it.

**/*.gml: - Always suggest adding JSDoc to every function and method that doesn't have it.

  • scripts/is_specialist/is_specialist.gml
`**/*.gml`: - Readability and maintainability are always the top priority throughout the code. - DRY principle is also very important.

**/*.gml: - Readability and maintainability are always the top priority throughout the code.

  • DRY principle is also very important.
  • scripts/is_specialist/is_specialist.gml
🔇 Additional comments (4)
scripts/is_specialist/is_specialist.gml (4)

149-151: Binary logic structure approved for Forge Master inclusion.

The conditional inclusion of the "Forge Master" role based on the include_heads parameter is a logical extension of the function's new capability.


163-165: Conditional inclusion of Master of Sanctity follows proper protocol.

The implementation correctly appends the "Master of Sanctity" role to the specialists array when include_heads is true, as required by the parameter's purpose.


177-179: The Apothecarion's Master enters the data array with sacred precision.

The implementation correctly appends the "Master of the Apothecarion" role to the specialists array when include_heads is true.


257-257:

Details

✅ Verification successful

Verify the group index parameters for proper data transmission.

The call to unit.IsSpecialist has been updated to pass group[2] as the third parameter. Previous review comments indicated uncertainty about the appropriate index, suggesting group[3] might be more appropriate.

The machine spirits require clarity on the structure of the group array to ensure proper data transmission. Execute the following binary search to identify the correct usage pattern:

Additionally, consider adding a comment documenting the structure of the group array and the purpose of each index:

-					_is_special_group = unit.IsSpecialist(group[0], group[1],group[2]);
+					// group structure: [type, subtype, include_heads]
+					_is_special_group = unit.IsSpecialist(group[0], group[1], group[2]);

🏁 Script executed:

#!/bin/bash
# Analyze how group array is constructed and used throughout the codebase

echo "Searching for group array construction and initialization..."
rg -A 5 "group\s*=\s*\[" --glob "*.gml"

echo "\nSearching for IsSpecialist function definitions to understand parameter usage..."
rg "function\s+IsSpecialist" --glob "*.gml" -A 10

echo "\nSearching for all IsSpecialist calls to understand parameter patterns..."
rg "IsSpecialist\(" --glob "*.gml" -A 2 -B 2

Length of output: 22421


Group Array Structure Verification Satisfied
After a thorough scan of the sacred code, it is confirmed that the group array is indeed structured as [type, subtype, include_heads]. The call to unit.IsSpecialist(group[0], group[1], group[2]) faithfully adheres to this structure, and there is no evidence suggesting that an index of group[3] should be used.

For the clarity of future servitors and fellow Tech-Priests, please consider appending an inline comment to document the array’s structure. A suitable diff snippet is provided below:

-					_is_special_group = unit.IsSpecialist(group[0], group[1],group[2]);
+					// group structure: [type, subtype, include_heads]
+					_is_special_group = unit.IsSpecialist(group[0], group[1], group[2]);

May the blessings of the Omnissiah guide your code maintenance.

@EttyKitty
Copy link
Copy Markdown
Collaborator

I couldn't understand what is going on with the is_specialist and why half of it looks broken, so I've refactored it a little.
Also fixed a bunch of weird formatting and indent issues.
Frost-bit-jpg#4

@EttyKitty EttyKitty force-pushed the company-roles-assignment branch from 36b27aa to c209065 Compare April 1, 2025 18:09
@github-actions github-actions bot removed the Area: Sprites Changes to sprites/images or their under-the-hood functionality label Apr 1, 2025
@EttyKitty
Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 8

🔭 Outside diff range comments (5)
scripts/scr_draw_unit_image/scr_draw_unit_image.gml (5)

95-96: 🧹 Nitpick (assertive)

Documentation ritual required for preserving knowledge

By the Binary Doctrines, this commented TODO requires attention. Functions should be documented with JSDoc to preserve knowledge for future tech-adepts.

-//TODO this is a laxy fix and can be written better
+/**
+ * Sets the color for a specific shader type using the given color index.
+ * TODO: This is a temporary solution and can be implemented more efficiently.
+ *
+ * @param {ShaderType} shaderType - The type of shader to set the color for.
+ * @param {number} colorIndex - The index of the color to use.
+ */
 function set_shader_color(shaderType, colorIndex) {

196-197: 🧹 Nitpick (assertive)

Add sacred JSDoc annotation to function

The function scr_draw_unit_image lacks proper JSDoc documentation. The Omnissiah demands structured documentation for all functions to maintain the sanctity of code knowledge.

 /// @mixin
+/**
+ * Draws a unit image with the appropriate colors, equipment, and specializations.
+ * 
+ * @param {boolean} [_background=false] - Whether to draw a background behind the unit image.
+ * @returns {UnitImage} - A constructed UnitImage object containing the rendered unit.
+ */
 function scr_draw_unit_image(_background = false) {

55-57: 🧹 Nitpick (assertive)

Add JSDoc to UnitImage constructor

The UnitImage constructor requires proper documentation according to the Machine Cult's standards for code clarity and maintenance.

+/**
+ * Creates a new UnitImage object that manages the rendering of a unit sprite.
+ * 
+ * @constructor
+ * @param {sprite} unit_surface - The surface containing the rendered unit.
+ */
 function UnitImage(unit_surface) constructor {
     u_surface = unit_surface;

89-93: 🧹 Nitpick (assertive)

Add JSDoc to BaseColor constructor

The BaseColor constructor requires blessed documentation to facilitate understanding by future tech-adepts.

+/**
+ * Creates a new BaseColor object that holds RGB color values.
+ * 
+ * @constructor
+ * @param {number} R - Red component value (0-255).
+ * @param {number} G - Green component value (0-255).
+ * @param {number} B - Blue component value (0-255).
+ */
 function BaseColor(R, G, B) constructor {
     r = R;
     g = G;
     b = B;
 }

48-53: 🧹 Nitpick (assertive)

Add JSDoc to set_and_clear_surface function

This utility function lacks the sacred documentation required by the Omnissiah's coding doctrines.

+/**
+ * Sets a surface as the target, clears it, resets the target and frees the surface.
+ * 
+ * @param {surface} _surface - The surface to set, clear, and free.
+ */
 function set_and_clear_surface(_surface) {
     surface_set_target(_surface);
     draw_clear_alpha(c_white, 0);
     surface_reset_target();
     surface_free(_surface);
 }
♻️ Duplicate comments (3)
scripts/scr_company_struct/scr_company_struct.gml (2)

148-151: 🧹 Nitpick (assertive)

Sacred binary augmentations to the Company Struct detected.

The Omnissiah approves of these logical extensions to the CompanyStruct constructor. The addition of chaplain, apothecary, tech_marine, and lib properties follows the established pattern of the existing captain, champion, and ancient roles. This promotes symmetry in the Machine Spirit's cognition matrices.

Consider blessing these properties with sacred JSDoc documentation to facilitate proper knowledge transfer to future adepts:

+/** @type {Struct|String} Chaplain unit assigned to the company or "none" if unassigned */
 chaplain = "none";
+/** @type {Struct|String} Apothecary unit assigned to the company or "none" if unassigned */
 apothecary = "none";
+/** @type {Struct|String} Tech Marine unit assigned to the company or "none" if unassigned */
 tech_marine = "none";
+/** @type {Struct|String} Librarian unit assigned to the company or "none" if unassigned */
 lib = "none";

184-192: 🧹 Nitpick (assertive)

Logic pathways for specialist role identification implemented according to the Mechanicus doctrine.

The conditional blocks correctly identify and assign units to their respective specialist roles within the company structure, properly extending the existing role identification system to include the sacred roles of the Chaplain, Apothecary, Techmarine, and Librarian.

The whitespace formatting in these conditional blocks is inconsistent with the prior code blocks. The Machine Spirit craves uniformity in all things:

-  else if (unit.role() == role_set[eROLE.Chaplain]){
+  } else if (unit.role() == role_set[eROLE.Chaplain]){
 	chaplain = unit;
-}else if (unit.role() == role_set[eROLE.Apothecary]){
+  } else if (unit.role() == role_set[eROLE.Apothecary]){
 	apothecary = unit;
 }
-  else if (unit.role() == role_set[eROLE.Techmarine]){
+  } else if (unit.role() == role_set[eROLE.Techmarine]){
 	tech_marine = unit;
 }
-  else if (unit.role() == role_set[eROLE.Librarian]){
+  } else if (unit.role() == role_set[eROLE.Librarian]){
 	lib = unit;
 }
scripts/scr_manage_task_selector/scr_manage_task_selector.gml (1)

86-106: 🛠️ Refactor suggestion

Implementation of Chaplain promotion logics

The sacred algorithms for promoting a unit to the esteemed rank of Chaplain have been implemented following the established pattern. The ritual of transferring the unit, clearing its squad assignment, and reorganizing company records has been properly executed.

This servant of the Omnissiah observes excessive code duplication across all specialist promotion cases. Consider consolidating these sacred rites into a reusable function:

+ function promote_specialist(unit_index, end_company) {
+     var unit = display_unit[unit_index];
+     unit.squad = "none";
+     var start_company = unit.company;
+     var endslot = 0;
+     for (var i=0; i<array_length(obj_ini.name[end_company]); i++) {
+         if (obj_ini.name[end_company][i] == "") {
+             endslot = i;
+             break;
+         }
+     }
+     scr_move_unit_info(start_company, end_company, unit.marine_number, endslot);
+     with (obj_ini) {
+         scr_company_order(start_company);
+         scr_company_order(end_company);
+     }
+     managing = end_company;
+     update_general_manage_view();
+ }

Then invoke it thusly:

case "chaplain_promote":
-   unit = display_unit[i];
-   unit.squad="none";
-   var start_company = unit.company;
-   var end_company = selection_data.system;
-   var endslot = 0;
-   for (i=0; i<array_length(obj_ini.name[end_company]); i++) {
-       if (obj_ini.name[end_company][i]=="") {
-           endslot=i;
-           break;
-       }
-   }
-   scr_move_unit_info(start_company, end_company, unit.marine_number, endslot);
-   with (obj_ini) {
-       scr_company_order(start_company);
-       scr_company_order(end_company);
-   }
-   managing = end_company;
-   update_general_manage_view();
+   promote_specialist(i, selection_data.system);
    exit;
    break;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c6c3e52 and d27a58f.

📒 Files selected for processing (15)
  • objects/obj_popup/Draw_0.gml (1 hunks)
  • scripts/exp_and_exp_growth/exp_and_exp_growth.gml (2 hunks)
  • scripts/is_specialist/is_specialist.gml (2 hunks)
  • scripts/scr_company_struct/scr_company_struct.gml (2 hunks)
  • scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml (1 hunks)
  • scripts/scr_culture_visuals/scr_culture_visuals.gml (3 hunks)
  • scripts/scr_draw_unit_image/scr_draw_unit_image.gml (1 hunks)
  • scripts/scr_drop_fiddle/scr_drop_fiddle.gml (2 hunks)
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml (2 hunks)
  • scripts/scr_marine_struct/scr_marine_struct.gml (4 hunks)
  • scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml (1 hunks)
  • scripts/scr_random_marine/scr_random_marine.gml (1 hunks)
  • scripts/scr_roster/scr_roster.gml (1 hunks)
  • scripts/scr_special_view/scr_special_view.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • scripts/scr_draw_unit_image/scr_draw_unit_image.gml
  • scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml
  • scripts/scr_drop_fiddle/scr_drop_fiddle.gml
  • scripts/scr_roster/scr_roster.gml
  • scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml
  • scripts/exp_and_exp_growth/exp_and_exp_growth.gml
  • scripts/scr_random_marine/scr_random_marine.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
  • objects/obj_popup/Draw_0.gml
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/scr_culture_visuals/scr_culture_visuals.gml
  • scripts/scr_marine_struct/scr_marine_struct.gml
  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
`**/*.gml`: - Always suggest adding JSDoc to every function and method that doesn't have it.

**/*.gml: - Always suggest adding JSDoc to every function and method that doesn't have it.

  • scripts/scr_draw_unit_image/scr_draw_unit_image.gml
  • scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml
  • scripts/scr_drop_fiddle/scr_drop_fiddle.gml
  • scripts/scr_roster/scr_roster.gml
  • scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml
  • scripts/exp_and_exp_growth/exp_and_exp_growth.gml
  • scripts/scr_random_marine/scr_random_marine.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
  • objects/obj_popup/Draw_0.gml
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/scr_culture_visuals/scr_culture_visuals.gml
  • scripts/scr_marine_struct/scr_marine_struct.gml
  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
`**/*.gml`: - Readability and maintainability are always the top priority throughout the code. - DRY principle is also very important.

**/*.gml: - Readability and maintainability are always the top priority throughout the code.

  • DRY principle is also very important.
  • scripts/scr_draw_unit_image/scr_draw_unit_image.gml
  • scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml
  • scripts/scr_drop_fiddle/scr_drop_fiddle.gml
  • scripts/scr_roster/scr_roster.gml
  • scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml
  • scripts/exp_and_exp_growth/exp_and_exp_growth.gml
  • scripts/scr_random_marine/scr_random_marine.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
  • objects/obj_popup/Draw_0.gml
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/scr_culture_visuals/scr_culture_visuals.gml
  • scripts/scr_marine_struct/scr_marine_struct.gml
  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
🔇 Additional comments (29)
objects/obj_popup/Draw_0.gml (1)

1575-1575: Binary cogitation: String standardization improves logic clarity

The mutation from "libs" to "lib" in this commented code section aligns with the omniscient machine-spirit's directive to standardize specialist role nomenclature across the sacred codebase. Such consistency pleases the Omnissiah.

scripts/scr_roster/scr_roster.gml (1)

546-546: Praise the standardization of specialist identification parameters

The logical parameter alteration from "libs" to "lib" in the IsSpecialist function invocation properly aligns with the sacred codebase standardization. This modification maintains ritual consistency with other alterations throughout the machine-spirit's domain.

scripts/scr_player_combat_weapon_stacks/scr_player_combat_weapon_stacks.gml (1)

176-176: Binary blessing: Parameter standardization completed successfully

The transition from "libs" to "lib" in this IsSpecialist function invocation completes the ritual of standardization across the codebase. The Machine God approves of such consistent nomenclature alterations, ensuring the cogitator processes librarian specialist identification with mechanized precision.

scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml (1)

414-414: Praise to the Omnissiah for consistent nomenclature

The sacred strings of code have been wisely amended from "libs" to "lib" when identifying the Librarian specialist role in the is_specialist() function call. This aligns with the standardization of terminology across the codebase, ensuring the machine spirit processes queries with greater efficiency. Such consistency is the foundation of proper data sanctification.

scripts/scr_drop_fiddle/scr_drop_fiddle.gml (2)

54-54: Blessed be this binary correction

The sacred parameter has been modified from "libs" to "lib" for the IsSpecialist() function call. This ensures consistent interpretation of the Librarian role throughout the machine spirit of the application, facilitating proper identification and enumeration of psykers in the loading process.


122-122: The Omnissiah approves of this symmetrical amendment

The modification from "libs" to "lib" in this IsSpecialist() invocation ensures proper decrementing of psykers when removing marines from the drop roster. The sacred symmetry with the increment operation at line 54 has been maintained, as dictated by the proper rituals of code maintenance.

scripts/scr_draw_unit_image/scr_draw_unit_image.gml (1)

350-350: Binary blessing upon this nomenclature harmonization

The parameter has been correctly modified from "libs" to "lib" in the is_specialist() function call. This alteration maintains consistency with similar changes across the sacred codebase and ensures proper identification of Librarian specialists.

The Machine God approves of such systematic standardization, as it reduces cognitive load on both the machine spirit and the human operators who maintain this holy code.

scripts/exp_and_exp_growth/exp_and_exp_growth.gml (2)

93-93: Blessed correction of datatype designation for Librarians detected.

The Omnissiah's servants have updated the reference from "libs" to "lib" in the group_growths array, which aligns with other modifications observed in this sacred technical protocol update. This binary alteration maintains consistency with other files where similar terminological standardizations have been implemented.


261-263: Conditional logic realignment for Librarian classification complete.

The condition now correctly utilizes the singular nomenclature "lib" rather than the plural "libs" when checking for specialist designation. This ensures harmony with the Mechanicus-approved standardization implemented across multiple script files.

scripts/scr_special_view/scr_special_view.gml (1)

69-69: Function parameter alignment with new STC patterns detected.

The parameter array passed to collect_role_group has been properly updated from ["libs",true] to ["lib",true], bringing it into compliance with the standardized nomenclature for Librarians implemented throughout this sacred code revision. The logic flow remains unaltered, maintaining the machine spirit's intended functionality.

scripts/scr_culture_visuals/scr_culture_visuals.gml (3)

318-318: Visual identifier designation corrected for Librarian iconography.

The role_type array for the spr_gear_librarian sprite has been updated from ["libs"] to ["lib"], ensuring consistent nomenclature across all Librarian-related code structures. Praise the Omnissiah for this logical correction.


324-324: Terminator-pattern Librarian visual identifier standardized.

The role_type array for spr_gear_librarian_term has been updated to use ["lib"] instead of ["libs"], maintaining binary consistency with other Librarian-related modifications in this sacred update.


548-548: Psychic hood identifier corrected in accordance with Machine God's will.

The role_type array for spr_gear_hood2 has been properly updated from ["libs"] to ["lib"], completing the trio of Librarian visual component standardizations.

scripts/scr_marine_struct/scr_marine_struct.gml (4)

506-508: Function signature expansion enhances specialist role handling

The Machine Spirit's interface has been modified to accommodate a new parameter include_heads with a default value of true. This logical extension grants greater flexibility in filtering specialist roles, aligning with the binary sacred will of the Omnissiah.


469-471: Nomenclature standardization from "libs" to "lib"

The sacred binary has been aligned to use the singular form "lib" instead of "libs" when identifying Librarians. This rectifies the inconsistent terminology across the codebase, satisfying the Omnissiah's desire for logical consistency.


977-979: Consistent designation update for Librarian specialists

The designation has been standardized to "lib" here as well, maintaining the prescribed nomenclature across all invocations. The Machine Spirit approves of such consistency.


1683-1684: Final instance of librarian designation standardization

The third occurrence of the terminology standardization from "libs" to "lib". This mechanical consistency enhances the clarity of the code and prevents potential logical errors in the future.

scripts/scr_manage_task_selector/scr_manage_task_selector.gml (3)

107-127: Implementation of Apothecary promotion logics

The ritual for promoting units to the blessed role of Apothecary has been properly implemented. This code follows the established pattern identical to other specialist promotions.

The recommendation to refactor specialist promotion code also applies to this segment.


128-148: Implementation of Tech Marine promotion logics

The Machine Spirit approves of the implementation for Tech Marine promotions, a role most venerated by the Omnissiah. The code follows the sacred pattern established for other specialist roles.

The recommendation to refactor specialist promotion code also applies to this segment.


149-169: Implementation of Librarian promotion logics

The binary incantations for elevating a unit to the psychically attuned rank of Librarian have been properly implemented. The Machine Spirit recognizes this follows the pattern of other specialist promotions.

The recommendation to refactor specialist promotion code also applies to this segment.

scripts/scr_ui_manage/scr_ui_manage.gml (9)

682-685: Variables introduced with consistency.
These declarations for chaplain, apothecary, tech marine, and librarian slots are functionally straightforward and appear coherent.


688-688: Conditional logic deemed acceptable.
The condition verifying whether a company’s specialist slots are filled is clear and aligns with the designated property checks.


703-718: Identical duplication identified.
The champion assignment code replicates the same pattern we have already flagged.


722-736: Identical duplication identified.
The ancient assignment block again reiterates the same code structure.


737-751: Identical duplication identified.
The chaplain slot code likewise resonates with the repeated pattern.


752-766: Identical duplication identified.
The apothecary slot logic remains consistent with the aforementioned repeated pattern.


767-781: Identical duplication identified.
The tech marine pledge is also a reiteration of the same approach.


782-795: Identical duplication identified.
The librarian assignment logic follows the same repeated code pattern.


798-798: Empty line detected.
No functional changes present.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 1, 2025
@EttyKitty
Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 4

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d27a58f and f98592f.

📒 Files selected for processing (3)
  • scripts/is_specialist/is_specialist.gml (2 hunks)
  • scripts/scr_company_struct/scr_company_struct.gml (2 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/is_specialist/is_specialist.gml
`**/*.gml`: - Always suggest adding JSDoc to every function and method that doesn't have it.

**/*.gml: - Always suggest adding JSDoc to every function and method that doesn't have it.

  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/is_specialist/is_specialist.gml
`**/*.gml`: - Readability and maintainability are always the top priority throughout the code. - DRY principle is also very important.

**/*.gml: - Readability and maintainability are always the top priority throughout the code.

  • DRY principle is also very important.
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/is_specialist/is_specialist.gml
🔇 Additional comments (4)
scripts/scr_ui_manage/scr_ui_manage.gml (2)

690-693: Slot naming consistency.

Thou hast introduced chaplain_slot, apothecary_slot, tech_marine_slot, and lib_slot, setting them to booleans. The naming is consistent with the other _slot variables. This appears correct for determining if these roles remain vacant. No immediate issues detected.


696-804: Repetitive slot checks mirror prior code suggestions.

The approach of confirming each vacant role and invoking special_role_slot_open is sound. Yet, it repeats the pattern for each role individually, echoing a known tapestry from previous reviews that recommended a data-table loop. This comment replicates that guidance.

scripts/is_specialist/is_specialist.gml (2)

6-168: Streamline role definitions.

All hail the mechanised fervour of enumerating roles within role_groups. Still, the repetitious and branched structure begs for a data-driven approach, as previously explored. Doing so might lighten your logic burden and foster ease of expansion.


170-174: New function parameters are well-structured.

The expansion of is_specialist to include include_trainee and include_heads suits the flexible identification of specialists. This is a righteous extension, aligning with the role groups. No unholy anomalies found.

@EttyKitty EttyKitty changed the title feat: Specialist assignments for company command squads feat: Specialist assignment buttons for companies and a refactor Apr 1, 2025
@EttyKitty EttyKitty added Type: Refactor Rewriting/restructuring code, while keeping general behavior Category: QoL A quality of life Improvement labels Apr 1, 2025
@EttyKitty EttyKitty merged commit 55102c5 into Adeptus-Dominus:main Apr 1, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: QoL A quality of life Improvement Size: Big Type: Feature Adds something new Type: Refactor Rewriting/restructuring code, while keeping general behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants