megamek.common.weapons
Class WeaponHandler

java.lang.Object
  extended by megamek.common.weapons.WeaponHandler
All Implemented Interfaces:
java.io.Serializable, AttackHandler
Direct Known Subclasses:
AmmoWeaponHandler, AutoGrenadeLauncherHandler, BAAPGaussWeaponHandler, BAMGHandler, BayWeaponHandler, BearHunterHandler, BombastLaserWeaponHandler, BombAttackHandler, EnergyWeaponHandler, FiredrakeHandler, FireExtinguisherHandler, FlamerHandler, FlamerHeatHandler, HeavyGrenadeLauncherHandler, HeavyRecoillessHandler, InfantryWeaponHandler, LegAttackHandler, LightRecoillessHandler, MediumRecoillessHandler, SpaceBombAttackHandler, StopSwarmAttackHandler, SwarmAttackHandler, TAGHandler

public class WeaponHandler
extends java.lang.Object
implements AttackHandler, java.io.Serializable

Author:
Andrew Hunter A basic, simple attack handler. May or may not work for any particular weapon; must be overloaded to support special rules.
See Also:
Serialized Form

Field Summary
protected  Entity ae
           
protected  boolean announcedEntityFiring
           
protected  int attackValue
           
protected  boolean bDirect
           
protected  boolean bGlancing
           
protected  boolean bMissed
           
protected  boolean bSalvo
           
protected  Server.DamageType damageType
           
protected  IGame game
           
protected  int generalDamageType
           
protected  java.util.Vector<java.lang.Integer> insertedAttacks
           
protected  boolean missed
           
protected  int nDamPerHit
           
protected  int nRange
           
protected  boolean nukeS2S
           
protected  int nweapons
           
 int roll
           
protected  Server server
           
protected  int subjectId
           
protected  Targetable target
           
protected  boolean throughFront
           
 ToHitData toHit
           
protected  boolean underWater
           
 WeaponAttackAction waa
           
protected  Mounted weapon
           
protected  WeaponType wtype
           
 
Constructor Summary
protected WeaponHandler()
           
  WeaponHandler(ToHitData t, WeaponAttackAction w, IGame g, Server s)
           
 
Method Summary
protected  void addHeat()
           
protected  boolean allShotsHit()
           
 boolean announcedEntityFiring()
           
protected  int calcAttackValue()
          Calculate the attack value based on range
protected  int calcDamagePerHit()
          Calculate the damage per hit.
protected  int calcHits(java.util.Vector<Report> vPhaseReport)
          Calculate the number of hits
protected  int calcnCluster()
          Calculate the clustering of the hits
protected  boolean canDoDirectBlowDamage()
           
 boolean cares(IGame.Phase phase)
          Do we care about the specified phase?
 int checkTerrain(int nDamage, Entity entityTarget, java.util.Vector<Report> vPhaseReport)
           
protected  boolean doChecks(java.util.Vector<Report> vPhaseReport)
           
 int getAttackerId()
          return the int Id of the attacking Entity
protected  double getBracketingMultiplier()
          adjustment factor on attack value for fighter squadrons
protected  int getCapMisMod()
           
protected  int getNumberWeapons()
           
 WeaponAttackAction getWaa()
           
 boolean handle(IGame.Phase phase, java.util.Vector<Report> vPhaseReport)
          handle this weapons firing
protected  void handleBuildingDamage(java.util.Vector<Report> vPhaseReport, Building bldg, int nDamage, Coords coords)
           
protected  void handleClearDamage(java.util.Vector<Report> vPhaseReport, Building bldg, int nDamage)
           
protected  void handleEntityDamage(Entity entityTarget, java.util.Vector<Report> vPhaseReport, Building bldg, int hits, int nCluster, int bldgAbsorbs)
          Handle damage against an entity, called once per hit by default.
protected  void handleIgnitionDamage(java.util.Vector<Report> vPhaseReport, Building bldg, int hits)
           
protected  boolean handleSpecialMiss(Entity entityTarget, boolean targetInBuilding, Building bldg, java.util.Vector<Report> vPhaseReport)
           
protected  void insertAttacks(IGame.Phase phase, java.util.Vector<Report> vPhaseReport)
          Insert any additionaly attacks that should occur before this attack
protected  void reportMiss(java.util.Vector<Report> vPhaseReport)
           
 void setAnnouncedEntityFiring(boolean announcedEntityFiring)
           
protected  void setDone()
           
protected  boolean specialResolution(java.util.Vector<Report> vPhaseReport, Entity entityTarget)
          special resolution, like minefields and arty
protected  void useAmmo()
           
protected  boolean usesClusterTable()
          Does this attack use the cluster hit table?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toHit

public ToHitData toHit

waa

public WeaponAttackAction waa

roll

public int roll

game

protected IGame game

server

protected transient Server server

bMissed

protected boolean bMissed

bSalvo

protected boolean bSalvo

bGlancing

protected boolean bGlancing

bDirect

protected boolean bDirect

nukeS2S

protected boolean nukeS2S

wtype

protected WeaponType wtype

weapon

protected Mounted weapon

ae

protected Entity ae

target

protected Targetable target

subjectId

protected int subjectId

nRange

protected int nRange

nDamPerHit

protected int nDamPerHit

attackValue

protected int attackValue

throughFront

protected boolean throughFront

underWater

protected boolean underWater

announcedEntityFiring

protected boolean announcedEntityFiring

missed

protected boolean missed

damageType

protected Server.DamageType damageType

generalDamageType

protected int generalDamageType

insertedAttacks

protected java.util.Vector<java.lang.Integer> insertedAttacks

nweapons

protected int nweapons
Constructor Detail

WeaponHandler

protected WeaponHandler()

WeaponHandler

public WeaponHandler(ToHitData t,
                     WeaponAttackAction w,
                     IGame g,
                     Server s)
Method Detail

getAttackerId

public int getAttackerId()
return the int Id of the attacking Entity

Specified by:
getAttackerId in interface AttackHandler

cares

public boolean cares(IGame.Phase phase)
Do we care about the specified phase?

Specified by:
cares in interface AttackHandler

doChecks

protected boolean doChecks(java.util.Vector<Report> vPhaseReport)
Parameters:
vPhaseReport - - A Vector containing the phasereport.
Returns:
a boolean value indicating wether or not the attack misses because of a failed check.

handleSpecialMiss

protected boolean handleSpecialMiss(Entity entityTarget,
                                    boolean targetInBuilding,
                                    Building bldg,
                                    java.util.Vector<Report> vPhaseReport)
Returns:
a boolean value indicating wether or not this attack needs further calculating, like a missed shot hitting a building, or an AMS only shooting down some missiles.

calcHits

protected int calcHits(java.util.Vector<Report> vPhaseReport)
Calculate the number of hits

Parameters:
vPhaseReport - - the Vector containing the phase report.
Returns:
an int containing the number of hits.

calcnCluster

protected int calcnCluster()
Calculate the clustering of the hits

Returns:
a int value saying how much hits are in each cluster of damage.

handle

public boolean handle(IGame.Phase phase,
                      java.util.Vector<Report> vPhaseReport)
handle this weapons firing

Specified by:
handle in interface AttackHandler
Returns:
a boolean value indicating whether this should be kept or not

calcDamagePerHit

protected int calcDamagePerHit()
Calculate the damage per hit.

Returns:
an int representing the damage dealt per hit.

calcAttackValue

protected int calcAttackValue()
Calculate the attack value based on range

Returns:
an int representing the attack value at that range.

getBracketingMultiplier

protected double getBracketingMultiplier()
adjustment factor on attack value for fighter squadrons


getCapMisMod

protected int getCapMisMod()

handleEntityDamage

protected void handleEntityDamage(Entity entityTarget,
                                  java.util.Vector<Report> vPhaseReport,
                                  Building bldg,
                                  int hits,
                                  int nCluster,
                                  int bldgAbsorbs)
Handle damage against an entity, called once per hit by default.

Parameters:
entityTarget -
vPhaseReport -
bldg -
hits -
nCluster -
bldgAbsorbs -

handleIgnitionDamage

protected void handleIgnitionDamage(java.util.Vector<Report> vPhaseReport,
                                    Building bldg,
                                    int hits)

handleClearDamage

protected void handleClearDamage(java.util.Vector<Report> vPhaseReport,
                                 Building bldg,
                                 int nDamage)

handleBuildingDamage

protected void handleBuildingDamage(java.util.Vector<Report> vPhaseReport,
                                    Building bldg,
                                    int nDamage,
                                    Coords coords)

allShotsHit

protected boolean allShotsHit()

reportMiss

protected void reportMiss(java.util.Vector<Report> vPhaseReport)

useAmmo

protected void useAmmo()

setDone

protected void setDone()

addHeat

protected void addHeat()

usesClusterTable

protected boolean usesClusterTable()
Does this attack use the cluster hit table? necessary to determine how Aero damage should be applied


specialResolution

protected boolean specialResolution(java.util.Vector<Report> vPhaseReport,
                                    Entity entityTarget)
special resolution, like minefields and arty

Parameters:
vPhaseReport - - a Vector containing the phase report
entityTarget - - the Entity targeted, or null, if no Entity targeted
Returns:
true when done with processing, false when not

announcedEntityFiring

public boolean announcedEntityFiring()
Specified by:
announcedEntityFiring in interface AttackHandler

setAnnouncedEntityFiring

public void setAnnouncedEntityFiring(boolean announcedEntityFiring)
Specified by:
setAnnouncedEntityFiring in interface AttackHandler

getWaa

public WeaponAttackAction getWaa()
Specified by:
getWaa in interface AttackHandler

checkTerrain

public int checkTerrain(int nDamage,
                        Entity entityTarget,
                        java.util.Vector<Report> vPhaseReport)

canDoDirectBlowDamage

protected boolean canDoDirectBlowDamage()

insertAttacks

protected void insertAttacks(IGame.Phase phase,
                             java.util.Vector<Report> vPhaseReport)
Insert any additionaly attacks that should occur before this attack


getNumberWeapons

protected int getNumberWeapons()
Returns:
the number of weapons of this type firing (for squadron weapon groups)