Action

public class Action implements Serializable, DeepEquatable

The primary class of issued commands. Action is immutable and it’s subtypes should be as well. Contains factory methods for easy construction of valid actions.

Author:The Condor

Fields

type

protected final ActionType type

unitId

protected final int unitId

Constructors

Action

public Action(int unitId, ActionType type)

Methods

createCompoundAttack

public static Action createCompoundAttack(int unitid, int targetid)

This is a TargetedAction, taking as parameters the acting unit’s ID and the target’s ID. When executed, it moves into range of a unit, then attacks it once.

Parameters:
  • unitid – Acting unit’s ID
  • targetid

createCompoundBuild

public static Action createCompoundBuild(int unitid, int templateID, int x, int y)

This is a LocatedProductionAction, taking as parameters the acting unit’s ID and the ID of the template of the building that you are trying to build, as well as x and y coordinates of where to build it. When executed, it uses repeated PRIMITIVEMOVEs to reach the specified location, then does PRIMITIVEBUILD until the building is done.

Parameters:
  • unitid – Acting unit’s ID
  • templateID
  • x
  • y

createCompoundDeposit

public static Action createCompoundDeposit(int unitid, int targetid)

This is a TargetedAction, taking as parameters the acting unit’s ID and the ID of a town hall to deposit at. When executed, it does PRIMITIVEMOVEs until next to the specified town hall, then performs a PRIMITIVEDEPOSIT on it.

Parameters:
  • unitid – Acting unit’s ID
  • targetid

createCompoundGather

public static Action createCompoundGather(int unitid, int targetid)

This is a TargetedAction, taking as parameters the acting unit’s ID and the ID of a resource node to gather from. When executed, it does PRIMITIVEMOVEs until next to the specified node, then performs a PRIMITIVEGATHER on it.

Parameters:
  • unitid – Acting unit’s ID
  • targetid

createCompoundMove

public static Action createCompoundMove(int unitid, int x, int y)

This is a LocatedAction, taking as parameters the acting unit’s ID and the x and y coordinates of where to move. When executed, it does PRIMITIVEMOVEs to reach that location.

Parameters:
  • unitid – Acting unit’s ID
  • x
  • y

createCompoundProduction

public static Action createCompoundProduction(int unitid, int templateID)

This is a ProductionAction, taking as parameters the acting unit’s ID and the ID of the template of the unit or upgrade that you are trying to build. When executed, it does PRIMITIVEPRODUCE until the unit or upgrade is completed.

Parameters:
  • unitid – Acting unit’s ID
  • templateID

createFail

public static Action createFail(int unitid)

Used internally to indicate that a compound action failed, and it should be redone

Parameters:
  • unitid – Acting unit’s ID

createPermanentFail

public static Action createPermanentFail(int unitid)

Used internally to indicate that a compound action failed permanently, and it should be aborted

Parameters:
  • unitid – Acting unit’s ID

createPrimitiveAttack

public static Action createPrimitiveAttack(int unitid, int targetid)

This is a TargetedAction, taking as parameters the acting unit’s ID and the target’s ID. When executed, it attempts to attack the targeted unit, failing when it out of range.

Parameters:
  • unitid – Acting unit’s ID
  • targetid

createPrimitiveBuild

public static Action createPrimitiveBuild(int unitid, int templateID)

This is a ProductionAction, taking as parameters the acting unit’s ID and the ID of the template of the building that you are trying to build. When executed, it does one turn’s work toward building that kind of building on the spot the unit is at. As all buildings take one turn to build, this is enough to complete it, making a building on the spot and moving the builder off to one side.

Parameters:
  • unitid – Acting unit’s ID Acting unit’s ID
  • templateID – Template ID of the building type to build

createPrimitiveDeposit

public static Action createPrimitiveDeposit(int unitid, Direction d)

This is a DirectedAction, taking as parameters the acting unit’s ID and a direction to attempt to deposit in. When executed, it looks in the specified direction for a town hall, if there is a town hall that you control, it moves resources from the unit’s inventory and gives them to you.

Parameters:
  • unitid – Acting unit’s ID
  • d

createPrimitiveGather

public static Action createPrimitiveGather(int unitid, Direction d)

This is a DirectedAction, taking as parameters the acting unit’s ID and a direction to attempt to gather in. When executed, it looks in the specified direction for a resource node, if there is a node, it moves resources from the node into the unit’s inventory.

Parameters:
  • unitid – Acting unit’s ID
  • d

createPrimitiveMove

public static Action createPrimitiveMove(int unitid, Direction d)

This is a DirectedAction, taking as parameters the acting unit’s ID and a direction to attempt to move. When executed, it attempts to move in that direction, failing if another unit is already there.

Parameters:
  • unitid – Acting unit’s ID
  • d

createPrimitiveProduction

public static Action createPrimitiveProduction(int unitid, int templateID)

This is a ProductionAction, taking as parameters the acting unit’s ID and the ID of the template of the unit or upgrade that you are trying to build. When executed, it does one turn’s work toward the creation of the unit or upgrade specified. As all units and upgrades take one turn to make, this is enough to complete it. If it is a unit being made, the new unit is put to one side after being made.

Parameters:
  • unitid – Acting unit’s ID
  • templateID

deepEquals

public boolean deepEquals(Object other)

equals

public boolean equals(Object other)

getType

public ActionType getType()

Get the type of action being done

Returns:The ActionType of the action

getUnitId

public int getUnitId()

Get the id of the unit doing the action.

Returns:The id of the unit doing the action

hashCode

public int hashCode()

toString

public String toString()