private static int countBV(ArrayList<MechSummary> units) { int bv = 0; for (MechSummary m : units) { bv += m.getBV(); } return bv; }
/** * @param index * @return - the BV of the unit at the indicated index, or 0 if this is a salvage entry */ public int getBV(int index) { if (index >= salvageTable.size()) { return unitTable.get(index - salvageTable.size()).getUnitEntry().getBV(); } else { return 0; } }
public static void main(String[] args) { Parameters p = new Parameters(); p.mechs = 4; p.tanks = 4; p.infantry = 0; p.ba = 4; p.maxBV = 8000; p.minBV = 7600; p.minYear = 3050; p.maxYear = 3055; p.tech = TechConstants.T_IS_TW_NON_BOX; p.canon = true; p.padWithInfantry = true; ArrayList<MechSummary> units = generateArmy(p); int totalBV = 0; for (MechSummary m : units) { totalBV += m.getBV(); System.out.print(m.getChassis()); System.out.print(" "); System.out.print(m.getModel()); System.out.print(" "); System.out.println(m.getBV()); } System.out.print("Total: "); System.out.println(totalBV); }
for (int i = 0; i < count; i++) { selection[i] = Compute.randomInt(unitList.size()); currentBV += unitList.get(selection[i]).getBV(); for (int i = 0; i < count; i++) { selection[i] = Compute.randomInt(top - bottom) + bottom; currentBV += unitList.get(selection[i]).getBV(); for (int i = 0; i < count; i++) { selection[i] = Compute.randomInt(top - bottom) + bottom; currentBV += unitList.get(selection[i]).getBV();
private void exportList(int connId, String path) { try { PrintWriter pw1 = new PrintWriter(new FileWriter(path)); MechSummary[] msums = MechSummaryCache.getInstance().getAllMechs(); for (MechSummary ms1 : msums) { pw1.println(ms1.getChassis() + ", " + ms1.getModel() + ", " + ms1.getBV()); } pw1.flush(); pw1.close(); server.sendServerChat(server.getPlayer(connId).getName() + " has exported a unit list."); } catch (Exception e) { server.sendServerChat(connId, "/exportlist: execution failed"); server.sendServerChat(connId, e.toString()); } } }
@Override public int compare(MechSummary ms1, MechSummary ms2) { switch (m_nType) { case T_CHASSIS: return ms1.getChassis().compareTo(ms2.getChassis()); case T_MODEL: return ms1.getModel().compareTo(ms2.getModel()); case T_WEIGHT: return Double.compare(ms1.getTons(), ms2.getTons()); case T_BV: return Integer.compare(ms1.getBV(), ms2.getBV()); case T_YEAR: return Integer.compare(ms1.getYear(), ms2.getYear()); case T_COST: return Long.compare(ms1.getCost(), ms2.getCost()); case T_LEVEL: return ms1.getLevel().compareTo(ms2.getLevel()); default: return 0; } } }
w.write(unit.getModel()); w.write(","); w.write(Integer.toString(unit.getBV())); w.write(","); w.write(Long.toString(unit.getCost()));
public Object getValueAt(int row, int col) { MechSummary ms = data[row]; if(col == COL_MODEL) { return ms.getModel(); } if(col == COL_CHASSIS) { return ms.getChassis(); } if(col == COL_WEIGHT) { return ms.getTons(); } if(col == COL_BV) { return ms.getBV(); } if(col == COL_YEAR) { return ms.getYear(); } if(col == COL_COST) { return formatter.format(getPurchasePrice(ms)); } return "?"; }
public Object getValueAt(int row, int col) { MechSummary m = getUnitAt(row); String value = ""; if (col == COL_BV) { value += m.getBV(); } else if (col == COL_MOVE) { value += m.getWalkMp() + "/" + m.getRunMp() + "/" + m.getJumpMp(); } else { return m.getName(); } return value; }
csvLine.append(mech.getBV() + ",");
baBV = Math.max(baBV, p.ba * allBA.get(0).getBV()); baBV = Math.min(baBV, p.ba * allBA.get(allBA.size() - 1).getBV()); } else { baBV = 0; mechBV = Math.max(mechBV, p.mechs * allMechs.get(0).getBV()); mechBV = Math.min(mechBV, p.mechs * allMechs.get(allMechs.size() - 1).getBV()); } else { mechBV = 0; tankBV = Math.max(tankBV, p.tanks * allTanks.get(0).getBV()); tankBV = Math.min(tankBV, p.tanks * allTanks.get(allTanks.size() - 1).getBV()); } else { tankBV = 0;
return ms.getRHBV(); } else { return ms.getBV();