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

Refactored Required Lances Calculation Logic #5351

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

IllianiCBT
Copy link
Collaborator

Earlier in this dev cycle we added 'required lance variance'. Essentially, the number of required lances could vary from 25% to 175% of the available lances (capped at 1, or available lances). However, the likelihood that a player would have 75% spare forces just lying about is effectively zero in most cases; causing required lances to hit their force cap more often than intended.

We now calculate Required Lances thus:

  1. Calculate the number of lances (or regional equivalent) the player can muster, based on combat units in their TO&E and campaign faction. This is referred to as 'available forces' in this PR write-up.
  2. Calculate the maximum number of forces the player can field, based on campaign commander strategy (if this option is enabled in campaign options).
  3. Roll 2d6 and consult the following table:
Roll / Divider
  2 = 4.5
  3 = 4
  4 = 3.5
5-9 = 3
 10 = 2.5
 11 = 2
 12 = 1.5
  1. Subtract that value from available forces the result of available forces divided by the divider rolled.
  2. Required Lances is equal to available forces, with a minimum of 1.

Bug Fix
Finally, previously we did not check whether 'use commander strategy' was enabled in Campaign Options when determining maximum lance count. This means that campaigns with that option disabled were still affected by its' settings. This PR corrects that.

A note on purpose
Recently there has been a general push towards harder contracts, with increased scenario count and players being increasingly forced to make difficult decisions. Furthermore, we're starting to encourage players to have more comprehensive TO&E. These two factors combined mean we don't want to be in a situation where the only way a player has to pick less intense contracts is to either hope they get a low Skull contract; or by removing units from their TO&E.

The changes in this PR mean contracts will offer a variety of intensities with not every contract requiring the player dedicate their entire TO&E to the effort. This, combined with FG3's Skulls rating system, means players are in a far better position to cherry pick contracts based on the needs of their campaign at that time.

Improved the method for calculating required lances by adding variance handling through a helper function. Replaced hardcoded roll adjustments with a switch-case structure for clarity and introduced randomized variance using `randomInt`. Refactoring ensures better readability, maintainability, and consistency in variance calculations.
Simplified the calculation of available forces and variance during contract generation, removing unnecessary methods and streamlining the workflow. Replaced redundant `Math.min` and `Math.abs` uses with more concise implementations. These changes improve clarity, maintainability, and adhere to modern coding conventions.
Updated the variance factor values in the contract force calculation to improve balance and align with gameplay goals. This change modifies the outcomes for specific roll values, making the distribution more gradual and consistent.
@IllianiCBT IllianiCBT added Bug UX User experience labels Dec 13, 2024
@IllianiCBT IllianiCBT self-assigned this Dec 13, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.46%. Comparing base (7ddb24c) to head (7c15751).
Report is 37 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5351      +/-   ##
============================================
- Coverage     10.47%   10.46%   -0.01%     
+ Complexity     6069     6062       -7     
============================================
  Files           959      959              
  Lines        135559   135593      +34     
  Branches      19750    19749       -1     
============================================
- Hits          14204    14195       -9     
- Misses       119997   120043      +46     
+ Partials       1358     1355       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug UX User experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants