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

How to use
GameTurn
in
megamek.common

Best Java code snippets using megamek.common.GameTurn (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 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 accept(Entity acc) {
    if (turn.isValid(ownerId, acc, game)) {
      return true;
    }
    return false;
  }
});
origin: MegaMek/megamek

  public String toString() {
    return super.toString() + " eid: " + entityId;
  }
}
origin: MegaMek/megamek

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

  public String toString() {
    return super.toString() + " mask: " + mask;
  }
}
origin: MegaMek/megamek

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 
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

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

@Override
public String toString() {
  return super.toString() + ", entity IDs: [" + entityIds + "]";
}
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

/**
 * Can I unload entities stranded on immobile transports?
 */
public boolean canUnloadStranded() {
  return (game.getTurn() instanceof GameTurn.UnloadStrandedTurn)
      && game.getTurn().isValid(localPlayerNumber, game);
}
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

/**
 * is it my turn?
 */
public boolean isMyTurn() {
  if (game.isPhaseSimultaneous()) {
    return game.getTurnForPlayer(localPlayerNumber) != null;
  }
  return (game.getTurn() != null) && game.getTurn().isValid(localPlayerNumber, game);
}
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

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;
}
megamek.commonGameTurn

Javadoc

Represents a single turn within a phase of the game, where a specific player has to declare his/her action. The default game turn allows a player to move any entity.

Most used methods

  • isValidEntity
    Determine if the specified entity is a valid one to use for this turn. In addition to the "standard"
  • 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

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • requestLocationUpdates (LocationManager)
  • setContentView (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • JButton (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Runner (org.openjdk.jmh.runner)
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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