game.interfaces
Interface Command

All Superinterfaces:
Combatant, java.lang.Comparable
All Known Subinterfaces:
Army, HighCommand, TaskForce
All Known Implementing Classes:
AbstractCommand, ArmyCommand, HighCommandClass, TaskForceCommand

public interface Command
extends Combatant, java.lang.Comparable

Command is the interface that groups units in a command sense, not a physical one. It dispatches orders to its various components. It gives orders to armies and die when all are dead.


Method Summary
 void addNewUnit(Unit unit)
          Add a unit, creating lower level coommands as needed.
 void addTaskForceToList(TaskForceList commandList)
          Add this command to a list.
 void cancelAllOrders()
          Cancel all orders, including subcommands, clear the order queue.
 void carryOutOrders()
          Carry out orders.
 java.util.Iterator commandIterator()
          Iterate over the sub-commands if any.
 java.lang.String commandStructure(java.lang.String indent)
          The whole command structure.
 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.
 int getNumberOfSubCommands()
          Return number of sub-commands.
 int getNumberOfUnits()
          Count the units in this command.
 float getPersonnel()
          Return the total personnel.
 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 hasSettlers()
          Return true if the command has settlers.
 boolean hasUnits()
          Whether this command has any units to command.
 void issueOrders()
          Issue orders.
 boolean merge(Command command)
          Merge the other command with this one, removing the other command.
 Command newSubCommand()
          Create a new sub-command.
 void remove()
          Tidy up when this civilization is no more.
 void setName(java.lang.String value)
          Set the name of this instance.
 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 structure(java.lang.String indent)
          Return a complete command structure.
 java.util.Iterator taskForceIterator()
          Iterate over the task forces if any.
 void transfer(Command subCommand)
          Transfer sub-command.
 
Methods inherited from interface game.interfaces.Combatant
getCombatData
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getCivilization

public Civilization getCivilization()
Get the owning civilization.

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

getHighCommand

public HighCommand getHighCommand()
Get the high command.

Returns:
the high command.

getSuperior

public Army getSuperior()
Get the next higher command.

Returns:
the next higher command.

getNumberOfSubCommands

public int getNumberOfSubCommands()
Return number of sub-commands.

Returns:
number of sub-commands.

setName

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

Parameters:
value - the name to set.

getName

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

Specified by:
getName in interface Combatant
Returns:
the name of this instance.

dies

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


remove

public void remove()
Tidy up when this civilization is no more. Notifies downward.


addNewUnit

public void addNewUnit(Unit unit)
Add a unit, creating lower level coommands as needed.

Parameters:
unit - the new unit to add.

newSubCommand

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

Returns:
a new sub-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.

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.

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. The new command should have the same superior as this command.

Parameters:
subCommand - the sub-command to be transferred to a new command.

getNumberOfUnits

public int getNumberOfUnits()
Count the units in this command.

Returns:
the units in this command.

setSuperior

public void setSuperior(Army value)
Set the superior 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.

Parameters:
value - the new superior command.

commandStructure

public java.lang.String commandStructure(java.lang.String indent)
The whole command structure.

Returns:
a string showing the whole command structure.

getTaskForce

public TaskForce getTaskForce()
Add task force - return a new level 2 command, inserting commands in between as needed.


addTaskForceToList

public void addTaskForceToList(TaskForceList commandList)
Add this command to a list.


hasUnits

public boolean hasUnits()
Whether this command has any units to command.


getAttackStrength

public float getAttackStrength()
Return the attack strength.

Returns:
the attack strength.

getPersonnel

public float getPersonnel()
Return the total personnel.

Returns:
the total personnel.

commandIterator

public java.util.Iterator commandIterator()
Iterate over the sub-commands if any.

Returns:
iterator.
TODO
Check whether this is necessary.

taskForceIterator

public java.util.Iterator taskForceIterator()
Iterate over the task forces if any.

Returns:
iterator.

hasSettlers

public boolean hasSettlers()
Return true if the command has settlers.

Returns:
true if the command has settlers.

cancelAllOrders

public void cancelAllOrders()
Cancel all orders, including subcommands, clear the order queue.


issueOrders

public void issueOrders()
Issue orders.


carryOutOrders

public void carryOutOrders()
Carry out orders.


structure

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


structure

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