Class People

java.lang.Object
  |
  +--java.awt.Component
        |
        +--MapObject
              |
              +--People
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
Person, Player, Trainer

public abstract class People
extends MapObject

Class to define People, the superclass of Person, Player and Trainer. Carry Items Monsters and Monsters at Home

See Also:
Monster, Item, Person, Player, Trainer, Serialized Form

Field Summary
protected  int activeMon
          The index of the active Monster
protected  boolean battling
          True if in a battle, with Player or Person
protected  boolean beaten
          True if has beed beaten by the Player
protected static MapObject behind
          The MapObject to paint this on top of
protected  int dir
          The direction facing as specified in Grid
protected  java.lang.String dlg
          The dialogue to present when in Battle
protected  java.util.Vector hmon
          The Monsters caught, and not able to be used, ie in the Pepole's home collection
protected  java.util.Vector items
          The Items bought.
protected  int MAXMON
          The Maximum number of Monsters to cary
protected  java.util.Vector mon
          The Monsters caught, and able to be used, ie in the Pepole's hand
protected  int money
          The amount of money carrying
protected  java.lang.String name
          The name of this
 
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
People()
           
 
Method Summary
 void addItem(Item i)
          Adds the Item specified to this.
 boolean addMonster(Monster p)
          Adds a Monster to this, either to the hand or to home if the hand has more than this.MAXMON
 void addMonsterHome(Monster p)
          Adds a Monster to the Home collection
 void battle()
          Begins a battle with this, sets battle to true.
 void beat()
          Defeat this, ie sets beaten to true.
 int getActiveMonster()
          Gets the index of the Active Monster.
 MapObject getBehind()
          Gets the MapObject standing on
 java.lang.String getDialogue()
          Gets the dialogue associated with this
 int getDirection()
          Gets the direction facing
 Item getItem(java.lang.String name)
          Gets the Item corresponding to the name specified.
 int getItemCount(java.lang.String name)
          Gets the number of Item this has.
 java.lang.String[] getItems()
          Gets an array of Strings of the Item that the Player is currently carrying
 int getMoney()
          Gets the amount of Money carried.
 Monster getMonster(int i)
          Gets the Monster from the hand at the specified index, ignoring Monsters that have no HP.
 Monster getMonsterAtHome(int i)
          Gets the Monster from home at the specified index, ignoring Monsters that have no HP.
 java.lang.String[] getMonsterAttacks(int p)
          Gets an array of String for the Attacks available for the Monster at index p, ignoring the Monsters with no HP.
 java.lang.String[] getMonsters()
          Gets an array of Strings of the Monsters that the Player is currently carrying, ignoring those with no HP.
 java.lang.String getName()
          Gets the name of this.
 int getNumberOfMonsters()
          Gets the number of Monsters in the hand that do not have 0 hp.
 int getNumberOfMonstersAtHome()
          Gets the number of Monsters at home that do not have 0 hp.
 void healAllMonsters()
          Heals all Monster to full HP, Attack Points, and Defense Points
 boolean isBattling()
          Gets if this is in a Battle
 boolean isBeaten()
          Determine if this has been beaten.
 boolean isEnterable()
          Returns false, as this cannot be entered
 void setActiveMonster(int i)
          Sets the ActiveMonster for this.
 void setBehind(MapObject beh)
          Sets the MapObject to paint behind
 void setDialogue(java.lang.String slf)
          Sets the dialogue associated with this
 boolean setDirection(int direct)
          Sets the directio of this as specified in Grid
 void setMoney(int mon)
          Sets the amount of Money carried.
 void setName(java.lang.String name)
          Sets the name of this.
 void stopBattle()
          Ends a battle with this, sets battle to false.
 boolean switchMonster(Monster hand, Monster home)
          Switches a Monster from Home collection to the Hand collection.
 void useItem(Item it, Monster m)
          Uses the Item specified on the Monster specified
 
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, paint, 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAXMON

protected final int MAXMON
The Maximum number of Monsters to cary

See Also:
Constant Field Values

mon

protected java.util.Vector mon
The Monsters caught, and able to be used, ie in the Pepole's hand


hmon

protected java.util.Vector hmon
The Monsters caught, and not able to be used, ie in the Pepole's home collection


items

protected java.util.Vector items
The Items bought.


activeMon

protected int activeMon
The index of the active Monster


beaten

protected boolean beaten
True if has beed beaten by the Player


battling

protected boolean battling
True if in a battle, with Player or Person


money

protected int money
The amount of money carrying


behind

protected static MapObject behind
The MapObject to paint this on top of


dir

protected int dir
The direction facing as specified in Grid

See Also:
Grid

name

protected java.lang.String name
The name of this


dlg

protected java.lang.String dlg
The dialogue to present when in Battle

See Also:
Battle
Constructor Detail

People

public People()
Method Detail

getDialogue

public java.lang.String getDialogue()
Gets the dialogue associated with this

Returns:
the dialogue associated with this

setDialogue

public void setDialogue(java.lang.String slf)
Sets the dialogue associated with this

Parameters:
slf - the dialogue associated with this

isEnterable

public boolean isEnterable()
Returns false, as this cannot be entered


setDirection

public boolean setDirection(int direct)
Sets the directio of this as specified in Grid

Parameters:
direct - the direction to face
Returns:
true iff direct is a valid direction
See Also:
Grid

getDirection

public int getDirection()
Gets the direction facing

Returns:
the direction facing, as specified in Grid
See Also:
Grid

setBehind

public void setBehind(MapObject beh)
Sets the MapObject to paint behind

Parameters:
beh - the MapObject to paint this over

getBehind

public MapObject getBehind()
Gets the MapObject standing on

Returns:
the MapObject standing on

beat

public void beat()
Defeat this, ie sets beaten to true.


isBattling

public boolean isBattling()
Gets if this is in a Battle

Returns:
true if is in a Battle
See Also:
Battle, PersonAI

battle

public void battle()
Begins a battle with this, sets battle to true.


stopBattle

public void stopBattle()
Ends a battle with this, sets battle to false.


setMoney

public void setMoney(int mon)
Sets the amount of Money carried.

Parameters:
mon - the amount of money carried

getMoney

public int getMoney()
Gets the amount of Money carried.

Returns:
mon the amount of money carried

getName

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

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

setName

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

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

isBeaten

public boolean isBeaten()
Determine if this has been beaten.

Returns:
true iff this has been beaten.

addMonster

public boolean addMonster(Monster p)
Adds a Monster to this, either to the hand or to home if the hand has more than this.MAXMON

Parameters:
p - the Monster to add
Returns:
true if added to hand, false otherwise
See Also:
Monster

addMonsterHome

public void addMonsterHome(Monster p)
Adds a Monster to the Home collection

See Also:
Monster

switchMonster

public boolean switchMonster(Monster hand,
                             Monster home)
Switches a Monster from Home collection to the Hand collection.

Parameters:
hand - the Monster in the hand to send home
home - the Monster at home to send to the hand
See Also:
Monster

setActiveMonster

public void setActiveMonster(int i)
Sets the ActiveMonster for this. Does not count Monsters that have no HP.

Parameters:
i - the new index of the ActiveMonster for this.

getActiveMonster

public int getActiveMonster()
Gets the index of the Active Monster. Does not count Monsters that have no HP.

Returns:
the index of the Active Monster

getMonster

public Monster getMonster(int i)
Gets the Monster from the hand at the specified index, ignoring Monsters that have no HP.

Parameters:
i - the index to retrieve the Monster from
Returns:
the Monster at the specified index, not counting Monsters that have no HP

getMonsterAtHome

public Monster getMonsterAtHome(int i)
Gets the Monster from home at the specified index, ignoring Monsters that have no HP.

Parameters:
i - the index to retrieve the Monster from
Returns:
the Monster at the specified index, not counting Monsters that have no HP

getNumberOfMonsters

public int getNumberOfMonsters()
Gets the number of Monsters in the hand that do not have 0 hp.

Returns:
the number of Monsters in the hand that do not have 0 hp.

getNumberOfMonstersAtHome

public int getNumberOfMonstersAtHome()
Gets the number of Monsters at home that do not have 0 hp.

Returns:
the number of Monsters at home that do not have 0 hp.

addItem

public void addItem(Item i)
Adds the Item specified to this.

Parameters:
i - the Item to add
See Also:
Item

getItem

public Item getItem(java.lang.String name)
Gets the Item corresponding to the name specified.

Returns:
the Item corresponding to the name specified.
See Also:
Item

useItem

public void useItem(Item it,
                    Monster m)
Uses the Item specified on the Monster specified

Parameters:
it - the Item to use on the Monster
m - the Monster to use the Item on
See Also:
Monster, Item

getItemCount

public int getItemCount(java.lang.String name)
Gets the number of Item this has.

Parameters:
name - the name of the Item to get the count of.
See Also:
Item

healAllMonsters

public void healAllMonsters()
Heals all Monster to full HP, Attack Points, and Defense Points

See Also:
Monster, Shop

getMonsterAttacks

public java.lang.String[] getMonsterAttacks(int p)
Gets an array of String for the Attacks available for the Monster at index p, ignoring the Monsters with no HP.

Returns:
an array of String for the Attacks available for the Monster at index p, ignoring the Monsters with no HP.
See Also:
Monster, Battle

getMonsters

public java.lang.String[] getMonsters()
Gets an array of Strings of the Monsters that the Player is currently carrying, ignoring those with no HP.

Returns:
an array of Strings of the Monsters that the Player is currently carrying, ignoring those with no HP.
See Also:
Monster, Battle

getItems

public java.lang.String[] getItems()
Gets an array of Strings of the Item that the Player is currently carrying

Returns:
an array of Strings of the Item that the Player is currently carrying.
See Also:
Item, Battle, Shop