/** * Returns an enumeration of the entities in game.entities */ public List<Entity> getEntitiesVector() { return game.getEntitiesVector(); }
/** * @param source event source */ @SuppressWarnings("unchecked") public GameVictoryEvent(Object source, IGame game) { super(source); for (Entity entity : game.getEntitiesVector()) { entities.add(entity); entityIds.put(entity.getId(), entity); } vOutOfGame = (Vector<Entity>) game.getOutOfGameEntitiesVector().clone(); for (Entity entity : vOutOfGame) { entityIds.put(entity.getId(), entity); } }
/** * Checks to see if an entity has already been detected by anyone * Used for sensor return icons on board * * @param game - the current game * @param detector - the entity making a sensor scan */ public static boolean isSensorContact(IGame game, Entity target) { for (Entity detector : game.getEntitiesVector()) { if (detector.sensorContacts.contains(target)) { target.addBeenDetectedBy(detector.getOwner()); return true; } } return false; }
/** * Checks to see if an entity is in anyone's firing solutions list * Used for visibility * * @param game - the current game * @param detector - the entity making a sensor scan */ public static boolean hasAnyFiringSolution(IGame game, Entity target) { for (Entity detector : game.getEntitiesVector()) { if (detector.firingSolutions.contains(target)) { target.addBeenSeenBy(detector.getOwner()); return true; } } return false; }
/** * Return a list of all nova CEWS units the clients player owns. * * @return */ private List<Entity> getMyNovaUnits(int connID) { List<Entity> novaUnits = new LinkedList<Entity>(); for (Entity ent : server.getGame().getEntitiesVector()) { if ((ent.getOwnerId() == connID) && ent.hasNovaCEWS()) { novaUnits.add(ent); } } return novaUnits; }
public List<Entity> getFriendEntities() { List<Entity> result = new ArrayList<>(); for (Entity entity : game.getEntitiesVector()) { if (!entity.getOwner().isEnemyOf(getLocalPlayer()) && (entity.getPosition() != null) && !entity.isOffBoard()) { result.add(entity); } } return result; }
public List<Entity> getEntitiesOwned() { ArrayList<Entity> result = new ArrayList<>(); for (Entity entity : game.getEntitiesVector()) { if (entity.getOwner().equals(getLocalPlayer()) && (entity.getPosition() != null) && !entity.isOffBoard()) { result.add(entity); } } return result; }
public void refreshMoveVectors() { clearAllMoveVectors(); for (Entity e : game.getEntitiesVector()) { if (e.getPosition() != null) { movementSprites.add(new MovementSprite(this, e, e.getVectors(), Color.gray, false)); } } }
public void updateEntityLabels() { for (Entity e: game.getEntitiesVector()) { e.generateShortName(); } for (EntitySprite eS: entitySprites) { eS.prepare(); } repaint(); }
private JMenu createViewMenu() { JMenu menu = new JMenu("View"); IGame game = client.getGame(); IPlayer localPlayer = client.getLocalPlayer(); for (Entity entity : game.getEntitiesVector(coords, true)) { // Only add the unit if it's actually visible // With double blind on, the game may unseen units if (!entity.isSensorReturn(localPlayer) && entity.hasSeenEntity(localPlayer)) { menu.add(viewJMenuItem(entity)); } } return menu; }
@Override protected void initFiring() { ArrayList<Entity> entities = new ArrayList<Entity>( game.getEntitiesVector()); for (int i = 0; i < entities.size(); i++) { Entity entity = entities.get(i); CEntity centity = centities.get(entity); centity.reset(); centity.enemy_num = i; } for (Entity entity : getEnemyEntities()) { CEntity centity = centities.get(entity); if (entity.isMakingDfa() || entity.isCharging()) { // try to prevent a physical attack from happening // but should take into account the toHit of the attack centity.strategy.target = 2.5; } } }
/** * Returns any known displacement attacks (should only be one) that this * entity is a target of. */ public DisplacementAttackAction findTargetedDisplacement() { for (Entity other : game.getEntitiesVector()) { if (other.hasDisplacementAttack() && (other.getDisplacementAttack().getTargetId() == id)) { return other.getDisplacementAttack(); } } return null; }
private JMenu createSelectMenu() { JMenu menu = new JMenu("Select"); // add select options if (canSelectEntities()) { for (Entity entity : client.getGame().getEntitiesVector(coords, canTargetEntities())) { if (client.getMyTurn().isValidEntity(entity, client.getGame())) { menu.add(selectJMenuItem(entity)); } } } return menu; }
public void loadRandomNames() { clientgui.getRandomNameDialog().showDialog(clientgui.getClient().getGame().getEntitiesVector()); }
public void loadRandomSkills() { clientgui.getRandomSkillDialog().showDialog(clientgui.getClient().getGame().getEntitiesVector()); }
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 void refreshMoveVectors(Entity en, MovePath md, Color col) { clearAllMoveVectors(); // same as normal but when I find the active entity I used the MovePath // to get vector for (Entity e : game.getEntitiesVector()) { if (e.getPosition() != null) { if ((en != null) && (e.getId() == en.getId())) { movementSprites.add(new MovementSprite(this, e, md .getFinalVectors(), col, true)); } else { movementSprites.add(new MovementSprite(this, e, e.getVectors(), col, false)); } } } }
/** * @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; }
public Precognition(Princess owner) { this.owner = owner; this.game = new Game(); getGame().addGameListener(new GameListenerAdapter() { @Override public void gameEntityChange(GameEntityChangeEvent changeEvent) { getEventsToProcess().add(changeEvent); wakeUp(); } @Override public void gamePhaseChange(GamePhaseChangeEvent changeEvent) { getEventsToProcess().add(changeEvent); wakeUp(); } }); setPathEnumerator(new PathEnumerator(owner, getGame())); // Initialize ECM Info, especially important if Princess added mid-game ecmInfo = ComputeECM.computeAllEntitiesECMInfo( getGame().getEntitiesVector()); }
/** * 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"); }