@Override public String toString() { return "Entity [" + getDisplayName() + ", " + getId() + "]"; }
public String toString() { String entName = "None"; if (getEntity() != null) { entName = getEntity().getDisplayName(); } return "Unit for Entity: " + entName; }
StringBuffer callsign = new StringBuffer(other.getDisplayName()); callsign.append(" (")//$NON-NLS-1$ .append((other.getUnitNumber() + PreferenceManager
private JMenuItem viewJMenuItem(Entity en) { JMenuItem item = new JMenuItem( Messages.getString("ClientGUI.viewMenuItem") + en.getDisplayName()); item.setActionCommand(Integer.toString(en.getId())); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { selectedEntity = game.getEntity(Integer.parseInt(e .getActionCommand())); gui.setDisplayVisible(true); gui.mechD.displayEntity(selectedEntity); } catch (Exception ex) { ex.printStackTrace(); } } }); return item; }
private void parseAdvantages(Entity entity, String adv) { String[] advantages = adv.split(SEPARATOR_SPACE, -1); for(String curAdv : advantages) { String[] advantageData = curAdv.split(SEPARATOR_COLON, -1); IOption option = entity.getCrew().getOptions().getOption(advantageData[0]); if(null == option) { System.err.println(String.format("Ignoring invalid pilot advantage '%s'", //$NON-NLS-1$ curAdv)); } else { System.out.println(String.format("Adding pilot advantage '%s' to %s", //$NON-NLS-1$ curAdv, entity.getDisplayName())); if(advantageData.length > 1) { option.setValue(advantageData[1]); } else { option.setValue(true); } } } }
private JMenuItem selectJMenuItem(Entity en) { JMenuItem item = new JMenuItem( Messages.getString("ClientGUI.selectMenuItem") + en.getDisplayName()); item.setActionCommand(Integer.toString(en.getId())); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Entity entity = game.getEntity(Integer.parseInt(e .getActionCommand())); selectedEntity = entity; if (currentPanel instanceof MovementDisplay) { ((MovementDisplay) currentPanel) .selectEntity(selectedEntity.getId()); } else if (currentPanel instanceof FiringDisplay) { ((FiringDisplay) currentPanel) .selectEntity(selectedEntity.getId()); } else if (currentPanel instanceof PhysicalDisplay) { ((PhysicalDisplay) currentPanel) .selectEntity(selectedEntity.getId()); } } catch (Exception ex) { ex.printStackTrace(); } } }); return item; }
private void parseCamo(Entity entity, String camoString) throws ScenarioLoaderException { String[] camoData = camoString.split(SEPARATOR_COMMA, -1); String camoGroup = getValidCamoGroup(camoData[0]); if(null == camoGroup) { throw new ScenarioLoaderException("invalidIndividualCamoGroup", //$NON-NLS-1$ camoData[0], entity.getDisplayName()); } String camoName = getValidCamoName(camoGroup, camoData[1]); if(null == camoName) { throw new ScenarioLoaderException("invalidIndividualCamoName", //$NON-NLS-1$ camoData[1], camoGroup, entity.getDisplayName()); } entity.setCamoCategory(camoGroup); entity.setCamoFileName(camoName); }
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(); }
boolean canFlankAndKick(Entity enemy, Coords behind, Coords leftFlank, Coords rightFlank, int myFacing) { final String METHOD_NAME = "canFlankAndKick(Entity, Coords, Coords, " + "Coords, int)"; Set<CoordFacingCombo> enemyFacingSet = pathEnumerator.getUnitPotentialLocations().get(enemy.getId()); if (enemyFacingSet == null) { getOwner().log(getClass(), METHOD_NAME, LogLevel.WARNING, "no facing set for " + enemy.getDisplayName()); return false; } return enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(behind, myFacing)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(behind, (myFacing + 1) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(behind, (myFacing + 5) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(leftFlank, myFacing)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(leftFlank, (myFacing + 4) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(leftFlank, (myFacing + 5) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(rightFlank, myFacing)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(rightFlank, (myFacing + 1) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(rightFlank, (myFacing + 2) % 6)); }
private String strListNetwork(int id, boolean planned) { String rval = ""; Entity ent = client.getEntity(id); if(ent != null) { for(Entity e : listNetwork(ent,planned)) { rval += "+ "+e.getId()+" "+e.getDisplayName()+"\n"; } } if(rval != "") { rval = "Unit "+id+" is in the Network consisting of:\n"; } else { rval = "Error. No ID match.\n"; } return rval; }
public String printTechLevel() { return "Chassis: " + getEntity().getDisplayName() + " - " + TechConstants.getLevelName(getEntity().getTechLevel()) + " (" + Integer.toString(getEntity().getYear()) + ")\n"; }
rval += "+ " + re.getId() + " " + re.getDisplayName() + "\n"; allreadyReported.add(re.getId()); noLink += "+ " + ent.getId() + " " + ent.getDisplayName() + "\n"; allreadyReported.add(ent.getId());
private String strListNetwork(int connID, int id, boolean planned) { String rval = ""; Entity ent = server.getGame().getEntity(id); if (ent != null) { if (ent.getOwnerId() != connID) { return "This unit doesn't belong to you!\n"; } for (Entity e : listNetwork(connID, ent, planned)) { rval += "+ " + e.getId() + " " + e.getDisplayName() + "\n"; } } if (rval != "") { rval = "Unit " + id + " is in the Network consisting of:\n"; } else { rval = "Error. No ID match.\n"; } return rval; }
public void run() { final String METHOD_NAME = "run()"; getOwner().methodBegin(getClass(), METHOD_NAME); try { // todo There's probably a better way to handle this than a loop that only exits on an error. //noinspection InfiniteLoopStatement while (!getDone().get()) { if (!getEventsToProcess().isEmpty()) { processGameEvents(); ecmInfo = ComputeECM.computeAllEntitiesECMInfo( getGame().getEntitiesVector()); } else if (!getDirtyUnits().isEmpty()) { Entity entity = getGame().getEntity(getDirtyUnits().pollFirst()); if ((entity != null) && isEntityOnMap(entity)) { unPause(); getOwner().log(getClass(), METHOD_NAME, "recalculating paths for " + entity.getDisplayName()); getPathEnumerator().recalculateMovesFor(entity); getOwner().log(getClass(), METHOD_NAME, "finished recalculating paths for " + entity .getDisplayName()); } } else if (getWaitWhenDone().get()) { waitForUnpause(); // paused for a reason } else { waitForUnpause(); // idling because there's nothing to do } } } finally { getOwner().methodEnd(getClass(), METHOD_NAME); } }
/** * Run this command with the arguments supplied * * @see megamek.server.commands.ServerCommand#run(int, java.lang.String[]) */ @Override public void run(int connId, String[] args) { IPlayer p = server.getGame().getPlayer(connId); if(null == p) { return; } for (Entity ent : server.getGame().getEntitiesVector()) { try { if(ent.getOwnerId() == connId) { server.sendServerChat(connId, ent.getId() + " - " + ent.getDisplayName()); } } catch (NumberFormatException nfe) { } catch (NullPointerException npe) { } catch (IndexOutOfBoundsException ioobe) { } } } }
/** * 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; }
server.sendServerChat(connId, ent.getDisplayName() + " will switch to " + player.getName() + "'s side at the end of this turn."); ent.setTraitorId(pid);
/** * Run this command with the arguments supplied */ @Override public void run(int connId, String[] args) { int countbad = 0; for (Entity entity : server.getGame().getEntitiesVector()) { if (entity.fixElevation()) { Building bldg = server.getGame().getBoard().getBuildingAt(entity.getPosition()); if (bldg != null) { server.checkForCollapse(bldg, server.getGame().getPositionMap(), entity.getPosition(), true, server.getvPhaseReport()); } server.sendServerChat(entity.getDisplayName() + " elevation fixed, see megameklog.txt for details & report a bug if you know how this happened"); countbad++; } } server.sendServerChat(connId, "" + countbad + " unit(s) had elevation problems"); }
shooter.getDisplayName() + " tried to load " + currentWeapon.getName() + " with ammo " + mountedAmmo.getDesc() + " but failed somehow.");
/** * This returns a textual description of the entity for visualy impaired * users. */ public String statusToString() { // should include additional information like imobile. String str = "Entity [" + getDisplayName() + ", " + getId() + "]: "; if (getPosition() != null) { str = str + "Location: (" + (getPosition().getX() + 1) + ", " + (getPosition().getY() + 1) + ") "; } str = str + "Owner: " + owner.getName() + " Armor: " + getTotalArmor() + "/" + getTotalOArmor() + " Internal Structure: " + getTotalInternal() + "/" + getTotalOInternal(); if (!isActive()) { str += " Inactive"; } if (isImmobile()) { str += " Immobile"; } if (isProne()) { str += " Prone"; } if (isDone()) { str += " Done"; } return str; }