Class NewPersonnelMarket

java.lang.Object
mekhq.campaign.market.personnelMarket.markets.NewPersonnelMarket
Direct Known Subclasses:
PersonnelMarketCamOpsRevised, PersonnelMarketMekHQ

public class NewPersonnelMarket extends Object
Represents the Personnel Market system for managing the recruitment, listing, and data persistence of potential recruits within a campaign.

Handles the generation, filtration, and display of available applicants, as well as reading and writing applicant data from/to XML. Integrates campaign state, planetary context, reputation effects, market style, and market-specific applicant pools for a flexible personnel recruitment experience.

Since:
0.50.06
  • Constructor Details

    • NewPersonnelMarket

      public NewPersonnelMarket()
      Creates a new Personnel Market instance bound to a campaign.
      Since:
      0.50.06
  • Method Details

    • generatePersonnelMarketDataFromXML

      public static NewPersonnelMarket generatePersonnelMarketDataFromXML(Campaign campaign, Node parentNode, megamek.Version version)
      Generates Personnel Market data by loading it from an XML document node.
      Parameters:
      campaign - The relevant campaign save
      parentNode - XML node parent containing market data
      version - Version the save was last made in
      Returns:
      Loaded Personnel Market instance
      Since:
      0.50.06
    • gatherApplications

      public void gatherApplications()
      Gathers new applicant data and updates the internal applicant list based on current campaign state and settings.
      Since:
      0.50.06
    • generateApplicants

      public void generateApplicants()
      Generates new applicants and adds them to the market's applicant pool.
      Since:
      0.50.06
    • getSingleApplicant

      @Nullable public Person getSingleApplicant()
      Retrieves a single applicant if available.
      Returns:
      a Person, or null if no applicant exists
    • showPersonnelMarketDialog

      public void showPersonnelMarketDialog()
      Launches the user interface dialog displaying the current personnel market.
      Since:
      0.50.06
    • writePersonnelMarketDataToXML

      public void writePersonnelMarketDataToXML(PrintWriter writer, int indent)
      Serializes the Personnel Market data to XML output.
      Parameters:
      writer - Output PrintWriter
      indent - XML indentation level
      Since:
      0.50.06
    • getAssociatedPersonnelMarketStyle

      public PersonnelMarketStyle getAssociatedPersonnelMarketStyle()
      Gets the associated personnel market style used by this market.
      Returns:
      the personnel market style
      Since:
      0.50.06
    • setAssociatedPersonnelMarketStyle

      public void setAssociatedPersonnelMarketStyle(PersonnelMarketStyle associatedPersonnelMarketStyle)
      Sets the market style for the personnel market.
      Parameters:
      associatedPersonnelMarketStyle - the personnel market style to use
      Since:
      0.50.06
    • getLowPopulationRecruitmentDivider

      public static int getLowPopulationRecruitmentDivider()
      Gets the recruitment divider value for low population systems.
      Returns:
      recruitment divider integer
      Since:
      0.50.06
    • setLowPopulationRecruitmentDivider

      public static void setLowPopulationRecruitmentDivider(int divider)
      Sets the recruitment divider for low population systems.
      Parameters:
      divider - recruitment divider to set
      Since:
      0.50.06
    • getUnitReputationRecruitmentCutoff

      public static int getUnitReputationRecruitmentCutoff()
      Gets the unit reputation cutoff value for recruitment.
      Returns:
      reputation cutoff threshold
      Since:
      0.50.06
    • setUnitReputationRecruitmentCutoff

      public static void setUnitReputationRecruitmentCutoff(int cutoff)
      Sets the cutoff value for unit reputation in recruitment eligibility.
      Parameters:
      cutoff - reputation cutoff to set
      Since:
      0.50.06
    • getClanMarketEntries

      public Map<PersonnelRole,PersonnelMarketEntry> getClanMarketEntries()
      Returns the map of available clan market entries and their role distributions.
      Returns:
      map of personnel roles to market entries (Clan)
      Since:
      0.50.06
    • setClanMarketEntries

      public void setClanMarketEntries(Map<PersonnelRole,PersonnelMarketEntry> clanMarketEntries)
      Sets the clan market entries data.
      Parameters:
      clanMarketEntries - map of personnel roles to market entries
      Since:
      0.50.06
    • getInnerSphereMarketEntries

      public Map<PersonnelRole,PersonnelMarketEntry> getInnerSphereMarketEntries()
      Returns the map of available Inner Sphere market entries and their role distributions.
      Returns:
      map of personnel roles to market entries (Inner Sphere)
      Since:
      0.50.06
    • setInnerSphereMarketEntries

      public void setInnerSphereMarketEntries(Map<PersonnelRole,PersonnelMarketEntry> innerSphereMarketEntries)
      Sets the Inner Sphere market entries data.
      Parameters:
      innerSphereMarketEntries - map of personnel roles to market entries
      Since:
      0.50.06
    • getCampaign

      public Campaign getCampaign()
      Returns the campaign associated with this Personnel Market.
      Returns:
      campaign instance
      Since:
      0.50.06
    • setCampaign

      public void setCampaign(Campaign campaign)
      Parameters:
      campaign - Campaign instance that this instance will be attached to and access
    • getCampaignFaction

      public Faction getCampaignFaction()
      Returns the faction associated with the campaign for recruitment filtering.
      Returns:
      campaign's faction
      Since:
      0.50.06
    • setCampaignFaction

      public void setCampaignFaction(Faction campaignFaction)
      Sets the campaign's faction, influencing applicant origins.
      Parameters:
      campaignFaction - the new campaign faction
      Since:
      0.50.06
    • getToday

      public LocalDate getToday()
      Returns the in-game date currently used for market evaluation.
      Returns:
      current date
      Since:
      0.50.06
    • setToday

      public void setToday(LocalDate today)
      Sets the in-game date used to determine market status.
      Parameters:
      today - new current date
      Since:
      0.50.06
    • getGameYear

      public int getGameYear()
      Returns the campaign year for market behavior.
      Returns:
      game year
      Since:
      0.50.06
    • setGameYear

      public void setGameYear(int gameYear)
      Sets the current game year for the personnel market.
      Parameters:
      gameYear - the game year to set
      Since:
      0.50.06
    • getApplicantOriginFactions

      public List<Faction> getApplicantOriginFactions()
      Returns the factions from which applicants may originate.
      Returns:
      list of applicant origin factions
      Since:
      0.50.06
    • setApplicantOriginFactions

      public void setApplicantOriginFactions(List<Faction> applicantOriginFactions)
      Sets the list of origin factions for new applicants.
      Parameters:
      applicantOriginFactions - list to set
      Since:
      0.50.06
    • getCurrentApplicants

      public List<Person> getCurrentApplicants()
      Returns the current list of market applicants.
      Returns:
      list of applicants
      Since:
      0.50.06
    • getLastSelectedFilter

      public int getLastSelectedFilter()
      Returns the index or filter value last used for applicant selection.
      Returns:
      filter index
      Since:
      0.50.06
    • setLastSelectedFilter

      public void setLastSelectedFilter(int lastSelectedFilter)
      Sets the last-used selection filter value.
      Parameters:
      lastSelectedFilter - filter index
      Since:
      0.50.06
    • addApplicant

      public void addApplicant(Person applicant)
      Adds a new applicant to the current applicant pool.
      Parameters:
      applicant - the new Personnel applicant
      Since:
      0.50.06
    • clearCurrentApplicants

      public void clearCurrentApplicants()
      Clears all current applicants from the market.
      Since:
      0.50.06
    • setCurrentApplicants

      public void setCurrentApplicants(List<Person> currentApplicants)
      Sets the list of current market applicants.
      Parameters:
      currentApplicants - list of applicants to set
      Since:
      0.50.06
    • isOfferingGoldenHello

      public boolean isOfferingGoldenHello()
      Returns whether a golden hello (recruitment incentive) is being offered.
      Returns:
      true if a golden hello is offered, otherwise false
      Since:
      0.50.06
    • setOfferingGoldenHello

      public void setOfferingGoldenHello(boolean offeringGoldenHello)
      Sets whether a golden hello (recruitment incentive) is being offered.
      Parameters:
      offeringGoldenHello - true to offer, false otherwise
      Since:
      0.50.06
    • isWasOfferingGoldenHello

      public boolean isWasOfferingGoldenHello()
      Returns whether a golden hello (recruitment incentive) was being offered when applicants were generated.
      Returns:
      true if a golden hello was offered, false otherwise
      Since:
      0.50.06
    • setWasOfferingGoldenHello

      public void setWasOfferingGoldenHello(boolean wasOfferingGoldenHello)
      Sets whether a golden hello (recruitment incentive) was being offered when applicants were generated.
      Parameters:
      wasOfferingGoldenHello - true if a golden hello was offered, false otherwise
      Since:
      0.50.07
    • getHasRarePersonnel

      public boolean getHasRarePersonnel()
      Returns whether rare personnel are available on the market.
      Returns:
      true if rare personnel are present, otherwise false
      Since:
      0.50.06
    • setHasRarePersonnel

      @Deprecated(since="0.50.07", forRemoval=true) public void setHasRarePersonnel(boolean hasRarePersonnel)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the status of rare personnel availability.
      Parameters:
      hasRarePersonnel - true if present, false otherwise
      Since:
      0.50.06
    • getRarePersonnel

      public Set<UUID> getRarePersonnel()
      Returns the set of rare personnel.
      Returns:
      a Set containing Person objects considered rare personnel
      Since:
      0.50.07
    • addRarePerson

      public void addRarePerson(UUID personId)
      Adds a UUID to the set of rare personnel, if not null.
      Parameters:
      personId - the UUID to add to the rare personnel set; ignored if null
      Since:
      0.50.07
    • getRareProfessions

      public List<PersonnelRole> getRareProfessions()
      Returns a list of rare professions currently stored.
      Returns:
      a list of PersonnelRole representing rare professions
      Since:
      0.50.06
    • addRareProfession

      public void addRareProfession(PersonnelRole rareProfession)
      Adds a profession to the list of rare professions.
      Parameters:
      rareProfession - the PersonnelRole to mark as rare and add to the list
      Since:
      0.50.06
    • getRecruitmentRolls

      public int getRecruitmentRolls()
      Returns the number of recruitment rolls performed for the current market evaluation.
      Returns:
      recruitment rolls value
      Since:
      0.50.06
    • setRecruitmentRolls

      public void setRecruitmentRolls(int recruitmentRolls)
      Sets the number of recruitment rolls for the market.
      Parameters:
      recruitmentRolls - number of rolls to set
      Since:
      0.50.06
    • getCurrentSystem

      public PlanetarySystem getCurrentSystem()
      Returns the planetary system currently used for market context.
      Returns:
      planetary system
      Since:
      0.50.06
    • setCurrentSystem

      public void setCurrentSystem(PlanetarySystem currentSystem)
      Sets the planetary system for the current personnel market.
      Parameters:
      currentSystem - planetary system to set
      Since:
      0.50.06
    • getAvailabilityMessage

      public String getAvailabilityMessage()
      Gets an availability message describing the market's state or conditions.
      Returns:
      market availability message
      Since:
      0.50.06
    • sanitizeMarketEntries

      public Map<PersonnelRole,PersonnelMarketEntry> sanitizeMarketEntries(Map<PersonnelRole,PersonnelMarketEntry> marketEntries)
      Removes entries with non-positive weights or counts from the supplied personnel market entries map.

      Iterates over the existing map and removes any PersonnelMarketEntry whose weight() or count() is less than or equal to zero.

      Parameters:
      marketEntries - the map of personnel roles to market entries to sanitize; modified in place
      Returns:
      the sanitized map, containing only entries with positive weights
      Since:
      0.50.06
    • getMarketEntriesAsList

      public List<PersonnelMarketEntry> getMarketEntriesAsList(Map<PersonnelRole,PersonnelMarketEntry> marketEntries)
      Returns a list of PersonnelMarketEntry objects sorted alphabetically by the string value of each entry's profession. This ensures a deterministic order for processing or testing, regardless of the original iteration order of the provided map.
      Parameters:
      marketEntries - a map containing personnel roles as keys and their corresponding market entries as values
      Returns:
      a list of market entries sorted alphabetically by profession
      Since:
      0.50.06
    • getHiringCost

      public Money getHiringCost(Person applicant)
    • getHiringCostBreakdown

      public HiringCostBreakdown getHiringCostBreakdown(Person applicant)
      Gets the cost of hiring an applicant, split by part, so the hiring hall can show how it is made up.
      Parameters:
      applicant - the applicant
      Returns:
      the hiring cost, by part; its total matches getHiringCost(Person)
      Since:
      0.51.01