Class Monster

java.lang.Object
  |
  +--java.awt.Component
        |
        +--MapObject
              |
              +--Monster
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
EarthMon, ElectricMon, FireMon, GasMon, WaterMon

public abstract class Monster
extends MapObject

Class to define a Monster and its attributes.

See Also:
FireMon, EarthMon, WaterMon, GasMon, ElectricMon, Serialized Form

Field Summary
protected  java.util.Vector attacks
          The attacks this knows
protected  int attp
          The Attack Of this
protected  boolean battle
          tru iff battling
protected  int defp
          The Defense Of this
static int EARTH
          Earth kind
static int ELECTRIC
          Electric kind
protected  int exp
          The Experience Of this
static int FIRE
          Fire kind
static int GAS
          Gas kind
protected  int hp
          The HP Of this
protected  int kind
          The kind of Monster this is
protected  int level
          The level of this
protected  int maxAtt
          The Maximum Attack Of this at this level
static int MAXATTACKS
          The Maximum number of attack to have
protected  int maxDef
          The Maximum Defense Of this at this level
protected  int maxExp
          The Maximum Experience before a level up
protected  int maxHP
          The Maximum HP Of this, ie full health
protected  int maxLevel
          The Maximum level before learning a new attack
static int MAXLEVEL
          The Maximum level allowed for Monsters to have
protected  java.lang.String name
          The name of this
static int WATER
          Water kind
 
Fields inherited from class MapObject
BUILDING, enterable, FLOOR, GRASS, MONSTER, PERSON, PLAYER, REDIRECT, ROCK, TRAINER, type, WALL
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Monster()
           
 
Method Summary
abstract  void addAttack(java.lang.String attack)
          Learn the attack specifid by attack
 boolean equals(Monster m)
          Tests for equality, ie if all the parameters are the same
 boolean equals(java.lang.Object o)
          Tests for equality
 boolean finishFight(Monster m)
          Finish the fight with the opposing Monster, ie give this the requisite experience
abstract  java.lang.String getA1()
          Gets the name of the first Attack
abstract  java.lang.String getA2()
          Gets the name of the second Attack
abstract  java.lang.String getA3()
          Gets the name of the third Attack
abstract  java.lang.String getA4()
          Gets the name of the fourth Attack
abstract  java.lang.String getA5()
          Gets the name of the fifth Attack
abstract  java.lang.String getA6()
          Gets the name of the sixth Attack
 int getAttack()
          Gets the Attack Points of this.
 Attack getAttack(int pos)
          Gets the Attack known at the specified position
 java.lang.String[] getAttacks()
          Gets the array of attacks available to this, adds null if less then Monster.MAXATTACKS
 int getDefense()
          Gers the defense of this
 int getExperience()
          Gets the Experience of this
 int getHP()
          Gets the HP of this
 int getKind()
          Gets the Kind of this
 int getLevel()
          Gets the level of this
 int getMaxAttack()
          Gets the Maximum Attack Points of this
 int getMaxDefense()
          Gets the Maximum Defense
 int getMaxExperience()
          Gets the Maximum Experience Pointsup
 int getMaxHP()
          Gets the maximum hp
 int getMaxLevel()
          Gets the Max level
 java.lang.String getName()
          Gets the name of this.
 int getNumberOfAttacks()
          Gets the number of attacks this knows.
 boolean isBattling()
          Returns true iff battling
protected  void levelUp()
          Preforms a level up increasing attack, defense, and hp.
 void paint(java.awt.Graphics g)
          Draws this for the Grid.
 void setAttack(int nap)
          Sets the Attack points of this
 void setBehind(MapObject m)
          Sets the MapObject to paint where this is.
 void setDefense(int ndp)
          Sets the defense of this
protected  boolean setExperience(int nep)
          Sets the Experience Pints and levels up if needed.
 void setHP(int nhp)
          Sets the hp
 void setLevel(int level)
          Sets the level of this.
protected  void setMaxAttack(int nmap)
          Sets the Maximum Attack Points of this
protected  void setMaxDefense(int nmdp)
          Sets the Maximum defense of this
protected  void setMaxExperience(int nmep)
          Sets the maximum Experience of this, the amount required before a level up
protected  void setMaxHP(int nmhp)
          Sets the maximum hp
 void setName(java.lang.String name)
          Sets the name of this Monster
 void startBattle()
          Starts a fight
 void stopBattle()
          Stop a fight
abstract  boolean substituteAttack(Attack removed, Attack added)
          Substitute one Attack for another.
 
Methods inherited from class MapObject
canBeEntered, getClone, getType, setImage
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ELECTRIC

public static final int ELECTRIC
Electric kind

See Also:
Constant Field Values

EARTH

public static final int EARTH
Earth kind

See Also:
Constant Field Values

FIRE

public static final int FIRE
Fire kind

See Also:
Constant Field Values

WATER

public static final int WATER
Water kind

See Also:
Constant Field Values

GAS

public static final int GAS
Gas kind

See Also:
Constant Field Values

MAXLEVEL

public static final int MAXLEVEL
The Maximum level allowed for Monsters to have

See Also:
Constant Field Values

MAXATTACKS

public static final int MAXATTACKS
The Maximum number of attack to have

See Also:
Constant Field Values

hp

protected int hp
The HP Of this


defp

protected int defp
The Defense Of this


attp

protected int attp
The Attack Of this


exp

protected int exp
The Experience Of this


maxHP

protected int maxHP
The Maximum HP Of this, ie full health


maxDef

protected int maxDef
The Maximum Defense Of this at this level


maxAtt

protected int maxAtt
The Maximum Attack Of this at this level


maxExp

protected int maxExp
The Maximum Experience before a level up


level

protected int level
The level of this


maxLevel

protected int maxLevel
The Maximum level before learning a new attack


kind

protected int kind
The kind of Monster this is


attacks

protected java.util.Vector attacks
The attacks this knows


name

protected java.lang.String name
The name of this


battle

protected boolean battle
tru iff battling

Constructor Detail

Monster

public Monster()
Method Detail

addAttack

public abstract void addAttack(java.lang.String attack)
Learn the attack specifid by attack

Parameters:
attack - The Attack to learn

getA1

public abstract java.lang.String getA1()
Gets the name of the first Attack

Returns:
the name of the first Attack

getA2

public abstract java.lang.String getA2()
Gets the name of the second Attack

Returns:
the name of the second Attack

getA3

public abstract java.lang.String getA3()
Gets the name of the third Attack

Returns:
the name of the third Attack

getA4

public abstract java.lang.String getA4()
Gets the name of the fourth Attack

Returns:
the name of the fourth Attack

getA5

public abstract java.lang.String getA5()
Gets the name of the fifth Attack

Returns:
the name of the fifth Attack

getA6

public abstract java.lang.String getA6()
Gets the name of the sixth Attack

Returns:
the name of the sixth Attack

substituteAttack

public abstract boolean substituteAttack(Attack removed,
                                         Attack added)
Substitute one Attack for another.

Parameters:
removed - the Attack to remove
added - the Attack to add

setHP

public void setHP(int nhp)
Sets the hp


getHP

public int getHP()
Gets the HP of this

Returns:
the HP of this

setMaxHP

protected void setMaxHP(int nmhp)
Sets the maximum hp


getMaxHP

public int getMaxHP()
Gets the maximum hp

Returns:
the new maximum HP of this

setDefense

public void setDefense(int ndp)
Sets the defense of this

Parameters:
ndp - the new defense of this

getDefense

public int getDefense()
Gers the defense of this

Returns:
the defense of this

setMaxDefense

protected void setMaxDefense(int nmdp)
Sets the Maximum defense of this

Parameters:
nmdp - the new Maximum Defense of this

getMaxDefense

public int getMaxDefense()
Gets the Maximum Defense

Returns:
the Maximum defense of this

setAttack

public void setAttack(int nap)
Sets the Attack points of this

Parameters:
nap - the new Attack Points

getAttack

public int getAttack()
Gets the Attack Points of this.

Returns:
the Attack Points of this

setMaxAttack

protected void setMaxAttack(int nmap)
Sets the Maximum Attack Points of this

Parameters:
nmap - the new Maximum Attack Points of this

getMaxAttack

public int getMaxAttack()
Gets the Maximum Attack Points of this

Returns:
the Maximum Attack Points of this

setExperience

protected boolean setExperience(int nep)
                         throws AttacksFullException
Sets the Experience Pints and levels up if needed.

Parameters:
nep - the new Experience Points of this
Returns:
true iff leveled up
AttacksFullException

getExperience

public int getExperience()
Gets the Experience of this

Returns:
the Experience of this

setMaxExperience

protected void setMaxExperience(int nmep)
Sets the maximum Experience of this, the amount required before a level up

Parameters:
nmep - the New Maximum Experience Ponts

getMaxExperience

public int getMaxExperience()
Gets the Maximum Experience Pointsup

Returns:
the Maximum Experience Points, the amount required before a level up

getLevel

public int getLevel()
Gets the level of this

Returns:
the level of this

getKind

public int getKind()
Gets the Kind of this

Returns:
the kind of this

setLevel

public void setLevel(int level)
Sets the level of this.

Parameters:
level - the level to mak this

getMaxLevel

public int getMaxLevel()
Gets the Max level

Returns:
the max level before a new attack is learned

getNumberOfAttacks

public int getNumberOfAttacks()
Gets the number of attacks this knows.


levelUp

protected void levelUp()
                throws AttacksFullException
Preforms a level up increasing attack, defense, and hp.

Throws:
AttacksFullException - iff this has more than Monster.MAXATTACKS

finishFight

public boolean finishFight(Monster m)
                    throws AttacksFullException
Finish the fight with the opposing Monster, ie give this the requisite experience

Parameters:
m - the Opposing Monster
Throws:
AttacksFullException - iff this has more than Monster.MAXATTACKS, and is leveling up

setName

public void setName(java.lang.String name)
Sets the name of this Monster

Overrides:
setName in class java.awt.Component
Parameters:
name - The Name of this

getName

public java.lang.String getName()
Gets the name of this.

Overrides:
getName in class java.awt.Component
Returns:
the name of this

getAttacks

public java.lang.String[] getAttacks()
Gets the array of attacks available to this, adds null if less then Monster.MAXATTACKS

Returns:
the array of attacks available to this, adds null if less then Monster.MAXATTACKS

getAttack

public Attack getAttack(int pos)
Gets the Attack known at the specified position

Parameters:
pos - the index of the Attack to return
Returns:
the Attack at the specified position

equals

public boolean equals(java.lang.Object o)
Tests for equality

Overrides:
equals in class java.lang.Object
Parameters:
o - the Object to compare to
Returns:
true iff equivalant

equals

public boolean equals(Monster m)
Tests for equality, ie if all the parameters are the same

Parameters:
m - the Monster to compare to
Returns:
true iff equivalant

isBattling

public boolean isBattling()
Returns true iff battling

Returns:
true iff battling

startBattle

public void startBattle()
Starts a fight


stopBattle

public void stopBattle()
Stop a fight


setBehind

public void setBehind(MapObject m)
Sets the MapObject to paint where this is.

Parameters:
m - the MapObject to paint where this is

paint

public void paint(java.awt.Graphics g)
Draws this for the Grid.

Overrides:
paint in class java.awt.Component
Parameters:
g - the Graphics.