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

Filter out inactive factions when determining capitals for personnel market generation #4882

Merged
Merged
Changes from all commits
Commits
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
37 changes: 19 additions & 18 deletions MekHQ/src/mekhq/campaign/market/PersonnelMarket.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public PersonnelMarket(Campaign c) {

/**
* Sets the method for generating potential recruits for the personnel market.
*
*
* @param key The lookup name of the market type to use.
*/
public void setType(String key) {
Expand All @@ -108,19 +108,20 @@ public void handleCampaignOptionsEvent(OptionsChangedEvent ev) {
* Generate new personnel to be added to the
* market availability pool
*/
public void generatePersonnelForDay(Campaign c) {
public void generatePersonnelForDay(Campaign campaign) {
List<String> capitals = Factions.getInstance().getFactions().stream()
.map(faction -> faction.getStartingPlanet(c.getLocalDate()))
.filter(faction -> faction.validIn(campaign.getLocalDate()))
.map(faction -> faction.getStartingPlanet(campaign.getLocalDate()))
.collect(Collectors.toList());

String currentSystem = c.getCurrentSystem().getId();
String currentSystem = campaign.getCurrentSystem().getId();

boolean updated = false;

if (!personnel.isEmpty()) {
removePersonnelForDay(c);
if (c.getCampaignOptions().isUsePersonnelHireHiringHallOnly()
&& !c.getAtBConfig().isHiringHall(currentSystem, c.getLocalDate())
removePersonnelForDay(campaign);
if (campaign.getCampaignOptions().isUsePersonnelHireHiringHallOnly()
&& !campaign.getAtBConfig().isHiringHall(currentSystem, campaign.getLocalDate())
&& !capitals.contains(currentSystem)) {
removeAll();
}
Expand All @@ -129,10 +130,10 @@ public void generatePersonnelForDay(Campaign c) {
if (null != method) {
List<Person> newPersonnel = new ArrayList<>();

if (!c.getCampaignOptions().isUsePersonnelHireHiringHallOnly()
|| c.getAtBConfig().isHiringHall(currentSystem, c.getLocalDate())
if (!campaign.getCampaignOptions().isUsePersonnelHireHiringHallOnly()
|| campaign.getAtBConfig().isHiringHall(currentSystem, campaign.getLocalDate())
|| capitals.contains(currentSystem)) {
newPersonnel = method.generatePersonnelForDay(c);
newPersonnel = method.generatePersonnelForDay(campaign);
}

if ((null != newPersonnel) && !newPersonnel.isEmpty()) {
Expand All @@ -142,13 +143,13 @@ public void generatePersonnelForDay(Campaign c) {
}
}

if (updated && c.getCampaignOptions().isPersonnelMarketReportRefresh()) {
if (updated && campaign.getCampaignOptions().isPersonnelMarketReportRefresh()) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<a href='PERSONNEL_MARKET'>Personnel market updated</a>");
if (c.getCampaignOptions().getPersonnelMarketName().equals("Campaign Ops") && !personnel.isEmpty()) {
if (campaign.getCampaignOptions().getPersonnelMarketName().equals("Campaign Ops") && !personnel.isEmpty()) {
stringBuilder.append(':');
Person person = personnel.get(0);
String expLevel = SkillType.getExperienceLevelName(person.getExperienceLevel(c, false));
String expLevel = SkillType.getExperienceLevelName(person.getExperienceLevel(campaign, false));
stringBuilder.append("<br>A ")
.append("<b> ")
.append(expLevel)
Expand All @@ -159,7 +160,7 @@ public void generatePersonnelForDay(Campaign c) {
.append(person.getFullName())
.append(" is available.");
}
c.addReport(stringBuilder.toString());
campaign.addReport(stringBuilder.toString());
}
}

Expand Down Expand Up @@ -211,7 +212,7 @@ public void removePerson(Person p) {

/**
* Assign an <code>Entity</code> to a recruit
*
*
* @param pid The recruit's id
* @param en The Entity to assign
*/
Expand All @@ -221,7 +222,7 @@ public void addAttachedEntity(UUID pid, Entity en) {

/**
* Get the Entity associated with a recruit, if any
*
*
* @param p The recruit
* @return The Entity associated with the recruit, or null if there is none
*/
Expand All @@ -231,7 +232,7 @@ public Entity getAttachedEntity(Person p) {

/**
* Get the Entity associated with a recruit, if any
*
*
* @param pid The id of the recruit
* @return The Entity associated with the recruit, or null if there is none
*/
Expand All @@ -241,7 +242,7 @@ public Entity getAttachedEntity(UUID pid) {

/**
* Clears the <code>Entity</code> associated with a recruit
*
*
* @param pid The recruit's id
*/
public void removeAttachedEntity(UUID pid) {
Expand Down