de.hagenah.diplomacy.game
Class Order

java.lang.Object
  extended by de.hagenah.diplomacy.game.Order
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public final class Order
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

The following orders are supported.

  • (type) = "army", "a", "fleet", "f" or (empty).
  • (s-prov) = Source province.
  • (d-prov) = Destination province.
  • (r-prov) = Railway province.
  • (g-prov) = Gateway province.
  • (c-prov) = Intermediate water province in a convoy route.
  • (power) = Power name or abbreviation of two or more characters.
  • (holds) = "h", "hold", "holds", "stand", "stands".
  • (moves) = "-", "-<", "m", "move", "moves", "move to", "moves to".
  • (support) = "s", "support", "supports".
  • (convoy) = "c", "convoy", "convoys".
  • (proxy) = "p", "proxy", "proxy to".
  • (disband) = "d", "disband".
  • (build) = "b", "build" or (empty).
  • (remove) = "r", "remove", "d", "disband" or (empty).
  • (waive) = "w", "waive".
  • See Also:
    Serialized Form

    Field Summary
    static int RESULT_BLOCKED
              Gateway is blocked
    static int RESULT_BOUNCE
              Move or retreat was not possible
    static int RESULT_CUT
              Support was cut
    static int RESULT_DESTROYED
              Unit was destroyed
    static int RESULT_DISLODGED
              Unit was dislodged
    static int RESULT_NOCONVOY
              Convoy was not possible
    static int RESULT_NOORDER
              No order processed
    static int RESULT_VOID
              Convoy or support was not possible
    static int TOSTRING_COUNTRY
              Returns the country, e.g.
    static int TOSTRING_CSS
              The CSS class color-?
    static int TOSTRING_HTML
              Returns a xhtml text, e.g. → instead of ->
    static int TOSTRING_JUDGE
              If TOSTRING_COUNTRY is set returns a judge compatible output, if TOSTRING_COUNTRY is not set returns a judge compatible input.
    static int TOSTRING_OWNER
              Returns the owner of foreign units, e.g.
    static int TOSTRING_RESULT
              Returns the result, e.g.
    static int TOSTRING_SHORT
              Returns a short text , e.g.
    static int TYPE_BUILD
              1 SubProvince
    static int TYPE_CONVOY
              3 SubProvinces
    static int TYPE_DISBAND
              1 SubProvinces
    static int TYPE_GATEWAY
              3 SubProvinces
    static int TYPE_HOLD
              1 SubProvince
    static int TYPE_MOVE
              1 SubProvince
    static int TYPE_MOVECONVOY
              2,3,...
    static int TYPE_MOVEGATEWAY
              3 SubProvinces
    static int TYPE_MOVERAILWAY
              3 SubProvinces
    static int TYPE_PROXY
              1 SubProvince,
    static int TYPE_REMOVE
              1 SubProvince
    static int TYPE_RETREAT
              2 SubProvinces
    static int TYPE_SUPPORTHOLD
              2 SubProvinces
    static int TYPE_SUPPORTMOVE
              3 SubProvinces
    static int TYPE_WAIVE
              0 SubProvinces
    static java.util.Comparator UNIQUE_ORDER
              Compares two orders by Country and Province (waive orders are always different).
     
    Constructor Summary
    Order(Country country, int type)
              Creates a waive order.
    Order(Country country, int type, java.util.List subprovinces)
              Creates an unambiguous moveconvoy order.
    Order(Country country, int type, SubProvince subprovince)
              Creates a hold, disband, build, or remove order.
    Order(Country country, int type, SubProvince subprovince, Country proxy)
              Creates a proxy order.
    Order(Country country, int type, SubProvince from, SubProvince to)
              Creates a retreat, move, ambiguous moveconvoy, or supporthold order.
    Order(Country country, int type, SubProvince from, SubProvince to, int coasthint)
              Creates a supporthold order with coasthint.
    Order(Country country, int type, SubProvince subprovince, SubProvince from, SubProvince to)
              Creates a support, convoy, moverailway, movegateway, or gateway order.
    Order(Country country, int type, SubProvince subprovince, SubProvince from, SubProvince to, int coasthint)
              Creates a support order with a coast hint.
     
    Method Summary
     int compareTo(java.lang.Object obj)
              Compares two Orders by Country, SubProvinces, CoastHint, Type, Proxy (all waive orders are different from each other)
     boolean equals(java.lang.Object obj)
              Compares two Orders by Country, SubProvinces, Type, Proxy (all waive orders are different from each other)
     int getCoastHint()
              Returns the coast hint (Coast.LAND if there is none).
     Country getCountry()
              Returns the country who ordered this order.
     SubProvince getFirst()
              Returns the first subprovince in the order.
     SubProvince getLast()
              Returns the last subprovince in the order.
     Country getProxy()
              Returns the country to which the unit is proxied.
     int getResult()
              Returns the order result flags (combination of RESULT_...).
     SubProvince getSecond()
              Returns the second subprovince in the order.
     SubProvince getSubProvince(int n)
              Returns the n-th subprovince in the order.
     java.util.List getSubProvinces()
              Returns the subprovinces in the order.
     int getType()
              Returns the type of the order (TYPE_...).
     int hashCode()
              Returns a hashcode for this unit.
     boolean isMove()
              Returns true if the order is a move order (TYPE_MOVE...)
     boolean isSupport()
              Returns true if the order is a support order (TYPE_SUPPORT...)
     java.lang.String toString()
              Returns a description of the order, e.g.
     java.lang.String toString(int flags, java.util.Map units)
              Retrieves a text for the order.
     
    Methods inherited from class java.lang.Object
    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
     

    Field Detail

    TOSTRING_COUNTRY

    public static final int TOSTRING_COUNTRY
    Returns the country, e.g. "Austria: "

    See Also:
    Constant Field Values

    TOSTRING_OWNER

    public static final int TOSTRING_OWNER
    Returns the owner of foreign units, e.g. "... TYPE_CONVOY Turkish Army ..."

    See Also:
    Constant Field Values

    TOSTRING_RESULT

    public static final int TOSTRING_RESULT
    Returns the result, e.g. "(*bounce*)"

    See Also:
    Constant Field Values

    TOSTRING_SHORT

    public static final int TOSTRING_SHORT
    Returns a short text , e.g. "A Mun S A Ber-Kie"

    See Also:
    Constant Field Values

    TOSTRING_JUDGE

    public static final int TOSTRING_JUDGE
    If TOSTRING_COUNTRY is set returns a judge compatible output, if TOSTRING_COUNTRY is not set returns a judge compatible input. Note: Instead of one time "x builds pending" for each waive "1 build pending" is generated. The country for proxy orders is not like the judge output.

    See Also:
    Constant Field Values

    TOSTRING_HTML

    public static final int TOSTRING_HTML
    Returns a xhtml text, e.g. → instead of ->

    See Also:
    Constant Field Values

    TOSTRING_CSS

    public static final int TOSTRING_CSS
    The CSS class color-? (e.g. color-m) is used for the color

    See Also:
    Constant Field Values

    TYPE_HOLD

    public static final int TYPE_HOLD
    1 SubProvince

    See Also:
    Constant Field Values

    TYPE_MOVE

    public static final int TYPE_MOVE
    1 SubProvince

    See Also:
    Constant Field Values

    TYPE_MOVECONVOY

    public static final int TYPE_MOVECONVOY
    2,3,... SubProvinces

    See Also:
    Constant Field Values

    TYPE_SUPPORTHOLD

    public static final int TYPE_SUPPORTHOLD
    2 SubProvinces

    See Also:
    Constant Field Values

    TYPE_SUPPORTMOVE

    public static final int TYPE_SUPPORTMOVE
    3 SubProvinces

    See Also:
    Constant Field Values

    TYPE_CONVOY

    public static final int TYPE_CONVOY
    3 SubProvinces

    See Also:
    Constant Field Values

    TYPE_PROXY

    public static final int TYPE_PROXY
    1 SubProvince,

    See Also:
    Constant Field Values

    TYPE_RETREAT

    public static final int TYPE_RETREAT
    2 SubProvinces

    See Also:
    Constant Field Values

    TYPE_DISBAND

    public static final int TYPE_DISBAND
    1 SubProvinces

    See Also:
    Constant Field Values

    TYPE_BUILD

    public static final int TYPE_BUILD
    1 SubProvince

    See Also:
    Constant Field Values

    TYPE_REMOVE

    public static final int TYPE_REMOVE
    1 SubProvince

    See Also:
    Constant Field Values

    TYPE_WAIVE

    public static final int TYPE_WAIVE
    0 SubProvinces

    See Also:
    Constant Field Values

    TYPE_MOVERAILWAY

    public static final int TYPE_MOVERAILWAY
    3 SubProvinces

    See Also:
    Constant Field Values

    TYPE_MOVEGATEWAY

    public static final int TYPE_MOVEGATEWAY
    3 SubProvinces

    See Also:
    Constant Field Values

    TYPE_GATEWAY

    public static final int TYPE_GATEWAY
    3 SubProvinces

    See Also:
    Constant Field Values

    RESULT_BOUNCE

    public static final int RESULT_BOUNCE
    Move or retreat was not possible

    See Also:
    Constant Field Values

    RESULT_CUT

    public static final int RESULT_CUT
    Support was cut

    See Also:
    Constant Field Values

    RESULT_DISLODGED

    public static final int RESULT_DISLODGED
    Unit was dislodged

    See Also:
    Constant Field Values

    RESULT_DESTROYED

    public static final int RESULT_DESTROYED
    Unit was destroyed

    See Also:
    Constant Field Values

    RESULT_NOCONVOY

    public static final int RESULT_NOCONVOY
    Convoy was not possible

    See Also:
    Constant Field Values

    RESULT_VOID

    public static final int RESULT_VOID
    Convoy or support was not possible

    See Also:
    Constant Field Values

    RESULT_NOORDER

    public static final int RESULT_NOORDER
    No order processed

    See Also:
    Constant Field Values

    RESULT_BLOCKED

    public static final int RESULT_BLOCKED
    Gateway is blocked

    See Also:
    Constant Field Values

    UNIQUE_ORDER

    public static final java.util.Comparator UNIQUE_ORDER
    Compares two orders by Country and Province (waive orders are always different).

    Constructor Detail

    Order

    public Order(Country country,
                 int type)
    Creates a waive order.


    Order

    public Order(Country country,
                 int type,
                 SubProvince subprovince)
    Creates a hold, disband, build, or remove order.


    Order

    public Order(Country country,
                 int type,
                 SubProvince subprovince,
                 Country proxy)
    Creates a proxy order.


    Order

    public Order(Country country,
                 int type,
                 SubProvince from,
                 SubProvince to)
    Creates a retreat, move, ambiguous moveconvoy, or supporthold order.


    Order

    public Order(Country country,
                 int type,
                 SubProvince from,
                 SubProvince to,
                 int coasthint)
    Creates a supporthold order with coasthint.


    Order

    public Order(Country country,
                 int type,
                 SubProvince subprovince,
                 SubProvince from,
                 SubProvince to)
    Creates a support, convoy, moverailway, movegateway, or gateway order.


    Order

    public Order(Country country,
                 int type,
                 SubProvince subprovince,
                 SubProvince from,
                 SubProvince to,
                 int coasthint)
    Creates a support order with a coast hint.


    Order

    public Order(Country country,
                 int type,
                 java.util.List subprovinces)
    Creates an unambiguous moveconvoy order.

    Method Detail

    getCountry

    public Country getCountry()
    Returns the country who ordered this order.


    getType

    public int getType()
    Returns the type of the order (TYPE_...).


    isMove

    public boolean isMove()
    Returns true if the order is a move order (TYPE_MOVE...)


    isSupport

    public boolean isSupport()
    Returns true if the order is a support order (TYPE_SUPPORT...)


    getSubProvince

    public SubProvince getSubProvince(int n)
    Returns the n-th subprovince in the order.

    Parameters:
    n - The zero-based index of the subprovince
    Returns:
    The subprovince, e.g. Yor for F NWS S A Yor-Nwy if n is 1.

    getFirst

    public SubProvince getFirst()
    Returns the first subprovince in the order.


    getSecond

    public SubProvince getSecond()
    Returns the second subprovince in the order.


    getLast

    public SubProvince getLast()
    Returns the last subprovince in the order.


    getSubProvinces

    public java.util.List getSubProvinces()
    Returns the subprovinces in the order.


    getProxy

    public Country getProxy()
    Returns the country to which the unit is proxied.


    getCoastHint

    public int getCoastHint()
    Returns the coast hint (Coast.LAND if there is none).


    getResult

    public int getResult()
    Returns the order result flags (combination of RESULT_...).


    equals

    public boolean equals(java.lang.Object obj)
    Compares two Orders by Country, SubProvinces, Type, Proxy (all waive orders are different from each other)

    Overrides:
    equals in class java.lang.Object

    compareTo

    public int compareTo(java.lang.Object obj)
    Compares two Orders by Country, SubProvinces, CoastHint, Type, Proxy (all waive orders are different from each other)

    Specified by:
    compareTo in interface java.lang.Comparable

    hashCode

    public int hashCode()
    Returns a hashcode for this unit.

    Overrides:
    hashCode in class java.lang.Object

    toString

    public java.lang.String toString(int flags,
                                     java.util.Map units)
    Retrieves a text for the order.

    Parameters:
    flags - TOSTRING_COUNTRY, TOSTRING_OWNER, TOSTRING_RESULT, TOSTRING_SHORT, TOSTRING_JUDGE, TOSTRING_HTML, TOSTRING_CSS
    units - The units on the board (Province → Unit), can be null. Needed if TOSTRING_OWNER is specified.
    Returns:
    The text, e.g. "Italy: Fleet Tyrrhenian Sea CONVOY Turkish Army Bulgaria -> Trieste (*bounce*)".

    toString

    public java.lang.String toString()
    Returns a description of the order, e.g. Army Rumania -> Ukraine (*bounce*).

    Overrides:
    toString in class java.lang.Object