Class AbstractUnitMarket

java.lang.Object
mekhq.campaign.market.unitMarket.AbstractUnitMarket
Direct Known Subclasses:
AtBMonthlyUnitMarket, DisabledUnitMarket

public abstract class AbstractUnitMarket extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • getMethod

      public UnitMarketMethod getMethod()
    • getOffers

      public List<UnitMarketOffer> getOffers()
    • setOffers

      public void setOffers(List<UnitMarketOffer> offers)
    • processNewDay

      public abstract void processNewDay(Campaign campaign)
      This is the primary method for processing the Unit Market. It is executed as part of Campaign.newDay()
      Parameters:
      campaign - the campaign to process the Unit Market new day using
    • generateUnitOffers

      public abstract void generateUnitOffers(Campaign campaign)
      This is the primary Unit Market generation method, which is how the market specified generates unit offers
      Parameters:
      campaign - the campaign to generate the unit offers for
    • addOffers

      public abstract void addOffers(Campaign campaign, int number, UnitMarketType market, int unitType, @Nullable Faction faction, int quality, int priceTarget)
      This adds a number of unit offers
      Parameters:
      campaign - the campaign to add the offers based on
      number - the number of units to generate
      market - the unit market type the unit is part of
      unitType - the unit type to generate
      faction - the faction to add the offers for, or null. If null, that must be handled within this method before any generated offers may be added to the market.
      quality - the quality of the unit to generate
      priceTarget - the target number used to determine the percent
    • addSingleUnit

      @Nullable public String addSingleUnit(Campaign campaign, UnitMarketType market, int unitType, Faction faction, int quality, int percent)
      Parameters:
      campaign - the campaign to use to generate the unit
      market - the market type the unit is being offered in
      unitType - the unit type to generate the unit with
      faction - the faction to generate the unit from
      quality - the quality to generate the unit at
      percent - the percentage of the original unit cost the unit will be offered at
      Returns:
      the name of the unit that has been added to the market, or null if none were added
    • addSingleUnit

      @Nullable public String addSingleUnit(Campaign campaign, UnitMarketType market, int unitType, Faction faction, int quality, Collection<megamek.common.units.EntityMovementMode> movementModes, Collection<megamek.client.ratgenerator.MissionRole> missionRoles, int percent)
      Parameters:
      campaign - the campaign to use to generate the unit offer
      market - the market type the unit is being offered in
      unitType - the unit type to generate the unit with
      faction - the faction to generate the unit from
      quality - the quality to generate the unit at
      movementModes - the movement modes to generate for
      missionRoles - the mission roles to generate for
      percent - the percentage of the original unit cost the unit will be offered at
      Returns:
      the name of the unit that has been added to the market, or null if none were added
    • addSingleUnit

      @Nullable protected String addSingleUnit(Campaign campaign, UnitMarketType market, int unitType, Faction faction, int weight, int quality, Collection<megamek.common.units.EntityMovementMode> movementModes, Collection<megamek.client.ratgenerator.MissionRole> missionRoles, int percent)
      Parameters:
      campaign - the campaign to use to generate the unit offer
      market - the market type the unit is being offered in
      unitType - the unit type to generate the unit with
      faction - the faction to generate the unit from
      weight - the weight class to generate the unit at
      quality - the quality to generate the unit at
      movementModes - the movement modes to generate for
      missionRoles - the mission roles to generate for
      percent - the percentage of the original unit cost the unit will be offered at
      Returns:
      the name of the unit that has been added to the market, or null if none were added
    • addSingleUnit

      public String addSingleUnit(Campaign campaign, UnitMarketType market, int unitType, megamek.common.loaders.MekSummary mekSummary, int percent)
      Parameters:
      campaign - the campaign to use to generate the offer
      market - the market type the unit is being offered in
      unitType - the unit type of the generated unit
      mekSummary - the generated mek summary
      percent - the percentage of the original unit cost the unit will be offered at
      Returns:
      the name of the unit that has been added to the market
    • generateWeight

      protected abstract int generateWeight(Campaign campaign, int unitType, Faction faction)
      Parameters:
      campaign - the campaign to generate the unit weight based on
      unitType - the unit type to determine the format of weight to generate
      faction - the faction to generate the weight for
      Returns:
      the generated weight
    • generateTransitDuration

      protected int generateTransitDuration(Campaign campaign)
      Parameters:
      campaign - the campaign to use to generate the transit duration
      Returns:
      the generated transit duration
    • writeRefreshReport

      protected void writeRefreshReport(Campaign campaign)
      Parameters:
      campaign - the campaign to write the refresh report to
    • removeUnitOffers

      protected abstract void removeUnitOffers(Campaign campaign)
      This is the primary Unit Market removal method, which is how the market specified removes unit offers
      Parameters:
      campaign - the campaign to use in determining the offers to remove
    • writeToXML

      public void writeToXML(PrintWriter pw, int indent)
      This writes the Unit Market to XML
      Parameters:
      pw - the PrintWriter to write to
      indent - the base indent level to write at
    • writeBodyToXML

      protected void writeBodyToXML(PrintWriter pw, int indent)
      This is meant to be overridden so that a market can have additional elements added to it, albeit with this called by super.writeBodyToXML(pw, indent) first.
      Parameters:
      pw - the PrintWriter to write to
      indent - the base indent level to write at
    • fillFromXML

      public void fillFromXML(Node wn, Campaign campaign, megamek.Version version)
      This method fills the market based on the supplied XML node. The market is initialized as empty before this is called.
      Parameters:
      wn - the node to fill the market from
      campaign - the campaign the market is being parsed as part of
      version - the version of the market being parsed
    • parseXMLNode

      protected void parseXMLNode(Node wn, Campaign campaign, megamek.Version version)
      This is meant to be overridden so that a market can have additional elements added to it, albeit with this called by super.parseXMLNode(wn) first.
      Parameters:
      wn - the node to parse from XML
      campaign - the campaign the market is being parsed as part of
      version - the version of the market being parsed