Tabnine Logo
GameTurn.isValidEntity
Code IndexAdd Tabnine to your IDE (free)

How to use
isValidEntity
method
in
megamek.common.GameTurn

Best Java code snippets using megamek.common.GameTurn.isValidEntity (Showing top 20 results out of 315)

origin: MegaMek/megamek

/**
 * 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);
}
origin: MegaMek/megamek

/**
 * 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);
}

origin: MegaMek/megamek

/**
 * 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;
}
origin: MegaMek/megamek

  /**
   * 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()));
  }
}
origin: MegaMek/megamek

/**
 * 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);
}
origin: MegaMek/megamek

/**
 * 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;
}
origin: MegaMek/megamek

/**
 * 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);
}

origin: MegaMek/megamek

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;
}
origin: MegaMek/megamek

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;
}
origin: MegaMek/megamek

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;
}
origin: MegaMek/megamek

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;
}
origin: MegaMek/megamek

/**
 * 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;
}
origin: MegaMek/megamek

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);
}
origin: MegaMek/megamek

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;
}
origin: MegaMek/megamek

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;
}
origin: MegaMek/megamek

/**
 * 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;
}
origin: MegaMek/megamek

@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());
    }
  }
}
origin: MegaMek/megamek

@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());
    }
  }
}
origin: MegaMek/megamek

@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());
    }
  }
}
origin: MegaMek/megamek

@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());
    }
  }
}
megamek.commonGameTurnisValidEntity

Javadoc

Determine if the specified entity is a valid one to use for this turn.

Popular methods of GameTurn

  • getClassCode
    Get the class code for the given entity.
  • getPlayerNum
  • isValid
    Returns true if the player is valid.
  • toString
    Prints out a shortened class name (w/o package information) plus the id of the player whose turn thi

Popular in Java

  • Creating JSON documents from java classes using gson
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
  • onRequestPermissionsResult (Fragment)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Permission (java.security)
    Legacy security code; do not use.
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now