public ECMInfo(int range, double strength, Entity e) { owningEntity = e; owner = e.getOwner(); pos = e.getPosition(); this.range = range; this.strength = strength; }
/** * Returns the number of entities owned by the player, regardless of their * status, as long as they are in the game. */ public int getEntitiesOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player)) { count++; } } return count; }
/** * Returns true if the other entity is an enemy of this entity. This is more * reliable than Player.isEnemyOf since it knows that an entity will never * be an enemy of itself. */ public boolean isEnemyOf(Entity other) { if(null == other) { return false; } if(null == owner) { return ((id != other.getId()) && (ownerId != other.ownerId)); } return (id != other.getId()) && ((null == other.getOwner()) || owner.isEnemyOf(other.getOwner())); }
/** * 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; }
public String getPlayerColor() { if (onlyDetectedBySensors()) { return "C0C0C0"; } else { return Integer.toHexString(PlayerColors.getColorRGB(entity .getOwner().getColorIndex())); } }
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 FlyOverSprite(BoardView1 boardView1, final Entity e) { super(boardView1); en = e; spriteColor = PlayerColors.getColor(e.getOwner().getColorIndex()); image = null; prepare(); }
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 void loadFS(Vector<Integer> fighterIds) { String name = JOptionPane.showInputDialog(clientgui.frame, "Choose a squadron designation"); if ((name == null) || (name.trim().length() == 0)) { name = "Flying Circus"; } FighterSquadron fs = new FighterSquadron(name); fs.setOwner(clientgui.getClient().getGame().getEntity(fighterIds.firstElement()).getOwner()); clientgui.getClient().sendAddSquadron(fs, fighterIds); }
@Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = tableEntities.rowAtPoint(e.getPoint()); Entity entity = mekModel.getEntityAt(row); if (entity != null) { boolean isOwner = entity.getOwner().equals(clientgui.getClient().getLocalPlayer()); boolean isBot = clientgui.getBots().get(entity.getOwner().getName()) != null; if ((isOwner || isBot)) { customizeMech(entity); } } } }
VTOLAttackSprite(BoardView1 boardView, Entity en) { super(boardView); this.bv = boardView; this.entity = en; spriteColor = PlayerColors.getColor(en.getOwner().getColorIndex()); image = null; prepare(); }
/** * 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; }
/** * Returns the number of remaining selectable infantry owned by a player. */ public int getInfantryLeft(int playerId) { IPlayer player = getPlayer(playerId); int remaining = 0; for (Entity entity : entities) { if (player.equals(entity.getOwner()) && entity.isSelectableThisTurn() && (entity instanceof Infantry)) { remaining++; } } return remaining; }
/** * Returns the number of remaining selectable Protomechs owned by a player. */ public int getProtomechsLeft(int playerId) { IPlayer player = getPlayer(playerId); int remaining = 0; for (Entity entity : entities) { if (player.equals(entity.getOwner()) && entity.isSelectableThisTurn() && (entity instanceof Protomech)) { remaining++; } } return remaining; }
private boolean isEnemyInfantry(final Entity entity, final Coords coords) { return entity.hasETypeFlag(Entity.ETYPE_INFANTRY) && !entity.hasETypeFlag(Entity.ETYPE_MECHWARRIOR) && entity.getOwner().isEnemyOf(getLocalPlayer()) && !getStrategicBuildingTargets().contains(coords); }
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; }
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(); }
/** * @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; }
/** * 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; }