game.military.command
Class AbstractCommand

java.lang.Object
  |
  +--game.military.command.AbstractCommand
All Implemented Interfaces:
Combatant, Command, java.lang.Comparable
Direct Known Subclasses:
ArmyCommand, TaskForceCommand

public abstract class AbstractCommand
extends java.lang.Object
implements Command

An abstract class to implement the order queue management. This class gives a basic implementation of a superior cammand, orders, and a displayable image.


Constructor Summary
AbstractCommand()
          Constructor.
 
Method Summary
 int compareTo(java.lang.Object object)
           
protected abstract  java.lang.String createName()
          Return a name for this command.
 void dies()
          Called when all units in the command are dead.
 float getAttackStrength()
          Return the attack strength.
 Civilization getCivilization()
          Get the owning civilization.
 HighCommand getHighCommand()
          Get the high command.
 java.lang.String getName()
          Return the name of this instance.
 Army getSuperior()
          Get the next higher command.
 TaskForce getTaskForce()
          Add task force - return a new level 2 command, inserting commands in between as needed.
 boolean merge(Command command)
          Merge the other command with this one, removing the other command.
 Command newSubCommand()
          Create a new sub-command.
 void setName(java.lang.String value)
          Set the name of this instance.
 void setParent(java.lang.Object parent)
          Special setter for the parser so the army knows which high command it belongs to.
 void setSuperior(Army value)
          Set the superior command.
 void split(Command subCommand)
          Split the specified sub-command off into a separate command at this level.
 java.lang.String structure()
          Return a complete command structure.
 java.lang.String toString()
          String representation.
 void transfer(Command subCommand)
          Transfer sub-command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface game.interfaces.Command
addNewUnit, addTaskForceToList, cancelAllOrders, carryOutOrders, commandIterator, commandStructure, getNumberOfSubCommands, getNumberOfUnits, getPersonnel, hasSettlers, hasUnits, issueOrders, remove, structure, taskForceIterator
 
Methods inherited from interface game.interfaces.Combatant
getCombatData
 

Constructor Detail

AbstractCommand

public AbstractCommand()
Constructor.

Method Detail

setParent

public void setParent(java.lang.Object parent)
Special setter for the parser so the army knows which high command it belongs to.


createName

protected abstract java.lang.String createName()
Return a name for this command.

Returns:
a name for this command.

getCivilization

public Civilization getCivilization()
Get the owning civilization.

Specified by:
getCivilization in interface Command
Returns:
the owning civilization.

getHighCommand

public HighCommand getHighCommand()
Get the high command.

Specified by:
getHighCommand in interface Command
Returns:
the high command.

getSuperior

public Army getSuperior()
Get the next higher command.

Specified by:
getSuperior in interface Command
Returns:
the next higher command.

setSuperior

public void setSuperior(Army value)
Set the superior command.

Specified by:
setSuperior in interface Command
Parameters:
value - the new superior command.

setName

public void setName(java.lang.String value)
Set the name of this instance.

Specified by:
setName in interface Command
Parameters:
value - the name to set.

getName

public java.lang.String getName()
Return the name of this instance.

Specified by:
getName in interface Command
Returns:
the name.

compareTo

public int compareTo(java.lang.Object object)
Specified by:
compareTo in interface java.lang.Comparable

dies

public void dies()
Called when all units in the command are dead.

Specified by:
dies in interface Command

newSubCommand

public Command newSubCommand()
Create a new sub-command. Default does nothing.

Specified by:
newSubCommand in interface Command
Returns:
a new sub-command.

getTaskForce

public TaskForce getTaskForce()
Add task force - return a new level 2 command, inserting commands in between as needed. Inoperative here (for levels 1 and 2).

Specified by:
getTaskForce in interface Command

transfer

public void transfer(Command subCommand)
Transfer sub-command. This is not type-safe, there are no checks to ensure that the sub-command specified is actually one step lower than this command.

Specified by:
transfer in interface Command
Parameters:
subCommand - the sub-command to be transferred to this command.

merge

public boolean merge(Command command)
Merge the other command with this one, removing the other command.

Specified by:
merge in interface Command
Parameters:
command - the other same level command.
Returns:
true if the merge succeeded.

split

public void split(Command subCommand)
Split the specified sub-command off into a separate command at this level.

Specified by:
split in interface Command
Parameters:
subCommand - the sub-command to be transferred to a new command.

getAttackStrength

public float getAttackStrength()
Return the attack strength.

Specified by:
getAttackStrength in interface Command
Returns:
the attack strength.

toString

public java.lang.String toString()
String representation.

Overrides:
toString in class java.lang.Object
Returns:
string representation.

structure

public java.lang.String structure()
Return a complete command structure.

Specified by:
structure in interface Command