/** * Returns true if the player and entity are both valid. */ public boolean isValid(int playerId, Entity entity, IGame game) { return (playerId == this.playerId) && isValidEntity(entity, game); }
/** * Determine if the specified entity is a valid one to use for this turn. * * @param entity the <code>Entity</code> that may take this turn. * @param game the <code>IGame</code> this turn belongs to. * @return <code>true</code> if the specified entity can take this turn. * <code>false</code> if the entity is not valid for this turn. */ public boolean isValidEntity(Entity entity, IGame game) { return isValidEntity(entity,game,true); }
/** * Removes the first turn found that the specified entity can move in. Used * when a turn is played out of order */ public GameTurn removeFirstTurnFor(Entity entity) { assert (phase != Phase.PHASE_MOVEMENT); // special move multi cases // ignored for (int i = turnIndex; i < turnVector.size(); i++) { GameTurn turn = turnVector.elementAt(i); if (turn.isValidEntity(entity, this)) { turnVector.removeElementAt(i); return turn; } } return null; }
/** * Returns true if the specified entity is a valid one to use for this * turn. */ @Override public boolean isValidEntity(Entity entity, IGame game, boolean useValidNonInfantryCheck) { return (super.isValidEntity(entity, game, useValidNonInfantryCheck) && (unitNumber == entity.getUnitNumber())); } }
/** * Returns true if the entity is normally valid and it is the specific * entity that can move this turn. */ @Override public boolean isValidEntity(Entity entity, IGame game, boolean useValidNonInfantryCheck) { return super.isValidEntity(entity, game, useValidNonInfantryCheck) && (entity.getId() == entityId); }
/** * Returns the id of the first entity that can act in the specified turn, or * -1 if none can. */ public int getFirstEntityNum(GameTurn turn) { if (turn == null) { return -1; } for (Entity entity : entities) { if (turn.isValidEntity(entity, this)) { return entity.getId(); } } return -1; }
/** * Determine if the given entity is a valid one to use for this turn. * * @param entity the <code>Entity</code> being tested for the move. * @param game the <code>IGame</code> the entity belongs to * @return <code>true</code> if the entity can be moved. */ @Override public boolean isValidEntity(Entity entity, IGame game, boolean useValidNonInfantryCheck) { // The entity must be in the mask, and pass // the requirements of the parent class. return ((GameTurn.getClassCode(entity) & mask) != 0) && super.isValidEntity(entity, game, useValidNonInfantryCheck); }
public boolean checkForValidJumpships(int playerId) { Iterator<Entity> iter = getPlayerEntities(getPlayer(playerId), false) .iterator(); while (iter.hasNext()) { Entity entity = iter.next(); if ((entity instanceof Jumpship) && !(entity instanceof Warship) && getTurn().isValidEntity(entity, this)) { return true; } } return false; }
public boolean checkForValidWarships(int playerId) { Iterator<Entity> iter = getPlayerEntities(getPlayer(playerId), false) .iterator(); while (iter.hasNext()) { Entity entity = iter.next(); if ((entity instanceof Warship) && getTurn().isValidEntity(entity, this)) { return true; } } return false; }
public boolean checkForValidDropships(int playerId) { Iterator<Entity> iter = getPlayerEntities(getPlayer(playerId), false) .iterator(); while (iter.hasNext()) { Entity entity = iter.next(); if ((entity instanceof Dropship) && getTurn().isValidEntity(entity, this)) { return true; } } return false; }
public boolean checkForValidSmallCraft(int playerId) { Iterator<Entity> iter = getPlayerEntities(getPlayer(playerId), false) .iterator(); while (iter.hasNext()) { Entity entity = iter.next(); if ((entity instanceof SmallCraft) && getTurn().isValidEntity(entity, this)) { return true; } } return false; }
/** * A set of checks for aero units to make sure that the movement order is * maintained */ public boolean checkForValidSpaceStations(int playerId) { Iterator<Entity> iter = getPlayerEntities(getPlayer(playerId), false) .iterator(); while (iter.hasNext()) { Entity entity = iter.next(); if ((entity instanceof SpaceStation) && getTurn().isValidEntity(entity, this)) { return true; } } return false; }
public int getNextDeployableEntityNum(GameTurn turn, int start) { if (start >= 0) { for (int i = start; i < entities.size(); i++) { final Entity entity = entities.get(i); if (turn.isValidEntity(entity, this) && entity.shouldDeploy(getRoundCount())) { return entity.getId(); } } } return getFirstDeployableEntityNum(turn); }
public int getFirstDeployableEntityNum(GameTurn turn) { // Repeat the logic from getFirstEntityNum. if (turn == null) { return -1; } for (Entity entity : entities) { if (turn.isValidEntity(entity, this) && entity.shouldDeploy(getRoundCount())) { return entity.getId(); } } return -1; }
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; }
/** * Returns true if the player has any valid units this turn that are not * infantry, not protomechs, or not either of those. This method is * utitilized by the "A players Infantry moves after that players other * units", and "A players Protomechs move after that players other units" * options. */ public boolean checkForValidNonInfantryAndOrProtomechs(int playerId) { Iterator<Entity> iter = getPlayerEntities(getPlayer(playerId), false) .iterator(); while (iter.hasNext()) { Entity entity = iter.next(); boolean excluded = false; if ((entity instanceof Infantry) && getOptions().booleanOption(OptionsConstants.INIT_INF_MOVE_LATER)) { excluded = true; } else if ((entity instanceof Protomech) && getOptions().booleanOption(OptionsConstants.INIT_PROTOS_MOVE_LATER)) { excluded = true; } if (!excluded && getTurn().isValidEntity(entity, this)) { return true; } } return false; }
@Override public void unitSelected(BoardViewEvent b) { // Are we ignoring events? if (isIgnoringEvents()) { return; } Entity e = clientgui.getClient().getGame().getEntity(b.getEntityId()); if (clientgui.getClient().isMyTurn()) { if (clientgui.getClient().getMyTurn() .isValidEntity(e, clientgui.getClient().getGame())) { selectEntity(e.getId()); } } else { clientgui.setDisplayVisible(true); clientgui.mechD.displayEntity(e); if (e.isDeployed()) { clientgui.bv.centerOnHex(e.getPosition()); } } }
@Override public void unitSelected(BoardViewEvent b) { // Are we ignoring events? if (isIgnoringEvents()) { return; } Entity e = clientgui.getClient().getGame().getEntity(b.getEntityId()); if (clientgui.getClient().isMyTurn()) { if (clientgui.getClient().getMyTurn() .isValidEntity(e, clientgui.getClient().getGame())) { selectEntity(e.getId()); } } else { clientgui.setDisplayVisible(true); clientgui.mechD.displayEntity(e); if (e.isDeployed()) { clientgui.bv.centerOnHex(e.getPosition()); } } }
@Override public void unitSelected(BoardViewEvent b) { // Are we ignoring events? if (isIgnoringEvents()) { return; } Entity e = clientgui.getClient().getGame().getEntity(b.getEntityId()); if (clientgui.getClient().isMyTurn()) { if (clientgui.getClient().getMyTurn() .isValidEntity(e, clientgui.getClient().getGame())) { selectEntity(e.getId()); } } else { clientgui.setDisplayVisible(true); clientgui.mechD.displayEntity(e); if (e.isDeployed()) { clientgui.bv.centerOnHex(e.getPosition()); } } }
@Override public void unitSelected(BoardViewEvent b) { // Are we ignoring events? if (isIgnoringEvents()) { return; } Entity e = clientgui.getClient().getGame().getEntity(b.getEntityId()); if (null == e) { return; } if (clientgui.getClient().isMyTurn()) { if (clientgui.getClient().getGame().getTurn() .isValidEntity(e, clientgui.getClient().getGame())) { selectEntity(e.getId()); } } else { clientgui.setDisplayVisible(true); clientgui.mechD.displayEntity(e); if (e.isDeployed()) { clientgui.bv.centerOnHex(e.getPosition()); } } }