net.sf.freecol.common.model
Class SimpleCombatModel

java.lang.Object
  extended by net.sf.freecol.common.model.SimpleCombatModel
All Implemented Interfaces:
CombatModel

public class SimpleCombatModel
extends java.lang.Object
implements CombatModel

This class implements the original Colonization combat model.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sf.freecol.common.model.CombatModel
CombatModel.CombatOdds, CombatModel.CombatResult, CombatModel.CombatResultType
 
Field Summary
static java.lang.String ARTILLERY_AGAINST_RAID
           
static java.lang.String ARTILLERY_IN_THE_OPEN
           
static java.lang.String ATTACK_BONUS
           
static java.lang.String BIG_MOVEMENT_PENALTY
           
static java.lang.String FORTIFIED
           
static int MAXIMUM_BOMBARD_POWER
          The maximum attack power of a Colony's fortifications against a naval unit.
static java.lang.String SMALL_MOVEMENT_PENALTY
           
 
Constructor Summary
SimpleCombatModel()
           
 
Method Summary
 void attack(Unit attacker, Unit defender, CombatModel.CombatResult result, int plunderGold, Location repairLocation)
          Attack a unit with the given outcome.
 void bombard(Colony colony, Unit defender, CombatModel.CombatResult result, Location repairLocation)
          Bombard a unit with the given outcome.
 CombatModel.CombatOdds calculateCombatOdds(Unit attacker, Unit defender)
          Calculates the chance of the outcomes of combat between the units.
 void captureColony(Unit attacker, Colony colony, int plunderGold, Location repairLocation)
          Captures an enemy colony and plunders gold.
 CombatModel.CombatResult generateAttackResult(Colony colony, Unit defender)
          Generates the result of a colony bombarding a Unit.
 CombatModel.CombatResult generateAttackResult(Unit attacker, Unit defender)
          Generates a result of an attack.
static java.lang.String getApparentOwnerName(Unit unit)
          Get the name of the apparent owner of this Unit, (like getOwner().getNationAsString() but handles pirates)
 float getDefencePower(Colony colony, Unit defender)
          Return the defensive power of the defender versus the bombarding colony.
 float getDefencePower(Unit attacker, Unit defender)
          Return the defensive power of the defender versus the attacker.
 java.util.Set<Modifier> getDefensiveModifiers(Colony colony, Unit defender)
          Return a list of all defensive modifiers that apply to the defender versus the bombarding colony.
 java.util.Set<Modifier> getDefensiveModifiers(Unit attacker, Unit defender)
          Return a list of all defensive modifiers that apply to the defender versus the attacker.
 float getOffencePower(Colony colony, Unit defender)
          Returns the power for bombarding
 float getOffencePower(Unit attacker, Unit defender)
          Return the offensive power of the attacker versus the defender.
 java.util.Set<Modifier> getOffensiveModifiers(Colony colony, Unit defender)
          Return a list of all offensive modifiers that apply to the attacker versus the defender.
 java.util.Set<Modifier> getOffensiveModifiers(Unit attacker, Unit defender)
          Return a list of all offensive modifiers that apply to the attacker versus the defender.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXIMUM_BOMBARD_POWER

public static final int MAXIMUM_BOMBARD_POWER
The maximum attack power of a Colony's fortifications against a naval unit.

See Also:
Constant Field Values

SMALL_MOVEMENT_PENALTY

public static final java.lang.String SMALL_MOVEMENT_PENALTY
See Also:
Constant Field Values

BIG_MOVEMENT_PENALTY

public static final java.lang.String BIG_MOVEMENT_PENALTY
See Also:
Constant Field Values

ARTILLERY_IN_THE_OPEN

public static final java.lang.String ARTILLERY_IN_THE_OPEN
See Also:
Constant Field Values

ATTACK_BONUS

public static final java.lang.String ATTACK_BONUS
See Also:
Constant Field Values

FORTIFIED

public static final java.lang.String FORTIFIED
See Also:
Constant Field Values

ARTILLERY_AGAINST_RAID

public static final java.lang.String ARTILLERY_AGAINST_RAID
See Also:
Constant Field Values
Constructor Detail

SimpleCombatModel

public SimpleCombatModel()
Method Detail

getApparentOwnerName

public static java.lang.String getApparentOwnerName(Unit unit)
Get the name of the apparent owner of this Unit, (like getOwner().getNationAsString() but handles pirates)

Parameters:
unit - an Unit value
Returns:
The name of the owner of this Unit unless this is hidden.

calculateCombatOdds

public CombatModel.CombatOdds calculateCombatOdds(Unit attacker,
                                                  Unit defender)
Calculates the chance of the outcomes of combat between the units. Currently only calculates the chance of winning combat.

Specified by:
calculateCombatOdds in interface CombatModel
Parameters:
attacker - The attacking Unit.
defender - The defending unit.
Returns:
A CombatOdds value.

generateAttackResult

public CombatModel.CombatResult generateAttackResult(Unit attacker,
                                                     Unit defender)
Generates a result of an attack.

Specified by:
generateAttackResult in interface CombatModel
Parameters:
attacker - The Unit attacking.
defender - The defending unit.
Returns:
a CombatResult value

generateAttackResult

public CombatModel.CombatResult generateAttackResult(Colony colony,
                                                     Unit defender)
Generates the result of a colony bombarding a Unit.

Specified by:
generateAttackResult in interface CombatModel
Parameters:
colony - the bombarding Colony
defender - the defending Unit
Returns:
a CombatResult value

getOffencePower

public float getOffencePower(Colony colony,
                             Unit defender)
Returns the power for bombarding

Specified by:
getOffencePower in interface CombatModel
Parameters:
colony - a Colony value
defender - an Unit value
Returns:
the power for bombarding

getOffencePower

public float getOffencePower(Unit attacker,
                             Unit defender)
Return the offensive power of the attacker versus the defender. Null can be passed as the defender when only the attacker unit stats are required

Specified by:
getOffencePower in interface CombatModel
Parameters:
attacker - an Unit value
defender - an Unit value
Returns:
a float value

getOffensiveModifiers

public java.util.Set<Modifier> getOffensiveModifiers(Colony colony,
                                                     Unit defender)
Return a list of all offensive modifiers that apply to the attacker versus the defender. Null can be passed as the defender when only the attacker unit stats are required

Specified by:
getOffensiveModifiers in interface CombatModel
Parameters:
colony - an Colony value
defender - an Unit value
Returns:
a List of Modifiers

getOffensiveModifiers

public java.util.Set<Modifier> getOffensiveModifiers(Unit attacker,
                                                     Unit defender)
Return a list of all offensive modifiers that apply to the attacker versus the defender. Null can be passed as the defender when only the attacker unit stats are required

Specified by:
getOffensiveModifiers in interface CombatModel
Parameters:
attacker - an Unit value
defender - an Unit value
Returns:
a List of Modifiers

getDefencePower

public float getDefencePower(Colony colony,
                             Unit defender)
Return the defensive power of the defender versus the bombarding colony.

Specified by:
getDefencePower in interface CombatModel
Parameters:
colony - a Colony value
defender - a Unit value
Returns:
an float value

getDefencePower

public float getDefencePower(Unit attacker,
                             Unit defender)
Return the defensive power of the defender versus the attacker.

Specified by:
getDefencePower in interface CombatModel
Parameters:
attacker - an Unit value
defender - an Unit value
Returns:
an float value

getDefensiveModifiers

public java.util.Set<Modifier> getDefensiveModifiers(Colony colony,
                                                     Unit defender)
Return a list of all defensive modifiers that apply to the defender versus the bombarding colony.

Specified by:
getDefensiveModifiers in interface CombatModel
Parameters:
colony - a Colony value
defender - an Unit value
Returns:
a List of Modifiers

getDefensiveModifiers

public java.util.Set<Modifier> getDefensiveModifiers(Unit attacker,
                                                     Unit defender)
Return a list of all defensive modifiers that apply to the defender versus the attacker.

Specified by:
getDefensiveModifiers in interface CombatModel
Parameters:
attacker - an Unit value
defender - an Unit value
Returns:
a List of Modifiers

attack

public void attack(Unit attacker,
                   Unit defender,
                   CombatModel.CombatResult result,
                   int plunderGold,
                   Location repairLocation)
Attack a unit with the given outcome. This method ignores the damage parameter.

Specified by:
attack in interface CombatModel
Parameters:
attacker - an Unit value
defender - The Unit defending against attack.
result - The result of the attack.
plunderGold - an int value
repairLocation - a Location value

bombard

public void bombard(Colony colony,
                    Unit defender,
                    CombatModel.CombatResult result,
                    Location repairLocation)
Bombard a unit with the given outcome.

Specified by:
bombard in interface CombatModel
Parameters:
colony - a Colony value
defender - The Unit defending against bombardment.
result - The result of the bombardment.

captureColony

public void captureColony(Unit attacker,
                          Colony colony,
                          int plunderGold,
                          Location repairLocation)
Captures an enemy colony and plunders gold.

Parameters:
attacker - an Unit value
colony - a Colony value
plunderGold - The amount of gold to plunder.