rl.leviathan.game.elements
Class CapitalShip

java.lang.Object
  extended by rl.common.game.elements.GameElement
      extended by rl.leviathan.game.elements.CapitalShip
All Implemented Interfaces:
java.io.Serializable, FiringCapableElement, MovementCapableElement

public class CapitalShip
extends GameElement
implements MovementCapableElement, FiringCapableElement

See Also:
Serialized Form

Nested Class Summary
 class CapitalShip.DamagedSystem
           
static class CapitalShip.ShieldStatus
           
 class CapitalShip.ShieldStatusStruct
           
 class CapitalShip.WeaponMountStatus
          This class captures the information about a weapon mount
 
Nested classes/interfaces inherited from class rl.common.game.elements.GameElement
GameElement.StatusPhase
 
Field Summary
(package private) static long serialVersionUID
           
 
Constructor Summary
CapitalShip(CapitalShipDesign design, CapitalShipInternalStructure internalStructure)
           
 
Method Summary
 void addDamageListener(CapitalShipDamageListener Listener)
           
 void addFiringListener(CapitalShipFiringListener Listener)
           
 void addListener(CapitalShipStatusListener cssl)
           
 void addMovementListener(CapitalShipMovementListener Listener)
           
 void applyArmourDamage(ShipSide side, GridReference ref)
           
 void applyDamageSummary(GameElementDamageSummary geds)
           
 void applyFiringSummary(GameElementFiringSummary gefs)
          function called to apply firing summary to element.
 void applyInternalDamage(int gameTurn, GridReference ref, ShipSide side)
           
 void applyMovementSummary(GameElementMovementSummary gems)
          applies the summary of movement to the element.
 void applyWeaponDamage(int turn, CapitalShipWeapon w, ShipSide side, int range, int column)
           
 GameElementDamageSummary calculateStatus(int turn, GameElement.StatusPhase phase)
           
 boolean canAllocatePower()
           
 boolean canFire(int turn)
          Returns whether this unit can make a firing attempt on a particular turn
 boolean canFireIndirect(int turn)
          Returns whether this unit can make an indirect firing attempt on a particular turn
 boolean canJumpFTL()
           
 boolean canManouver()
           
 boolean canMove(int turn)
          returns whether the element can move in a given turn
 boolean canRoll()
           
 boolean canTurnLeft()
           
 boolean canTurnRight()
           
 boolean destroyedByExplosion(int turn)
           
 java.util.Vector<CapitalShipWeaponMount> getAllPointDefenceWeapons(int turn, java.util.HashMap<ShipSide,java.lang.Integer> sides)
           
 java.util.Vector<CapitalShipWeaponMount> getAllWeapons(int turn, java.util.HashMap<ShipSide,java.lang.Integer> sides)
           
 CapitalShipArmour getArmour()
           
 int getBayWeaponFireControlDamageModifier(CapitalShipWeaponMount cswm)
           
 java.util.Vector<CapitalShipWeaponMount> getBayWeapons(int turn, java.util.HashMap<ShipSide,java.lang.Integer> sides)
           
 double getDamageSummary(int turn)
           
 CapitalShipDesign getDesign()
           
 java.lang.String getElementType()
           
 int getFireControlDamageModifier(int index)
           
 GameElementFiringSummary getFiringSummary(int turn)
          get a new GameElementFiringSummary object appropriate to the object implementing this interface
 double getInternalDamageSummary(int turn)
           
 CapitalShipInternalStructure getInternalStructure()
           
 java.util.Vector<CapitalShipWeaponMount> getMissileWeapons(int turn)
           
 GameElementMovementSummary getMovementSummary(int turn)
          return a new GameElementMovementSummary appropriate for the element implementing this interface
 java.lang.String getName()
           
 CapitalShipPowerAllocation getPowerAllocation()
           
 int getShieldFactor(ShipSide side)
           
 CapitalShipWeaponMount getSpinalMount(int turn, java.util.HashMap<ShipSide,java.lang.Integer> sides)
           
 int getThrustForAcceleration()
           
 int getThrustForManouvering()
           
 int getTurretFireControlDamageModifier(CapitalShipWeaponMount cswm)
           
 java.util.Vector<CapitalShipWeaponMount> getTurretWeapons(int turn, java.util.HashMap<ShipSide,java.lang.Integer> sides)
           
 CapitalShipWeaponMount getWeaponMountByIndex(int index)
           
 CapitalShip.WeaponMountStatus getWeaponMountStatusByIndex(int index)
           
 boolean hasInternalStructure()
           
 boolean hasMoved(int turn)
          returns whether a unit has moved in a given turn
 boolean isDestroyed(int turn)
           
 boolean isManouverPowerSystemDamaged()
           
 boolean isShieldOk(ShipSide side)
           
 boolean isShipDestroyed()
           
 boolean isWeaponMountDamaged(int index)
           
 boolean isWeaponMountDestroyed(int index)
           
 boolean isWeaponMountOk(int index)
           
 boolean isWeaponPowerSystemDamaged()
           
 void notifySelectionOfDestroyedShieldRequired(java.util.Vector<ShipSide> sides)
           
 int powerBlocksAvailable()
           
 void processDamagedArmourAndInternal()
           
 void removeDamageListener(CapitalShipDamageListener Listener)
           
 void removeFiringListener(CapitalShipFiringListener Listener)
           
 void removeListener(CapitalShipStatusListener cssl)
           
 void removeMovementListener(CapitalShipMovementListener Listener)
           
 void setMoved(int turn)
          sets the status of an element that has moved in a given turn
 void setName(java.lang.String name)
           
 void setPowerAllocation(CapitalShipPowerAllocation cspa)
           
 void systemDamaged(CapitalShipSystem system, int gameTurn, ShipSide side, int blockIndex)
           
 java.lang.String toString()
           
 void weaponFired(java.lang.String weaponName, java.lang.String ammoType, int weaponIndex)
          This is called when an element fires a weapon
 boolean weaponIgnoresShields(int index)
           
 void widowArmour()
           
 
Methods inherited from class rl.common.game.elements.GameElement
equals, getID, getIdentifier, getUnit, hashCode, setUnit
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

CapitalShip

public CapitalShip(CapitalShipDesign design,
                   CapitalShipInternalStructure internalStructure)
Method Detail

addMovementListener

public void addMovementListener(CapitalShipMovementListener Listener)

removeMovementListener

public void removeMovementListener(CapitalShipMovementListener Listener)

addFiringListener

public void addFiringListener(CapitalShipFiringListener Listener)

removeFiringListener

public void removeFiringListener(CapitalShipFiringListener Listener)

addDamageListener

public void addDamageListener(CapitalShipDamageListener Listener)

removeDamageListener

public void removeDamageListener(CapitalShipDamageListener Listener)

canMove

public boolean canMove(int turn)
Description copied from interface: MovementCapableElement
returns whether the element can move in a given turn

Specified by:
canMove in interface MovementCapableElement
Returns:
whether the element is capable of being moved on the turn supplied

hasMoved

public boolean hasMoved(int turn)
Description copied from interface: MovementCapableElement
returns whether a unit has moved in a given turn

Specified by:
hasMoved in interface MovementCapableElement
Returns:
if the element has moved on the turn supplied

setMoved

public void setMoved(int turn)
Description copied from interface: MovementCapableElement
sets the status of an element that has moved in a given turn

Specified by:
setMoved in interface MovementCapableElement

applyMovementSummary

public void applyMovementSummary(GameElementMovementSummary gems)
Description copied from interface: MovementCapableElement
applies the summary of movement to the element. This is to provide a synch between the element on the server and the one on the client.

Specified by:
applyMovementSummary in interface MovementCapableElement

getMovementSummary

public GameElementMovementSummary getMovementSummary(int turn)
Description copied from interface: MovementCapableElement
return a new GameElementMovementSummary appropriate for the element implementing this interface

Specified by:
getMovementSummary in interface MovementCapableElement

isDestroyed

public boolean isDestroyed(int turn)
Specified by:
isDestroyed in class GameElement

destroyedByExplosion

public boolean destroyedByExplosion(int turn)

getInternalStructure

public final CapitalShipInternalStructure getInternalStructure()

getArmour

public final CapitalShipArmour getArmour()

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()
Specified by:
getName in class GameElement

getDesign

public CapitalShipDesign getDesign()

getElementType

public java.lang.String getElementType()
Specified by:
getElementType in class GameElement

toString

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

setPowerAllocation

public void setPowerAllocation(CapitalShipPowerAllocation cspa)

getPowerAllocation

public CapitalShipPowerAllocation getPowerAllocation()

applyArmourDamage

public void applyArmourDamage(ShipSide side,
                              GridReference ref)

applyInternalDamage

public void applyInternalDamage(int gameTurn,
                                GridReference ref,
                                ShipSide side)

getDamageSummary

public double getDamageSummary(int turn)
Specified by:
getDamageSummary in class GameElement

hasInternalStructure

public boolean hasInternalStructure()
Specified by:
hasInternalStructure in class GameElement

getInternalDamageSummary

public double getInternalDamageSummary(int turn)
Specified by:
getInternalDamageSummary in class GameElement

calculateStatus

public GameElementDamageSummary calculateStatus(int turn,
                                                GameElement.StatusPhase phase)
Specified by:
calculateStatus in class GameElement

applyDamageSummary

public void applyDamageSummary(GameElementDamageSummary geds)
Specified by:
applyDamageSummary in class GameElement

addListener

public void addListener(CapitalShipStatusListener cssl)

removeListener

public void removeListener(CapitalShipStatusListener cssl)

isShipDestroyed

public boolean isShipDestroyed()

isShieldOk

public boolean isShieldOk(ShipSide side)

isWeaponPowerSystemDamaged

public boolean isWeaponPowerSystemDamaged()

isManouverPowerSystemDamaged

public boolean isManouverPowerSystemDamaged()

canAllocatePower

public boolean canAllocatePower()

canManouver

public boolean canManouver()

getThrustForAcceleration

public int getThrustForAcceleration()

getThrustForManouvering

public int getThrustForManouvering()

powerBlocksAvailable

public int powerBlocksAvailable()

canRoll

public boolean canRoll()

canTurnLeft

public boolean canTurnLeft()

canTurnRight

public boolean canTurnRight()

canJumpFTL

public boolean canJumpFTL()

getShieldFactor

public int getShieldFactor(ShipSide side)

weaponIgnoresShields

public boolean weaponIgnoresShields(int index)

getFireControlDamageModifier

public int getFireControlDamageModifier(int index)

getTurretFireControlDamageModifier

public int getTurretFireControlDamageModifier(CapitalShipWeaponMount cswm)

getBayWeaponFireControlDamageModifier

public int getBayWeaponFireControlDamageModifier(CapitalShipWeaponMount cswm)

systemDamaged

public void systemDamaged(CapitalShipSystem system,
                          int gameTurn,
                          ShipSide side,
                          int blockIndex)

isWeaponMountOk

public boolean isWeaponMountOk(int index)

isWeaponMountDamaged

public boolean isWeaponMountDamaged(int index)

isWeaponMountDestroyed

public boolean isWeaponMountDestroyed(int index)

getWeaponMountByIndex

public CapitalShipWeaponMount getWeaponMountByIndex(int index)

getWeaponMountStatusByIndex

public CapitalShip.WeaponMountStatus getWeaponMountStatusByIndex(int index)

getAllWeapons

public java.util.Vector<CapitalShipWeaponMount> getAllWeapons(int turn,
                                                              java.util.HashMap<ShipSide,java.lang.Integer> sides)

getAllPointDefenceWeapons

public java.util.Vector<CapitalShipWeaponMount> getAllPointDefenceWeapons(int turn,
                                                                          java.util.HashMap<ShipSide,java.lang.Integer> sides)

getSpinalMount

public CapitalShipWeaponMount getSpinalMount(int turn,
                                             java.util.HashMap<ShipSide,java.lang.Integer> sides)

getBayWeapons

public java.util.Vector<CapitalShipWeaponMount> getBayWeapons(int turn,
                                                              java.util.HashMap<ShipSide,java.lang.Integer> sides)

getTurretWeapons

public java.util.Vector<CapitalShipWeaponMount> getTurretWeapons(int turn,
                                                                 java.util.HashMap<ShipSide,java.lang.Integer> sides)

getMissileWeapons

public java.util.Vector<CapitalShipWeaponMount> getMissileWeapons(int turn)

notifySelectionOfDestroyedShieldRequired

public void notifySelectionOfDestroyedShieldRequired(java.util.Vector<ShipSide> sides)

applyWeaponDamage

public void applyWeaponDamage(int turn,
                              CapitalShipWeapon w,
                              ShipSide side,
                              int range,
                              int column)

processDamagedArmourAndInternal

public void processDamagedArmourAndInternal()

widowArmour

public void widowArmour()

canFire

public boolean canFire(int turn)
Description copied from interface: FiringCapableElement
Returns whether this unit can make a firing attempt on a particular turn

Specified by:
canFire in interface FiringCapableElement
Parameters:
turn - The turn that we're checking the element can fire
Returns:
If the element can fire on the turn supplied

canFireIndirect

public boolean canFireIndirect(int turn)
Description copied from interface: FiringCapableElement
Returns whether this unit can make an indirect firing attempt on a particular turn

Specified by:
canFireIndirect in interface FiringCapableElement
Parameters:
turn - The turn that we're checking the element can fire indirectly
Returns:
If the element can fire indirectly on the turn supplied

getFiringSummary

public GameElementFiringSummary getFiringSummary(int turn)
Description copied from interface: FiringCapableElement
get a new GameElementFiringSummary object appropriate to the object implementing this interface

Specified by:
getFiringSummary in interface FiringCapableElement
Returns:
A GameElementFiringSummary object containing all of the information for all of the outgoing fire from this element

applyFiringSummary

public void applyFiringSummary(GameElementFiringSummary gefs)
Description copied from interface: FiringCapableElement
function called to apply firing summary to element. This is used as a synch between the element on the server and one on the client.

Specified by:
applyFiringSummary in interface FiringCapableElement
Parameters:
gefs - Applies all of the firing information contained in the GameElementFiringSummary. This is primarily used to capture ammunition expenditure

weaponFired

public void weaponFired(java.lang.String weaponName,
                        java.lang.String ammoType,
                        int weaponIndex)
Description copied from interface: FiringCapableElement
This is called when an element fires a weapon

Specified by:
weaponFired in interface FiringCapableElement
Parameters:
weaponName - The name of the weapon system firing
ammoType - The ammo type used in the firing attempt
weaponIndex - The index of the weapon system firing