megamek.common
Class GameTurn

java.lang.Object
  extended by megamek.common.GameTurn
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
GameTurn.EntityClassTurn, GameTurn.SpecificEntityTurn, GameTurn.UnitNumberTurn, GameTurn.UnloadStrandedTurn

public class GameTurn
extends java.lang.Object
implements java.io.Serializable

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.

Author:
Ben
See Also:
Serialized Form

Nested Class Summary
static class GameTurn.CounterGrappleTurn
          A type of game turn that allows only one specific entity to counterattack a break grapple by original attacker
static class GameTurn.EntityClassTurn
          A type of game turn that allows only certain types of units to move.
static class GameTurn.SpecificEntityTurn
          A type of game turn that allows only one specific entity to move.
static class GameTurn.TriggerAPPodTurn
          A type of game turn that allows only one specific entity to trigger their Anti-Personell pods against attacking infantry.
static class GameTurn.TriggerBPodTurn
          A type of game turn that allows only one specific entity to trigger their Anti-Battle Armor pods against attacking infantry/BA.
static class GameTurn.UnitNumberTurn
          A type of game turn that allows only entities belonging to certain units to move.
static class GameTurn.UnloadStrandedTurn
          A type of game turn that indicates that one or more players should be given the opportunity to unload entities that are stranded on immobile transports.
 
Field Summary
static int CLASS_AERO
          The constant to represent Aero entities.
static int CLASS_DROPSHIP
          The constant to represent dropship entities.
static int CLASS_GUN_EMPLACEMENT
          The constant to represent Gun Emplacement entities.
static int CLASS_INFANTRY
          The constant to represent Infantry (and Battle Armor) entities.
static int CLASS_JUMPSHIP
          The constant to represent jumpship entities.
static int CLASS_MECH
          The constant to represent Mech entities.
static int CLASS_PROTOMECH
          The constant to represent Protomech entities.
static int CLASS_SMALL_CRAFT
          The constant to represent warship entities.
static int CLASS_SPACE_STATION
          The constant to represent space station entities.
static int CLASS_TANK
          The constant to represent Tank entities.
static int CLASS_WARSHIP
          The constant to represent warship entities.
 
Constructor Summary
GameTurn(int playerId)
          Creates a new instance of GameTurn
 
Method Summary
static int getClassCode(Entity entity)
          Get the class code for the given entity.
 int getPlayerNum()
           
 boolean isValid(int playerId, Entity entity, IGame game)
          Returns true if the player and entity are both valid.
 boolean isValid(int playerId, IGame game)
          Returns true if the player is valid.
 boolean isValidEntity(Entity entity, IGame game)
          Determine if the specified entity is a valid one to use for this turn.
 void setPlayerNum(int playerId)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_INFANTRY

public static final int CLASS_INFANTRY
The constant to represent Infantry (and Battle Armor) entities.

See Also:
Constant Field Values

CLASS_PROTOMECH

public static final int CLASS_PROTOMECH
The constant to represent Protomech entities.

See Also:
Constant Field Values

CLASS_TANK

public static final int CLASS_TANK
The constant to represent Tank entities.

See Also:
Constant Field Values

CLASS_MECH

public static final int CLASS_MECH
The constant to represent Mech entities.

See Also:
Constant Field Values

CLASS_GUN_EMPLACEMENT

public static final int CLASS_GUN_EMPLACEMENT
The constant to represent Gun Emplacement entities.

See Also:
Constant Field Values

CLASS_AERO

public static final int CLASS_AERO
The constant to represent Aero entities.

See Also:
Constant Field Values

CLASS_SPACE_STATION

public static final int CLASS_SPACE_STATION
The constant to represent space station entities.

See Also:
Constant Field Values

CLASS_JUMPSHIP

public static final int CLASS_JUMPSHIP
The constant to represent jumpship entities.

See Also:
Constant Field Values

CLASS_WARSHIP

public static final int CLASS_WARSHIP
The constant to represent warship entities.

See Also:
Constant Field Values

CLASS_DROPSHIP

public static final int CLASS_DROPSHIP
The constant to represent dropship entities.

See Also:
Constant Field Values

CLASS_SMALL_CRAFT

public static final int CLASS_SMALL_CRAFT
The constant to represent warship entities.

See Also:
Constant Field Values
Constructor Detail

GameTurn

public GameTurn(int playerId)
Creates a new instance of GameTurn

Method Detail

getPlayerNum

public int getPlayerNum()

setPlayerNum

public void setPlayerNum(int playerId)

isValidEntity

public boolean isValidEntity(Entity entity,
                             IGame game)
Determine if the specified entity is a valid one to use for this turn.

Parameters:
entity - the Entity that may take this turn.
game - the IGame this turn belongs to.
Returns:
true if the specified entity can take this turn. false if the entity is not valid for this turn.

isValid

public boolean isValid(int playerId,
                       Entity entity,
                       IGame game)
Returns true if the player and entity are both valid.


isValid

public boolean isValid(int playerId,
                       IGame game)
Returns true if the player is valid.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getClassCode

public static int getClassCode(Entity entity)
Get the class code for the given entity.

Parameters:
entity - the Entity whose class code is needed.
Returns:
the int code for the entity's class.