games.strategy.triplea.delegate
Class MustFightBattle

java.lang.Object
  extended by games.strategy.triplea.delegate.MustFightBattle
All Implemented Interfaces:
BattleStepStrings

public class MustFightBattle
extends java.lang.Object
implements BattleStepStrings

Handles logic for battles in which fighting actually occurs.

Author:
Sean Bridges
See Also:
Serialized Form

Nested Class Summary
static class MustFightBattle.AttackSubs
           
static class MustFightBattle.DefendSubs
           
static class MustFightBattle.ReturnFire
           
 
Field Summary
static int DEFAULT_RETREAT_TYPE
           
static int PARTIAL_AMPHIB_RETREAT_TYPE
           
static int PLANES_RETREAT_TYPE
           
static java.lang.String RETREAT_PLANES
           
static int SUBS_RETREAT_TYPE
           
 
Fields inherited from interface games.strategy.triplea.delegate.BattleStepStrings
AA_GUNS_FIRE, AIR_ATTACK_NON_SUBS, AIR_DEFEND_NON_SUBS, ATTACKER_WITHDRAW, FIRE, LAND_PARATROOPS, NAVAL_BOMBARDMENT, NONAMPHIB_WITHDRAW, PLANES_WITHDRAW, REMOVE_AA_CASUALTIES, REMOVE_CASUALTIES, REMOVE_SNEAK_ATTACK_CASUALTIES, REMOVE_UNESCORTED_TRANSPORTS, SELECT_AA_CASUALTIES, SELECT_CASUALTIES, SELECT_NAVAL_BOMBARDMENT_CASUALTIES, SELECT_SUB_CASUALTIES, SUBMERGE_SUBS_VS_AIR_ONLY, SUBS_FIRE, SUBS_SUBMERGE, SUBS_WITHDRAW
 
Constructor Summary
MustFightBattle(Territory battleSite, PlayerID attacker, GameData data, BattleTracker tracker)
           
 
Method Summary
 Change addAttackChange(Route route, java.util.Collection<Unit> units)
          Add a bunch of attacking units to the battle.
 void addBombardingUnit(Unit unit)
          Add bombarding unit.
 java.util.List<java.lang.String> determineStepStrings(boolean showFirstRun, IDelegateBridge bridge)
           
 boolean equals(java.lang.Object o)
           
 void fight(IDelegateBridge bridge)
          Fight this battle.
 java.util.Collection<Territory> getAmphibiousAttackTerritories()
          Return the territories where there are amphibious attacks.
 java.util.Collection<Unit> getAmphibiousLandAttackers()
          Return units which are actually assaulting amphibiously
 java.util.Collection<Territory> getAttackingFrom()
           
 java.util.Map<Territory,java.util.Collection<Unit>> getAttackingFromMap()
           
 java.util.Collection<Unit> getAttackingUnits()
           
 int getBattleRound()
           
 java.util.Collection<Unit> getBombardingUnits()
          Return bombarding units.
 java.util.Collection<Unit> getDependentUnits(java.util.Collection<Unit> units)
          Return units which are dependent on the given units.
static int getMaxHits(java.util.Collection<Unit> units)
           
 java.util.List<Unit> getRemainingAttackingUnits()
           
 java.util.List<Unit> getRemainingDefendingUnits()
           
 Territory getTerritory()
          Return what territory this battle is occuring in.
 java.util.Collection<Unit> getTransportDependents(java.util.Collection<Unit> targets, GameData data)
           
 int hashCode()
           
 boolean isAmphibious()
          Return whether battle is amphibious.
 boolean isBombingRun()
          Return whether this battle is a bombing run.
 boolean isEmpty()
          After an attack has been removed, you can use this to test if there are still units left to fight
 boolean isOver()
          Return whether this battle is over or not.
 void removeAttack(Route route, java.util.Collection<Unit> units)
          This occurs when a move has been undone
 void setHeadless(boolean aBool)
           
 void setUnits(java.util.Collection<Unit> defending, java.util.Collection<Unit> attacking, java.util.Collection<Unit> bombarding, PlayerID defender)
          Used for headless battles
 void sortAmphib(java.util.List<Unit> units, GameData data)
           
 java.lang.String toString()
           
 void unitsLostInPrecedingBattle(games.strategy.triplea.delegate.Battle battle, java.util.Collection<Unit> units, IDelegateBridge bridge)
          Call this method when units are lost in another battle.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RETREAT_PLANES

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

DEFAULT_RETREAT_TYPE

public static final int DEFAULT_RETREAT_TYPE
See Also:
Constant Field Values

SUBS_RETREAT_TYPE

public static final int SUBS_RETREAT_TYPE
See Also:
Constant Field Values

PLANES_RETREAT_TYPE

public static final int PLANES_RETREAT_TYPE
See Also:
Constant Field Values

PARTIAL_AMPHIB_RETREAT_TYPE

public static final int PARTIAL_AMPHIB_RETREAT_TYPE
See Also:
Constant Field Values
Constructor Detail

MustFightBattle

public MustFightBattle(Territory battleSite,
                       PlayerID attacker,
                       GameData data,
                       BattleTracker tracker)
Method Detail

setUnits

public void setUnits(java.util.Collection<Unit> defending,
                     java.util.Collection<Unit> attacking,
                     java.util.Collection<Unit> bombarding,
                     PlayerID defender)
Used for headless battles


setHeadless

public void setHeadless(boolean aBool)

isOver

public boolean isOver()
Return whether this battle is over or not.


removeAttack

public void removeAttack(Route route,
                         java.util.Collection<Unit> units)
This occurs when a move has been undone


isEmpty

public boolean isEmpty()
After an attack has been removed, you can use this to test if there are still units left to fight


addAttackChange

public Change addAttackChange(Route route,
                              java.util.Collection<Unit> units)
Add a bunch of attacking units to the battle.


isBombingRun

public boolean isBombingRun()
Return whether this battle is a bombing run.


getTerritory

public Territory getTerritory()
Return what territory this battle is occuring in.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

fight

public void fight(IDelegateBridge bridge)
Fight this battle.


determineStepStrings

public java.util.List<java.lang.String> determineStepStrings(boolean showFirstRun,
                                                             IDelegateBridge bridge)

getMaxHits

public static int getMaxHits(java.util.Collection<Unit> units)

getAmphibiousAttackTerritories

public java.util.Collection<Territory> getAmphibiousAttackTerritories()
Return the territories where there are amphibious attacks.


addBombardingUnit

public void addBombardingUnit(Unit unit)
Add bombarding unit.


getBombardingUnits

public java.util.Collection<Unit> getBombardingUnits()
Return bombarding units.


getDependentUnits

public java.util.Collection<Unit> getDependentUnits(java.util.Collection<Unit> units)
Return units which are dependent on the given units.


getTransportDependents

public java.util.Collection<Unit> getTransportDependents(java.util.Collection<Unit> targets,
                                                         GameData data)

getRemainingAttackingUnits

public java.util.List<Unit> getRemainingAttackingUnits()

getRemainingDefendingUnits

public java.util.List<Unit> getRemainingDefendingUnits()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

sortAmphib

public void sortAmphib(java.util.List<Unit> units,
                       GameData data)

getAttackingUnits

public java.util.Collection<Unit> getAttackingUnits()

getAttackingFrom

public java.util.Collection<Territory> getAttackingFrom()

getAttackingFromMap

public java.util.Map<Territory,java.util.Collection<Unit>> getAttackingFromMap()

getAmphibiousLandAttackers

public java.util.Collection<Unit> getAmphibiousLandAttackers()
Return units which are actually assaulting amphibiously


unitsLostInPrecedingBattle

public void unitsLostInPrecedingBattle(games.strategy.triplea.delegate.Battle battle,
                                       java.util.Collection<Unit> units,
                                       IDelegateBridge bridge)
Call this method when units are lost in another battle. This is needed to remove dependent units who have been lost in another battle.


isAmphibious

public boolean isAmphibious()
Return whether battle is amphibious.


getBattleRound

public int getBattleRound()