Class PerformResupply

java.lang.Object
mekhq.campaign.mission.resupplyAndCaches.PerformResupply

public class PerformResupply extends Object
The PerformResupply class handles the execution and management of resupply operations within MekHQ campaigns. It covers various aspects of resupply, including generating convoy contents, distributing supplies, resolving convoy interceptions, and facilitating player interaction through dialogs tied to specific resupply scenarios.
  • Field Details

  • Constructor Details

    • PerformResupply

      public PerformResupply()
  • Method Details

    • performResupply

      public static void performResupply(Resupply resupply, AtBContract contract)
      Initiates the resupply process for a specified campaign and active contract.

      This method provides a simplified entry point to the resupply workflow, using a default value of 1 for the supply drop count. It delegates to the overloaded method performResupply(Resupply, AtBContract, int) for the main execution of the resupply process, encompassing supply generation, convoy interaction, and delivery confirmation.

      This entry point is typically used when the exact number of supply drops is not specified or defaults to a single drop per invocation.

      Parameters:
      resupply - the Resupply instance containing information about the resupply operation, such as the supplies to be delivered, convoy setup, and context-specific rules.
      contract - the AtBContract representing the current contract, which provides the operational context for the resupply, including permissions and restrictions.
    • performResupply

      public static void performResupply(Resupply resupply, AtBContract contract, int dropCount)
      Executes the resupply process for a specified campaign, contract, and supply drop count. This method coordinates supply allocation, convoy interaction, potential for interception, and player confirmation dialogs, ensuring the resupply process adheres to the campaign's context and player decisions.

      Functionality includes:

      • Early-exit handling for invalid cargo tonnage or drop count.
      • Displaying dialogs to involve the player in choosing convoys or resupply focus.
      • Randomized content generation for armor, ammo, and parts.
      • Dialog-based confirmation for resupply delivery and associated costs.
      Parameters:
      resupply - the Resupply instance that defines the campaign's resupply operation, including cargo, player and NPC convoys, and mission-related data.
      contract - the AtBContract representing the context of the current contract, determining aspects such as independent resupply permissions and guerrilla warfare rules.
      dropCount - the number of supply drops planned for this resupply operation. If zero, the method exits early.
    • makeDelivery

      public static void makeDelivery(Resupply resupply, @Nullable List<Part> contents)
      Facilitates the delivery of resupply contents to the campaign's resources.

      This method categorizes parts like ammunition, armor, and general equipment, placing them in the warehouse.

      Parameters:
      resupply - the Resupply instance defining the current campaign operation.
      contents - a list of Part objects representing the resupply contents to be delivered. If null, fetches convoy contents from the Resupply instance.
    • makeSmugglerDelivery

      public static void makeSmugglerDelivery(Resupply resupply)
      Facilitates the delivery of supplies through smugglers, incorporating chances for smuggler swindling.

      Key behaviors:

      • Calculates the chance of being swindled based on the contract's morale level.
      • If swindled, invokes a dialog to inform the player; otherwise, schedules delivery of supplies.
      Parameters:
      resupply - the Resupply instance defining the resupply context.
    • loadPlayerConvoys

      public static void loadPlayerConvoys(Resupply resupply)
      Loads and organizes player convoys for a resupply operation. It calculates available convoy capacities, sorts convoys and contents, and assigns parts to convoys based on capacity.
      Parameters:
      resupply - the Resupply instance containing convoy and mission-specific data.
    • processConvoy

      public static void processConvoy(Resupply resupply, List<Part> convoyContents, @Nullable Force playerConvoy)
      Processes convoy interactions, resolving outcomes based on player decisions, convoy details, and interception chances. This includes factors such as convoy weight and morale influence.

      Handles logic for:

      • Calculating interception chances based on convoy weight and mission context.
      • Generating roleplay events for player convoys.
      • Triggering convoys and interception scenarios.
      Parameters:
      resupply - the Resupply instance defining the resupply operation.
      convoyContents - a list of Part objects representing the contents of the convoy.
      playerConvoy - the Force object representing the player's convoy. If null, the convoy is an NPC-controlled unit.