Ejemplo n.º 1
0
  private void addPart(boolean purchase, boolean bulk, boolean bonus) {
    int row = partsTable.getSelectedRow();
    if (row < 0) {
      return;
    }
    Part selectedPart = partsModel.getPartAt(partsTable.convertRowIndexToModel(row));
    int quantity = 1;
    if (bulk) {
      PopupValueChoiceDialog pcd =
          new PopupValueChoiceDialog(
              campaignGUI.getFrame(), true, "How Many " + selectedPart.getName(), quantity, 1, 100);
      pcd.setVisible(true);
      quantity = pcd.getValue();
    }

    if (bonus) {
      String report = selectedPart.getAcquisitionWork().find(0);
      if (report.endsWith("0 days.")) {
        AtBContract contract = null;
        for (Mission m : campaign.getMissions()) {
          if (m.isActive()
              && m instanceof AtBContract
              && ((AtBContract) m).getNumBonusParts() > 0) {
            contract = (AtBContract) m;
            break;
          }
        }
        if (null == contract) {
          MekHQ.logError("AtB: used bonus part but no contract has bonus parts available.");
        } else {
          contract.useBonusPart();
        }
      }
    } else if (purchase) {
      campaign
          .getShoppingList()
          .addShoppingItem(selectedPart.getAcquisitionWork(), quantity, campaign);
    } else {
      while (quantity > 0) {
        campaign.addPart(selectedPart.clone(), 0);
        quantity--;
      }
    }
    campaignGUI.refreshReport();
    campaignGUI.refreshAcquireList();
    campaignGUI.refreshPartsList();
    campaignGUI.refreshFinancialTransactions();
    campaignGUI.refreshOverview();
  }
Ejemplo n.º 2
0
 /** Creates new form PartsStoreDialog */
 public PartsStoreDialog(boolean modal, CampaignGUI gui) {
   this(gui.getFrame(), modal, gui, gui.getCampaign(), true);
 }