Class TrainingPresets

java.lang.Object
mekhq.campaign.personnel.training.TrainingPresets

public final class TrainingPresets extends Object
A campaign's saved auto-train presets, and running the ones marked to run at the start of each month.
Since:
0.51.01
  • Constructor Details

    • TrainingPresets

      public TrainingPresets()
  • Method Details

    • getPresets

      public List<AutoTrainSettings> getPresets()
      Returns:
      the presets, in the order the player saved them
    • find

      @Nullable public AutoTrainSettings find(String name)
      Parameters:
      name - a preset's name
      Returns:
      the preset with that name, ignoring case, or null
    • save

      public void save(AutoTrainSettings preset)
      Saves a preset, replacing any with the same name.
      Parameters:
      preset - the preset
    • remove

      public boolean remove(String name)
      Parameters:
      name - a preset's name
      Returns:
      true if a preset with that name was removed
    • runMonthly

      public void runMonthly(Campaign campaign)
      Runs every preset marked to run monthly, in order, on the campaign's active personnel. A preset whose training fees the campaign can't pay is skipped, with a note in the daily report.
      Parameters:
      campaign - the campaign
    • writeToXML

      public void writeToXML(PrintWriter writer, int indent)
      Writes the presets as a <trainingPresets> element, or nothing if there are none.
      Parameters:
      writer - the writer
      indent - the indent
    • generateInstanceFromXML

      public static TrainingPresets generateInstanceFromXML(Node node, CampaignOptions campaignOptions)
      Reads presets from a <trainingPresets> element; an unreadable preset is logged and skipped.
      Parameters:
      node - the element
      campaignOptions - the campaign's options, for the defaults of missing values
      Returns:
      the presets