|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
All Order objects must implement this interface.
All classes that use Orders must use Orderable objects, rather than Order objects, for compatibility with the OrderFactory system.
Please note that the Order class provides default implementations for some of these methods, and a number of protected internal methods for convenience.
Method Summary | |
void |
determineDependencies(Adjudicator adjudicator)
This method is called once all orders are known. |
void |
evaluate(Adjudicator adjudicator)
Evaluates an Order. |
java.lang.String |
getBriefName()
Returns the Brief name of the Order (e.g., "H" for a Hold order) |
java.lang.String |
getDefaultFormat()
Get the default OrderFormat String used to custom-format orders. |
java.lang.String |
getFullName()
Returns the Full name of the Order (e.g., "Hold" for a Hold order) |
Power |
getPower()
Gets the Power ordering the ordered Source unit |
Location |
getSource()
Gets the Location of the ordered unit |
Unit.Type |
getSourceUnitType()
Gets the Type of the ordered unit |
java.lang.String |
toBriefString()
Prints the entire order, in a brief syntax |
java.lang.String |
toFormattedString(OrderFormatOptions ofo)
Formats the order using the OrderFormat format string. |
java.lang.String |
toFullString()
Prints the entire order, in a verbose syntax |
void |
validate(TurnState state,
ValidationOptions valOpts,
RuleOptions ruleOpts)
Validate the order; state-independent. |
void |
verify(Adjudicator adjudicator)
Ensure that the order can be processed, assuming the complete turn state is known (i.e., all unit positions AND all orders for all powers). |
Method Detail |
public Location getSource()
public Unit.Type getSourceUnitType()
public Power getPower()
public java.lang.String getFullName()
public java.lang.String getBriefName()
public java.lang.String toBriefString()
public java.lang.String toFullString()
public java.lang.String getDefaultFormat()
public java.lang.String toFormattedString(OrderFormatOptions ofo)
Note that this is equivalent to calling OrderFormat.format(ofo, this, getDefaultFormat())
To print with default (not user-specified) options, use
OrderFormat.format(OrderFormatOptions.DEFAULT, this, getDefaultFormat())
While this enables better formatting, it is slower than using the toBriefString() and toFullString() methods.
public void validate(TurnState state, ValidationOptions valOpts, RuleOptions ruleOpts) throws OrderException
This checks the order for legality. An order is not considered to be well-formed until it has been validated. It validates locations (at the least) and other order syntax as appropriate, throwing exceptions if there is a conflict.
This is used by the UI to flag bad orders, as well as by the adjudicator to eliminate bad orders before processing.
Important Note:
The only state that should be assumed is the following:
Usage Notes:
Subclasses should generally call super.validate() before performing additional validation.
There should be no side effects of calling validate() multiple times, nor should behavior differ between multiple calls of validate(), given the same order.
state
- Current turn statevalOpts
- Current validation options
OrderException
public void verify(Adjudicator adjudicator)
For example, this is useful for:
By default, this method does nothing.
DO NOT call validate() within this method; there is no need! The Adjudicator must validate()
all orders prior to verification.
Remember, an order that fails validation is an illegal order (and usually converts to a Hold) while an order that fails verification is just a failed order (e.g., a power supports another power's unit move, but the other power's unit is ordered to hold), NOT an illegal order.
THIS is called BEFORE dependency information is available for the order. so do not assume that dependent order information is available.
This method should NEVER throw checked exceptions (e.g., an OrderException)
public void determineDependencies(Adjudicator adjudicator)
This is typically only used by orders generated in the Movement phase.
public void evaluate(Adjudicator adjudicator)
When an order is evaluated, it must change its OrderState. The OrderState cannot be changed once it is set. If an OrderState is uncertain, then it may be re-evaluated until the OrderState is certain (either Success or Failure).
NOTE: this method assumes that all dependency information is complete.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |