wyvern.kernel.combat.slots
Class AbstractArmorWeaponSlot

java.lang.Object
  extended bywyvern.kernel.combat.slots.AbstractSlot
      extended bywyvern.kernel.combat.slots.AbstractArmorSlot
          extended bywyvern.kernel.combat.slots.AbstractArmorWeaponSlot
All Implemented Interfaces:
ArmorSlot, ItemSlot, WeaponSlot
Direct Known Subclasses:
HoldingSlot

public abstract class AbstractArmorWeaponSlot
extends AbstractArmorSlot
implements WeaponSlot

This class serves as the superclass for a body part that can hold either an armor or a weapon.

Version:
1.0, Jun 09, 1998
Author:
Steve Yegge

Field Summary
protected  GameObject either_
           
protected  java.lang.Class type_
           
 
Fields inherited from class wyvern.kernel.combat.slots.AbstractArmorSlot
armor_
 
Fields inherited from class wyvern.kernel.combat.slots.AbstractSlot
layer_
 
Constructor Summary
AbstractArmorWeaponSlot()
          Constructs a new AbstractArmorWeaponSlot
 
Method Summary
 void checkType(Armor armor)
          Throws an IllegalArgumentException if the armor isn't of the expected type.
 Armor getArmor()
          Gets the armor currently in the slot.
 java.lang.Class getArmorType()
          Returns the Armor subclass that this part can wear.
protected abstract  java.lang.Class getDefaultArmorType()
          Subclasses must specify their armor type via this method.
 GameObject getItem()
          Returns the item in this slot.
 Weapon getWeapon()
          Returns the Weapon that this part is holding.
 boolean isEmpty()
          Returns false if this slot has armor or a weapon in it.
 void remove(GameObject item)
          Removes the item in the slot.
 void setArmor(Armor armor)
          Puts the armor in the slot (nuking what was there before).
 void setItem(GameObject item)
          Sets the item in the slot.
 void setWeapon(Weapon weapon)
          Puts a Weapon in this slot.
 java.lang.String toString()
          Returns String representation.
 
Methods inherited from class wyvern.kernel.combat.slots.AbstractSlot
getLayer, setLayer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wyvern.kernel.combat.slots.ItemSlot
getLayer, setLayer
 

Field Detail

either_

protected GameObject either_

type_

protected java.lang.Class type_
Constructor Detail

AbstractArmorWeaponSlot

public AbstractArmorWeaponSlot()
Constructs a new AbstractArmorWeaponSlot

Method Detail

isEmpty

public boolean isEmpty()
Returns false if this slot has armor or a weapon in it.

Specified by:
isEmpty in interface ItemSlot
Overrides:
isEmpty in class AbstractArmorSlot
Returns:
true if the slot is empty

getArmorType

public java.lang.Class getArmorType()
Returns the Armor subclass that this part can wear.

Specified by:
getArmorType in interface ArmorSlot

getDefaultArmorType

protected abstract java.lang.Class getDefaultArmorType()
Subclasses must specify their armor type via this method.


getArmor

public Armor getArmor()
Gets the armor currently in the slot.

Specified by:
getArmor in interface ArmorSlot
Overrides:
getArmor in class AbstractArmorSlot
Returns:
the Armor in the slot

setArmor

public void setArmor(Armor armor)
Puts the armor in the slot (nuking what was there before).

Specified by:
setArmor in interface ArmorSlot
Overrides:
setArmor in class AbstractArmorSlot

getItem

public GameObject getItem()
Returns the item in this slot.

Specified by:
getItem in interface ItemSlot
Overrides:
getItem in class AbstractArmorSlot
Returns:
null, or the Armor or Weapon in the slot

setItem

public void setItem(GameObject item)
Sets the item in the slot.

Overrides:
setItem in class AbstractArmorSlot
Parameters:
item - the weapon or armor to set

checkType

public void checkType(Armor armor)
Throws an IllegalArgumentException if the armor isn't of the expected type.

Overrides:
checkType in class AbstractArmorSlot
Parameters:
armor - the armor to use

getWeapon

public Weapon getWeapon()
Returns the Weapon that this part is holding.

Specified by:
getWeapon in interface WeaponSlot
Returns:
the Weapon we're holding. If we're empty, or are currently holding armor, returns null.

setWeapon

public void setWeapon(Weapon weapon)
Puts a Weapon in this slot. Nukes whatever was there before; it's up to the caller to handle the old weapon.

Specified by:
setWeapon in interface WeaponSlot
Parameters:
weapon - the weapon to put in the slot

remove

public void remove(GameObject item)
Removes the item in the slot.

Specified by:
remove in interface ItemSlot
Overrides:
remove in class AbstractArmorSlot
Parameters:
item - the item to remove.
Throws:
java.lang.IllegalArgumentException - if the passed item doesn't match the item in the slot.

toString

public java.lang.String toString()
Returns String representation.

Overrides:
toString in class AbstractArmorSlot
Returns:
a debugging string