Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Trait cost adjustments #490

Merged
merged 1 commit into from
Feb 18, 2025
Merged

Conversation

KRdaMystic
Copy link
Contributor

@KRdaMystic KRdaMystic commented Feb 18, 2025

Description of changes

  • Adjust prices and effects to be more uniform for "Enemy:" traits and specialist traits as well as changing some meta data

Reasons for changes

  • Adjust the cost to actual value of chapter traits

How have you tested your changes?

  • Compile
  • New game
  • Next turn
  • Space Travel
  • Ground Battle

Adjust prices and effects to be more uniform for "Enemy:" traits and specialist traits
Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

📝 Walkthrough

Walkthrough

The changes update gameplay parameters by modifying the properties of certain advantages and disadvantages along with adjustments to the unit initialization logic. Specific numeric values for attributes associated with enemy advantages and thematic disadvantages have been revised, and some metadata arrays have been updated. Additionally, the script responsible for custom initialization now alters the adjustments applied to unit counts such as techmarines, tenth, codiciery, chaplains, and apothecary based on these advantages and disadvantages. These modifications collectively recalibrate the character attributes and faction unit configurations without altering the overall structure of the system.


🪧 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.

@github-actions github-actions bot added the PR: Fix This is a fix for a bug label Feb 18, 2025
@EttyKitty
Copy link
Collaborator

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Feb 18, 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
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: 0

🧹 Nitpick comments (4)
scripts/scr_initialize_custom/scr_initialize_custom.gml (4)

865-970: Standardized trait adjustments improve balance.

The trait adjustments have been standardized to consistently use +/-5 for specialist/tenth company trade-offs, making the system more balanced and predictable. This change helps ensure that the cost of chapter traits better reflects their actual value.

Consider documenting these standardized values in a configuration file or constants to make future balancing easier to maintain.


3292-3380: Enhance helper function robustness.

While the unit initialization helper is well-structured, it could benefit from:

  1. Input validation for critical parameters
  2. Extraction of Librarian power initialization into a separate function
  3. More explicit documentation of the default parameter behavior

Consider this refactor:

 function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1="default", wep2="default", gear="default", mobi="default", armour="default"){
+    // Validate inputs
+    if (!is_string(ttrpg_name) || !is_real(company) || !is_real(slot) || !is_string(role_name) || !is_real(role_id)) {
+        throw("Invalid parameters provided to add_unit_to_company");
+    }
+    
     // ... existing initialization code ...
     
-    if(role_id == eROLE.Librarian){
-        var let = "";
-        if (obj_creation.discipline = "default") {
-            let = "D";
-        }
-        // ... more librarian initialization ...
-    }
+    if(role_id == eROLE.Librarian){
+        initialize_librarian_powers(company, slot);
+    }
 }
+
+function initialize_librarian_powers(company, slot) {
+    var let = "";
+    if (obj_creation.discipline = "default") {
+        let = "D";
+    }
+    // ... rest of librarian initialization ...
+}

3271-3286: Improve vehicle initialization flexibility.

The vehicle initialization function could be more robust and configurable:

  1. It lacks input validation
  2. Contains hardcoded values that could be configurable
  3. Is tightly coupled to the obj_ini object

Consider this enhancement:

+// Define vehicle constants
+#macro DEFAULT_VEHICLE_HP 100
+#macro DEFAULT_VEHICLE_CHAOS 0
+#macro DEFAULT_VEHICLE_PILOTS 0
+#macro DEFAULT_VEHICLE_LID -1
+#macro DEFAULT_VEHICLE_WID 2

-function add_veh_to_company(name, company, slot, wep1, wep2, wep3, upgrade, accessory) {
+function add_veh_to_company(name, company, slot, wep1, wep2, wep3, upgrade, accessory, config = {}) {
+    // Validate inputs
+    if (!is_string(name) || !is_real(company) || !is_real(slot)) {
+        throw("Invalid parameters provided to add_veh_to_company");
+    }
+    
     obj_ini.veh_race[company, slot] = 1;
     obj_ini.veh_loc[company, slot] = obj_ini.home_name;
     obj_ini.veh_role[company, slot] = name;
     obj_ini.veh_wep1[company, slot] = wep1;
     obj_ini.veh_wep2[company, slot] = wep2;
     obj_ini.veh_wep3[company, slot] = wep3;
     obj_ini.veh_upgrade[company, slot] = upgrade;
     obj_ini.veh_acc[company, slot] = accessory;
-    obj_ini.veh_hp[company, slot] = 100;
-    obj_ini.veh_chaos[company, slot] = 0;
-    obj_ini.veh_pilots[company, slot] = 0;
-    obj_ini.veh_lid[company, slot] = -1;
-    obj_ini.veh_wid[company, slot] = 2;
+    obj_ini.veh_hp[company, slot] = config[? "hp"] ?? DEFAULT_VEHICLE_HP;
+    obj_ini.veh_chaos[company, slot] = config[? "chaos"] ?? DEFAULT_VEHICLE_CHAOS;
+    obj_ini.veh_pilots[company, slot] = config[? "pilots"] ?? DEFAULT_VEHICLE_PILOTS;
+    obj_ini.veh_lid[company, slot] = config[? "lid"] ?? DEFAULT_VEHICLE_LID;
+    obj_ini.veh_wid[company, slot] = config[? "wid"] ?? DEFAULT_VEHICLE_WID;
 }

3383-3402: Enhance struct cloning robustness and performance.

The DeepCloneStruct function could benefit from:

  1. Error handling for circular references
  2. Performance optimization for large structures
  3. Type validation

Consider this enhancement:

+/// @description Creates a deep copy of a struct or array, with circular reference detection
+/// @param {Struct|Array} clone_struct The structure to clone
+/// @returns {Struct|Array} A deep copy of the input
 function DeepCloneStruct(clone_struct) {
+    static seen = ds_map_create();
+    
+    // Handle circular references
+    if (is_struct(clone_struct) || is_array(clone_struct)) {
+        var ref_id = string(ptr(clone_struct));
+        if (ds_map_exists(seen, ref_id)) {
+            throw("Circular reference detected in DeepCloneStruct");
+        }
+        ds_map_add(seen, ref_id, true);
+    }
+    
     if (is_array(clone_struct)) {
         var len = array_length(clone_struct);
         var arr = array_create(len);
         for (var i = 0; i < len; ++i) {
             arr[i] = DeepCloneStruct(clone_struct[i]);
         }
+        ds_map_delete(seen, string(ptr(clone_struct)));
         return arr;
     } else if (is_struct(clone_struct)) {
         var stc = {};
         var nms = variable_struct_get_names(clone_struct);
         var len = array_length(nms);
         for (var i = 0; i < len; ++i) {
             var nm = nms[i];
             stc[$nm] = DeepCloneStruct(clone_struct[$nm]);
         }
+        ds_map_delete(seen, string(ptr(clone_struct)));
         return stc;
     }
+    
+    // Validate primitive types
+    if (!is_real(clone_struct) && !is_string(clone_struct) && !is_bool(clone_struct) && clone_struct != undefined) {
+        throw("Unsupported type in DeepCloneStruct");
+    }
     return clone_struct;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e84320b and efc2da3.

📒 Files selected for processing (2)
  • objects/obj_creation/Create_0.gml (4 hunks)
  • scripts/scr_initialize_custom/scr_initialize_custom.gml (3 hunks)
🔇 Additional comments (2)
objects/obj_creation/Create_0.gml (2)

665-665: LGTM! Standardizing enemy trait costs improves balance.

The standardization of all "Enemy:" trait values to 20 points creates a more balanced and intuitive system, as the combat bonus against different enemy types should have equivalent value.

Also applies to: 671-671, 677-677, 683-683


720-720: LGTM! Improved trait metadata and cost adjustments.

The changes improve the trait system by:

  1. Using more specific metadata tags (e.g., "Librarians" instead of "Specialists")
  2. Adjusting the "Reverent Guardians" cost to better reflect its value

Also applies to: 726-727, 732-732

@EttyKitty
Copy link
Collaborator

@KRdaMystic, can't really comment on the balancing stuff and still don't understand what's the point of meta stuff.

I'll check optional comments that coderabbit left and merge.

@OH296
Copy link
Collaborator

OH296 commented Feb 18, 2025

@KRdaMystic, can't really comment on the balancing stuff and still don't understand what's the point of meta stuff.

I'll check optional comments that coderabbit left and merge.

metat stuff just stops you being able to take two contradictory things. e.g you can't have two things marked with the same meta tag like psyker intolerant and psyker abundance. Stops annoying checks down the line

@OH296
Copy link
Collaborator

OH296 commented Feb 18, 2025

comments are ouside of scope of pr therefore will merge

@OH296 OH296 closed this Feb 18, 2025
@OH296 OH296 reopened this Feb 18, 2025
@OH296 OH296 merged commit 1bee20b into Adeptus-Dominus:main Feb 18, 2025
6 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Feb 18, 2025
5 tasks
@KRdaMystic KRdaMystic mentioned this pull request Feb 19, 2025
5 tasks
@EttyKitty EttyKitty added the PR: Backport Needs to be backported to stable label Feb 21, 2025
@KRdaMystic KRdaMystic deleted the adv_tweaks-6 branch February 22, 2025 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Backport Needs to be backported to stable PR: Fix This is a fix for a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants