/** * 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 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 accept(Entity acc) { if (turn.isValid(ownerId, acc, game)) { return true; } return false; } });
public String toString() { return super.toString() + " eid: " + entityId; } }
/** * Sets the current turn index */ public void setTurnIndex(int turnIndex, int prevPlayerId) { // FIXME: occasionally getTurn() returns null. Handle that case // intelligently. this.turnIndex = turnIndex; processGameEvent(new GameTurnChangeEvent(this, getPlayer(getTurn() .getPlayerNum()), prevPlayerId)); }
public String toString() { return super.toString() + " mask: " + mask; } }
GameTurn turn = m_game.getTurn(); if ((turn != null) && (turn.getPlayerNum() == m_client.getLocalPlayer() .getId())) { Entity depEnt = m_bview.getDeployingEntity(); depEnt.getOwnerId() == turn.getPlayerNum()) { dir = depEnt.getStartingPos(); } else { // if we can't get the deploy zone from the
/** * 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); }
public GameTurn getTurnForPlayer(int pn) { for (int i = turnIndex; i < turnVector.size(); i++) { GameTurn gt = turnVector.get(i); if (gt.isValid(pn, this)) { return gt; } } return null; }
@Override public String toString() { return super.toString() + ", entity IDs: [" + entityIds + "]"; }
/** * 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; }
/** * Can I unload entities stranded on immobile transports? */ public boolean canUnloadStranded() { return (game.getTurn() instanceof GameTurn.UnloadStrandedTurn) && game.getTurn().isValid(localPlayerNumber, game); }
/** * 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())); } }
/** * is it my turn? */ public boolean isMyTurn() { if (game.isPhaseSimultaneous()) { return game.getTurnForPlayer(localPlayerNumber) != null; } return (game.getTurn() != null) && game.getTurn().isValid(localPlayerNumber, game); }
/** * 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; }
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; }