de.hagenah.diplomacy.game
Class DecisionAdjudicator

java.lang.Object
  extended by de.hagenah.diplomacy.game.DecisionAdjudicator

public class DecisionAdjudicator
extends java.lang.Object

This is an adjudicator (like the judges) for diplomacy. It supports especially

Open questions (marked with !!!)


Field Summary
static int OPTION_NMR_MASK
          Mask for the OPTION_NMR_... options
static int OPTION_NMR_NO
          NMRs are not allowed.
static int OPTION_NMR_YES
          NMRs are allowed.
static int OPTION_NOORDER_IGNORE
          Orders with the RESULT_NOORDER flag are ignored
static int OPTION_NOORDER_MASK
          Mask for the OPTION_NOORDER_... options
static int OPTION_NOORDER_NORMAL
          Orders with the RESULT_NOORDER flag are processed like normal orders
static int OPTION_PROXY_MASK
          Mask for the OPTION_PROXY_... options
static int OPTION_PROXY_NO
          Proxy orders are not allowed.
static int OPTION_PROXY_YES
          Proxy orders are allowed.
static int OPTION_RULE_IX7_MASK
          Mask for the OPTION_RULE_IX7_... options
static int OPTION_RULE_IX7_RELAXED
          A dislodged unit, even with support, has no effect on the province that dislodged it if neither the dislodged nor the dislodging unit is convoyed.
static int OPTION_RULE_XII3_ALL_SUCCESSFUL
          A convoy is only successful if all possible convoy route are successful.
static int OPTION_RULE_XII3_MASK
          Mask for the OPTION_RULE_XII3_... options
static int OPTION_RULE_XII3_ONE_SUCCESSFUL
          A convoy is successful if atleast one convoy route is successful.
static int OPTION_RULE_XII5_ARMYNOTCONVOYED
          If there is a paradox it is resolved by not convoying all armies involved in the paradox (the RESULT_NOCONVOY result flag is set for these armies).
static int OPTION_RULE_XII5_MASK
          Mask for the OPTION_RULE_XII5_... options
 
Constructor Summary
DecisionAdjudicator(int options)
          Creates an adjudicator for the specified options.
 
Method Summary
 Phase adjudicate(Turn turn, MapData map, java.util.Map specialphasecenters, java.util.Map units, java.util.Map dislodgedunits, java.util.Map centers, java.util.Map builds, java.util.Collection nmrorders, java.util.SortedMap results, java.util.List errors)
          Adjudicates a turn.
static boolean areOrdersIncomplete(Turn turn, MapData map, boolean noorderignore)
          Are the orders of the turn incomplete (NMR orders necessary)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPTION_RULE_XII5_ARMYNOTCONVOYED

public static final int OPTION_RULE_XII5_ARMYNOTCONVOYED
If there is a paradox it is resolved by not convoying all armies involved in the paradox (the RESULT_NOCONVOY result flag is set for these armies). This is the default.

See Also:
Constant Field Values

OPTION_RULE_IX7_RELAXED

public static final int OPTION_RULE_IX7_RELAXED
A dislodged unit, even with support, has no effect on the province that dislodged it if neither the dislodged nor the dislodging unit is convoyed. This is the default.

See Also:
Constant Field Values

OPTION_RULE_XII3_ONE_SUCCESSFUL

public static final int OPTION_RULE_XII3_ONE_SUCCESSFUL
A convoy is successful if atleast one convoy route is successful. This is the default.

See Also:
Constant Field Values

OPTION_RULE_XII3_ALL_SUCCESSFUL

public static final int OPTION_RULE_XII3_ALL_SUCCESSFUL
A convoy is only successful if all possible convoy route are successful.

See Also:
Constant Field Values

OPTION_NMR_NO

public static final int OPTION_NMR_NO
NMRs are not allowed. So a missing order is an error. This is the default. Note: A missing order isn't an error if the cause are circular proxy orders or a proxy order with no follow-up .

See Also:
Constant Field Values

OPTION_NMR_YES

public static final int OPTION_NMR_YES
NMRs are allowed. Orders with the RESULT_NOORDER result flag are created for the missing orders.

See Also:
Constant Field Values

OPTION_PROXY_NO

public static final int OPTION_PROXY_NO
Proxy orders are not allowed. So a proxy order or an order from the wrong country is an error. This is the default.

See Also:
Constant Field Values

OPTION_PROXY_YES

public static final int OPTION_PROXY_YES
Proxy orders are allowed. If an order is missing after the evaluation of a proxy order then a order with a RESULT_NOORDER result flag is created even if OPTION_NMR_NO is set.

See Also:
Constant Field Values

OPTION_NOORDER_NORMAL

public static final int OPTION_NOORDER_NORMAL
Orders with the RESULT_NOORDER flag are processed like normal orders

See Also:
Constant Field Values

OPTION_NOORDER_IGNORE

public static final int OPTION_NOORDER_IGNORE
Orders with the RESULT_NOORDER flag are ignored

See Also:
Constant Field Values

OPTION_RULE_XII5_MASK

public static final int OPTION_RULE_XII5_MASK
Mask for the OPTION_RULE_XII5_... options

See Also:
Constant Field Values

OPTION_RULE_IX7_MASK

public static final int OPTION_RULE_IX7_MASK
Mask for the OPTION_RULE_IX7_... options

See Also:
Constant Field Values

OPTION_RULE_XII3_MASK

public static final int OPTION_RULE_XII3_MASK
Mask for the OPTION_RULE_XII3_... options

See Also:
Constant Field Values

OPTION_NMR_MASK

public static final int OPTION_NMR_MASK
Mask for the OPTION_NMR_... options

See Also:
Constant Field Values

OPTION_PROXY_MASK

public static final int OPTION_PROXY_MASK
Mask for the OPTION_PROXY_... options

See Also:
Constant Field Values

OPTION_NOORDER_MASK

public static final int OPTION_NOORDER_MASK
Mask for the OPTION_NOORDER_... options

See Also:
Constant Field Values
Constructor Detail

DecisionAdjudicator

public DecisionAdjudicator(int options)
Creates an adjudicator for the specified options.

Parameters:
options - The options for this adjudicator (OPTION_...)
Method Detail

adjudicate

public Phase adjudicate(Turn turn,
                        MapData map,
                        java.util.Map specialphasecenters,
                        java.util.Map units,
                        java.util.Map dislodgedunits,
                        java.util.Map centers,
                        java.util.Map builds,
                        java.util.Collection nmrorders,
                        java.util.SortedMap results,
                        java.util.List errors)
Adjudicates a turn.

Parameters:
turn - The turn to adjudicate.
map - The map of the game.
specialphasecenters - If the home centers type is HOME_CENTERS_PHASE and the special home centers phase is before the phase of the turn the centers for the special home centers phase, null otherwise.
units - The units after the turn (Unit). The map must be empty and the comparator must not be set.
dislodgedunits - The dislodged units after the turn (Unit). The map must be empty and the comparator must not be set.
centers - The centers after the turn (Province → Country). The map must be empty and the comparator must not be set.
builds - The builds after the turn (Country → Integer). The map must be empty and the comparator must not be set.
nmrorders - The NMR orders created are added to this collection (Order), can be null. If there already exists an order with a RESULT_NOORDER flag it is checked that it's a NMR order but it is not added to this collection.
results - The result flags for the adjudication (Order → Integer). The map must be empty and the comparator must be a UniqueOrderComparator. If this parameter is null, the result flags are set with Order.setResult().
errors - The errors if the result is false. The list must be empty.
Returns:
The next phase if the adjudication was successful, null otherwise.

areOrdersIncomplete

public static boolean areOrdersIncomplete(Turn turn,
                                          MapData map,
                                          boolean noorderignore)
Are the orders of the turn incomplete (NMR orders necessary)

Parameters:
turn - The turn to test
map - The map of the game
noorderignore - true: orders with the RESULT_NOORDER flag are ignored, false: orders with the RESULT_NOORDER flag are processed like normal orders
Returns:
true if information is missing or NMR orders are necessary, false otherwise