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

Decoupled Dependents from AtB, Reworked Dependents, Reworked New Personnel Ages, Added Documentation #4463

Merged
merged 35 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a17878c
Updated getAgeByExpLevel method in Utilities
IllianiCBT Jul 22, 2024
c33ff82
Refactored tech level switch and string append
IllianiCBT Jul 22, 2024
eea5866
Removed RandomDependentMethod and added assign recruit rank option
IllianiCBT Jul 22, 2024
a097001
Removed useAssignRecruitRank from campaign options
IllianiCBT Jul 22, 2024
32a5da9
Removed RandomDependentMethodTest.java
IllianiCBT Jul 22, 2024
955cc99
Refactored dependent addition and removal process
IllianiCBT Jul 22, 2024
a300a11
Updated dependent removal and addition in Campaign
IllianiCBT Jul 22, 2024
8dfb3e3
Updated documentation drawing dependents into the existing prisoners …
IllianiCBT Jul 22, 2024
b00254a
Refactored and rearranged dependent management code in Campaign.java
IllianiCBT Jul 22, 2024
96bd9a9
Updated documentation
IllianiCBT Jul 22, 2024
02cb255
Refined dependent removal process in Campaign class
IllianiCBT Jul 22, 2024
db050c6
Removed recruit rank assignment and adjusted dependent calculation
IllianiCBT Jul 22, 2024
a1775f0
Removed recruit rank assignment and adjusted dependent calculation
IllianiCBT Jul 22, 2024
a8f5077
Updated base age and experience level calculations
IllianiCBT Jul 22, 2024
301c0e0
Removed dirty edits
IllianiCBT Jul 22, 2024
fc61640
Merge branch 'refs/heads/master' into dependentsRework
IllianiCBT Jul 26, 2024
97a9beb
Merge branch 'refs/heads/master' into dependentsRework
IllianiCBT Jul 26, 2024
3821d0c
Merge remote-tracking branch 'origin/dependentsRework' into dependent…
IllianiCBT Jul 26, 2024
6b7b60e
Merge branch 'refs/heads/master' into dependentsRework
IllianiCBT Jul 31, 2024
e4ac8e5
Merge branch 'master' into dependentsRework
IllianiCBT Aug 2, 2024
17ff7c9
Merge branch 'master' into dependentsRework
IllianiCBT Aug 7, 2024
6c1db8b
Merge branch 'refs/heads/master' into dependentsRework
IllianiCBT Aug 19, 2024
0698766
Merge branch 'refs/heads/master' into dependentsRework
IllianiCBT Sep 17, 2024
3baf55d
Merged changes from master
IllianiCBT Sep 17, 2024
ef7b884
Merge branch 'refs/heads/master' into dependentsRework
IllianiCBT Sep 17, 2024
414d9ec
Update copyright years and improve code readability
IllianiCBT Sep 17, 2024
fafe88a
Update copyright years and improve code readability
IllianiCBT Sep 17, 2024
3f3cacb
Merge remote-tracking branch 'origin/dependentsRework' into dependent…
IllianiCBT Sep 17, 2024
83a80c5
Refactor `processRandomDependents` method in `Campaign.java`
IllianiCBT Sep 17, 2024
2ad6e3c
Merge branch 'MegaMek:master' into dependentsRework
IllianiCBT Sep 17, 2024
e173f88
Merge remote-tracking branch 'origin/master'
IllianiCBT Sep 25, 2024
098a6bc
Merge branch 'refs/heads/master' into dependentsRework
IllianiCBT Sep 25, 2024
79b8d6b
Merge remote-tracking branch 'origin/dependentsRework' into dependent…
IllianiCBT Sep 26, 2024
0857b74
Merge branch 'refs/heads/master' into dependentsRework
IllianiCBT Sep 26, 2024
caef4d9
merge conflicts
IllianiCBT Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@
<prisonerBabyStatus>true</prisonerBabyStatus>
<useAtBPrisonerDefection>false</useAtBPrisonerDefection>
<useAtBPrisonerRansom>false</useAtBPrisonerRansom>
<randomDependentMethod>NONE</randomDependentMethod>
<useRandomDependentAddition>true</useRandomDependentAddition>
<useRandomDependentRemoval>true</useRandomDependentRemoval>
<useRandomDependentAddition>false</useRandomDependentAddition>
<useRandomDependentRemoval>false</useRandomDependentRemoval>
<usePersonnelRemoval>true</usePersonnelRemoval>
<useRemovalExemptCemetery>true</useRemovalExemptCemetery>
<useRemovalExemptRetirees>true</useRemovalExemptRetirees>
Expand Down
5 changes: 2 additions & 3 deletions MekHQ/mmconf/campaignPresets/Campaign Operations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@
<prisonerBabyStatus>true</prisonerBabyStatus>
<useAtBPrisonerDefection>false</useAtBPrisonerDefection>
<useAtBPrisonerRansom>false</useAtBPrisonerRansom>
<randomDependentMethod>NONE</randomDependentMethod>
<useRandomDependentAddition>true</useRandomDependentAddition>
<useRandomDependentRemoval>true</useRandomDependentRemoval>
<useRandomDependentAddition>false</useRandomDependentAddition>
<useRandomDependentRemoval>false</useRandomDependentRemoval>
<usePersonnelRemoval>true</usePersonnelRemoval>
<useRemovalExemptCemetery>true</useRemovalExemptCemetery>
<useRemovalExemptRetirees>true</useRemovalExemptRetirees>
Expand Down
1 change: 0 additions & 1 deletion MekHQ/mmconf/campaignPresets/Complete Experience.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@
<prisonerBabyStatus>true</prisonerBabyStatus>
<useAtBPrisonerDefection>true</useAtBPrisonerDefection>
<useAtBPrisonerRansom>true</useAtBPrisonerRansom>
<randomDependentMethod>AGAINST_THE_BOT</randomDependentMethod>
<useRandomDependentAddition>true</useRandomDependentAddition>
<useRandomDependentRemoval>true</useRandomDependentRemoval>
<usePersonnelRemoval>true</usePersonnelRemoval>
Expand Down
5 changes: 2 additions & 3 deletions MekHQ/mmconf/campaignPresets/New Pilot Program.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@
<prisonerBabyStatus>true</prisonerBabyStatus>
<useAtBPrisonerDefection>true</useAtBPrisonerDefection>
<useAtBPrisonerRansom>true</useAtBPrisonerRansom>
<randomDependentMethod>NONE</randomDependentMethod>
<useRandomDependentAddition>true</useRandomDependentAddition>
<useRandomDependentRemoval>true</useRandomDependentRemoval>
<useRandomDependentAddition>false</useRandomDependentAddition>
<useRandomDependentRemoval>false</useRandomDependentRemoval>
<usePersonnelRemoval>true</usePersonnelRemoval>
<useRemovalExemptCemetery>true</useRemovalExemptCemetery>
<useRemovalExemptRetirees>true</useRemovalExemptRetirees>
Expand Down
5 changes: 2 additions & 3 deletions MekHQ/mmconf/campaignPresets/Tabula Rasa.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@
<prisonerBabyStatus>true</prisonerBabyStatus>
<useAtBPrisonerDefection>false</useAtBPrisonerDefection>
<useAtBPrisonerRansom>false</useAtBPrisonerRansom>
<randomDependentMethod>NONE</randomDependentMethod>
<useRandomDependentAddition>true</useRandomDependentAddition>
<useRandomDependentRemoval>true</useRandomDependentRemoval>
<useRandomDependentAddition>false</useRandomDependentAddition>
<useRandomDependentRemoval>false</useRandomDependentRemoval>
<usePersonnelRemoval>true</usePersonnelRemoval>
<useRemovalExemptCemetery>true</useRemovalExemptCemetery>
<useRemovalExemptRetirees>true</useRemovalExemptRetirees>
Expand Down
4 changes: 2 additions & 2 deletions MekHQ/resources/mekhq/resources/Campaign.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ turnoverPersonnelKilled.text=<html>You have personnel who have left the unit or
divorce.text=%s has divorced %s.

#### Unsorted Campaign Resources
dependentLeavesForce.text=%s is no longer travelling with the force, and is thus no longer dependent on it.
dependentJoinsForce.text=%s has started traveling with the force, and is now dependent on it.
dependentLeavesForce.text=%s is no longer travelling with the force.
dependentJoinsForce.text=%s has started traveling with the force.
relativeJoinsForce.text=%s, %s's %s, has started traveling with the force, and is now dependent on it.
relativeJoinsForceSpouse.text=spouse
relativeJoinsForceChild.text=child
Expand Down
10 changes: 3 additions & 7 deletions MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,11 @@ lblFatigueLeaveThreshold.toolTipText=<html>Automatically assign personnel to Lea

# Dependent
dependentPanel.title=Dependents (Unofficial)
dependentPanel.toolTipText=Warning: This is a temporary setup, and is very much subject to changes including removing functionality if deemed necessary.
randomDependentPanel.title=Random Dependents (AtB Only)
randomDependentPanel.toolTipText=Warning: This is a temporary setup, and is very much subject to changes including removing functionality if deemed necessary.
lblRandomDependentMethod.text=Random Dependents Method
lblRandomDependentMethod.toolTipText=This is the method used to determine if a dependent is randomly added or removed from the force.
dependentPanel.toolTipText=These options concern the random addition or removal of dependents from the campaign.
chkUseRandomDependentAddition.text=Use Random Dependent Addition
chkUseRandomDependentAddition.toolTipText=This enables the random additions of dependents to the Force.
chkUseRandomDependentAddition.toolTipText=This enables the monthly addition of random dependents to the campaign.
chkUseRandomDependentRemoval.text=Use Random Dependent Removal
chkUseRandomDependentRemoval.toolTipText=This enables the random removal of dependents from the Force.
chkUseRandomDependentRemoval.toolTipText=This enables the monthly removal of dependents from the campaign.

# Personnel Removal
personnelRemovalPanel.title=Personnel Clean Up
Expand Down
82 changes: 42 additions & 40 deletions MekHQ/src/mekhq/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,6 @@
*/
package mekhq;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Consumer;

import javax.swing.JTable;
import javax.swing.table.TableModel;

import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.w3c.dom.Node;

import megamek.client.Client;
import megamek.client.generator.RandomNameGenerator;
import megamek.codeUtilities.MathUtility;
Expand All @@ -63,6 +42,21 @@
import mekhq.campaign.unit.CrewType;
import mekhq.campaign.unit.Unit;
import mekhq.campaign.unit.UnitTechProgression;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.w3c.dom.Node;

import javax.swing.*;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Consumer;

public class Utilities {
private static final MMLogger logger = MMLogger.create(Utilities.class);
Expand Down Expand Up @@ -839,37 +833,45 @@ public static boolean rollProbability(int prob) {
return Compute.randomInt(100) <= prob;
}

/**
* Calculates the age of a character based on their experience level and clan status.
*
* @param expLevel the experience level of the character represented by an integer value.
* @param clan a boolean value indicating whether the character is a clan character.
* @return the age of the character calculated based on the provided expLevel and clan.
*/
public static int getAgeByExpLevel(int expLevel, boolean clan) {
int baseAge = 19;
int nDice = 1;
switch (expLevel) {
case SkillType.EXP_REGULAR:
nDice = 2;
break;
case SkillType.EXP_VETERAN:
nDice = 3;
break;
case SkillType.EXP_ELITE:
nDice = 4;
break;
default:
break;
}
int baseAge = 18;

int nDice = switch (expLevel) {
case SkillType.EXP_NONE -> 7;
case SkillType.EXP_GREEN -> 1;
case SkillType.EXP_REGULAR -> 2;
case SkillType.EXP_VETERAN -> 4;
case SkillType.EXP_ELITE -> 8;
default -> 0;
};

int age = baseAge;
while (nDice > 0) {
int roll = Compute.d6();
// reroll all sixes once

for (int i = 0; i < nDice; i++) {
int roll = Compute.d6(1);

if (roll == 6) {
roll += (Compute.d6() - 1);
}

if (clan) {
roll = (int) Math.ceil(roll / 2.0);
}

age += roll;
nDice--;
}

if (expLevel == SkillType.EXP_NONE) {
age -= baseAge; // only use the result of the dice roll
}

return age;
}

Expand Down
Loading