/** * Has this entity been captured? * * @return <code>true</code> if it has. */ public boolean isCaptured() { return captured && !isDestroyed(); }
/** * The default implementation calls getSubEntities(), then filters them. This might not be * the optimal code for many applications, so feel free to override both if needed. * * @return an optional collection of sub-entities, if this entity is considered a grouping of them, * pre-filtered to only contain active (non-destroyed and non-doomed) entities. */ public Optional<List<Entity>> getActiveSubEntities() { return getSubEntities().map( ents -> ents.stream().filter( ent -> !(ent.isDestroyed() || ent.isDoomed())).collect(Collectors.toList())); }
/** * Returns the number of non-destroyed entityes owned by the player */ public int getLiveEntitiesOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player) && !entity.isDestroyed() && !entity.isCarcass()) { count++; } } return count; }
public String destroy(String reason, boolean survivable, boolean canSalvage) { StringBuffer sb = new StringBuffer(); int condition = IEntityRemovalConditions.REMOVE_SALVAGEABLE; if (!canSalvage) { setSalvage(canSalvage); condition = IEntityRemovalConditions.REMOVE_DEVASTATED; } if (isDoomed() || isDestroyed()) { return sb.toString(); } // working under the assumption that entity was neither doomed or // destroyed before from here on out setDoomed(true); Enumeration<Integer> iter = getPickedUpMechWarriors().elements(); while (iter.hasMoreElements()) { Integer mechWarriorId = iter.nextElement(); Entity mw = game.getEntity(mechWarriorId.intValue()); mw.setDestroyed(true); game.removeEntity(mw.getId(), condition); sb.append("\n*** ").append( mw.getDisplayName() + " died in the wreckage. ***\n"); } return sb.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 static boolean isLikelyCapture(Entity en) { //most of these conditions are now controlled better in en.canEscape, but there //are some additional ones we want to add if(!en.canEscape()) { return true; } return en.isDestroyed() || en.isDoomed() || en.isStalled() || en.isStuck(); }
Vector<Entity> toRemove = new Vector<Entity>(); if (detector.isDestroyed() || detector.isOffBoard() || detector.getPosition() == null) { if (target.isDestroyed() || target.isOffBoard() || target.getPosition() == null) {
/** * cycle through entities on team and collect all the airborne VTOL/WIGE * * @return a vector of relevant entity ids */ @Override public Vector<Integer> getAirborneVTOL() { //a vector of unit ids Vector<Integer> units = new Vector<Integer>(); for (Entity entity : game.getEntitiesVector()) { if (entity.getOwner().equals(this)) { if (((entity instanceof VTOL) || (entity.getMovementMode() == EntityMovementMode.WIGE)) && (!entity.isDestroyed()) && (entity.getElevation() > 0)) { units.add(entity.getId()); } } } return units; }
/** * @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; }
Vector<Entity> toRemove = new Vector<Entity>(); if (detector.isDestroyed() || detector.isOffBoard() || detector.getPosition() == null) { if (target.isDestroyed() || target.isOffBoard() || target.getPosition() == null) {
/** * Are we trapped inside of a destroyed transport? If so we shouldn't count * for BV, which is why we have this check. */ public boolean isTrapped() { if (getTransportId() != Entity.NONE) { Entity transport = game.getEntity(getTransportId()); if (transport == null) { transport = game.getOutOfGameEntity(getTransportId()); } if (transport.isDestroyed()) { return true; } } return false; }
/** * Returns the number of non-destroyed entities owned by the player, * including entities not yet deployed. Ignore offboard units and captured * Mek pilots. */ public int getLiveDeployedEntitiesOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player) && !entity.isDestroyed() && !entity.isCarcass() && !entity.isOffBoard() && !entity.isCaptured()) { count++; } } return count; }
/** * Returns the number of non-destroyed deployed entities owned by the * player. Ignore offboard units and captured Mek pilots. */ public int getLiveCommandersOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player) && !entity.isDestroyed() && !entity.isCarcass() && entity.isCommander() && !entity.isOffBoard() && !entity.isCaptured()) { count++; } } return count; }
@Override protected void handleEntityDamage(Entity entityTarget, Vector<Report> vPhaseReport, Building bldg, int hits, int nCluster, int bldgAbsorbs) { Report r; // Is the target already swarmed? if (Entity.NONE != entityTarget.getSwarmAttackerId()) { r = new Report(3265); r.subject = subjectId; vPhaseReport.addElement(r); } // Did the target get destroyed by weapons fire? else if (entityTarget.isDoomed() || entityTarget.isDestroyed() || entityTarget.getCrew().isDead()) { r = new Report(3270); r.subject = subjectId; vPhaseReport.addElement(r); } else { // success r = new Report(3275); r.subject = subjectId; vPhaseReport.addElement(r); ae.setSwarmTargetId(waa.getTargetId()); entityTarget.setSwarmAttackerId(waa.getEntityId()); } }
escaped = new JCheckBox("Escapes"); escaped.setSelected(!status.isLikelyCaptured()); escaped.setEnabled(!(u.getEntity().isDestroyed() || u.getEntity().isDoomed())); escaped.addItemListener(new ItemListener() { @Override
/** * Returns true if the player has a valid unit with the Tactical Genius * pilot special ability. */ public boolean hasTacticalGenius(IPlayer player) { for (Entity entity : entities) { if (entity.hasAbility(OptionsConstants.MISC_TACTICAL_GENIUS) && entity.getOwner().equals(player) && !entity.isDestroyed() && entity.isDeployed() && !entity.isCarcass() && !entity.getCrew().isUnconscious()) { return true; } } return false; }
boolean isPlatoon, boolean ammoExplosion, boolean ignoreInfantryDoubleDamage) { if (isPlatoon && !te.isDestroyed() && !te.isDoomed() && !ignoreInfantryDoubleDamage && (((Infantry) te).getDugIn() != Infantry.DUG_IN_COMPLETE) && !te.hasAbility(OptionsConstants.MD_DERMAL_ARMOR)) {
if ((null != entity.getOwner()) && entity.getOwner().equals(this) && !entity.isDestroyed() && entity.isDeployed() && !entity.isOffBoard()