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(); }
public int getCombatRecordValue() { setSuccessCount(0); setFailCount(0); setBreachCount(0); for (Mission m : getCampaign().getMissions()) { // Skip ongoing missions. if (m.isActive()) { continue; } if (m.getStatus() == Mission.S_SUCCESS) { setSuccessCount(getSuccessCount() + 1); } else if (m.getStatus() == Mission.S_FAILED) { setFailCount(getFailCount() + 1); } else if (m.getStatus() == Mission.S_BREACH) { setBreachCount(getBreachCount() + 1); } } return (getSuccessCount() * 5) - (getFailCount() * 10) - (getBreachCount() * 25); }