public double calculatePointValue(Entity en) { return en.calculateBattleValue(true, true) / 100.0; }
/** * Calculates the battle value of this mech. If the parameter is true, then * the battle value for c3 will be added whether the mech is currently part * of a network or not. This should be overwritten if necessary * * @param ignoreC3 if the contribution of the C3 computer should be ignored when * calculating BV. * @param ignorePilot if the extra BV due to piloting skill should be ignore, needed * for c3 bv */ public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) { if (useManualBV) { return manualBV; } return calculateBattleValue(); }
/** * Start of Battle Force Conversion Methods */ public int getBattleForcePoints() { double bv = calculateBattleValue(true, true); int points = (int) Math.round(bv / 100); return Math.max(1, points); }
public int getTotalBV() { int bv = 0; for(Entity entity : getEntityList()) { bv += entity.calculateBattleValue(true, false); } return bv; }
public void addEntities(List<Entity> entities) { for (int i = 0; i < entities.size(); i++) { addEntity(entities.get(i), false); } // We need to delay calculating BV until all units have been added because // C3 network connections will be cleared if the master is not in the game yet. entities.forEach(e -> e.setInitialBV(e.calculateBattleValue(false, false))); processGameEvent(new GameEntityNewEvent(this, entities)); }
/** * get the total BV (unmodified by force size mod) for the units of this * player that have fled the field * * @return the BV */ @Override public int getFledBV() { Enumeration<Entity> fledUnits = game.getRetreatedEntities(); int bv = 0; while (fledUnits.hasMoreElements()) { Entity entity = fledUnits.nextElement(); if (entity.getOwner().equals(this)) { bv += entity.calculateBattleValue(); } } return bv; }
return; e.calculateBattleValue(); tEditorPane.setText(e.getBVText()); tEditorPane.setCaretPosition(0);
@Override public Object getValueAt(int rowIndex, int columnIndex) { final Entity en = entities.get(rowIndex); switch (columnIndex) { case COL_ENTITY: return en.getShortNameRaw(); case COL_BV: return en.calculateBattleValue(); case COL_MOVE: return en.getWalkMP() + "/" + en.getRunMPasString() + "/" + en.getJumpMP(); } return ""; }
protected void addBasicData(Entity entity) { model.put("formatBasicDataRow", new FormatTableRowMethod(new int[] { 30, 20, 5 }, new Justification[] { Justification.LEFT, Justification.LEFT, Justification.RIGHT })); model.put("fullName", entity.getShortNameRaw()); model.put("chassis", entity.getChassis()); model.put("techBase", formatTechBase(entity)); model.put("tonnage", NumberFormat.getInstance().format(entity.getWeight())); model.put("battleValue", NumberFormat.getInstance().format(entity.calculateBattleValue())); model.put("cost", NumberFormat.getInstance().format(entity.getCost(false))); final StringJoiner quirksList = new StringJoiner(", "); final Quirks quirks = entity.getQuirks(); for (final Enumeration<IOptionGroup> optionGroups = quirks.getGroups(); optionGroups.hasMoreElements();) { final IOptionGroup group = optionGroups.nextElement(); if (quirks.count(group.getKey()) > 0) { for (final Enumeration<IOption> options = group.getOptions(); options.hasMoreElements();) { final IOption option = options.nextElement(); if ((option != null) && option.booleanValue()) { quirksList.add(option.getDisplayableNameWithValue()); } } } } if (quirksList.length() > 0) { model.put("quirks", quirksList.toString()); } }
@Override public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) { if (useManualBV) { return manualBV; } int bv = 0; // We'll just add up the BV of all non-destroyed fighters in the squadron. for (Integer fid : fighters) { final Entity fighter = game.getEntity(fid); if ((null != fighter) && !fighter.isDoomed() && !fighter.isDestroyed()) { bv += fighter.calculateBattleValue(ignoreC3, ignorePilot); } } return bv; }
public void addPlayer(IPlayer player) { players.add(player); int bv = 0; int cost = 0; double ton = 0; for (Entity entity : clientgui.getClient().getEntitiesVector()) { if (entity.getOwner().equals(player)) { bv += entity.calculateBattleValue(); cost += entity.getCost(false); ton += entity.getWeight(); } } bvs.add(bv); costs.add(cost); tons.add(ton); fireTableDataChanged(); }
number++; if (p != null) { bv += u.getEntity().calculateBattleValue(true, false); } else { bv += u.getEntity().calculateBattleValue(true, true);
private Entity setupGunEmplacement() { Entity testEntity = Mockito.mock(GunEmplacement.class); Mockito.when(testEntity.calculateBattleValue()).thenCallRealMethod(); Mockito.when(testEntity.calculateBattleValue(Mockito.anyBoolean(), Mockito.anyBoolean())).thenCallRealMethod(); Mockito.when(testEntity.getTotalArmor()).thenReturn(100); ArrayList<Mounted> equipment = new ArrayList<Mounted>(2); WeaponType ppcType = Mockito.mock(WeaponType.class); Mockito.when(ppcType.getBV(Mockito.any(Entity.class))).thenReturn(50.0); Mounted ppc = Mockito.mock(Mounted.class); Mockito.when(ppc.getType()).thenReturn(ppcType); Mockito.when(ppc.isDestroyed()).thenReturn(false); equipment.add(ppc); equipment.add(ppc); Mockito.when(testEntity.getEquipment()).thenReturn(equipment); Mockito.when(testEntity.getWeaponList()).thenReturn(equipment); Mockito.when(testEntity.getAmmo()).thenReturn(new ArrayList<Mounted>(0)); return testEntity; }
@Test public void testCalculateBattleValue() { // Test a gun emplacement. Entity testEntity = setupGunEmplacement(); Mockito.when(testEntity.useGeometricMeanBV()).thenReturn(false); int expected = 94; int actual = testEntity.calculateBattleValue(true, true); TestCase.assertEquals(expected, actual); Mockito.when(testEntity.useGeometricMeanBV()).thenReturn(true); expected = 94; actual = testEntity.calculateBattleValue(true, true); TestCase.assertEquals(expected, actual); Mockito.when(testEntity.getTotalArmor()).thenReturn(0); // Gun Emplacement with no armor. Mockito.when(testEntity.useGeometricMeanBV()).thenReturn(false); expected = 44; actual = testEntity.calculateBattleValue(true, true); TestCase.assertEquals(expected, actual); Mockito.when(testEntity.useGeometricMeanBV()).thenReturn(true); expected = 44; actual = testEntity.calculateBattleValue(true, true); TestCase.assertEquals(expected, actual); }
/** * @return The combined Battle Value of all the player's current assets. */ @Override public int getBV() { int bv = 0; for (Entity entity : game.getEntitiesVector()) { if (equals(entity.getOwner()) && !entity.isDestroyed() && !entity.isTrapped()) { bv += entity.calculateBattleValue(); } } return bv; }
return r.getNewEntity().calculateBattleValue(true, true);
public int getTotalBV(Campaign c) { int bvTotal = 0; for(Force sforce : getSubForces()) { bvTotal += sforce.getTotalBV(c); } for(UUID id : getUnits()) { // no idea how this would happen, but some times a unit in a forces unit ID list has an invalid ID? if(c.getUnit(id) == null) { continue; } bvTotal += c.getUnit(id).getEntity().calculateBattleValue(); } return bvTotal; } }
public int getExtraC3BV(int baseBV) { // extra from c3 networks. a valid network requires at least 2 members // some hackery and magic numbers here. could be better // also, each 'has' loops through all equipment. inefficient to do it 3 // times int xbv = 0; if ((game != null) && ((hasC3MM() && (calculateFreeC3MNodes() < 2)) || (hasC3M() && (calculateFreeC3Nodes() < 3)) || (hasC3S() && (c3Master > NONE)) || ((hasC3i() || hasNavalC3()) && (calculateFreeC3Nodes() < 5)))) { int totalForceBV = 0; totalForceBV += baseBV; for (Entity e : game.getC3NetworkMembers(this)) { if (!equals(e) && onSameC3NetworkAs(e)) { totalForceBV += e.calculateBattleValue(true, true); } } double multiplier = 0.05; if (hasBoostedC3()) { multiplier = 0.07; } xbv += totalForceBV * multiplier; } return xbv; }
public String getSummaryFor(Unit unit) { String toReturn = "<html><font size='2'><b>" + unit.getName() + "</b><br/>"; toReturn += "<b>BV:</b> " + unit.getEntity().calculateBattleValue(true, null == unit.getEntity().getCrew()) + "<br/>"; toReturn += unit.getStatus(); Entity entity = unit.getEntity(); if (entity.hasC3i()) { toReturn += "<br><i>"; if (entity.calculateFreeC3Nodes() >= 5) { toReturn += Messages.getString("ChatLounge.C3iNone"); } else { toReturn += Messages .getString("ChatLounge.C3iNetwork") + entity.getC3NetId(); if (entity.calculateFreeC3Nodes() > 0) { toReturn += Messages.getString("ChatLounge.C3Nodes", new Object[] { entity.calculateFreeC3Nodes() }); } } toReturn += "</i>"; } toReturn += "</font></html>"; return toReturn; }
@Override public Object getValueAt(int row, int col) { boolean compact = butCompact.isSelected(); Entity entity = getEntityAt(row); boolean blindDrop = !entity.getOwner().equals(clientgui.getClient().getLocalPlayer()) && clientgui.getClient().getGame().getOptions().booleanOption(OptionsConstants.BASE_BLIND_DROP); String value = ""; if (col == COL_BV) { value += entity.calculateBattleValue(); } else if (col == COL_PLAYER) { if (compact) { value += entity.getOwner().getName(); } else { value += entity.getOwner().getName() + "<br>Team " + clientgui.getClient().getGame().getPlayer(entity.getOwnerId()).getTeam(); } } else if (col == COL_PILOT) { if (compact) { return formatPilotCompact(entity.getCrew(), blindDrop); } return formatPilotHTML(entity.getCrew(), blindDrop); } else { if (compact) { return formatUnitCompact(entity, blindDrop); } return formatUnitHTML(entity, blindDrop); } return value; }