net.sf.freecol.common.model
Class CombatModel

java.lang.Object
  extended by net.sf.freecol.common.model.CombatModel
Direct Known Subclasses:
SimpleCombatModel

public abstract class CombatModel
extends java.lang.Object


Nested Class Summary
 class CombatModel.CombatOdds
          Odds a particular outcome will occur in combat.
static class CombatModel.CombatResult
           
 
Constructor Summary
CombatModel()
          Empty constructor is sufficient.
 
Method Summary
abstract  CombatModel.CombatOdds calculateCombatOdds(FreeColGameObject attacker, FreeColGameObject defender)
          Calculates the chance of the outcomes of a combat.
 boolean combatIsAmphibious(FreeColGameObject attacker, FreeColGameObject defender)
          Could this attack be an amphibious operation?
 boolean combatIsAttack(FreeColGameObject attacker, FreeColGameObject defender)
          Is this combat a normal attack?
 boolean combatIsBombard(FreeColGameObject attacker, FreeColGameObject defender)
          Is this combat a bombardment?
 boolean combatIsMeasurement(FreeColGameObject attacker, FreeColGameObject defender)
          Is this just a measurement of offence power?
 boolean combatIsSettlementAttack(FreeColGameObject attacker, FreeColGameObject defender)
          Is this combat a attack on a settlement? These happen on the client side only, for the purposes of the pre-combat display.
abstract  java.util.List<CombatModel.CombatResult> generateAttackResult(java.util.Random random, FreeColGameObject attacker, FreeColGameObject defender)
          Generates a list of results of an attack.
abstract  float getDefencePower(FreeColGameObject attacker, FreeColGameObject defender)
          Get the defensive power of a defender wrt an attacker.
abstract  java.util.Set<Modifier> getDefensiveModifiers(FreeColGameObject attacker, FreeColGameObject defender)
          Collect all defensive modifiers that apply to a unit defending against another.
abstract  float getOffencePower(FreeColGameObject attacker, FreeColGameObject defender)
          Get the offensive power of a attacker wrt a defender.
abstract  java.util.Set<Modifier> getOffensiveModifiers(FreeColGameObject attacker, FreeColGameObject defender)
          Collect all the offensive modifiers that apply to an attack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CombatModel

public CombatModel()
Empty constructor is sufficient.

Method Detail

combatIsMeasurement

public boolean combatIsMeasurement(FreeColGameObject attacker,
                                   FreeColGameObject defender)
Is this just a measurement of offence power?

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
True if no defender is provided.

combatIsAttack

public boolean combatIsAttack(FreeColGameObject attacker,
                              FreeColGameObject defender)
Is this combat a normal attack?

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
True if the combat is a normal attack.

combatIsSettlementAttack

public boolean combatIsSettlementAttack(FreeColGameObject attacker,
                                        FreeColGameObject defender)
Is this combat a attack on a settlement? These happen on the client side only, for the purposes of the pre-combat display. In these cases the actual defender unit is hidden from the attacker player, so the defender is shown as the settlement itself.

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
True if the combat is a client-side attack on a settlement.

combatIsBombard

public boolean combatIsBombard(FreeColGameObject attacker,
                               FreeColGameObject defender)
Is this combat a bombardment?

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
True if the combat is a bombardment.

combatIsAmphibious

public boolean combatIsAmphibious(FreeColGameObject attacker,
                                  FreeColGameObject defender)
Could this attack be an amphibious operation?

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
True if the attack is amphibious.

calculateCombatOdds

public abstract CombatModel.CombatOdds calculateCombatOdds(FreeColGameObject attacker,
                                                           FreeColGameObject defender)
Calculates the chance of the outcomes of a combat.

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
The CombatOdds.

getOffencePower

public abstract float getOffencePower(FreeColGameObject attacker,
                                      FreeColGameObject defender)
Get the offensive power of a attacker wrt a defender. Null can be passed for the defender when only the attacker stats are required.

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
The offensive power.

getDefencePower

public abstract float getDefencePower(FreeColGameObject attacker,
                                      FreeColGameObject defender)
Get the defensive power of a defender wrt an attacker.

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
The defensive power.

getOffensiveModifiers

public abstract java.util.Set<Modifier> getOffensiveModifiers(FreeColGameObject attacker,
                                                              FreeColGameObject defender)
Collect all the offensive modifiers that apply to an attack. Null can be passed as the defender when only the attacker unit stats are required.

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
All the applicable offensive modifiers.

getDefensiveModifiers

public abstract java.util.Set<Modifier> getDefensiveModifiers(FreeColGameObject attacker,
                                                              FreeColGameObject defender)
Collect all defensive modifiers that apply to a unit defending against another.

Parameters:
attacker - The attacker.
defender - The defender.
Returns:
All the applicable defensive modifiers.

generateAttackResult

public abstract java.util.List<CombatModel.CombatResult> generateAttackResult(java.util.Random random,
                                                                              FreeColGameObject attacker,
                                                                              FreeColGameObject defender)
Generates a list of results of an attack. The first must be one of NO_RESULT, LOSE or WIN. The rest can be any other CombatResult suitable to the situation. To be called by the server only.

Parameters:
random - A pseudo-random number source.
attacker - The attacker.
defender - The defender.
Returns:
The results of the combat.