Skip to content

Commit

Permalink
Merge pull request #4233 from IllianiCBT/autoAwards_warAgainstPiracy
Browse files Browse the repository at this point in the history
Fixed and Enhanced FactionHunterAwards Processing
  • Loading branch information
IllianiCBT authored Jun 21, 2024
2 parents 941cff3 + 79d7ba5 commit 94379f1
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 11 deletions.
Binary file modified MekHQ/docs/Personnel Modules/Awards Module.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
import mekhq.campaign.mission.AtBContract;
import mekhq.campaign.mission.Mission;
import mekhq.campaign.personnel.Award;
import mekhq.campaign.universe.Faction;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static mekhq.campaign.personnel.autoAwards.TheatreOfWarAwards.processFaction;
import java.util.*;

public class FactionHunterAwards {
/**
Expand All @@ -21,20 +17,85 @@ public class FactionHunterAwards {
* @param awards the awards to be processed (should only include awards where item == TheatreOfWar)
*/
public static Map<Integer, List<Object>> FactionHunterAwardsProcessor(Campaign campaign, Mission mission, UUID person, List<Award> awards) {
boolean isEligible;
boolean isEligible = false;
List<Award> eligibleAwards = new ArrayList<>();

String missionFaction = ((AtBContract) mission).getEnemy().getFullName(campaign.getGameYear());
Faction missionFaction = ((AtBContract) mission).getEnemy();

for (Award award : awards) {
if (award.canBeAwarded(campaign.getPerson(person))) {
List<String> targetFactions = List.of(award.getRange().split(","));

if (!targetFactions.isEmpty()) {
// returns true if missionFaction matches the requirements of the listed targetFactions
isEligible = targetFactions
.stream()
.anyMatch(targetFaction -> processFaction(missionFaction, targetFaction));
for (String awardFaction : targetFactions) {
// does the awardFaction equal missionFaction? if so, break the loop
if ((Objects.equals(awardFaction, missionFaction.getShortName()))) {
isEligible = true;
break;
}

// does awardFaction match one of the special super-factions?
switch (awardFaction.toLowerCase()) {
case "major powers":
if (missionFaction.isMajorOrSuperPower()) {
isEligible = true;
}
break;
case "inner sphere":
if (missionFaction.isInnerSphere()) {
isEligible = true;
}
break;
case "clans":
if (missionFaction.isClan()) {
isEligible = true;
}
break;
case "periphery":
if (missionFaction.isPeriphery()) {
isEligible = true;
}
break;
case "pirate":
if (missionFaction.isPirate()) {
isEligible = true;
}
break;
case "mercenary":
if (missionFaction.isMercenary()) {
isEligible = true;
}
break;
case "independent":
if (missionFaction.isIndependent()) {
isEligible = true;
}
break;
case "deep periphery":
if (missionFaction.isDeepPeriphery()) {
isEligible = true;
}
break;
case "wob":
if (missionFaction.isWoB()) {
isEligible = true;
}
break;
case "comstar or wob":
if (missionFaction.isComStarOrWoB()) {
isEligible = true;
}
break;
default:
break;
}

// once we have one positive, there is no need to continue cycling through factions
if (isEligible) {
break;
}
}

if (isEligible) {
eligibleAwards.add(award);
Expand Down

0 comments on commit 94379f1

Please sign in to comment.