public List<Entity> getEnemyEntities() { ArrayList<Entity> result = new ArrayList<>(); for (Entity entity : game.getEntitiesVector()) { if (entity.getOwner().isEnemyOf(getLocalPlayer()) && (entity.getPosition() != null) && !entity.isOffBoard() && (entity.getCrew() != null) && !entity.getCrew().isDead()) { result.add(entity); } } return result; }
public boolean canLoad(Entity unit) { return unit.hasETypeFlag(Entity.ETYPE_DROPSHIP) && (unit.getWeight() <= 5000) && (currentSpace >= 1); }
/** * Creates a new mount for this equipment and adds it in. */ public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted, int baMountLoc, boolean isArmored, boolean isTurreted) throws LocationFullException { return addEquipment(etype, loc, rearMounted, baMountLoc, isArmored, isTurreted, false, false, false); }
/** * Tries to load the specified weapon with the first available ammo */ public void loadWeapon(Mounted mounted) { for (Mounted mountedAmmo : getAmmo()) { if (loadWeapon(mounted, mountedAmmo)) { break; } } }
/** * Returns a string representing the armor in the location */ public String getArmorString(int loc, boolean rear) { return Entity.armorStringFor(getArmor(loc, rear)); }
final Entity mockShooter = Mockito.mock(BipedMech.class); Targetable mockTarget = Mockito.mock(BipedMech.class); Mockito.when(((Entity) mockTarget).getArmorType(Mockito.anyInt())).thenReturn(EquipmentType.T_ARMOR_STANDARD); final FireControl testFireControl = new FireControl(mockPrincess); Mockito.when(mockShooter.getCrew()).thenReturn(mockCrew); Mockito.when(((Entity) mockTarget).getCrew()).thenReturn(mockCrew); testAmmoList.add(mockAmmoInfero5); testAmmoList.add(mockAmmoLRM5); Mockito.when(mockShooter.getAmmo()).thenReturn(testAmmoList); Mockito.when(mockShooter.getPosition()).thenReturn(new Coords(10, 10)); Mockito.when(((Entity) mockTarget).getArmorType(Mockito.anyInt())).thenReturn(EquipmentType.T_ARMOR_STANDARD); Mockito.when(mockTarget.getPosition()).thenReturn(new Coords(10, 15)); Mockito.when(mockTarget.isAirborne()).thenReturn(true); Mockito.when(((Entity) mockTarget).getArmorType(Mockito.anyInt())).thenReturn(EquipmentType.T_ARMOR_STANDARD); Mockito.when(mockTarget.getPosition()).thenReturn(new Coords(10, 15)); Assert.assertEquals(mockAmmoLB10XCluster, testFireControl.getPreferredAmmo(mockShooter, mockTarget, mockLB10X)); Mockito.when(((Entity) mockTarget).getArmorType(Mockito.anyInt())).thenReturn(EquipmentType.T_ARMOR_STANDARD); Mockito.when(mockTarget.getPosition()).thenReturn(new Coords(10, 15)); Assert.assertTrue( Mockito.when(((Entity) mockTarget).getArmorType(Mockito.anyInt())).thenReturn(EquipmentType.T_ARMOR_STANDARD); Mockito.when(mockTarget.getPosition()).thenReturn(new Coords(10, 15)); Mockito.when(((Entity) mockTarget).getDamageLevel()).thenReturn(Entity.DMG_HEAVY); Assert.assertEquals(mockAmmoLB10XCluster, testFireControl.getPreferredAmmo(mockShooter, mockTarget, mockLB10X));
double armorPoints = 0; for (int loc = 0; loc < locations(); loc++) { double armorMod = 1; switch (getArmorType(loc)) { case EquipmentType.T_ARMOR_COMMERCIAL: armorMod = .5; case EquipmentType.T_ARMOR_INDUSTRIAL: case EquipmentType.T_ARMOR_HEAVY_INDUSTRIAL: armorMod = getBARRating(0) / 10; break; case EquipmentType.T_ARMOR_FERRO_LAMELLOR: break; armorPoints += Math.ceil(getArmor(loc) * armorMod); if (this.hasModularArmor()) { for (Mounted mount : this.getEquipment()) { if (!mount.isDestroyed() && (mount.getType() instanceof MiscType) if (isCapitalScale()) { return (int)Math.round(armorPoints * 0.33);
if (target instanceof Entity) { targetEntity = (Entity) target; final int armorType = targetEntity.getArmorType(0); if (targetEntity instanceof Mech) { targetEntity.getArmorType(1); final List<Mounted> ammo = shooter.getAmmo(); final List<Mounted> validAmmo = new ArrayList<>(); for (final Mounted a : ammo) { final int range = shooter.getPosition().distance(target.getPosition()); msg.append("\n\tRange to target is ").append(range); if (targetEntity.isAirborne() || (targetEntity instanceof VTOL)) { msg.append("\n\tTarget is airborne... "); preferredAmmo = getAntiAirAmmo(validAmmo, weaponType, range); if (Entity.DMG_HEAVY <= targetEntity.getDamageLevel()) { msg.append("\n\tTarget is heavily damaged... "); preferredAmmo = getClusterAmmo(validAmmo, weaponType, range); if (9 <= targetEntity.getHeat() && !fireResistant) { msg.append("\n\tTarget is at ").append(targetEntity.getHeat()).append(" heat... "); preferredAmmo = getHeatAmmo(validAmmo, weaponType, range); if (null != preferredAmmo) {
@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 ""; }
/** * defensively check and correct elevation */ public boolean fixElevation() { if (!isDeployed() || isOffBoard() || !game.getBoard().contains(getPosition())) { return false; } if (!isElevationValid(getElevation(), game.getBoard().getHex(getPosition()))) { System.err.println(getDisplayName() + " in hex " + HexTarget.coordsToId(getPosition()) + " is at invalid elevation: " + getElevation()); setElevation(0 - game.getBoard() .getHex(getPosition()).depth()); System.err.println(" moved to elevation " + getElevation()); return true; } return false; }
hit = entityTarget.rollHitLocation(toHit.getHitTable(), toHit.getSideTable(), waa.getAimedLocation(), waa.getAimingMode(), toHit.getCover()); hit.setAttackerId(getAttackerId()); if (entityTarget.removePartialCoverHits(hit.getLocation(), toHit .getCover(), Compute.targetSideTable(ae, entityTarget, weapon.getCalledShot().getCall()))) { r.subject = subjectId; r.add(toHit.getTableDesc()); r.add(entityTarget.getLocationAbbr(hit)); vPhaseReport.addElement(r); r.subject = subjectId; r.indent(2); if (entityTarget.getArmor(hit) > 0 && ((entityTarget.getArmorType(hit.getLocation()) == EquipmentType.T_ARMOR_HEAT_DISSIPATING) || (entityTarget.getArmorType(hit.getLocation()) == EquipmentType.T_ARMOR_REFLECTIVE))){ entityTarget.heatFromExternal += 1; r.add(2); r.add(EquipmentType.armorNames [entityTarget.getArmorType(hit.getLocation())]); } else { entityTarget.heatFromExternal += 2;
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(); }
protected String formatArmorType(Entity entity, boolean trim) { if (entity.hasETypeFlag(Entity.ETYPE_SUPPORT_TANK) || entity.hasETypeFlag(Entity.ETYPE_SUPPORT_VTOL) || entity.hasETypeFlag(Entity.ETYPE_FIXED_WING_SUPPORT)) { return "BAR " + entity.getBARRating(Tank.LOC_FRONT); } if (entity.hasPatchworkArmor()) { return EquipmentType.getArmorTypeName(EquipmentType.T_ARMOR_PATCHWORK); } // Some types do not have armor on the first location, and others have only a // single location final int at = entity.getArmorType(Math.min(1, entity.locations() - 1)); if (trim && (at == EquipmentType.T_ARMOR_STANDARD)) { return ""; } String name = EquipmentType.getArmorTypeName(at); if (trim) { name = name.replace("-Fibrous", "").replace("-Aluminum", ""); if (at == EquipmentType.T_ARMOR_EDP) { name = "EDP"; } } return name; }
private boolean isEnemyGunEmplacement(final Entity entity, final Coords coords) { return entity.hasETypeFlag(Entity.ETYPE_GUN_EMPLACEMENT) && entity.getOwner().isEnemyOf(getLocalPlayer()) && !getStrategicBuildingTargets().contains(coords) && (null != entity.getCrew()) && !entity.getCrew().isDead(); }
private static String formatHeader(Entity e) { StringBuffer sb = new StringBuffer(1024); sb.append("Model: ").append(e.getChassis()).append(" - ") .append(e.getModel()).append(CommonConstants.NL); for (int i = 0; i < e.getCrew().getSlotCount(); i++) { if (e.getCrew().isMissing(i)) { sb.append("No ").append(e.getCrew().getCrewType().getRoleName(i)); } else { sb.append(e.getCrew().getCrewType().getRoleName(i)).append(": ") .append(e.getCrew().getName(i)); sb.append(" (").append(e.getCrew().getGunnery(i)).append("/") .append(e.getCrew().getPiloting(i)).append(")"); } sb.append(CommonConstants.NL); } if (e.isCaptured()) { sb.append(" *** CAPTURED BY THE ENEMY ***"); sb.append(CommonConstants.NL); } return sb.toString(); }
/** * @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; }
/** * Generate a Quirk's Unit ID given an Entity. * * @param ent Entity to generate UnitId from * @param useModel determines if the model should be used, or be 'all' * @return The ID for the unit. */ private static String getUnitId(Entity ent, boolean useModel) { String typeText = Entity.getEntityMajorTypeName(ent.getEntityType()); if (useModel) { return ent.getChassis() + "~" + ent.getModel() + "~" + typeText; } else { return ent.getChassis() + "~~" + typeText; } }
/** * Returns the total amount of armor on the entity. */ public int getTotalArmor() { int totalArmor = 0; for (int i = 0; i < locations(); i++) { if (getArmor(i) > 0) { totalArmor += getArmor(i); } if (hasRearArmor(i) && (getArmor(i, true) > 0)) { totalArmor += getArmor(i, true); } } return totalArmor; }
Vector<Report> vPhaseReport, Building bldg, int hits, int nCluster, int bldgAbsorbs) { HitData hit = entityTarget.rollHitLocation(toHit.getHitTable(), toHit.getSideTable(), waa.getAimedLocation(), waa.getAimingMode(), toHit.getCover()); if (entityTarget.getInternal(hit) <= 0) { if (hit.getLocation() == Mech.LOC_RLEG) { hit = new HitData(Mech.LOC_LLEG); r.subject = subjectId; r.add(toHit.getTableDesc()); r.add(entityTarget.getLocationAbbr(hit)); vPhaseReport.addElement(r); if (entityTarget.getArmorType(hit.getLocation()) == EquipmentType.T_ARMOR_HARDENED) { critMod -= 2; if (ae.hasAbility(OptionsConstants.MISC_HUMAN_TRO,Crew.HUMANTRO_MECH)) { critMod += 1;
@Override public String toString() { return "Entity [" + getDisplayName() + ", " + getId() + "]"; }