예제 #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();
  }
 private void hire() {
   int number = (Integer) spnNumber.getModel().getValue();
   while (number > 0) {
     Person p = campaign.newPerson(choiceType.getSelectedIndex() + 1);
     p.setRankNumeric(
         campaign
             .getRanks()
             .getRankNumericFromNameAndProfession(
                 p.getProfession(), (String) choiceRanks.getSelectedItem()));
     if (!campaign.recruitPerson(p)) {
       number = 0;
     } else {
       number--;
     }
   }
   hqView.refreshPersonnelList();
   hqView.refreshPatientList();
   hqView.refreshTechsList();
   hqView.refreshDoctorsList();
   hqView.refreshReport();
   hqView.refreshFinancialTransactions();
   hqView.refreshOverview();
 }